author | Alexandre Poirot <poirot.alex@gmail.com> |
Mon, 31 May 2021 20:29:55 +0000 | |
changeset 581530 | 8967dc205c2191c67b30baa1960b842861292a8c |
parent 581529 | a4562f19df5477490c07d91f257abe100c456dfe |
child 581531 | 90d2e0a0ead6aaab6dfaadb53a5354b22a94f681 |
push id | 144084 |
push user | apoirot@mozilla.com |
push date | Mon, 31 May 2021 20:32:33 +0000 |
treeherder | autoland@f7988048b5d7 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jdescottes, nchevobbe |
bugs | 1702511 |
milestone | 91.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
devtools/shared/commands/resource/resource-command.js | file | annotate | diff | comparison | revisions |
--- a/devtools/shared/commands/resource/resource-command.js +++ b/devtools/shared/commands/resource/resource-command.js @@ -449,16 +449,17 @@ class ResourceCommand { * A dictionary object with only one of these two attributes: * - targetFront: a Target Front, if the resource is watched from the target process or thread * - watcherFront: a Watcher Front, if the resource is watched from the parent process * @param {Array<json/Front>} resources * Depending on the resource Type, it can be an Array composed of either JSON objects or Fronts, * which describes the resource. */ async _onResourceAvailable({ targetFront, watcherFront }, resources) { + let includesDocumentEventWillNavigate = false; for (let resource of resources) { const { resourceType } = resource; if (watcherFront) { targetFront = await this._getTargetForWatcherResource(resource); } // isAlreadyExistingResource indicates that the resources already existed before @@ -477,21 +478,35 @@ class ResourceCommand { resource = ResourceTransformers[resourceType]({ resource, targetCommand: this.targetCommand, targetFront, watcherFront: this.watcherFront, }); } + if ( + resourceType == ResourceCommand.TYPES.DOCUMENT_EVENT && + resource.name == "will-navigate" + ) { + includesDocumentEventWillNavigate = true; + } + this._queueResourceEvent("available", resourceType, resource); this._cache.push(resource); } - this._throttledNotifyWatchers(); + // If we receive the DOCUMENT_EVENT for will-navigate, + // flush immediately the resources in order to notify about the navigation sooner than later. + // (this is especially useful for tests, even if they should probably avoid depending on this...) + if (includesDocumentEventWillNavigate) { + this._notifyWatchers(); + } else { + this._throttledNotifyWatchers(); + } } /** * Method called either by: * - the backward compatibility code (LegacyListeners) * - target actors RDP events * Called everytime a resource is updated in the remote target. *