Backed out 3 changesets (bug 1660268) for failures on browser_ext_devtools_network_targetSwitch.js. CLOSED TREE
Backed out changeset 749fda4e5eb1 (bug 1660268) Backed out changeset 9d4c305f6b88 (bug 1660268) Backed out changeset 7ec118209790 (bug 1660268)
This commit is contained in:
@@ -79,7 +79,7 @@ class DebuggerPanel {
|
|||||||
const resourceWatcher = this.toolbox.resourceWatcher;
|
const resourceWatcher = this.toolbox.resourceWatcher;
|
||||||
await resourceWatcher.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceWatcher.TYPES.ERROR_MESSAGE],
|
[resourceWatcher.TYPES.ERROR_MESSAGE],
|
||||||
{ onAvailable: actions.addExceptionFromResources }
|
{ onAvailable: actions.addExceptionFromResource }
|
||||||
);
|
);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -9,12 +9,11 @@ import { hasException } from "../selectors";
|
|||||||
import type { ThunkArgs } from "./types";
|
import type { ThunkArgs } from "./types";
|
||||||
import type { Exception } from "../types";
|
import type { Exception } from "../types";
|
||||||
|
|
||||||
export function addExceptionFromResources(resources: Array<Object>) {
|
export function addExceptionFromResource({ resource }: Object) {
|
||||||
return async function({ dispatch }: ThunkArgs) {
|
return async function({ dispatch }: ThunkArgs) {
|
||||||
for (const resource of resources) {
|
|
||||||
const { pageError } = resource;
|
const { pageError } = resource;
|
||||||
if (!pageError.error) {
|
if (!pageError.error) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
const { columnNumber, lineNumber, sourceId, errorMessage } = pageError;
|
const { columnNumber, lineNumber, sourceId, errorMessage } = pageError;
|
||||||
const stacktrace = pageError.stacktrace || [];
|
const stacktrace = pageError.stacktrace || [];
|
||||||
@@ -28,7 +27,6 @@ export function addExceptionFromResources(resources: Array<Object>) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
dispatch(addException(exception));
|
dispatch(addException(exception));
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -438,12 +438,10 @@ class SourceMapURLService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._onResourceAvailable = async resources => {
|
this._onResourceAvailable = async ({ resource }) => {
|
||||||
if (this._sourcesLoading === sourcesLoading) {
|
if (this._sourcesLoading === sourcesLoading) {
|
||||||
for (const resource of resources) {
|
|
||||||
this._onNewStyleSheet(resource);
|
this._onNewStyleSheet(resource);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
|||||||
@@ -119,11 +119,10 @@ class ChangesView {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onResourceAvailable(resources) {
|
onResourceAvailable({ resource }) {
|
||||||
for (const resource of resources) {
|
|
||||||
if (resource.resourceType === this.resourceWatcher.TYPES.CSS_CHANGE) {
|
if (resource.resourceType === this.resourceWatcher.TYPES.CSS_CHANGE) {
|
||||||
this.onAddChange(resource);
|
this.onAddChange(resource);
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resource.name === "dom-loading" && resource.targetFront.isTopLevel) {
|
if (resource.name === "dom-loading" && resource.targetFront.isTopLevel) {
|
||||||
@@ -136,7 +135,6 @@ class ChangesView {
|
|||||||
this.onClearChanges();
|
this.onClearChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for the "Copy All Changes" button. Simple wrapper that just calls
|
* Handler for the "Copy All Changes" button. Simple wrapper that just calls
|
||||||
|
|||||||
@@ -256,8 +256,7 @@ class CompatibilityView {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onResourceAvailable(resources) {
|
_onResourceAvailable({ resource }) {
|
||||||
for (const resource of resources) {
|
|
||||||
// Style changes applied inline directly to
|
// Style changes applied inline directly to
|
||||||
// the element and its changes are monitored by
|
// the element and its changes are monitored by
|
||||||
// _onMarkupMutation via markupmutation events.
|
// _onMarkupMutation via markupmutation events.
|
||||||
@@ -266,7 +265,6 @@ class CompatibilityView {
|
|||||||
this._onChangeAdded(resource);
|
this._onChangeAdded(resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_onTopLevelTargetChanged() {
|
_onTopLevelTargetChanged() {
|
||||||
if (!this._isAvailable()) {
|
if (!this._isAvailable()) {
|
||||||
|
|||||||
@@ -1300,12 +1300,9 @@ Inspector.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onResourceAvailable: function(resources) {
|
onResourceAvailable: function({ resourceType, targetFront, resource }) {
|
||||||
for (const resource of resources) {
|
if (resourceType === this.toolbox.resourceWatcher.TYPES.ROOT_NODE) {
|
||||||
if (
|
const isTopLevelTarget = !!targetFront.isTopLevel;
|
||||||
resource.resourceType === this.toolbox.resourceWatcher.TYPES.ROOT_NODE
|
|
||||||
) {
|
|
||||||
const isTopLevelTarget = !!resource.targetFront.isTopLevel;
|
|
||||||
if (resource.isTopLevelDocument && isTopLevelTarget) {
|
if (resource.isTopLevelDocument && isTopLevelTarget) {
|
||||||
// Note: the resource (ie the root node here) will be fetched from the
|
// Note: the resource (ie the root node here) will be fetched from the
|
||||||
// walker later on in _getDefaultNodeForSelection.
|
// walker later on in _getDefaultNodeForSelection.
|
||||||
@@ -1316,7 +1313,6 @@ Inspector.prototype = {
|
|||||||
this.emit("frame-root-available", resource);
|
this.emit("frame-root-available", resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -81,10 +81,13 @@ add_task(async function navigateFrameNotExpandedInMarkupView() {
|
|||||||
//
|
//
|
||||||
// The iframe we are about to navigate is therefore hidden and we are not
|
// The iframe we are about to navigate is therefore hidden and we are not
|
||||||
// watching it - ie, it is not in the list of known NodeFronts/Actors.
|
// watching it - ie, it is not in the list of known NodeFronts/Actors.
|
||||||
const { resource } = await navigateIframeTo(inspector, EXAMPLE_COM_URI);
|
const { resource, targetFront } = await navigateIframeTo(
|
||||||
|
inspector,
|
||||||
|
EXAMPLE_COM_URI
|
||||||
|
);
|
||||||
|
|
||||||
is(
|
is(
|
||||||
resource.resourceType,
|
resource?.resourceType,
|
||||||
resourceWatcher.TYPES.ROOT_NODE,
|
resourceWatcher.TYPES.ROOT_NODE,
|
||||||
"A resource with resourceType ROOT_NODE was received when navigating"
|
"A resource with resourceType ROOT_NODE was received when navigating"
|
||||||
);
|
);
|
||||||
@@ -105,7 +108,7 @@ add_task(async function navigateFrameNotExpandedInMarkupView() {
|
|||||||
// This should be fixed when implementing the RootNode resource on the server
|
// This should be fixed when implementing the RootNode resource on the server
|
||||||
// in https://bugzilla.mozilla.org/show_bug.cgi?id=1644190
|
// in https://bugzilla.mozilla.org/show_bug.cgi?id=1644190
|
||||||
todo(
|
todo(
|
||||||
!resource.targetFront.getCachedFront("inspector"),
|
!targetFront.getCachedFront("inspector"),
|
||||||
"The inspector front for the new target should not be initialized"
|
"The inspector front for the new target should not be initialized"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -149,21 +149,20 @@ class FirefoxConnector {
|
|||||||
this.responsiveFront = await this.currentTarget.getFront("responsive");
|
this.responsiveFront = await this.currentTarget.getFront("responsive");
|
||||||
}
|
}
|
||||||
|
|
||||||
async onResourceAvailable(resources) {
|
async onResourceAvailable({ resourceType, targetFront, resource }) {
|
||||||
for (const resource of resources) {
|
|
||||||
const { TYPES } = this.toolbox.resourceWatcher;
|
const { TYPES } = this.toolbox.resourceWatcher;
|
||||||
|
|
||||||
if (resource.resourceType === TYPES.DOCUMENT_EVENT) {
|
if (resourceType === TYPES.DOCUMENT_EVENT) {
|
||||||
this.onDocEvent(resource);
|
this.onDocEvent(targetFront, resource);
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resource.resourceType === TYPES.NETWORK_EVENT) {
|
if (resourceType === TYPES.NETWORK_EVENT) {
|
||||||
this.dataProvider.onNetworkResourceAvailable(resource);
|
this.dataProvider.onNetworkResourceAvailable(resource);
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resource.resourceType === TYPES.WEBSOCKET) {
|
if (resourceType === TYPES.WEBSOCKET) {
|
||||||
const { wsMessageType } = resource;
|
const { wsMessageType } = resource;
|
||||||
|
|
||||||
switch (wsMessageType) {
|
switch (wsMessageType) {
|
||||||
@@ -193,27 +192,18 @@ class FirefoxConnector {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "frameSent": {
|
case "frameSent": {
|
||||||
this.dataProvider.onFrameSent(
|
this.dataProvider.onFrameSent(resource.httpChannelId, resource.data);
|
||||||
resource.httpChannelId,
|
|
||||||
resource.data
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async onResourceUpdated(updates) {
|
async onResourceUpdated({ resourceType, targetFront, resource }) {
|
||||||
for (const { resource } of updates) {
|
if (resourceType === this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT) {
|
||||||
if (
|
|
||||||
resource.resourceType ===
|
|
||||||
this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT
|
|
||||||
) {
|
|
||||||
this.dataProvider.onNetworkResourceUpdated(resource);
|
this.dataProvider.onNetworkResourceUpdated(resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async addListeners(ignoreExistingResources = false) {
|
async addListeners(ignoreExistingResources = false) {
|
||||||
const targetResources = [this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT];
|
const targetResources = [this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT];
|
||||||
@@ -328,28 +318,29 @@ class FirefoxConnector {
|
|||||||
/**
|
/**
|
||||||
* The "DOMContentLoaded" and "Load" events sent by the console actor.
|
* The "DOMContentLoaded" and "Load" events sent by the console actor.
|
||||||
*
|
*
|
||||||
* @param {object} resource The DOCUMENT_EVENT resource
|
* @param {object} targetFront
|
||||||
|
* @param {object} event
|
||||||
*/
|
*/
|
||||||
onDocEvent(resource) {
|
onDocEvent(targetFront, event) {
|
||||||
if (!resource.targetFront.isTopLevel) {
|
if (!targetFront.isTopLevel) {
|
||||||
// Only handle document events for the top level target.
|
// Only handle document events for the top level target.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resource.name === "dom-loading") {
|
if (event.name === "dom-loading") {
|
||||||
// Netmonitor does not support dom-loading event yet.
|
// Netmonitor does not support dom-loading event yet.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.actions) {
|
if (this.actions) {
|
||||||
this.actions.addTimingMarker(resource);
|
this.actions.addTimingMarker(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resource.name === "dom-complete") {
|
if (event.name === "dom-complete") {
|
||||||
this.navigate();
|
this.navigate();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emitForTests(TEST_EVENTS.TIMELINE_EVENT, resource);
|
this.emitForTests(TEST_EVENTS.TIMELINE_EVENT, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -166,8 +166,7 @@ HarCollector.prototype = {
|
|||||||
|
|
||||||
// Event Handlers
|
// Event Handlers
|
||||||
|
|
||||||
onResourceAvailable: function(resources) {
|
onResourceAvailable: function({ resourceType, targetFront, resource }) {
|
||||||
for (const resource of resources) {
|
|
||||||
trace.log("HarCollector.onNetworkEvent; ", resource);
|
trace.log("HarCollector.onNetworkEvent; ", resource);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -191,7 +190,7 @@ HarCollector.prototype = {
|
|||||||
console.error(
|
console.error(
|
||||||
"HarCollector.onNetworkEvent; ERROR " + "existing file conflict!"
|
"HarCollector.onNetworkEvent; ERROR " + "existing file conflict!"
|
||||||
);
|
);
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
file = {
|
file = {
|
||||||
@@ -207,11 +206,9 @@ HarCollector.prototype = {
|
|||||||
|
|
||||||
// Mimic the Net panel data structure
|
// Mimic the Net panel data structure
|
||||||
this.items.push(file);
|
this.items.push(file);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onResourceUpdated: function(updates) {
|
onResourceUpdated: function({ resourceType, targetFront, resource }) {
|
||||||
for (const { resource } of updates) {
|
|
||||||
// Skip events from unknown actors (not in the list).
|
// Skip events from unknown actors (not in the list).
|
||||||
// It can happen when there are zombie requests received after
|
// It can happen when there are zombie requests received after
|
||||||
// the target is closed or multiple tabs are attached through
|
// the target is closed or multiple tabs are attached through
|
||||||
@@ -299,7 +296,6 @@ HarCollector.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.resetPageLoadTimeout();
|
this.resetPageLoadTimeout();
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getData: function(actor, method, callback) {
|
getData: function(actor, method, callback) {
|
||||||
|
|||||||
@@ -1187,8 +1187,8 @@ function getCurrentTestFilePath() {
|
|||||||
*/
|
*/
|
||||||
function waitForResourceOnce(resourceWatcher, resourceType) {
|
function waitForResourceOnce(resourceWatcher, resourceType) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const onAvailable = resources => {
|
const onAvailable = ({ targetFront, resource }) => {
|
||||||
resolve(resources[0]);
|
resolve({ targetFront, resource });
|
||||||
resourceWatcher.unwatchResources([resourceType], { onAvailable });
|
resourceWatcher.unwatchResources([resourceType], { onAvailable });
|
||||||
};
|
};
|
||||||
resourceWatcher.watchResources([resourceType], {
|
resourceWatcher.watchResources([resourceType], {
|
||||||
|
|||||||
@@ -1200,8 +1200,7 @@ StyleEditorUI.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async _onResourceAvailable(resources) {
|
async _onResourceAvailable({ resource }) {
|
||||||
for (const resource of resources) {
|
|
||||||
if (
|
if (
|
||||||
resource.resourceType === this._toolbox.resourceWatcher.TYPES.STYLESHEET
|
resource.resourceType === this._toolbox.resourceWatcher.TYPES.STYLESHEET
|
||||||
) {
|
) {
|
||||||
@@ -1213,11 +1212,11 @@ StyleEditorUI.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await onStyleSheetHandled;
|
await onStyleSheetHandled;
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resource.targetFront.isTopLevel) {
|
if (!resource.targetFront.isTopLevel) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resource.name === "dom-loading") {
|
if (resource.name === "dom-loading") {
|
||||||
@@ -1232,17 +1231,13 @@ StyleEditorUI.prototype = {
|
|||||||
} else if (resource.name === "dom-complete") {
|
} else if (resource.name === "dom-complete") {
|
||||||
await this._waitForLoadingStyleSheets();
|
await this._waitForLoadingStyleSheets();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async _onResourceUpdated(updates) {
|
async _onResourceUpdated({ update }) {
|
||||||
for (const { update } of updates) {
|
|
||||||
if (
|
if (
|
||||||
update.resourceType === this._toolbox.resourceWatcher.TYPES.STYLESHEET
|
update.resourceType === this._toolbox.resourceWatcher.TYPES.STYLESHEET
|
||||||
) {
|
) {
|
||||||
const editor = this.editors.find(
|
const editor = this.editors.find(e => e.resourceId === update.resourceId);
|
||||||
e => e.resourceId === update.resourceId
|
|
||||||
);
|
|
||||||
|
|
||||||
switch (update.updateType) {
|
switch (update.updateType) {
|
||||||
case "style-applied": {
|
case "style-applied": {
|
||||||
@@ -1264,7 +1259,6 @@ StyleEditorUI.prototype = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async _onTargetAvailable({ targetFront }) {
|
async _onTargetAvailable({ targetFront }) {
|
||||||
|
|||||||
@@ -70,10 +70,8 @@ async function generateConsoleApiStubs() {
|
|||||||
// resource to `handleConsoleMessage`, dynamically updated for each command.
|
// resource to `handleConsoleMessage`, dynamically updated for each command.
|
||||||
let handleConsoleMessage = function() {};
|
let handleConsoleMessage = function() {};
|
||||||
|
|
||||||
const onConsoleMessage = resources => {
|
const onConsoleMessage = ({ resource }) => {
|
||||||
for (const resource of resources) {
|
|
||||||
handleConsoleMessage(resource);
|
handleConsoleMessage(resource);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
await resourceWatcher.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
|
|||||||
@@ -68,10 +68,8 @@ async function generateCssMessageStubs() {
|
|||||||
// resource to `handleErrorMessage`, dynamically updated for each command.
|
// resource to `handleErrorMessage`, dynamically updated for each command.
|
||||||
let handleCSSMessage = function() {};
|
let handleCSSMessage = function() {};
|
||||||
|
|
||||||
const onCSSMessageAvailable = resources => {
|
const onCSSMessageAvailable = ({ resource }) => {
|
||||||
for (const resource of resources) {
|
|
||||||
handleCSSMessage(resource);
|
handleCSSMessage(resource);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_MESSAGE], {
|
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_MESSAGE], {
|
||||||
|
|||||||
@@ -70,15 +70,11 @@ async function generateNetworkEventStubs() {
|
|||||||
let addNetworkStub = function() {};
|
let addNetworkStub = function() {};
|
||||||
let addNetworkUpdateStub = function() {};
|
let addNetworkUpdateStub = function() {};
|
||||||
|
|
||||||
const onAvailable = resources => {
|
const onAvailable = resource => {
|
||||||
for (const resource of resources) {
|
|
||||||
addNetworkStub(resource);
|
addNetworkStub(resource);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
const onUpdated = updates => {
|
const onUpdated = resource => {
|
||||||
for (const { resource } of updates) {
|
|
||||||
addNetworkUpdateStub(resource);
|
addNetworkUpdateStub(resource);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.NETWORK_EVENT], {
|
await resourceWatcher.watchResources([resourceWatcher.TYPES.NETWORK_EVENT], {
|
||||||
@@ -89,14 +85,14 @@ async function generateNetworkEventStubs() {
|
|||||||
for (const [key, code] of getCommands()) {
|
for (const [key, code] of getCommands()) {
|
||||||
const noExpectedUpdates = 7;
|
const noExpectedUpdates = 7;
|
||||||
const networkEventDone = new Promise(resolve => {
|
const networkEventDone = new Promise(resolve => {
|
||||||
addNetworkStub = resource => {
|
addNetworkStub = ({ resourceType, targetFront, resource }) => {
|
||||||
stubs.set(key, getCleanedPacket(key, getOrderedResource(resource)));
|
stubs.set(key, getCleanedPacket(key, getOrderedResource(resource)));
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
const networkEventUpdateDone = new Promise(resolve => {
|
const networkEventUpdateDone = new Promise(resolve => {
|
||||||
let updateCount = 0;
|
let updateCount = 0;
|
||||||
addNetworkUpdateStub = resource => {
|
addNetworkUpdateStub = ({ resourceType, targetFront, resource }) => {
|
||||||
const updateKey = `${key} update`;
|
const updateKey = `${key} update`;
|
||||||
// make sure all the updates have been happened
|
// make sure all the updates have been happened
|
||||||
if (updateCount >= noExpectedUpdates) {
|
if (updateCount >= noExpectedUpdates) {
|
||||||
|
|||||||
@@ -72,10 +72,8 @@ async function generatePageErrorStubs() {
|
|||||||
// resource to `handleErrorMessage`, dynamically updated for each command.
|
// resource to `handleErrorMessage`, dynamically updated for each command.
|
||||||
let handleErrorMessage = function() {};
|
let handleErrorMessage = function() {};
|
||||||
|
|
||||||
const onErrorMessageAvailable = resources => {
|
const onErrorMessageAvailable = ({ resource }) => {
|
||||||
for (const resource of resources) {
|
|
||||||
handleErrorMessage(resource);
|
handleErrorMessage(resource);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.ERROR_MESSAGE], {
|
await resourceWatcher.watchResources([resourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||||
onAvailable: onErrorMessageAvailable,
|
onAvailable: onErrorMessageAvailable,
|
||||||
|
|||||||
@@ -80,10 +80,8 @@ async function generatePlatformMessagesStubs() {
|
|||||||
// resource to `handlePlatformMessage`, dynamically updated for each command.
|
// resource to `handlePlatformMessage`, dynamically updated for each command.
|
||||||
let handlePlatformMessage = function() {};
|
let handlePlatformMessage = function() {};
|
||||||
|
|
||||||
const onPlatformMessageAvailable = resources => {
|
const onPlatformMessageAvailable = ({ resource }) => {
|
||||||
for (const resource of resources) {
|
|
||||||
handlePlatformMessage(resource);
|
handlePlatformMessage(resource);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
await resourceWatcher.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceWatcher.TYPES.PLATFORM_MESSAGE],
|
[resourceWatcher.TYPES.PLATFORM_MESSAGE],
|
||||||
|
|||||||
@@ -1006,7 +1006,7 @@ async function openMessageInNetmonitor(toolbox, hud, url, urlInConsole) {
|
|||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
const selected = getSelectedRequest(store.getState());
|
const selected = getSelectedRequest(store.getState());
|
||||||
return selected && selected.url === url;
|
return selected && selected.url === url;
|
||||||
}, `network entry for the URL "${url}" wasn't found`);
|
}, "network entry for the URL wasn't found");
|
||||||
|
|
||||||
ok(true, "The attached url is correct.");
|
ok(true, "The attached url is correct.");
|
||||||
|
|
||||||
|
|||||||
@@ -353,36 +353,31 @@ class WebConsoleUI {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_onResourceAvailable(resources) {
|
_onResourceAvailable({ resourceType, targetFront, resource }) {
|
||||||
if (!this.hud) {
|
if (!this.hud) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const resource of resources) {
|
|
||||||
const { TYPES } = this.hud.resourceWatcher;
|
const { TYPES } = this.hud.resourceWatcher;
|
||||||
// Ignore messages forwarded from content processes if we're in fission browser toolbox.
|
// Ignore messages forwarded from content processes if we're in fission browser toolbox.
|
||||||
if (
|
if (
|
||||||
!this.wrapper ||
|
!this.wrapper ||
|
||||||
((resource.resourceType === TYPES.ERROR_MESSAGE ||
|
((resourceType === TYPES.ERROR_MESSAGE ||
|
||||||
resource.resourceType === TYPES.CSS_MESSAGE) &&
|
resourceType === TYPES.CSS_MESSAGE) &&
|
||||||
resource.pageError?.isForwardedFromContentProcess &&
|
resource.pageError?.isForwardedFromContentProcess &&
|
||||||
(this.isBrowserToolboxConsole || this.isBrowserConsole) &&
|
(this.isBrowserToolboxConsole || this.isBrowserConsole) &&
|
||||||
this.fissionSupport)
|
this.fissionSupport)
|
||||||
) {
|
) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
this.wrapper.dispatchMessageAdd(resource);
|
this.wrapper.dispatchMessageAdd(resource);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_onResourceUpdated(updates) {
|
_onResourceUpdated({ resourceType, targetFront, resource }) {
|
||||||
for (const { resource } of updates) {
|
if (resourceType == this.hud.resourceWatcher.TYPES.NETWORK_EVENT) {
|
||||||
if (
|
|
||||||
resource.resourceType == this.hud.resourceWatcher.TYPES.NETWORK_EVENT
|
|
||||||
) {
|
|
||||||
this.wrapper.dispatchMessageUpdate(resource);
|
this.wrapper.dispatchMessageUpdate(resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called any time a new target is available.
|
* Called any time a new target is available.
|
||||||
|
|||||||
@@ -295,8 +295,6 @@ class ResourceWatcher {
|
|||||||
* which describes the resource.
|
* which describes the resource.
|
||||||
*/
|
*/
|
||||||
async _onResourceAvailable({ targetFront, watcherFront }, resources) {
|
async _onResourceAvailable({ targetFront, watcherFront }, resources) {
|
||||||
let currentType = null;
|
|
||||||
let resourceBuffer = [];
|
|
||||||
for (let resource of resources) {
|
for (let resource of resources) {
|
||||||
const { resourceType } = resource;
|
const { resourceType } = resource;
|
||||||
|
|
||||||
@@ -322,24 +320,15 @@ class ResourceWatcher {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentType) {
|
this._availableListeners.emit(resourceType, {
|
||||||
currentType = resourceType;
|
// XXX: We may want to read resource.resourceType instead of passing this resourceType argument?
|
||||||
}
|
resourceType,
|
||||||
// Flush the current list of buffered resource if we switch to another type
|
targetFront,
|
||||||
else if (currentType != resourceType) {
|
resource,
|
||||||
this._availableListeners.emit(currentType, resourceBuffer);
|
});
|
||||||
currentType = resourceType;
|
|
||||||
resourceBuffer = [];
|
|
||||||
}
|
|
||||||
resourceBuffer.push(resource);
|
|
||||||
|
|
||||||
this._cache.push(resource);
|
this._cache.push(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush the buffered resources if there is any
|
|
||||||
if (resourceBuffer.length > 0) {
|
|
||||||
this._availableListeners.emit(currentType, resourceBuffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -375,8 +364,6 @@ class ResourceWatcher {
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
async _onResourceUpdated({ targetFront, watcherFront }, updates) {
|
async _onResourceUpdated({ targetFront, watcherFront }, updates) {
|
||||||
let currentType = null;
|
|
||||||
let resourceBuffer = [];
|
|
||||||
for (const update of updates) {
|
for (const update of updates) {
|
||||||
const { resourceType, resourceId, resourceUpdates } = update;
|
const { resourceType, resourceId, resourceUpdates } = update;
|
||||||
|
|
||||||
@@ -401,25 +388,13 @@ class ResourceWatcher {
|
|||||||
Object.assign(existingResource, resourceUpdates);
|
Object.assign(existingResource, resourceUpdates);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentType) {
|
this._updatedListeners.emit(resourceType, {
|
||||||
currentType = resourceType;
|
resourceType,
|
||||||
}
|
targetFront,
|
||||||
// Flush the current list of buffered resource if we switch to another type
|
|
||||||
if (currentType != resourceType) {
|
|
||||||
this._updatedListeners.emit(currentType, resourceBuffer);
|
|
||||||
currentType = resourceType;
|
|
||||||
resourceBuffer = [];
|
|
||||||
}
|
|
||||||
resourceBuffer.push({
|
|
||||||
resource: existingResource,
|
resource: existingResource,
|
||||||
update,
|
update,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush the buffered resources if there is any
|
|
||||||
if (resourceBuffer.length > 0) {
|
|
||||||
this._updatedListeners.emit(currentType, resourceBuffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -427,8 +402,6 @@ class ResourceWatcher {
|
|||||||
* See _onResourceAvailable for the argument description.
|
* See _onResourceAvailable for the argument description.
|
||||||
*/
|
*/
|
||||||
async _onResourceDestroyed({ targetFront, watcherFront }, resources) {
|
async _onResourceDestroyed({ targetFront, watcherFront }, resources) {
|
||||||
let currentType = null;
|
|
||||||
let resourceBuffer = [];
|
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
const { resourceType, resourceId } = resource;
|
const { resourceType, resourceId } = resource;
|
||||||
|
|
||||||
@@ -457,21 +430,11 @@ class ResourceWatcher {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentType) {
|
this._destroyedListeners.emit(resourceType, {
|
||||||
currentType = resourceType;
|
resourceType,
|
||||||
}
|
targetFront,
|
||||||
// Flush the current list of buffered resource if we switch to another type
|
resource,
|
||||||
if (currentType != resourceType) {
|
});
|
||||||
this._destroyedListeners.emit(currentType, resourceBuffer);
|
|
||||||
currentType = resourceType;
|
|
||||||
resourceBuffer = [];
|
|
||||||
}
|
|
||||||
resourceBuffer.push(resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Flush the buffered resources if there is any
|
|
||||||
if (resourceBuffer.length > 0) {
|
|
||||||
this._destroyedListeners.emit(currentType, resourceBuffer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,11 +515,15 @@ class ResourceWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _forwardCachedResources(resourceTypes, onAvailable) {
|
async _forwardCachedResources(resourceTypes, onAvailable) {
|
||||||
await onAvailable(
|
for (const resource of this._cache) {
|
||||||
this._cache.filter(resource =>
|
if (resourceTypes.includes(resource.resourceType)) {
|
||||||
resourceTypes.includes(resource.resourceType)
|
await onAvailable({
|
||||||
)
|
resourceType: resource.resourceType,
|
||||||
);
|
targetFront: resource.targetFront,
|
||||||
|
resource,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ add_task(async function() {
|
|||||||
await resourceWatcher.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => cachedResources1.push(...resources),
|
onAvailable: ({ resource }) => cachedResources1.push(resource),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ add_task(async function() {
|
|||||||
await resourceWatcher.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => cachedResources2.push(...resources),
|
onAvailable: ({ resource }) => cachedResources2.push(resource),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ add_task(async function() {
|
|||||||
await resourceWatcher.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => availableResources.push(...resources),
|
onAvailable: ({ resource }) => availableResources.push(resource),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ add_task(async function() {
|
|||||||
await resourceWatcher.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => cachedResources.push(...resources),
|
onAvailable: ({ resource }) => cachedResources.push(resource),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ add_task(async function() {
|
|||||||
await resourceWatcher.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => cachedResources.push(...resources),
|
onAvailable: ({ resource }) => cachedResources.push(resource),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ add_task(async function() {
|
|||||||
ResourceWatcher.TYPES.ERROR_MESSAGE,
|
ResourceWatcher.TYPES.ERROR_MESSAGE,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onAvailable: resources => availableResources.push(...resources),
|
onAvailable: ({ resource }) => availableResources.push(resource),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ add_task(async function() {
|
|||||||
ResourceWatcher.TYPES.ERROR_MESSAGE,
|
ResourceWatcher.TYPES.ERROR_MESSAGE,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onAvailable: resources => cachedResources.push(...resources),
|
onAvailable: ({ resource }) => cachedResources.push(resource),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ async function testIgnoreExistingResources(isFirstListenerIgnoreExisting) {
|
|||||||
await resourceWatcher.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => cachedResources1.push(...resources),
|
onAvailable: ({ resource }) => cachedResources1.push(resource),
|
||||||
ignoreExistingResources: isFirstListenerIgnoreExisting,
|
ignoreExistingResources: isFirstListenerIgnoreExisting,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -238,7 +238,7 @@ async function testIgnoreExistingResources(isFirstListenerIgnoreExisting) {
|
|||||||
await resourceWatcher.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => cachedResources2.push(...resources),
|
onAvailable: ({ resource }) => cachedResources2.push(resource),
|
||||||
ignoreExistingResources: !isFirstListenerIgnoreExisting,
|
ignoreExistingResources: !isFirstListenerIgnoreExisting,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -35,10 +35,9 @@ async function testConsoleMessagesResources() {
|
|||||||
const expectedExistingCalls = [...expectedExistingConsoleCalls];
|
const expectedExistingCalls = [...expectedExistingConsoleCalls];
|
||||||
const expectedRuntimeCalls = [...expectedRuntimeConsoleCalls];
|
const expectedRuntimeCalls = [...expectedRuntimeConsoleCalls];
|
||||||
const onRuntimeDone = new Promise(resolve => (runtimeDoneResolve = resolve));
|
const onRuntimeDone = new Promise(resolve => (runtimeDoneResolve = resolve));
|
||||||
const onAvailable = resources => {
|
const onAvailable = ({ resourceType, targetFront, resource }) => {
|
||||||
for (const resource of resources) {
|
|
||||||
is(
|
is(
|
||||||
resource.resourceType,
|
resourceType,
|
||||||
ResourceWatcher.TYPES.CONSOLE_MESSAGE,
|
ResourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||||
"Received a message"
|
"Received a message"
|
||||||
);
|
);
|
||||||
@@ -51,7 +50,6 @@ async function testConsoleMessagesResources() {
|
|||||||
if (expectedRuntimeCalls.length == 0) {
|
if (expectedRuntimeCalls.length == 0) {
|
||||||
runtimeDoneResolve();
|
runtimeDoneResolve();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await resourceWatcher.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
@@ -103,7 +101,7 @@ async function testConsoleMessagesResourcesWithIgnoreExistingResources() {
|
|||||||
await resourceWatcher.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => availableResources.push(...resources),
|
onAvailable: ({ resource }) => availableResources.push(resource),
|
||||||
ignoreExistingResources: true,
|
ignoreExistingResources: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ add_task(async function() {
|
|||||||
|
|
||||||
const availableResources = [];
|
const availableResources = [];
|
||||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.CSS_CHANGE], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.CSS_CHANGE], {
|
||||||
onAvailable: resources => availableResources.push(...resources),
|
onAvailable: ({ resource }) => availableResources.push(resource),
|
||||||
});
|
});
|
||||||
assertResource(
|
assertResource(
|
||||||
availableResources[0],
|
availableResources[0],
|
||||||
@@ -83,7 +83,7 @@ add_task(async function() {
|
|||||||
info("Check whether ResourceWatcher sends all resources added in this test");
|
info("Check whether ResourceWatcher sends all resources added in this test");
|
||||||
const existingResources = [];
|
const existingResources = [];
|
||||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.CSS_CHANGE], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.CSS_CHANGE], {
|
||||||
onAvailable: resources => existingResources.push(...resources),
|
onAvailable: ({ resource }) => existingResources.push(resource),
|
||||||
});
|
});
|
||||||
await waitUntil(() => existingResources.length === 4);
|
await waitUntil(() => existingResources.length === 4);
|
||||||
is(availableResources[0], existingResources[0], "1st resource is correct");
|
is(availableResources[0], existingResources[0], "1st resource is correct");
|
||||||
|
|||||||
@@ -163,8 +163,7 @@ function setupOnAvailableFunction(targetList, receivedMessages) {
|
|||||||
|
|
||||||
let done;
|
let done;
|
||||||
const onAllMessagesReceived = new Promise(resolve => (done = resolve));
|
const onAllMessagesReceived = new Promise(resolve => (done = resolve));
|
||||||
const onAvailable = resources => {
|
const onAvailable = ({ resourceType, targetFront, resource }) => {
|
||||||
for (const resource of resources) {
|
|
||||||
const { pageError } = resource;
|
const { pageError } = resource;
|
||||||
|
|
||||||
is(
|
is(
|
||||||
@@ -175,22 +174,19 @@ function setupOnAvailableFunction(targetList, receivedMessages) {
|
|||||||
|
|
||||||
if (!pageError.sourceName.includes("test_css_messages")) {
|
if (!pageError.sourceName.includes("test_css_messages")) {
|
||||||
info(`Ignore error from unknown source: "${pageError.sourceName}"`);
|
info(`Ignore error from unknown source: "${pageError.sourceName}"`);
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const index = receivedMessages.length;
|
const index = receivedMessages.length;
|
||||||
receivedMessages.push(pageError);
|
receivedMessages.push(pageError);
|
||||||
|
|
||||||
info(
|
info(`checking received css message #${index}: ${pageError.errorMessage}`);
|
||||||
`checking received css message #${index}: ${pageError.errorMessage}`
|
|
||||||
);
|
|
||||||
ok(pageError, "The resource has a pageError attribute");
|
ok(pageError, "The resource has a pageError attribute");
|
||||||
checkObject(resource, expectedMessages[index]);
|
checkObject(resource, expectedMessages[index]);
|
||||||
|
|
||||||
if (receivedMessages.length == expectedMessages.length) {
|
if (receivedMessages.length == expectedMessages.length) {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
return { onAvailable, onAllMessagesReceived };
|
return { onAvailable, onAllMessagesReceived };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ async function testDocumentEventResourcesWithIgnoreExistingResources() {
|
|||||||
info("Check whether the existing document events will not be fired");
|
info("Check whether the existing document events will not be fired");
|
||||||
const documentEvents = [];
|
const documentEvents = [];
|
||||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.DOCUMENT_EVENT], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.DOCUMENT_EVENT], {
|
||||||
onAvailable: resources => documentEvents.push(...resources),
|
onAvailable: ({ resource }) => documentEvents.push(resource),
|
||||||
ignoreExistingResources: true,
|
ignoreExistingResources: true,
|
||||||
});
|
});
|
||||||
is(documentEvents.length, 0, "Existing document events are not fired");
|
is(documentEvents.length, 0, "Existing document events are not fired");
|
||||||
@@ -129,15 +129,13 @@ function assertEvents(loadingEvent, interactiveEvent, completeEvent) {
|
|||||||
class ResourceListener {
|
class ResourceListener {
|
||||||
_listeners = new Map();
|
_listeners = new Map();
|
||||||
|
|
||||||
dispatch(resources) {
|
dispatch({ resourceType, targetFront, resource }) {
|
||||||
for (const resource of resources) {
|
|
||||||
const resolve = this._listeners.get(resource.name);
|
const resolve = this._listeners.get(resource.name);
|
||||||
if (resolve) {
|
if (resolve) {
|
||||||
resolve(resource);
|
resolve(resource);
|
||||||
this._listeners.delete(resource.name);
|
this._listeners.delete(resource.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
once(resourceName) {
|
once(resourceName) {
|
||||||
return new Promise(r => this._listeners.set(resourceName, r));
|
return new Promise(r => this._listeners.set(resourceName, r));
|
||||||
|
|||||||
@@ -52,8 +52,7 @@ async function testErrorMessagesResources() {
|
|||||||
|
|
||||||
let done;
|
let done;
|
||||||
const onAllErrorReceived = new Promise(resolve => (done = resolve));
|
const onAllErrorReceived = new Promise(resolve => (done = resolve));
|
||||||
const onAvailable = resources => {
|
const onAvailable = ({ resourceType, targetFront, resource }) => {
|
||||||
for (const resource of resources) {
|
|
||||||
const { pageError } = resource;
|
const { pageError } = resource;
|
||||||
|
|
||||||
is(
|
is(
|
||||||
@@ -64,7 +63,7 @@ async function testErrorMessagesResources() {
|
|||||||
|
|
||||||
if (!pageError.sourceName.includes("test_page_errors")) {
|
if (!pageError.sourceName.includes("test_page_errors")) {
|
||||||
info(`Ignore error from unknown source: "${pageError.sourceName}"`);
|
info(`Ignore error from unknown source: "${pageError.sourceName}"`);
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const index = receivedMessages.length;
|
const index = receivedMessages.length;
|
||||||
@@ -77,7 +76,6 @@ async function testErrorMessagesResources() {
|
|||||||
if (receivedMessages.length == expectedMessages.length) {
|
if (receivedMessages.length == expectedMessages.length) {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ERROR_MESSAGE], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||||
@@ -119,7 +117,7 @@ async function testErrorMessagesResourcesWithIgnoreExistingResources() {
|
|||||||
|
|
||||||
const availableResources = [];
|
const availableResources = [];
|
||||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ERROR_MESSAGE], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||||
onAvailable: resources => availableResources.push(...resources),
|
onAvailable: ({ resource }) => availableResources.push(resource),
|
||||||
ignoreExistingResources: true,
|
ignoreExistingResources: true,
|
||||||
});
|
});
|
||||||
is(
|
is(
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ add_task(async function() {
|
|||||||
"Start to watch the available resources in order to compare with resources gotten from getAllResources"
|
"Start to watch the available resources in order to compare with resources gotten from getAllResources"
|
||||||
);
|
);
|
||||||
const availableResources = [];
|
const availableResources = [];
|
||||||
const onAvailable = resources => availableResources.push(...resources);
|
const onAvailable = ({ resource }) => availableResources.push(resource);
|
||||||
await resourceWatcher.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{ onAvailable }
|
{ onAvailable }
|
||||||
|
|||||||
@@ -128,8 +128,7 @@ async function testNetworkEventResources(options) {
|
|||||||
const waitOnAllExpectedUpdatesForExistingRequests = new Promise(resolve => {
|
const waitOnAllExpectedUpdatesForExistingRequests = new Promise(resolve => {
|
||||||
const existingRequestUrl = `${EXAMPLE_DOMAIN}existing_post.html`;
|
const existingRequestUrl = `${EXAMPLE_DOMAIN}existing_post.html`;
|
||||||
|
|
||||||
onResourceAvailable = resources => {
|
onResourceAvailable = ({ resource }) => {
|
||||||
for (const resource of resources) {
|
|
||||||
// A blocked request would only have two updates so lets also resolve here
|
// A blocked request would only have two updates so lets also resolve here
|
||||||
if (
|
if (
|
||||||
resource.request.url == existingRequestUrl &&
|
resource.request.url == existingRequestUrl &&
|
||||||
@@ -138,17 +137,15 @@ async function testNetworkEventResources(options) {
|
|||||||
) {
|
) {
|
||||||
// Reset the updates expectation as the request is blocked
|
// Reset the updates expectation as the request is blocked
|
||||||
if (options.expectedResourcesOnAvailable[resource.request.url]) {
|
if (options.expectedResourcesOnAvailable[resource.request.url]) {
|
||||||
options.expectedResourcesOnAvailable[
|
options.expectedResourcesOnAvailable[resource.request.url].updates = [
|
||||||
resource.request.url
|
...resource.updates,
|
||||||
].updates = [...resource.updates];
|
];
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onResourceUpdated = updates => {
|
onResourceUpdated = ({ resource }) => {
|
||||||
for (const { resource } of updates) {
|
|
||||||
// Wait until all the update events have fired for the existing request.
|
// Wait until all the update events have fired for the existing request.
|
||||||
// Handle both blocked and unblocked requests
|
// Handle both blocked and unblocked requests
|
||||||
if (
|
if (
|
||||||
@@ -158,13 +155,12 @@ async function testNetworkEventResources(options) {
|
|||||||
) {
|
) {
|
||||||
// Makes sure the expectation always correct (for either blocked or unblocked requests)
|
// Makes sure the expectation always correct (for either blocked or unblocked requests)
|
||||||
if (options.expectedResourcesOnAvailable[resource.request.url]) {
|
if (options.expectedResourcesOnAvailable[resource.request.url]) {
|
||||||
options.expectedResourcesOnAvailable[
|
options.expectedResourcesOnAvailable[resource.request.url].updates = [
|
||||||
resource.request.url
|
...resource.updates,
|
||||||
].updates = [...resource.updates];
|
];
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
resourceWatcher
|
resourceWatcher
|
||||||
@@ -194,10 +190,9 @@ async function testNetworkEventResources(options) {
|
|||||||
() => expectedOnUpdatedCounts == 0
|
() => expectedOnUpdatedCounts == 0
|
||||||
);
|
);
|
||||||
|
|
||||||
const onAvailable = resources => {
|
const onAvailable = ({ resourceType, targetFront, resource }) => {
|
||||||
for (const resource of resources) {
|
|
||||||
is(
|
is(
|
||||||
resource.resourceType,
|
resourceType,
|
||||||
ResourceWatcher.TYPES.NETWORK_EVENT,
|
ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
"Received a network event resource"
|
"Received a network event resource"
|
||||||
);
|
);
|
||||||
@@ -208,13 +203,11 @@ async function testNetworkEventResources(options) {
|
|||||||
updates: [...resource.updates],
|
updates: [...resource.updates],
|
||||||
};
|
};
|
||||||
expectedOnAvailableCounts--;
|
expectedOnAvailableCounts--;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onUpdated = updates => {
|
const onUpdated = ({ resourceType, targetFront, resource }) => {
|
||||||
for (const { resource } of updates) {
|
|
||||||
is(
|
is(
|
||||||
resource.resourceType,
|
resourceType,
|
||||||
ResourceWatcher.TYPES.NETWORK_EVENT,
|
ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
"Received a network update event resource"
|
"Received a network update event resource"
|
||||||
);
|
);
|
||||||
@@ -225,7 +218,6 @@ async function testNetworkEventResources(options) {
|
|||||||
updates: [...resource.updates],
|
updates: [...resource.updates],
|
||||||
};
|
};
|
||||||
expectedOnUpdatedCounts--;
|
expectedOnUpdatedCounts--;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.NETWORK_EVENT], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.NETWORK_EVENT], {
|
||||||
|
|||||||
@@ -42,10 +42,9 @@ async function testPlatformMessagesResources() {
|
|||||||
|
|
||||||
let done;
|
let done;
|
||||||
const onAllMessagesReceived = new Promise(resolve => (done = resolve));
|
const onAllMessagesReceived = new Promise(resolve => (done = resolve));
|
||||||
const onAvailable = resources => {
|
const onAvailable = ({ resourceType, targetFront, resource }) => {
|
||||||
for (const resource of resources) {
|
|
||||||
if (!expectedMessages.includes(resource.message)) {
|
if (!expectedMessages.includes(resource.message)) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
is(
|
is(
|
||||||
@@ -69,7 +68,6 @@ async function testPlatformMessagesResources() {
|
|||||||
if (receivedMessages.length == expectedMessages.length) {
|
if (receivedMessages.length == expectedMessages.length) {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await resourceWatcher.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
@@ -112,14 +110,12 @@ async function testPlatformMessagesResourcesWithIgnoreExistingResources() {
|
|||||||
await resourceWatcher.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[ResourceWatcher.TYPES.PLATFORM_MESSAGE],
|
[ResourceWatcher.TYPES.PLATFORM_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => {
|
onAvailable: ({ resource }) => {
|
||||||
for (const resource of resources) {
|
|
||||||
if (!expectedMessages.includes(resource.message)) {
|
if (!expectedMessages.includes(resource.message)) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
availableResources.push(resource);
|
availableResources.push(resource);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
ignoreExistingResources: true,
|
ignoreExistingResources: true,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ add_task(async function() {
|
|||||||
|
|
||||||
info("Call watchResources([ROOT_NODE], ...)");
|
info("Call watchResources([ROOT_NODE], ...)");
|
||||||
let onAvailableCounter = 0;
|
let onAvailableCounter = 0;
|
||||||
const onAvailable = resources => (onAvailableCounter += resources.length);
|
const onAvailable = () => onAvailableCounter++;
|
||||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ROOT_NODE], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ROOT_NODE], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
@@ -91,16 +91,16 @@ add_task(async function testRootNodeFrontIsCorrect() {
|
|||||||
|
|
||||||
let rootNodeResolve;
|
let rootNodeResolve;
|
||||||
let rootNodePromise = new Promise(r => (rootNodeResolve = r));
|
let rootNodePromise = new Promise(r => (rootNodeResolve = r));
|
||||||
const onAvailable = ([rootNodeFront]) => rootNodeResolve(rootNodeFront);
|
const onAvailable = rootNodeFront => rootNodeResolve(rootNodeFront);
|
||||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ROOT_NODE], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ROOT_NODE], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
|
|
||||||
info("Wait until onAvailable has been called");
|
info("Wait until onAvailable has been called");
|
||||||
const root1 = await rootNodePromise;
|
const { resource: root1, resourceType } = await rootNodePromise;
|
||||||
ok(!!root1, "onAvailable has been called with a valid argument");
|
ok(!!root1, "onAvailable has been called with a valid argument");
|
||||||
is(
|
is(
|
||||||
root1.resourceType,
|
resourceType,
|
||||||
ResourceWatcher.TYPES.ROOT_NODE,
|
ResourceWatcher.TYPES.ROOT_NODE,
|
||||||
"The resource has the expected type"
|
"The resource has the expected type"
|
||||||
);
|
);
|
||||||
@@ -113,7 +113,7 @@ add_task(async function testRootNodeFrontIsCorrect() {
|
|||||||
rootNodePromise = new Promise(r => (rootNodeResolve = r));
|
rootNodePromise = new Promise(r => (rootNodeResolve = r));
|
||||||
browser.reload();
|
browser.reload();
|
||||||
|
|
||||||
const root2 = await rootNodePromise;
|
const { resource: root2 } = await rootNodePromise;
|
||||||
ok(
|
ok(
|
||||||
root1 !== root2,
|
root1 !== root2,
|
||||||
"onAvailable has been called with a different node front after reload"
|
"onAvailable has been called with a different node front after reload"
|
||||||
@@ -122,7 +122,7 @@ add_task(async function testRootNodeFrontIsCorrect() {
|
|||||||
info("Navigate to another URL");
|
info("Navigate to another URL");
|
||||||
rootNodePromise = new Promise(r => (rootNodeResolve = r));
|
rootNodePromise = new Promise(r => (rootNodeResolve = r));
|
||||||
BrowserTestUtils.loadURI(browser, `data:text/html,<div id=div3>`);
|
BrowserTestUtils.loadURI(browser, `data:text/html,<div id=div3>`);
|
||||||
const root3 = await rootNodePromise;
|
const { resource: root3 } = await rootNodePromise;
|
||||||
info("Check we can query an expected node under the retrieved root");
|
info("Check we can query an expected node under the retrieved root");
|
||||||
const div3 = await root3.walkerFront.querySelector(root3, "div");
|
const div3 = await root3.walkerFront.querySelector(root3, "div");
|
||||||
is(div3.getAttribute("id"), "div3", "Correct root node retrieved");
|
is(div3.getAttribute("id"), "div3", "Correct root node retrieved");
|
||||||
|
|||||||
@@ -32,12 +32,10 @@ add_task(async function() {
|
|||||||
// We are only interested in console messages as a resource, the ROOT_NODE one
|
// We are only interested in console messages as a resource, the ROOT_NODE one
|
||||||
// is here to test the ResourceWatcher::unwatchResources API with several resources.
|
// is here to test the ResourceWatcher::unwatchResources API with several resources.
|
||||||
const receivedMessages = [];
|
const receivedMessages = [];
|
||||||
const onAvailable = resources => {
|
const onAvailable = ({ resource, resourceType }) => {
|
||||||
for (const resource of resources) {
|
if (resourceType === CONSOLE_MESSAGE) {
|
||||||
if (resource.resourceType === CONSOLE_MESSAGE) {
|
|
||||||
receivedMessages.push(resource);
|
receivedMessages.push(resource);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
info("Call watchResources([CONSOLE_MESSAGE, ROOT_NODE], ...)");
|
info("Call watchResources([CONSOLE_MESSAGE, ROOT_NODE], ...)");
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ add_task(async function() {
|
|||||||
info("Check whether ResourceWatcher gets existing stylesheet");
|
info("Check whether ResourceWatcher gets existing stylesheet");
|
||||||
const availableResources = [];
|
const availableResources = [];
|
||||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.STYLESHEET], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.STYLESHEET], {
|
||||||
onAvailable: resources => availableResources.push(...resources),
|
onAvailable: ({ resource }) => availableResources.push(resource),
|
||||||
});
|
});
|
||||||
|
|
||||||
is(
|
is(
|
||||||
@@ -176,8 +176,8 @@ add_task(async function() {
|
|||||||
const availableResources = [];
|
const availableResources = [];
|
||||||
const updates = [];
|
const updates = [];
|
||||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.STYLESHEET], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.STYLESHEET], {
|
||||||
onAvailable: resources => availableResources.push(...resources),
|
onAvailable: ({ resource }) => availableResources.push(resource),
|
||||||
onUpdated: newUpdates => updates.push(...newUpdates),
|
onUpdated: ({ resource, update }) => updates.push({ resource, update }),
|
||||||
});
|
});
|
||||||
is(
|
is(
|
||||||
availableResources.length,
|
availableResources.length,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ add_task(async function() {
|
|||||||
info("Check available resources at initial");
|
info("Check available resources at initial");
|
||||||
const availableResources = [];
|
const availableResources = [];
|
||||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.WEBSOCKET], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.WEBSOCKET], {
|
||||||
onAvailable: resources => availableResources.push(...resources),
|
onAvailable: ({ resource }) => availableResources.push(resource),
|
||||||
});
|
});
|
||||||
is(
|
is(
|
||||||
availableResources.length,
|
availableResources.length,
|
||||||
@@ -101,7 +101,7 @@ add_task(async function() {
|
|||||||
info("Check existing resources");
|
info("Check existing resources");
|
||||||
const existingResources = [];
|
const existingResources = [];
|
||||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.WEBSOCKET], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.WEBSOCKET], {
|
||||||
onAvailable: resources => existingResources.push(...resources),
|
onAvailable: ({ resource }) => existingResources.push(resource),
|
||||||
});
|
});
|
||||||
is(
|
is(
|
||||||
availableResources.length,
|
availableResources.length,
|
||||||
|
|||||||
Reference in New Issue
Block a user