Skip to content

Conversation

@adamraine
Copy link
Contributor

To get script contents in snapshot mode, we need to fetch the contents over the protocol using Debugger.getScriptSource instead of looking at the network request. Unfortunatley, we can't get the requestId this way.

We can replace ScriptElements with the implementation in ScriptElementsSnapshot for timespan and navigation modes, but we'll need to add the requestId separately kinda like what ImageRecords does in #12663. Since ScriptElements and ScriptElementsSnapshot are so different, I'm inclined to make that a breaking change and keep two separate gatherers for now.

The main use case for ScriptElementsSnapshot would be a new audit unminified-javascript-snapshot, a snapshot version of unminified-javascript.

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

but we'll need to add the requestId separately kinda like what ImageRecords does in #12663.

FWIW, I think this is a positive thing to do regardless of a split. Aligns our artifacts as unique bits of data :)

we need to fetch the contents over the protocol using Debugger.getScriptSource instead of looking at the network request

Does this work in our current gatherer in most cases? If so, I'm inclined to not maintain a fork. I don't know the answer to this but I might suspect that the network cache contents fetching we do is backed by the same data source as the Debugger version 🤷

The main use case for ScriptElementsSnapshot would be a new audit unminified-javascript-snapshot, a snapshot version of unminified-javascript.

Is this really it? If we're not able to convert any of the other JS opportunities as well, I'm also more hesitant to maintain a copy.

const session = context.driver.defaultSession;
const executionContext = context.driver.executionContext;

if (context.gatherMode === 'snapshot') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like you wrote this originally as a merged version, amirite? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guilty as charged

@adamraine
Copy link
Contributor Author

Does this work in our current gatherer in most cases?

It should. I didn't test it in navigation or timespan mode though.

Is this really it?

That's what's possible with this change alone. I will need to reinvestigate some audits like legacy-javascript and duplicated-javascript which might work in snapshot mode if we can get SourceMaps to work in snapshot mode.

@adamraine
Copy link
Contributor Author

It should. I didn't test it in navigation or timespan mode though.

With a few changes, navigation and timespan are supported in the currently named ScriptElementsSnapshot gatherer.

@patrickhulce
Copy link
Collaborator

With a few changes, navigation and timespan are supported in the currently named ScriptElementsSnapshot gatherer.

Great! I'm a little confused though, seems like we don't need the separate gatherer in that case then? If so, what feedback are you blocked on from reviewer? :)

@adamraine
Copy link
Contributor Author

Great! I'm a little confused though, seems like we don't need the separate gatherer in that case then? If so, what feedback are you blocked on from reviewer? :)

The new gatherer cannot provide the requestId, so we would need to add it in a computed artifact like we did with ImageElements. Would this be a breaking change?

@patrickhulce
Copy link
Collaborator

The new gatherer cannot provide the requestId, so we would need to add it in a computed artifact like we did with ImageElements. Would this be a breaking change?

Ah, yes it technically would. I couldn't find any usages with a quick GitHub, so we could consider returning null for all (semantic breaking change, but not a syntactical)

Should we shelve this until we can make a few 9.0 breaking changes?

@adamraine
Copy link
Contributor Author

I couldn't find any usages with a quick GitHub

It's used in unminified-javascript and legacy-javascript.

Should we shelve this until we can make a few 9.0 breaking changes?

I'm ok with shelving, adding snapshot support here isn't mission critical.

@patrickhulce
Copy link
Collaborator

It's used in unminified-javascript and legacy-javascript.

I meant usages by other open source projects ;) we can definitely fix our own usages without breaking

I'm ok with shelving, adding snapshot support here isn't mission critical.

Sounds good!

@connorjclark
Copy link
Collaborator

connorjclark commented Nov 1, 2021

We will continue this post-9.0, but probably keep existing ScriptElements intact until 10.0

@patrickhulce patrickhulce removed their assignment Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants