Bug 1701790 - Mass replace resourceWatcher with resourceCommand. r=nchevobbe
$ sed -i 's/resourceWatcher/resourceCommand/g' $(egrep -rl 'resourceWatcher' devtools/) Differential Revision: https://phabricator.services.mozilla.com/D113933
This commit is contained in:
@@ -52,7 +52,7 @@ class DebuggerPanel {
|
||||
client,
|
||||
} = await this.panelWin.Debugger.bootstrap({
|
||||
commands: this.commands,
|
||||
resourceWatcher: this.toolbox.resourceWatcher,
|
||||
resourceCommand: this.toolbox.resourceCommand,
|
||||
devToolsClient: this.toolbox.target.client,
|
||||
workers: {
|
||||
sourceMaps: this.toolbox.sourceMapService,
|
||||
|
||||
@@ -15,12 +15,12 @@ import sourceQueue from "../utils/source-queue";
|
||||
|
||||
let actions;
|
||||
let targetCommand;
|
||||
let resourceWatcher;
|
||||
let resourceCommand;
|
||||
|
||||
export async function onConnect(commands, _resourceWatcher, _actions, store) {
|
||||
export async function onConnect(commands, _resourceCommand, _actions, store) {
|
||||
actions = _actions;
|
||||
targetCommand = commands.targetCommand;
|
||||
resourceWatcher = _resourceWatcher;
|
||||
resourceCommand = _resourceCommand;
|
||||
|
||||
setupCommands(commands);
|
||||
setupCreate({ store });
|
||||
@@ -43,13 +43,13 @@ export async function onConnect(commands, _resourceWatcher, _actions, store) {
|
||||
|
||||
// Use independant listeners for SOURCE and THREAD_STATE in order to ease
|
||||
// doing batching and notify about a set of SOURCE's in one redux action.
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.SOURCE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.SOURCE], {
|
||||
onAvailable: onSourceAvailable,
|
||||
});
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.THREAD_STATE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.THREAD_STATE], {
|
||||
onAvailable: onBreakpointAvailable,
|
||||
});
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.ERROR_MESSAGE], {
|
||||
onAvailable: actions.addExceptionFromResources,
|
||||
});
|
||||
}
|
||||
@@ -60,13 +60,13 @@ export function onDisconnect() {
|
||||
onTargetAvailable,
|
||||
onTargetDestroyed
|
||||
);
|
||||
resourceWatcher.unwatchResources([resourceWatcher.TYPES.SOURCE], {
|
||||
resourceCommand.unwatchResources([resourceCommand.TYPES.SOURCE], {
|
||||
onAvailable: onSourceAvailable,
|
||||
});
|
||||
resourceWatcher.unwatchResources([resourceWatcher.TYPES.THREAD_STATE], {
|
||||
resourceCommand.unwatchResources([resourceCommand.TYPES.THREAD_STATE], {
|
||||
onAvailable: onBreakpointAvailable,
|
||||
});
|
||||
resourceWatcher.unwatchResources([resourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||
resourceCommand.unwatchResources([resourceCommand.TYPES.ERROR_MESSAGE], {
|
||||
onAvailable: actions.addExceptionFromResources,
|
||||
});
|
||||
sourceQueue.clear();
|
||||
|
||||
@@ -66,7 +66,7 @@ async function loadInitialState() {
|
||||
|
||||
export async function bootstrap({
|
||||
commands,
|
||||
resourceWatcher,
|
||||
resourceCommand,
|
||||
workers: panelWorkers,
|
||||
panel,
|
||||
}) {
|
||||
@@ -84,7 +84,7 @@ export async function bootstrap({
|
||||
|
||||
const connected = firefox.onConnect(
|
||||
commands,
|
||||
resourceWatcher,
|
||||
resourceCommand,
|
||||
actions,
|
||||
store
|
||||
);
|
||||
|
||||
@@ -202,10 +202,10 @@ class SourceMapURLService {
|
||||
this._pendingURLSubscriptions.clear();
|
||||
this._urlToIDMap.clear();
|
||||
|
||||
const { resourceWatcher } = this._toolbox;
|
||||
const { resourceCommand } = this._toolbox;
|
||||
try {
|
||||
resourceWatcher.unwatchResources(
|
||||
[resourceWatcher.TYPES.STYLESHEET, resourceWatcher.TYPES.SOURCE],
|
||||
resourceCommand.unwatchResources(
|
||||
[resourceCommand.TYPES.STYLESHEET, resourceCommand.TYPES.SOURCE],
|
||||
{ onAvailable: this._onResourceAvailable }
|
||||
);
|
||||
} catch (e) {
|
||||
@@ -421,10 +421,10 @@ class SourceMapURLService {
|
||||
}
|
||||
|
||||
if (!this._sourcesLoading) {
|
||||
const { resourceWatcher } = this._toolbox;
|
||||
const { STYLESHEET, SOURCE } = resourceWatcher.TYPES;
|
||||
const { resourceCommand } = this._toolbox;
|
||||
const { STYLESHEET, SOURCE } = resourceCommand.TYPES;
|
||||
|
||||
this._sourcesLoading = resourceWatcher.watchResources(
|
||||
this._sourcesLoading = resourceCommand.watchResources(
|
||||
[STYLESHEET, SOURCE],
|
||||
{
|
||||
onAvailable: this._onResourceAvailable,
|
||||
@@ -443,8 +443,8 @@ class SourceMapURLService {
|
||||
}
|
||||
|
||||
_onResourceAvailable(resources) {
|
||||
const { resourceWatcher } = this._toolbox;
|
||||
const { STYLESHEET, SOURCE } = resourceWatcher.TYPES;
|
||||
const { resourceCommand } = this._toolbox;
|
||||
const { STYLESHEET, SOURCE } = resourceCommand.TYPES;
|
||||
for (const resource of resources) {
|
||||
if (resource.resourceType == STYLESHEET) {
|
||||
this._onNewStyleSheet(resource);
|
||||
|
||||
@@ -120,19 +120,19 @@ function createScript(url) {
|
||||
function waitForSourceLoad(toolbox, url) {
|
||||
info(`Waiting for source ${url} to be available...`);
|
||||
return new Promise(resolve => {
|
||||
const { resourceWatcher } = toolbox;
|
||||
const { resourceCommand } = toolbox;
|
||||
|
||||
function onAvailable(sources) {
|
||||
for (const source of sources) {
|
||||
if (source.url === url) {
|
||||
resourceWatcher.unwatchResources([resourceWatcher.TYPES.SOURCE], {
|
||||
resourceCommand.unwatchResources([resourceCommand.TYPES.SOURCE], {
|
||||
onAvailable,
|
||||
});
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
}
|
||||
resourceWatcher.watchResources([resourceWatcher.TYPES.SOURCE], {
|
||||
resourceCommand.watchResources([resourceCommand.TYPES.SOURCE], {
|
||||
onAvailable,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -784,8 +784,8 @@ Toolbox.prototype = {
|
||||
this._onTargetThreadFrontResumeWrongOrder.bind(this)
|
||||
);
|
||||
|
||||
// TODO: Use commands.resourceCommand instead of toolbox.resourceWatcher
|
||||
this.resourceWatcher = this.commands.resourceCommand;
|
||||
// Bug 1709063: Use commands.resourceCommand instead of toolbox.resourceCommand
|
||||
this.resourceCommand = this.commands.resourceCommand;
|
||||
|
||||
// Optimization: fire up a few other things before waiting on
|
||||
// the iframe being ready (makes startup faster)
|
||||
@@ -803,16 +803,16 @@ Toolbox.prototype = {
|
||||
|
||||
// Watch for console API messages, errors and network events in order to populate
|
||||
// the error count icon in the toolbox.
|
||||
const onResourcesWatched = this.resourceWatcher.watchResources(
|
||||
const onResourcesWatched = this.resourceCommand.watchResources(
|
||||
[
|
||||
this.resourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||
this.resourceWatcher.TYPES.ERROR_MESSAGE,
|
||||
this.resourceCommand.TYPES.CONSOLE_MESSAGE,
|
||||
this.resourceCommand.TYPES.ERROR_MESSAGE,
|
||||
// Independently of watching network event resources for the error count icon,
|
||||
// we need to start tracking network activity on toolbox open for targets such
|
||||
// as tabs, in order to ensure there is always at least one listener existing
|
||||
// for network events across the lifetime of the various panels, so stopping
|
||||
// the resource watcher from clearing out its cache of network event resources.
|
||||
this.resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
// the resource command from clearing out its cache of network event resources.
|
||||
this.resourceCommand.TYPES.NETWORK_EVENT,
|
||||
],
|
||||
{
|
||||
onAvailable: this._onResourceAvailable,
|
||||
@@ -3761,11 +3761,11 @@ Toolbox.prototype = {
|
||||
this._onTargetAvailable,
|
||||
this._onTargetDestroyed
|
||||
);
|
||||
this.resourceWatcher.unwatchResources(
|
||||
this.resourceCommand.unwatchResources(
|
||||
[
|
||||
this.resourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||
this.resourceWatcher.TYPES.ERROR_MESSAGE,
|
||||
this.resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
this.resourceCommand.TYPES.CONSOLE_MESSAGE,
|
||||
this.resourceCommand.TYPES.ERROR_MESSAGE,
|
||||
this.resourceCommand.TYPES.NETWORK_EVENT,
|
||||
],
|
||||
{ onAvailable: this._onResourceAvailable }
|
||||
);
|
||||
@@ -4308,7 +4308,7 @@ Toolbox.prototype = {
|
||||
|
||||
for (const resource of resources) {
|
||||
if (
|
||||
resource.resourceType === this.resourceWatcher.TYPES.ERROR_MESSAGE &&
|
||||
resource.resourceType === this.resourceCommand.TYPES.ERROR_MESSAGE &&
|
||||
// ERROR_MESSAGE resources can be warnings/info, but here we only want to count errors
|
||||
resource.pageError.error
|
||||
) {
|
||||
@@ -4317,7 +4317,7 @@ Toolbox.prototype = {
|
||||
}
|
||||
|
||||
if (
|
||||
resource.resourceType === this.resourceWatcher.TYPES.CONSOLE_MESSAGE
|
||||
resource.resourceType === this.resourceCommand.TYPES.CONSOLE_MESSAGE
|
||||
) {
|
||||
const { level } = resource.message;
|
||||
if (level === "error" || level === "exception" || level === "assert") {
|
||||
@@ -4340,7 +4340,7 @@ Toolbox.prototype = {
|
||||
for (const { update } of resources) {
|
||||
// In order to match webconsole behaviour, we treat 4xx and 5xx network calls as errors.
|
||||
if (
|
||||
update.resourceType === this.resourceWatcher.TYPES.NETWORK_EVENT &&
|
||||
update.resourceType === this.resourceCommand.TYPES.NETWORK_EVENT &&
|
||||
update.resourceUpdates.status &&
|
||||
update.resourceUpdates.status.toString().match(REGEX_4XX_5XX)
|
||||
) {
|
||||
|
||||
@@ -54,13 +54,13 @@ class InspectorFront extends FrontClassWithSpec(inspectorSpec) {
|
||||
// If the server-side support for stylesheet resources is enabled, we need to start
|
||||
// to watch for them before instanciating the pageStyle actor (which does use the
|
||||
// watcher and assume we're already watching for stylesheets).
|
||||
const { resourceWatcher } = this.targetFront;
|
||||
const { resourceCommand } = this.targetFront;
|
||||
if (
|
||||
resourceWatcher?.hasResourceCommandSupport(
|
||||
resourceWatcher.TYPES.STYLESHEET
|
||||
resourceCommand?.hasResourceCommandSupport(
|
||||
resourceCommand.TYPES.STYLESHEET
|
||||
)
|
||||
) {
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.STYLESHEET], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.STYLESHEET], {
|
||||
// we simply want to start the watcher, we don't have to do anything with those resources.
|
||||
onAvailable: () => {},
|
||||
});
|
||||
|
||||
@@ -110,14 +110,14 @@ class StyleRuleFront extends FrontClassWithSpec(styleRuleSpec) {
|
||||
}
|
||||
|
||||
get parentStyleSheet() {
|
||||
const resourceWatcher = this.targetFront.resourceWatcher;
|
||||
const resourceCommand = this.targetFront.resourceCommand;
|
||||
if (
|
||||
resourceWatcher?.hasResourceCommandSupport(
|
||||
resourceWatcher.TYPES.STYLESHEET
|
||||
resourceCommand?.hasResourceCommandSupport(
|
||||
resourceCommand.TYPES.STYLESHEET
|
||||
)
|
||||
) {
|
||||
return resourceWatcher.getResourceById(
|
||||
resourceWatcher.TYPES.STYLESHEET,
|
||||
return resourceCommand.getResourceById(
|
||||
resourceCommand.TYPES.STYLESHEET,
|
||||
this._form.parentStyleSheet
|
||||
);
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ class ChangesView {
|
||||
return this._contextMenu;
|
||||
}
|
||||
|
||||
get resourceWatcher() {
|
||||
return this.inspector.toolbox.resourceWatcher;
|
||||
get resourceCommand() {
|
||||
return this.inspector.toolbox.resourceCommand;
|
||||
}
|
||||
|
||||
init() {
|
||||
@@ -101,27 +101,27 @@ class ChangesView {
|
||||
}
|
||||
|
||||
async watchResources() {
|
||||
await this.resourceWatcher.watchResources(
|
||||
[this.resourceWatcher.TYPES.DOCUMENT_EVENT],
|
||||
await this.resourceCommand.watchResources(
|
||||
[this.resourceCommand.TYPES.DOCUMENT_EVENT],
|
||||
{
|
||||
onAvailable: this.onResourceAvailable,
|
||||
// Ignore any DOCUMENT_EVENT resources that have occured in the past
|
||||
// and are cached by the resource watcher, otherwise the Changes panel will
|
||||
// and are cached by the resource command, otherwise the Changes panel will
|
||||
// react to them erroneously and interpret that the document is reloading *now*
|
||||
// which leads to clearing all stored changes.
|
||||
ignoreExistingResources: true,
|
||||
}
|
||||
);
|
||||
|
||||
await this.resourceWatcher.watchResources(
|
||||
[this.resourceWatcher.TYPES.CSS_CHANGE],
|
||||
await this.resourceCommand.watchResources(
|
||||
[this.resourceCommand.TYPES.CSS_CHANGE],
|
||||
{ onAvailable: this.onResourceAvailable }
|
||||
);
|
||||
}
|
||||
|
||||
onResourceAvailable(resources) {
|
||||
for (const resource of resources) {
|
||||
if (resource.resourceType === this.resourceWatcher.TYPES.CSS_CHANGE) {
|
||||
if (resource.resourceType === this.resourceCommand.TYPES.CSS_CHANGE) {
|
||||
this.onAddChange(resource);
|
||||
continue;
|
||||
}
|
||||
@@ -256,10 +256,10 @@ class ChangesView {
|
||||
* Destruction function called when the inspector is destroyed.
|
||||
*/
|
||||
destroy() {
|
||||
this.resourceWatcher.unwatchResources(
|
||||
this.resourceCommand.unwatchResources(
|
||||
[
|
||||
this.resourceWatcher.TYPES.CSS_CHANGE,
|
||||
this.resourceWatcher.TYPES.DOCUMENT_EVENT,
|
||||
this.resourceCommand.TYPES.CSS_CHANGE,
|
||||
this.resourceCommand.TYPES.DOCUMENT_EVENT,
|
||||
],
|
||||
{ onAvailable: this.onResourceAvailable }
|
||||
);
|
||||
|
||||
@@ -48,8 +48,8 @@ class CompatibilityView {
|
||||
|
||||
destroy() {
|
||||
try {
|
||||
this.resourceWatcher.unwatchResources(
|
||||
[this.resourceWatcher.TYPES.CSS_CHANGE],
|
||||
this.resourceCommand.unwatchResources(
|
||||
[this.resourceCommand.TYPES.CSS_CHANGE],
|
||||
{
|
||||
onAvailable: this._onResourceAvailable,
|
||||
}
|
||||
@@ -69,8 +69,8 @@ class CompatibilityView {
|
||||
this.inspector = null;
|
||||
}
|
||||
|
||||
get resourceWatcher() {
|
||||
return this.inspector.toolbox.resourceWatcher;
|
||||
get resourceCommand() {
|
||||
return this.inspector.toolbox.resourceCommand;
|
||||
}
|
||||
|
||||
async _init() {
|
||||
@@ -104,8 +104,8 @@ class CompatibilityView {
|
||||
this._onPanelSelected
|
||||
);
|
||||
|
||||
await this.resourceWatcher.watchResources(
|
||||
[this.resourceWatcher.TYPES.CSS_CHANGE],
|
||||
await this.resourceCommand.watchResources(
|
||||
[this.resourceCommand.TYPES.CSS_CHANGE],
|
||||
{
|
||||
onAvailable: this._onResourceAvailable,
|
||||
// CSS changes made before opening Compatibility View are already applied to
|
||||
|
||||
@@ -208,11 +208,11 @@ Inspector.prototype = {
|
||||
this._onTargetDestroyed
|
||||
);
|
||||
|
||||
await this.toolbox.resourceWatcher.watchResources(
|
||||
await this.toolbox.resourceCommand.watchResources(
|
||||
[
|
||||
this.toolbox.resourceWatcher.TYPES.ROOT_NODE,
|
||||
this.toolbox.resourceCommand.TYPES.ROOT_NODE,
|
||||
// To observe CSS change before opening changes view.
|
||||
this.toolbox.resourceWatcher.TYPES.CSS_CHANGE,
|
||||
this.toolbox.resourceCommand.TYPES.CSS_CHANGE,
|
||||
],
|
||||
{ onAvailable: this.onResourceAvailable }
|
||||
);
|
||||
@@ -1276,7 +1276,7 @@ Inspector.prototype = {
|
||||
for (const resource of resources) {
|
||||
if (
|
||||
resource.resourceType ===
|
||||
this.toolbox.resourceWatcher.TYPES.ROOT_NODE &&
|
||||
this.toolbox.resourceCommand.TYPES.ROOT_NODE &&
|
||||
// It might happen that the ROOT_NODE resource (which is a Front) is already
|
||||
// destroyed, and in such case we want to ignore it.
|
||||
!resource.isDestroyed()
|
||||
@@ -1679,9 +1679,9 @@ Inspector.prototype = {
|
||||
this._onTargetAvailable,
|
||||
this._onTargetDestroyed
|
||||
);
|
||||
const { resourceWatcher } = this.toolbox;
|
||||
resourceWatcher.unwatchResources(
|
||||
[resourceWatcher.TYPES.ROOT_NODE, resourceWatcher.TYPES.CSS_CHANGE],
|
||||
const { resourceCommand } = this.toolbox;
|
||||
resourceCommand.unwatchResources(
|
||||
[resourceCommand.TYPES.ROOT_NODE, resourceCommand.TYPES.CSS_CHANGE],
|
||||
{ onAvailable: this.onResourceAvailable }
|
||||
);
|
||||
|
||||
|
||||
@@ -372,8 +372,8 @@ function MarkupView(inspector, frame, controllerWindow) {
|
||||
mutations: this._onWalkerMutations,
|
||||
});
|
||||
|
||||
this.resourceWatcher = this.inspector.toolbox.resourceWatcher;
|
||||
this.resourceWatcher.watchResources([this.resourceWatcher.TYPES.ROOT_NODE], {
|
||||
this.resourceCommand = this.inspector.toolbox.resourceCommand;
|
||||
this.resourceCommand.watchResources([this.resourceCommand.TYPES.ROOT_NODE], {
|
||||
onAvailable: this._onResourceAvailable,
|
||||
});
|
||||
}
|
||||
@@ -1442,7 +1442,7 @@ MarkupView.prototype = {
|
||||
_onResourceAvailable: async function(resources) {
|
||||
for (const resource of resources) {
|
||||
if (
|
||||
resource.resourceType !== this.resourceWatcher.TYPES.ROOT_NODE ||
|
||||
resource.resourceType !== this.resourceCommand.TYPES.ROOT_NODE ||
|
||||
resource.isDestroyed()
|
||||
) {
|
||||
// Only handle alive root-node resources
|
||||
@@ -2379,8 +2379,8 @@ MarkupView.prototype = {
|
||||
this._elt.removeEventListener("mouseout", this._onMouseOut);
|
||||
this._frame.removeEventListener("focus", this._onFocus);
|
||||
this.inspector.selection.off("new-node-front", this._onNewSelection);
|
||||
this.resourceWatcher.unwatchResources(
|
||||
[this.resourceWatcher.TYPES.ROOT_NODE],
|
||||
this.resourceCommand.unwatchResources(
|
||||
[this.resourceCommand.TYPES.ROOT_NODE],
|
||||
{ onAvailable: this._onResourceAvailable }
|
||||
);
|
||||
this.inspector.toolbox.nodePicker.off(
|
||||
|
||||
@@ -213,9 +213,9 @@ class HighlightersOverlay {
|
||||
// Add inspector events, not specific to a given view.
|
||||
this.inspector.on("markupmutation", this.onMarkupMutation);
|
||||
|
||||
this.resourceWatcher = this.inspector.toolbox.resourceWatcher;
|
||||
this.resourceWatcher.watchResources(
|
||||
[this.resourceWatcher.TYPES.ROOT_NODE],
|
||||
this.resourceCommand = this.inspector.toolbox.resourceCommand;
|
||||
this.resourceCommand.watchResources(
|
||||
[this.resourceCommand.TYPES.ROOT_NODE],
|
||||
{ onAvailable: this._onResourceAvailable }
|
||||
);
|
||||
|
||||
@@ -1742,7 +1742,7 @@ class HighlightersOverlay {
|
||||
async _onResourceAvailable(resources) {
|
||||
for (const resource of resources) {
|
||||
if (
|
||||
resource.resourceType !== this.resourceWatcher.TYPES.ROOT_NODE ||
|
||||
resource.resourceType !== this.resourceCommand.TYPES.ROOT_NODE ||
|
||||
// It might happen that the ROOT_NODE resource (which is a Front) is already
|
||||
// destroyed, and in such case we want to ignore it.
|
||||
resource.isDestroyed()
|
||||
@@ -1888,8 +1888,8 @@ class HighlightersOverlay {
|
||||
*/
|
||||
destroy() {
|
||||
this.inspector.off("markupmutation", this.onMarkupMutation);
|
||||
this.resourceWatcher.unwatchResources(
|
||||
[this.resourceWatcher.TYPES.ROOT_NODE],
|
||||
this.resourceCommand.unwatchResources(
|
||||
[this.resourceCommand.TYPES.ROOT_NODE],
|
||||
{ onAvailable: this._onResourceAvailable }
|
||||
);
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ add_task(async function navigateFrameNotExpandedInMarkupView() {
|
||||
}
|
||||
|
||||
const { inspector } = await openInspectorForURL(TEST_ORG_URI);
|
||||
const resourceWatcher = inspector.toolbox.resourceWatcher;
|
||||
const resourceCommand = inspector.toolbox.resourceCommand;
|
||||
|
||||
// At this stage the expected layout of the markup view is
|
||||
// v html (expanded)
|
||||
@@ -81,7 +81,7 @@ add_task(async function navigateFrameNotExpandedInMarkupView() {
|
||||
|
||||
is(
|
||||
resource.resourceType,
|
||||
resourceWatcher.TYPES.ROOT_NODE,
|
||||
resourceCommand.TYPES.ROOT_NODE,
|
||||
"A resource with resourceType ROOT_NODE was received when navigating"
|
||||
);
|
||||
|
||||
@@ -110,12 +110,12 @@ async function navigateIframeTo(inspector, url) {
|
||||
info("Navigate the test iframe to " + url);
|
||||
|
||||
const { commands } = inspector;
|
||||
const { resourceWatcher } = inspector.toolbox;
|
||||
const { resourceCommand } = inspector.toolbox;
|
||||
const onTargetProcessed = waitForTargetProcessed(commands, url);
|
||||
|
||||
const onNewRoot = waitForNextResource(
|
||||
resourceWatcher,
|
||||
resourceWatcher.TYPES.ROOT_NODE,
|
||||
resourceCommand,
|
||||
resourceCommand.TYPES.ROOT_NODE,
|
||||
{
|
||||
ignoreExistingResources: true,
|
||||
}
|
||||
@@ -144,7 +144,7 @@ async function navigateIframeTo(inspector, url) {
|
||||
/**
|
||||
* Returns a promise that waits until the provided commands's TargetCommand has fully
|
||||
* processed a target with the provided URL.
|
||||
* This will avoid navigating again before the new resource watchers have fully
|
||||
* This will avoid navigating again before the new resource command have fully
|
||||
* attached to the new target.
|
||||
*/
|
||||
function waitForTargetProcessed(commands, url) {
|
||||
|
||||
@@ -29,15 +29,15 @@ class FirefoxDataProvider {
|
||||
* @param {Object} webConsoleFront represents the client object for Console actor.
|
||||
* @param {Object} actions set of actions fired during data fetching process.
|
||||
* @param {Object} owner all events are fired on this object.
|
||||
* @param {Object} resourceWatcher enables checking for watcher support
|
||||
* @param {Object} resourceCommand enables checking for watcher support
|
||||
*/
|
||||
constructor({ webConsoleFront, actions, owner, resourceWatcher }) {
|
||||
constructor({ webConsoleFront, actions, owner, resourceCommand }) {
|
||||
// Options
|
||||
this.webConsoleFront = webConsoleFront;
|
||||
this.actions = actions || {};
|
||||
this.actionsEnabled = true;
|
||||
this.owner = owner;
|
||||
this.resourceWatcher = resourceWatcher;
|
||||
this.resourceCommand = resourceCommand;
|
||||
// Map of all stacktrace resources keyed by network event's resourceId
|
||||
this.stackTraces = new Map();
|
||||
// Map of the stacktrace information keyed by the actor id's
|
||||
@@ -521,8 +521,8 @@ class FirefoxDataProvider {
|
||||
let response;
|
||||
if (
|
||||
clientMethodName == "getStackTrace" &&
|
||||
this.resourceWatcher.hasResourceCommandSupport(
|
||||
this.resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE
|
||||
this.resourceCommand.hasResourceCommandSupport(
|
||||
this.resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE
|
||||
)
|
||||
) {
|
||||
const requestInfo = this.stackTraceRequestInfoByActorID.get(
|
||||
|
||||
@@ -55,13 +55,13 @@ class Connector {
|
||||
}
|
||||
|
||||
get hasResourceCommandSupport() {
|
||||
return this.toolbox.resourceWatcher.hasResourceCommandSupport(
|
||||
this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT
|
||||
return this.toolbox.resourceCommand.hasResourceCommandSupport(
|
||||
this.toolbox.resourceCommand.TYPES.NETWORK_EVENT
|
||||
);
|
||||
}
|
||||
|
||||
get watcherFront() {
|
||||
return this.toolbox.resourceWatcher.watcherFront;
|
||||
return this.toolbox.resourceCommand.watcherFront;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,8 +85,8 @@ class Connector {
|
||||
this.onTargetAvailable
|
||||
);
|
||||
|
||||
await this.toolbox.resourceWatcher.watchResources(
|
||||
[this.toolbox.resourceWatcher.TYPES.DOCUMENT_EVENT],
|
||||
await this.toolbox.resourceCommand.watchResources(
|
||||
[this.toolbox.resourceCommand.TYPES.DOCUMENT_EVENT],
|
||||
{ onAvailable: this.onResourceAvailable }
|
||||
);
|
||||
}
|
||||
@@ -104,8 +104,8 @@ class Connector {
|
||||
this.onTargetAvailable
|
||||
);
|
||||
|
||||
this.toolbox.resourceWatcher.unwatchResources(
|
||||
[this.toolbox.resourceWatcher.TYPES.DOCUMENT_EVENT],
|
||||
this.toolbox.resourceCommand.unwatchResources(
|
||||
[this.toolbox.resourceCommand.TYPES.DOCUMENT_EVENT],
|
||||
{ onAvailable: this.onResourceAvailable }
|
||||
);
|
||||
|
||||
@@ -151,7 +151,7 @@ class Connector {
|
||||
webConsoleFront: this.webConsoleFront,
|
||||
actions: this.actions,
|
||||
owner: this.owner,
|
||||
resourceWatcher: this.toolbox.resourceWatcher,
|
||||
resourceCommand: this.toolbox.resourceCommand,
|
||||
});
|
||||
|
||||
// If this is the first top level target, lets register all the listeners
|
||||
@@ -168,7 +168,7 @@ class Connector {
|
||||
|
||||
async onResourceAvailable(resources) {
|
||||
for (const resource of resources) {
|
||||
const { TYPES } = this.toolbox.resourceWatcher;
|
||||
const { TYPES } = this.toolbox.resourceCommand;
|
||||
|
||||
if (resource.resourceType === TYPES.DOCUMENT_EVENT) {
|
||||
this.onDocEvent(resource);
|
||||
@@ -249,7 +249,7 @@ class Connector {
|
||||
for (const { resource, update } of updates) {
|
||||
if (
|
||||
resource.resourceType ===
|
||||
this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT &&
|
||||
this.toolbox.resourceCommand.TYPES.NETWORK_EVENT &&
|
||||
this.listenForNetworkEvents
|
||||
) {
|
||||
this.dataProvider.onNetworkResourceUpdated(resource, update);
|
||||
@@ -259,11 +259,11 @@ class Connector {
|
||||
|
||||
async addListeners(ignoreExistingResources = false) {
|
||||
const targetResources = [
|
||||
this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||
this.toolbox.resourceCommand.TYPES.NETWORK_EVENT,
|
||||
this.toolbox.resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||
];
|
||||
if (Services.prefs.getBoolPref("devtools.netmonitor.features.webSockets")) {
|
||||
targetResources.push(this.toolbox.resourceWatcher.TYPES.WEBSOCKET);
|
||||
targetResources.push(this.toolbox.resourceCommand.TYPES.WEBSOCKET);
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -272,11 +272,11 @@ class Connector {
|
||||
)
|
||||
) {
|
||||
targetResources.push(
|
||||
this.toolbox.resourceWatcher.TYPES.SERVER_SENT_EVENT
|
||||
this.toolbox.resourceCommand.TYPES.SERVER_SENT_EVENT
|
||||
);
|
||||
}
|
||||
|
||||
await this.toolbox.resourceWatcher.watchResources(targetResources, {
|
||||
await this.toolbox.resourceCommand.watchResources(targetResources, {
|
||||
onAvailable: this.onResourceAvailable,
|
||||
onUpdated: this.onResourceUpdated,
|
||||
ignoreExistingResources,
|
||||
@@ -284,12 +284,12 @@ class Connector {
|
||||
}
|
||||
|
||||
removeListeners() {
|
||||
this.toolbox.resourceWatcher.unwatchResources(
|
||||
this.toolbox.resourceCommand.unwatchResources(
|
||||
[
|
||||
this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||
this.toolbox.resourceWatcher.TYPES.WEBSOCKET,
|
||||
this.toolbox.resourceWatcher.TYPES.SERVER_SENT_EVENT,
|
||||
this.toolbox.resourceCommand.TYPES.NETWORK_EVENT,
|
||||
this.toolbox.resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||
this.toolbox.resourceCommand.TYPES.WEBSOCKET,
|
||||
this.toolbox.resourceCommand.TYPES.SERVER_SENT_EVENT,
|
||||
],
|
||||
{
|
||||
onAvailable: this.onResourceAvailable,
|
||||
|
||||
@@ -86,7 +86,7 @@ HarAutomation.prototype = {
|
||||
// data from events sent from the backend.
|
||||
this.collector = new HarCollector({
|
||||
webConsoleFront: this.webConsoleFront,
|
||||
resourceWatcher: this.toolbox.resourceWatcher,
|
||||
resourceCommand: this.toolbox.resourceCommand,
|
||||
});
|
||||
|
||||
this.collector.start();
|
||||
|
||||
@@ -17,7 +17,7 @@ const trace = {
|
||||
*/
|
||||
function HarCollector(options) {
|
||||
this.webConsoleFront = options.webConsoleFront;
|
||||
this.resourceWatcher = options.resourceWatcher;
|
||||
this.resourceCommand = options.resourceCommand;
|
||||
|
||||
this.onResourceAvailable = this.onResourceAvailable.bind(this);
|
||||
this.onResourceUpdated = this.onResourceUpdated.bind(this);
|
||||
@@ -36,8 +36,8 @@ HarCollector.prototype = {
|
||||
// Connection
|
||||
|
||||
start: async function() {
|
||||
await this.resourceWatcher.watchResources(
|
||||
[this.resourceWatcher.TYPES.NETWORK_EVENT],
|
||||
await this.resourceCommand.watchResources(
|
||||
[this.resourceCommand.TYPES.NETWORK_EVENT],
|
||||
{
|
||||
onAvailable: this.onResourceAvailable,
|
||||
onUpdated: this.onResourceUpdated,
|
||||
@@ -46,8 +46,8 @@ HarCollector.prototype = {
|
||||
},
|
||||
|
||||
stop: async function() {
|
||||
await this.resourceWatcher.unwatchResources(
|
||||
[this.resourceWatcher.TYPES.NETWORK_EVENT],
|
||||
await this.resourceCommand.unwatchResources(
|
||||
[this.resourceCommand.TYPES.NETWORK_EVENT],
|
||||
{
|
||||
onAvailable: this.onResourceAvailable,
|
||||
onUpdated: this.onResourceUpdated,
|
||||
|
||||
@@ -488,8 +488,8 @@ function waitForNetworkEvents(monitor, getRequests, options = {}) {
|
||||
async function waitForNetworkResource(toolbox, noOfExpectedResources = 1) {
|
||||
let countOfAvailableResources = 0;
|
||||
return waitForNextResource(
|
||||
toolbox.resourceWatcher,
|
||||
toolbox.resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
toolbox.resourceCommand,
|
||||
toolbox.resourceCommand.TYPES.NETWORK_EVENT,
|
||||
{
|
||||
ignoreExistingResources: true,
|
||||
predicate: resource =>
|
||||
|
||||
@@ -114,7 +114,7 @@ class ResponsiveUI {
|
||||
}
|
||||
|
||||
get watcherFront() {
|
||||
return this.resourceWatcher.watcherFront;
|
||||
return this.resourceCommand.watcherFront;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -329,8 +329,8 @@ class ResponsiveUI {
|
||||
this.onTargetAvailable
|
||||
);
|
||||
|
||||
this.resourceWatcher.unwatchResources(
|
||||
[this.resourceWatcher.TYPES.NETWORK_EVENT],
|
||||
this.resourceCommand.unwatchResources(
|
||||
[this.resourceCommand.TYPES.NETWORK_EVENT],
|
||||
{ onAvailable: this.onNetworkResourceAvailable }
|
||||
);
|
||||
|
||||
@@ -367,8 +367,7 @@ class ResponsiveUI {
|
||||
|
||||
async connectToServer() {
|
||||
this.commands = await CommandsFactory.forTab(this.tab);
|
||||
//TODO: use commands.resourceCommands instead of resourceWatcher
|
||||
this.resourceWatcher = this.commands.resourceCommand;
|
||||
this.resourceCommand = this.commands.resourceCommand;
|
||||
|
||||
await this.commands.targetCommand.startListening();
|
||||
|
||||
@@ -377,10 +376,10 @@ class ResponsiveUI {
|
||||
this.onTargetAvailable
|
||||
);
|
||||
|
||||
// To support network throttling the resource watcher
|
||||
// To support network throttling the resource command
|
||||
// needs to be watching for network resources.
|
||||
await this.resourceWatcher.watchResources(
|
||||
[this.resourceWatcher.TYPES.NETWORK_EVENT],
|
||||
await this.resourceCommand.watchResources(
|
||||
[this.resourceCommand.TYPES.NETWORK_EVENT],
|
||||
{ onAvailable: this.onNetworkResourceAvailable }
|
||||
);
|
||||
|
||||
|
||||
@@ -1194,7 +1194,7 @@ function getCurrentTestFilePath() {
|
||||
/**
|
||||
* Wait for a single resource of the provided resourceType.
|
||||
*
|
||||
* @param {ResourceCommand} resourceWatcher
|
||||
* @param {ResourceCommand} resourceCommand
|
||||
* The ResourceCommand instance that should emit the expected resource.
|
||||
* @param {String} resourceType
|
||||
* One of ResourceCommand.TYPES, type of the expected resource.
|
||||
@@ -1207,7 +1207,7 @@ function getCurrentTestFilePath() {
|
||||
* - targetFront {TargetFront} the target which owns the resource
|
||||
*/
|
||||
function waitForNextResource(
|
||||
resourceWatcher,
|
||||
resourceCommand,
|
||||
resourceType,
|
||||
{ ignoreExistingResources = false, predicate } = {}
|
||||
) {
|
||||
@@ -1220,11 +1220,11 @@ function waitForNextResource(
|
||||
const matchingResource = resources.find(resource => predicate(resource));
|
||||
if (matchingResource) {
|
||||
resolve(matchingResource);
|
||||
resourceWatcher.unwatchResources([resourceType], { onAvailable });
|
||||
resourceCommand.unwatchResources([resourceType], { onAvailable });
|
||||
}
|
||||
};
|
||||
|
||||
resourceWatcher.watchResources([resourceType], {
|
||||
resourceCommand.watchResources([resourceType], {
|
||||
ignoreExistingResources,
|
||||
onAvailable,
|
||||
});
|
||||
|
||||
@@ -285,17 +285,17 @@ class StorageUI {
|
||||
|
||||
this._onResourceListAvailable = this._onResourceListAvailable.bind(this);
|
||||
|
||||
const { resourceWatcher } = this._toolbox;
|
||||
await this._toolbox.resourceWatcher.watchResources(
|
||||
const { resourceCommand } = this._toolbox;
|
||||
await this._toolbox.resourceCommand.watchResources(
|
||||
[
|
||||
// The first item in this list will be the first selected storage item
|
||||
// Tests assume Cookie -- moving cookie will break tests
|
||||
resourceWatcher.TYPES.COOKIE,
|
||||
resourceWatcher.TYPES.CACHE_STORAGE,
|
||||
resourceWatcher.TYPES.EXTENSION_STORAGE,
|
||||
resourceWatcher.TYPES.INDEXED_DB,
|
||||
resourceWatcher.TYPES.LOCAL_STORAGE,
|
||||
resourceWatcher.TYPES.SESSION_STORAGE,
|
||||
resourceCommand.TYPES.COOKIE,
|
||||
resourceCommand.TYPES.CACHE_STORAGE,
|
||||
resourceCommand.TYPES.EXTENSION_STORAGE,
|
||||
resourceCommand.TYPES.INDEXED_DB,
|
||||
resourceCommand.TYPES.LOCAL_STORAGE,
|
||||
resourceCommand.TYPES.SESSION_STORAGE,
|
||||
],
|
||||
{
|
||||
onAvailable: this._onResourceListAvailable,
|
||||
@@ -376,15 +376,15 @@ class StorageUI {
|
||||
}
|
||||
|
||||
destroy() {
|
||||
const { resourceWatcher } = this._toolbox;
|
||||
resourceWatcher.unwatchResources(
|
||||
const { resourceCommand } = this._toolbox;
|
||||
resourceCommand.unwatchResources(
|
||||
[
|
||||
resourceWatcher.TYPES.COOKIE,
|
||||
resourceWatcher.TYPES.CACHE_STORAGE,
|
||||
resourceWatcher.TYPES.EXTENSION_STORAGE,
|
||||
resourceWatcher.TYPES.INDEXED_DB,
|
||||
resourceWatcher.TYPES.LOCAL_STORAGE,
|
||||
resourceWatcher.TYPES.SESSION_STORAGE,
|
||||
resourceCommand.TYPES.COOKIE,
|
||||
resourceCommand.TYPES.CACHE_STORAGE,
|
||||
resourceCommand.TYPES.EXTENSION_STORAGE,
|
||||
resourceCommand.TYPES.INDEXED_DB,
|
||||
resourceCommand.TYPES.LOCAL_STORAGE,
|
||||
resourceCommand.TYPES.SESSION_STORAGE,
|
||||
],
|
||||
{
|
||||
onAvailable: this._onResourceListAvailable,
|
||||
|
||||
@@ -145,14 +145,14 @@ StyleEditorUI.prototype = {
|
||||
this._onTargetAvailable
|
||||
);
|
||||
|
||||
await this._toolbox.resourceWatcher.watchResources(
|
||||
[this._toolbox.resourceWatcher.TYPES.DOCUMENT_EVENT],
|
||||
await this._toolbox.resourceCommand.watchResources(
|
||||
[this._toolbox.resourceCommand.TYPES.DOCUMENT_EVENT],
|
||||
{ onAvailable: this._onResourceAvailable }
|
||||
);
|
||||
|
||||
this._startLoadingStyleSheets();
|
||||
await this._toolbox.resourceWatcher.watchResources(
|
||||
[this._toolbox.resourceWatcher.TYPES.STYLESHEET],
|
||||
await this._toolbox.resourceCommand.watchResources(
|
||||
[this._toolbox.resourceCommand.TYPES.STYLESHEET],
|
||||
{
|
||||
onAvailable: this._onResourceAvailable,
|
||||
onUpdated: this._onResourceUpdated,
|
||||
@@ -259,8 +259,8 @@ StyleEditorUI.prototype = {
|
||||
// same stylesheet resources from ResourceCommand, but `_addStyleSheet` will trigger
|
||||
// or ignore the additional source-map mapping.
|
||||
this._root.classList.add("loading");
|
||||
for (const resource of this._toolbox.resourceWatcher.getAllResources(
|
||||
this._toolbox.resourceWatcher.TYPES.STYLESHEET
|
||||
for (const resource of this._toolbox.resourceCommand.getAllResources(
|
||||
this._toolbox.resourceCommand.TYPES.STYLESHEET
|
||||
)) {
|
||||
await this._handleStyleSheetResource(resource);
|
||||
}
|
||||
@@ -309,7 +309,7 @@ StyleEditorUI.prototype = {
|
||||
* instead (e.g. Sass sources), if applicable.
|
||||
*
|
||||
* @param {Resource} resource
|
||||
* The STYLESHEET resource which is received from resource watcher.
|
||||
* The STYLESHEET resource which is received from resource command.
|
||||
* @return {Promise}
|
||||
* A promise that resolves to the style sheet's editor when the style sheet has
|
||||
* been fully loaded. If the style sheet has a source map, and source mapping
|
||||
@@ -406,7 +406,7 @@ StyleEditorUI.prototype = {
|
||||
* Add a new editor to the UI for a source.
|
||||
*
|
||||
* @param {Resource} resource
|
||||
* The resource which is received from resource watcher.
|
||||
* The resource which is received from resource command.
|
||||
* @return {Promise} that is resolved with the created StyleSheetEditor when
|
||||
* the editor is fully initialized or rejected on error.
|
||||
*/
|
||||
@@ -1190,7 +1190,7 @@ StyleEditorUI.prototype = {
|
||||
const promises = [];
|
||||
for (const resource of resources) {
|
||||
if (
|
||||
resource.resourceType === this._toolbox.resourceWatcher.TYPES.STYLESHEET
|
||||
resource.resourceType === this._toolbox.resourceCommand.TYPES.STYLESHEET
|
||||
) {
|
||||
const onStyleSheetHandled = this._handleStyleSheetResource(resource);
|
||||
|
||||
@@ -1235,7 +1235,7 @@ StyleEditorUI.prototype = {
|
||||
async _onResourceUpdated(updates) {
|
||||
for (const { resource, update } of updates) {
|
||||
if (
|
||||
update.resourceType === this._toolbox.resourceWatcher.TYPES.STYLESHEET
|
||||
update.resourceType === this._toolbox.resourceCommand.TYPES.STYLESHEET
|
||||
) {
|
||||
const editor = this.editors.find(
|
||||
e => e.resourceId === update.resourceId
|
||||
@@ -1279,10 +1279,10 @@ StyleEditorUI.prototype = {
|
||||
this._onTargetAvailable
|
||||
);
|
||||
|
||||
this._toolbox.resourceWatcher.unwatchResources(
|
||||
this._toolbox.resourceCommand.unwatchResources(
|
||||
[
|
||||
this._toolbox.resourceWatcher.TYPES.DOCUMENT_EVENT,
|
||||
this._toolbox.resourceWatcher.TYPES.STYLESHEET,
|
||||
this._toolbox.resourceCommand.TYPES.DOCUMENT_EVENT,
|
||||
this._toolbox.resourceCommand.TYPES.STYLESHEET,
|
||||
],
|
||||
{
|
||||
onAvailable: this._onResourceAvailable,
|
||||
|
||||
@@ -63,7 +63,7 @@ const STYLE_SHEET_UPDATE_CAUSED_BY_STYLE_EDITOR = "styleeditor";
|
||||
* 'error': An error has occured
|
||||
*
|
||||
* @param {Resource} resource
|
||||
* The STYLESHEET resource which is received from resource watcher.
|
||||
* The STYLESHEET resource which is received from resource command.
|
||||
* @param {DOMWindow} win
|
||||
* panel window for style editor
|
||||
* @param {Walker} walker
|
||||
|
||||
@@ -171,13 +171,13 @@ function handleHelperResult(response) {
|
||||
return async ({ dispatch, hud, toolbox, webConsoleUI }) => {
|
||||
const { result, helperResult } = response;
|
||||
const helperHasRawOutput = !!helperResult?.rawOutput;
|
||||
const hasNetworkResourceCommandSupport = hud.resourceWatcher.hasResourceCommandSupport(
|
||||
hud.resourceWatcher.TYPES.NETWORK_EVENT
|
||||
const hasNetworkResourceCommandSupport = hud.resourceCommand.hasResourceCommandSupport(
|
||||
hud.resourceCommand.TYPES.NETWORK_EVENT
|
||||
);
|
||||
let networkFront = null;
|
||||
// @backward-compat { version 86 } default network events watcher support
|
||||
if (hasNetworkResourceCommandSupport) {
|
||||
networkFront = await hud.resourceWatcher.watcherFront.getNetworkParentActor();
|
||||
networkFront = await hud.resourceCommand.watcherFront.getNetworkParentActor();
|
||||
}
|
||||
|
||||
if (helperResult?.type) {
|
||||
|
||||
@@ -41,18 +41,11 @@ class BrowserConsole extends WebConsole {
|
||||
constructor(commands, iframeWindow, chromeWindow) {
|
||||
super(null, commands, iframeWindow, chromeWindow, true);
|
||||
|
||||
// Note that this.commands is being assigned from WebConsole's constructor
|
||||
//TODO: use commands.resourceCommand instead of _resourceWatcher
|
||||
this._resourceWatcher = commands.resourceCommand;
|
||||
this._telemetry = new Telemetry();
|
||||
this._bcInitializer = null;
|
||||
this._bcDestroyer = null;
|
||||
}
|
||||
|
||||
get resourceWatcher() {
|
||||
return this._resourceWatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the Browser Console instance.
|
||||
*
|
||||
|
||||
@@ -63,7 +63,7 @@ async function generateConsoleApiStubs() {
|
||||
const tab = await addTab(TEST_URI);
|
||||
const commands = await createCommandsForTab(tab);
|
||||
await commands.targetCommand.startListening();
|
||||
const resourceWatcher = commands.resourceCommand;
|
||||
const resourceCommand = commands.resourceCommand;
|
||||
|
||||
// The resource-watcher only supports a single call to watch/unwatch per
|
||||
// instance, so we attach a unique watch callback, which will forward the
|
||||
@@ -75,8 +75,8 @@ async function generateConsoleApiStubs() {
|
||||
handleConsoleMessage(resource);
|
||||
}
|
||||
};
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
onAvailable: onConsoleMessage,
|
||||
}
|
||||
@@ -111,7 +111,7 @@ async function generateConsoleApiStubs() {
|
||||
await received;
|
||||
}
|
||||
|
||||
resourceWatcher.unwatchResources([resourceWatcher.TYPES.CONSOLE_MESSAGE], {
|
||||
resourceCommand.unwatchResources([resourceCommand.TYPES.CONSOLE_MESSAGE], {
|
||||
onAvailable: onConsoleMessage,
|
||||
});
|
||||
|
||||
|
||||
@@ -63,9 +63,9 @@ async function generateCssMessageStubs() {
|
||||
const tab = await addTab(TEST_URI);
|
||||
const commands = await createCommandsForTab(tab);
|
||||
await commands.targetCommand.startListening();
|
||||
const resourceWatcher = commands.resourceCommand;
|
||||
const resourceCommand = commands.resourceCommand;
|
||||
|
||||
// The resource-watcher only supports a single call to watch/unwatch per
|
||||
// The resource command only supports a single call to watch/unwatch per
|
||||
// instance, so we attach a unique watch callback, which will forward the
|
||||
// resource to `handleErrorMessage`, dynamically updated for each command.
|
||||
let handleCSSMessage = function() {};
|
||||
@@ -76,7 +76,7 @@ async function generateCssMessageStubs() {
|
||||
}
|
||||
};
|
||||
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_MESSAGE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.CSS_MESSAGE], {
|
||||
onAvailable: onCSSMessageAvailable,
|
||||
});
|
||||
|
||||
@@ -101,7 +101,7 @@ async function generateCssMessageStubs() {
|
||||
await received;
|
||||
}
|
||||
|
||||
resourceWatcher.unwatchResources([resourceWatcher.TYPES.CSS_MESSAGE], {
|
||||
resourceCommand.unwatchResources([resourceCommand.TYPES.CSS_MESSAGE], {
|
||||
onAvailable: onCSSMessageAvailable,
|
||||
});
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ async function generateNetworkEventStubs() {
|
||||
const tab = await addTab(TEST_URI);
|
||||
const commands = await createCommandsForTab(tab);
|
||||
await commands.targetCommand.startListening();
|
||||
const resourceWatcher = commands.resourceCommand;
|
||||
const resourceCommand = commands.resourceCommand;
|
||||
|
||||
const stacktraces = new Map();
|
||||
let addNetworkStub = function() {};
|
||||
@@ -67,7 +67,7 @@ async function generateNetworkEventStubs() {
|
||||
|
||||
const onAvailable = resources => {
|
||||
for (const resource of resources) {
|
||||
if (resource.resourceType == resourceWatcher.TYPES.NETWORK_EVENT) {
|
||||
if (resource.resourceType == resourceCommand.TYPES.NETWORK_EVENT) {
|
||||
if (stacktraces.has(resource.channelId)) {
|
||||
const { stacktraceAvailable, lastFrame } = stacktraces.get(
|
||||
resource.channelId
|
||||
@@ -80,7 +80,7 @@ async function generateNetworkEventStubs() {
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
resource.resourceType == resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE
|
||||
resource.resourceType == resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE
|
||||
) {
|
||||
stacktraces.set(resource.channelId, resource);
|
||||
}
|
||||
@@ -92,10 +92,10 @@ async function generateNetworkEventStubs() {
|
||||
}
|
||||
};
|
||||
|
||||
await resourceWatcher.watchResources(
|
||||
await resourceCommand.watchResources(
|
||||
[
|
||||
resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||
resourceCommand.TYPES.NETWORK_EVENT,
|
||||
],
|
||||
{
|
||||
onAvailable,
|
||||
@@ -138,10 +138,10 @@ async function generateNetworkEventStubs() {
|
||||
});
|
||||
await Promise.all([networkEventDone, networkEventUpdateDone]);
|
||||
}
|
||||
resourceWatcher.unwatchResources(
|
||||
resourceCommand.unwatchResources(
|
||||
[
|
||||
resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||
resourceCommand.TYPES.NETWORK_EVENT,
|
||||
],
|
||||
{
|
||||
onAvailable,
|
||||
|
||||
@@ -65,7 +65,7 @@ async function generatePageErrorStubs() {
|
||||
const tab = await addTab(TEST_URI);
|
||||
const commands = await createCommandsForTab(tab);
|
||||
await commands.targetCommand.startListening();
|
||||
const resourceWatcher = commands.resourceCommand;
|
||||
const resourceCommand = commands.resourceCommand;
|
||||
|
||||
// The resource-watcher only supports a single call to watch/unwatch per
|
||||
// instance, so we attach a unique watch callback, which will forward the
|
||||
@@ -77,7 +77,7 @@ async function generatePageErrorStubs() {
|
||||
handleErrorMessage(resource);
|
||||
}
|
||||
};
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.ERROR_MESSAGE], {
|
||||
onAvailable: onErrorMessageAvailable,
|
||||
});
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ async function generatePlatformMessagesStubs() {
|
||||
|
||||
const commands = await createCommandsForMainProcess();
|
||||
await commands.targetCommand.startListening();
|
||||
const resourceWatcher = commands.resourceCommand;
|
||||
const resourceCommand = commands.resourceCommand;
|
||||
|
||||
// The resource-watcher only supports a single call to watch/unwatch per
|
||||
// instance, so we attach a unique watch callback, which will forward the
|
||||
@@ -73,8 +73,8 @@ async function generatePlatformMessagesStubs() {
|
||||
handlePlatformMessage(resource);
|
||||
}
|
||||
};
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.PLATFORM_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.PLATFORM_MESSAGE],
|
||||
{
|
||||
onAvailable: onPlatformMessageAvailable,
|
||||
}
|
||||
|
||||
@@ -202,21 +202,21 @@ class WebConsoleUI {
|
||||
this._onTargetDestroy
|
||||
);
|
||||
|
||||
const resourceWatcher = this.hud.resourceWatcher;
|
||||
resourceWatcher.unwatchResources(
|
||||
const resourceCommand = this.hud.resourceCommand;
|
||||
resourceCommand.unwatchResources(
|
||||
[
|
||||
resourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||
resourceWatcher.TYPES.ERROR_MESSAGE,
|
||||
resourceWatcher.TYPES.PLATFORM_MESSAGE,
|
||||
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||
resourceCommand.TYPES.CONSOLE_MESSAGE,
|
||||
resourceCommand.TYPES.ERROR_MESSAGE,
|
||||
resourceCommand.TYPES.PLATFORM_MESSAGE,
|
||||
resourceCommand.TYPES.NETWORK_EVENT,
|
||||
resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||
],
|
||||
{
|
||||
onAvailable: this._onResourceAvailable,
|
||||
onUpdated: this._onResourceUpdated,
|
||||
}
|
||||
);
|
||||
resourceWatcher.unwatchResources([resourceWatcher.TYPES.CSS_MESSAGE], {
|
||||
resourceCommand.unwatchResources([resourceCommand.TYPES.CSS_MESSAGE], {
|
||||
onAvailable: this._onResourceAvailable,
|
||||
});
|
||||
|
||||
@@ -355,15 +355,15 @@ class WebConsoleUI {
|
||||
this._onTargetDestroy
|
||||
);
|
||||
|
||||
const resourceWatcher = this.hud.resourceWatcher;
|
||||
await resourceWatcher.watchResources(
|
||||
const resourceCommand = this.hud.resourceCommand;
|
||||
await resourceCommand.watchResources(
|
||||
[
|
||||
resourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||
resourceWatcher.TYPES.ERROR_MESSAGE,
|
||||
resourceWatcher.TYPES.PLATFORM_MESSAGE,
|
||||
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||
resourceWatcher.TYPES.CLONED_CONTENT_PROCESS_MESSAGE,
|
||||
resourceCommand.TYPES.CONSOLE_MESSAGE,
|
||||
resourceCommand.TYPES.ERROR_MESSAGE,
|
||||
resourceCommand.TYPES.PLATFORM_MESSAGE,
|
||||
resourceCommand.TYPES.NETWORK_EVENT,
|
||||
resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||
resourceCommand.TYPES.CLONED_CONTENT_PROCESS_MESSAGE,
|
||||
],
|
||||
{
|
||||
onAvailable: this._onResourceAvailable,
|
||||
@@ -373,8 +373,8 @@ class WebConsoleUI {
|
||||
}
|
||||
|
||||
async watchCssMessages() {
|
||||
const { resourceWatcher } = this.hud;
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_MESSAGE], {
|
||||
const { resourceCommand } = this.hud;
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.CSS_MESSAGE], {
|
||||
onAvailable: this._onResourceAvailable,
|
||||
});
|
||||
}
|
||||
@@ -385,7 +385,7 @@ class WebConsoleUI {
|
||||
}
|
||||
const messages = [];
|
||||
for (const resource of resources) {
|
||||
const { TYPES } = this.hud.resourceWatcher;
|
||||
const { TYPES } = this.hud.resourceCommand;
|
||||
// Ignore messages forwarded from content processes if we're in fission browser toolbox.
|
||||
if (
|
||||
!this.wrapper ||
|
||||
@@ -426,7 +426,7 @@ class WebConsoleUI {
|
||||
const messageUpdates = updates
|
||||
.filter(
|
||||
({ resource }) =>
|
||||
resource.resourceType == this.hud.resourceWatcher.TYPES.NETWORK_EVENT
|
||||
resource.resourceType == this.hud.resourceCommand.TYPES.NETWORK_EVENT
|
||||
)
|
||||
.map(({ resource }) => {
|
||||
this.wrapper.networkDataProvider?.onNetworkResourceUpdated(resource);
|
||||
|
||||
@@ -90,7 +90,7 @@ class WebConsoleWrapper {
|
||||
updateRequest: (id, data) => this.batchedRequestUpdates({ id, data }),
|
||||
},
|
||||
webConsoleFront,
|
||||
resourceWatcher: this.hud.resourceWatcher,
|
||||
resourceCommand: this.hud.resourceCommand,
|
||||
});
|
||||
|
||||
return new Promise(resolve => {
|
||||
|
||||
@@ -101,8 +101,8 @@ class WebConsole {
|
||||
return this.commands.targetCommand.targetFront;
|
||||
}
|
||||
|
||||
get resourceWatcher() {
|
||||
return this.toolbox.resourceWatcher;
|
||||
get resourceCommand() {
|
||||
return this.commands.resourceCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,7 +67,7 @@ class ParentProcessStorage {
|
||||
storage.resourceType = this.storageType;
|
||||
storage.resourceId = `${this.storageType}-${browsingContext.id}`;
|
||||
storage.resourceKey = this.storageKey;
|
||||
// NOTE: the resource watcher needs this attribute
|
||||
// NOTE: the resource command needs this attribute
|
||||
storage.browsingContextID = browsingContext.id;
|
||||
|
||||
onAvailable([storage]);
|
||||
|
||||
@@ -26,10 +26,10 @@ addTest(async function setup() {
|
||||
const { commands, target } = await attachURL(url);
|
||||
|
||||
// We need an active resource command before initializing the inspector front.
|
||||
const resourceWatcher = commands.resourceCommand;
|
||||
// We don't listen for specific resources, we only need to trigger the resource command
|
||||
// onTargetAvailable callback so the resourceWatcher is set on the target front.
|
||||
await resourceWatcher.watchResources([], { onAvailable: () => {} });
|
||||
const resourceCommand = commands.resourceCommand;
|
||||
// We don't listen for specific resources, we only need to trigger the resource command
|
||||
// onTargetAvailable callback so the resourceCommand is set on the target front.
|
||||
await resourceCommand.watchResources([], { onAvailable: () => {} });
|
||||
|
||||
const inspector = await target.getFront("inspector");
|
||||
gWalker = inspector.walker;
|
||||
|
||||
@@ -30,10 +30,10 @@ addTest(async function setup() {
|
||||
gInspectee = doc;
|
||||
|
||||
// We need an active resource command before initializing the inspector front.
|
||||
const resourceWatcher = commands.resourceCommand;
|
||||
// We don't listen for specific resources, we only need to trigger the resource command
|
||||
// onTargetAvailable callback so the resourceWatcher is set on the target front.
|
||||
await resourceWatcher.watchResources([], { onAvailable: () => {} });
|
||||
const resourceCommand = commands.resourceCommand;
|
||||
// We don't listen for specific resources, we only need to trigger the resource command
|
||||
// onTargetAvailable callback so the resourceCommand is set on the target front.
|
||||
await resourceCommand.watchResources([], { onAvailable: () => {} });
|
||||
|
||||
const inspector = await target.getFront("inspector");
|
||||
gWalker = inspector.walker;
|
||||
|
||||
@@ -299,11 +299,11 @@ class ResourceCommand {
|
||||
* composed of a BrowsingContextTargetFront or ContentProcessTargetFront.
|
||||
*/
|
||||
async _onTargetAvailable({ targetFront, isTargetSwitching }) {
|
||||
// We put the resourceWatcher on the targetFront so it can be retrieved in the
|
||||
// We put the resourceCommand on the targetFront so it can be retrieved in the
|
||||
// inspector and style-rule fronts. This might be removed in the future if/when we
|
||||
// turn the resourceWatcher into a Command.
|
||||
// turn the resourceCommand into a Command.
|
||||
// ⚠️ This shouldn't be used anywhere else ⚠️
|
||||
targetFront.resourceWatcher = this;
|
||||
targetFront.resourceCommand = this;
|
||||
|
||||
const resources = [];
|
||||
if (isTargetSwitching) {
|
||||
@@ -430,7 +430,7 @@ class ResourceCommand {
|
||||
}
|
||||
|
||||
// isAlreadyExistingResource indicates that the resources already existed before
|
||||
// the resource watcher started watching for this type of resource.
|
||||
// the resource command started watching for this type of resource.
|
||||
resource.isAlreadyExistingResource = this._processingExistingResources.has(
|
||||
resourceType
|
||||
);
|
||||
|
||||
@@ -13,7 +13,7 @@ add_task(async function() {
|
||||
|
||||
const {
|
||||
client,
|
||||
resourceWatcher,
|
||||
resourceCommand,
|
||||
targetCommand,
|
||||
} = await initMultiProcessResourceCommand();
|
||||
|
||||
@@ -25,8 +25,8 @@ add_task(async function() {
|
||||
|
||||
info("Wait for existing browser mochitest log");
|
||||
const existingMsg = await waitForNextResource(
|
||||
resourceWatcher,
|
||||
resourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||
resourceCommand,
|
||||
resourceCommand.TYPES.CONSOLE_MESSAGE,
|
||||
{
|
||||
ignoreExistingResources: false,
|
||||
predicate({ message }) {
|
||||
@@ -52,15 +52,15 @@ add_task(async function() {
|
||||
resource => resource.message.arguments[0] == "foobar2"
|
||||
);
|
||||
if (runtimeLogResource) {
|
||||
resourceWatcher.unwatchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
resourceCommand.unwatchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{ onAvailable }
|
||||
);
|
||||
resolveMochitestRuntimeLog(runtimeLogResource);
|
||||
}
|
||||
};
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
ignoreExistingResources: true,
|
||||
onAvailable,
|
||||
@@ -78,8 +78,8 @@ add_task(async function() {
|
||||
);
|
||||
|
||||
const onEarlyLog = waitForNextResource(
|
||||
resourceWatcher,
|
||||
resourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||
resourceCommand,
|
||||
resourceCommand.TYPES.CONSOLE_MESSAGE,
|
||||
{
|
||||
ignoreExistingResources: true,
|
||||
predicate({ message }) {
|
||||
|
||||
@@ -12,7 +12,7 @@ add_task(async function() {
|
||||
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -22,8 +22,8 @@ add_task(async function() {
|
||||
|
||||
info("Register first listener");
|
||||
const cachedResources1 = [];
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
onAvailable: resources => cachedResources1.push(...resources),
|
||||
}
|
||||
@@ -31,8 +31,8 @@ add_task(async function() {
|
||||
|
||||
info("Register second listener");
|
||||
const cachedResources2 = [];
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
onAvailable: resources => cachedResources2.push(...resources),
|
||||
}
|
||||
@@ -52,7 +52,7 @@ add_task(async function() {
|
||||
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -62,8 +62,8 @@ add_task(async function() {
|
||||
|
||||
info("Register first listener to get all available resources");
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
onAvailable: resources => availableResources.push(...resources),
|
||||
}
|
||||
@@ -79,8 +79,8 @@ add_task(async function() {
|
||||
|
||||
info("Register second listener to get the cached resources");
|
||||
const cachedResources = [];
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
onAvailable: resources => cachedResources.push(...resources),
|
||||
}
|
||||
@@ -98,7 +98,7 @@ add_task(async function() {
|
||||
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -107,8 +107,8 @@ add_task(async function() {
|
||||
await logMessages(tab.linkedBrowser, existingMessages);
|
||||
|
||||
info("Register first listener");
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
onAvailable: () => {},
|
||||
}
|
||||
@@ -121,8 +121,8 @@ add_task(async function() {
|
||||
|
||||
info("Register second listener");
|
||||
const cachedResources = [];
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
onAvailable: resources => cachedResources.push(...resources),
|
||||
}
|
||||
@@ -139,16 +139,16 @@ add_task(async function() {
|
||||
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
info("Register first listener to get all available resources");
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources(
|
||||
await resourceCommand.watchResources(
|
||||
[
|
||||
resourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||
resourceWatcher.TYPES.ERROR_MESSAGE,
|
||||
resourceCommand.TYPES.CONSOLE_MESSAGE,
|
||||
resourceCommand.TYPES.ERROR_MESSAGE,
|
||||
],
|
||||
{
|
||||
onAvailable: resources => availableResources.push(...resources),
|
||||
@@ -176,10 +176,10 @@ add_task(async function() {
|
||||
|
||||
info("Register listener to get the cached resources");
|
||||
const cachedResources = [];
|
||||
await resourceWatcher.watchResources(
|
||||
await resourceCommand.watchResources(
|
||||
[
|
||||
resourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||
resourceWatcher.TYPES.ERROR_MESSAGE,
|
||||
resourceCommand.TYPES.CONSOLE_MESSAGE,
|
||||
resourceCommand.TYPES.ERROR_MESSAGE,
|
||||
],
|
||||
{
|
||||
onAvailable: resources => cachedResources.push(...resources),
|
||||
@@ -201,7 +201,7 @@ add_task(async function() {
|
||||
async function testIgnoreExistingResources(isFirstListenerIgnoreExisting) {
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -211,8 +211,8 @@ async function testIgnoreExistingResources(isFirstListenerIgnoreExisting) {
|
||||
|
||||
info("Register first listener");
|
||||
const cachedResources1 = [];
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
onAvailable: resources => cachedResources1.push(...resources),
|
||||
ignoreExistingResources: isFirstListenerIgnoreExisting,
|
||||
@@ -221,8 +221,8 @@ async function testIgnoreExistingResources(isFirstListenerIgnoreExisting) {
|
||||
|
||||
info("Register second listener");
|
||||
const cachedResources2 = [];
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
onAvailable: resources => cachedResources2.push(...resources),
|
||||
ignoreExistingResources: !isFirstListenerIgnoreExisting,
|
||||
@@ -266,7 +266,7 @@ add_task(async function() {
|
||||
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -282,8 +282,8 @@ add_task(async function() {
|
||||
onAvailableCallCount++;
|
||||
};
|
||||
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{ onAvailable }
|
||||
);
|
||||
is(availableResources.length, 0, "availableResources array is empty");
|
||||
@@ -301,7 +301,7 @@ add_task(async function() {
|
||||
"onAvailable was called with the expected resource"
|
||||
);
|
||||
|
||||
resourceWatcher.unwatchResources([resourceWatcher.TYPES.CONSOLE_MESSAGE], {
|
||||
resourceCommand.unwatchResources([resourceCommand.TYPES.CONSOLE_MESSAGE], {
|
||||
onAvailable,
|
||||
});
|
||||
targetCommand.destroy();
|
||||
|
||||
@@ -25,7 +25,7 @@ add_task(async function() {
|
||||
async function testTabConsoleMessagesResources(executeInIframe) {
|
||||
const tab = await addTab(FISSION_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -55,7 +55,7 @@ async function testTabConsoleMessagesResources(executeInIframe) {
|
||||
|
||||
is(
|
||||
resource.resourceType,
|
||||
resourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||
resourceCommand.TYPES.CONSOLE_MESSAGE,
|
||||
"Received a message"
|
||||
);
|
||||
ok(resource.message, "message is wrapped into a message attribute");
|
||||
@@ -77,8 +77,8 @@ async function testTabConsoleMessagesResources(executeInIframe) {
|
||||
}
|
||||
};
|
||||
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
onAvailable,
|
||||
}
|
||||
@@ -119,7 +119,7 @@ async function testTabConsoleMessagesResourcesWithIgnoreExistingResources(
|
||||
info("Test ignoreExistingResources option for console messages");
|
||||
const tab = await addTab(FISSION_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -129,8 +129,8 @@ async function testTabConsoleMessagesResourcesWithIgnoreExistingResources(
|
||||
await logExistingMessages(tab.linkedBrowser, executeInIframe);
|
||||
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
onAvailable: resources => availableResources.push(...resources),
|
||||
ignoreExistingResources: true,
|
||||
|
||||
@@ -18,7 +18,7 @@ add_task(async function() {
|
||||
|
||||
const {
|
||||
client,
|
||||
resourceWatcher,
|
||||
resourceCommand,
|
||||
targetCommand,
|
||||
} = await initResourceCommand(tab, { listenForWorkers: true });
|
||||
|
||||
@@ -51,8 +51,8 @@ add_task(async function() {
|
||||
}
|
||||
};
|
||||
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
onAvailable,
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ add_task(async function() {
|
||||
"data:text/html,<body style='color: lime;'>CSS Changes</body>"
|
||||
);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
// CSS_CHANGE watcher doesn't record modification made before watching,
|
||||
// so we have to start watching before doing any DOM mutation.
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_CHANGE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.CSS_CHANGE], {
|
||||
onAvailable: () => {},
|
||||
});
|
||||
|
||||
@@ -36,7 +36,7 @@ add_task(async function() {
|
||||
await setProperty(style.rule, 0, "color", "black");
|
||||
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_CHANGE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.CSS_CHANGE], {
|
||||
onAvailable: resources => availableResources.push(...resources),
|
||||
});
|
||||
assertResource(
|
||||
@@ -76,7 +76,7 @@ add_task(async function() {
|
||||
|
||||
info("Check whether ResourceCommand sends all resources added in this test");
|
||||
const existingResources = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_CHANGE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.CSS_CHANGE], {
|
||||
onAvailable: resources => existingResources.push(...resources),
|
||||
});
|
||||
await waitUntil(() => existingResources.length === 4);
|
||||
|
||||
@@ -35,7 +35,7 @@ async function testWatchingCssMessages() {
|
||||
// Open a test tab
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -45,7 +45,7 @@ async function testWatchingCssMessages() {
|
||||
receivedMessages,
|
||||
false
|
||||
);
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_MESSAGE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.CSS_MESSAGE], {
|
||||
onAvailable,
|
||||
});
|
||||
|
||||
@@ -98,7 +98,7 @@ async function testWatchingCachedCssMessages() {
|
||||
|
||||
// At this point, all messages should be in the ConsoleService cache, and we can begin
|
||||
// to watch and check that we do retrieve those messages.
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -108,7 +108,7 @@ async function testWatchingCachedCssMessages() {
|
||||
receivedMessages,
|
||||
true
|
||||
);
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_MESSAGE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.CSS_MESSAGE], {
|
||||
onAvailable,
|
||||
});
|
||||
is(receivedMessages.length, 3, "Cached messages were retrieved as expected");
|
||||
|
||||
@@ -22,7 +22,7 @@ async function testDocumentEventResources() {
|
||||
const tab = await addTab("data:text/html,Document Events");
|
||||
|
||||
const listener = new ResourceListener();
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -32,7 +32,7 @@ async function testDocumentEventResources() {
|
||||
const onLoadingAtInit = listener.once("dom-loading");
|
||||
const onInteractiveAtInit = listener.once("dom-interactive");
|
||||
const onCompleteAtInit = listener.once("dom-complete");
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.DOCUMENT_EVENT], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.DOCUMENT_EVENT], {
|
||||
onAvailable: parameters => listener.dispatch(parameters),
|
||||
});
|
||||
await assertPromises(onLoadingAtInit, onInteractiveAtInit, onCompleteAtInit);
|
||||
@@ -75,13 +75,13 @@ async function testDocumentEventResourcesWithIgnoreExistingResources() {
|
||||
|
||||
const tab = await addTab("data:text/html,Document Events");
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
info("Check whether the existing document events will not be fired");
|
||||
const documentEvents = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.DOCUMENT_EVENT], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.DOCUMENT_EVENT], {
|
||||
onAvailable: resources => documentEvents.push(...resources),
|
||||
ignoreExistingResources: true,
|
||||
});
|
||||
@@ -102,12 +102,12 @@ async function testCrossOriginNavigation() {
|
||||
|
||||
const tab = await addTab("http://example.com/document-builder.sjs?html=com");
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
const documentEvents = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.DOCUMENT_EVENT], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.DOCUMENT_EVENT], {
|
||||
onAvailable: resources => documentEvents.push(...resources),
|
||||
ignoreExistingResources: true,
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ async function testErrorMessagesResources() {
|
||||
// Open a test tab
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -82,7 +82,7 @@ async function testErrorMessagesResources() {
|
||||
}
|
||||
};
|
||||
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.ERROR_MESSAGE], {
|
||||
onAvailable,
|
||||
});
|
||||
|
||||
@@ -109,7 +109,7 @@ async function testErrorMessagesResourcesWithIgnoreExistingResources() {
|
||||
info("Test ignoreExistingResources option for ERROR_MESSAGE");
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -119,7 +119,7 @@ async function testErrorMessagesResourcesWithIgnoreExistingResources() {
|
||||
await triggerErrors(tab);
|
||||
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.ERROR_MESSAGE], {
|
||||
onAvailable: resources => availableResources.push(...resources),
|
||||
ignoreExistingResources: true,
|
||||
});
|
||||
|
||||
@@ -10,13 +10,13 @@ const TEST_URI = "data:text/html;charset=utf-8,getAllResources test";
|
||||
add_task(async function() {
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
info("Check the resources gotten from getAllResources at initial");
|
||||
is(
|
||||
resourceWatcher.getAllResources(resourceWatcher.TYPES.CONSOLE_MESSAGE)
|
||||
resourceCommand.getAllResources(resourceCommand.TYPES.CONSOLE_MESSAGE)
|
||||
.length,
|
||||
0,
|
||||
"There is no resources at initial"
|
||||
@@ -27,8 +27,8 @@ add_task(async function() {
|
||||
);
|
||||
const availableResources = [];
|
||||
const onAvailable = resources => availableResources.push(...resources);
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{ onAvailable }
|
||||
);
|
||||
|
||||
@@ -37,11 +37,11 @@ add_task(async function() {
|
||||
await logMessages(tab.linkedBrowser, messages);
|
||||
await waitUntil(() => availableResources.length >= messages.length);
|
||||
assertResources(
|
||||
resourceWatcher.getAllResources(resourceWatcher.TYPES.CONSOLE_MESSAGE),
|
||||
resourceCommand.getAllResources(resourceCommand.TYPES.CONSOLE_MESSAGE),
|
||||
availableResources
|
||||
);
|
||||
assertResources(
|
||||
resourceWatcher.getAllResources(resourceWatcher.TYPES.STYLESHEET),
|
||||
resourceCommand.getAllResources(resourceCommand.TYPES.STYLESHEET),
|
||||
[]
|
||||
);
|
||||
|
||||
@@ -50,7 +50,7 @@ add_task(async function() {
|
||||
gBrowser.reloadTab(tab);
|
||||
await onReloaded;
|
||||
assertResources(
|
||||
resourceWatcher.getAllResources(resourceWatcher.TYPES.CONSOLE_MESSAGE),
|
||||
resourceCommand.getAllResources(resourceCommand.TYPES.CONSOLE_MESSAGE),
|
||||
[]
|
||||
);
|
||||
|
||||
@@ -58,16 +58,16 @@ add_task(async function() {
|
||||
await logMessages(tab.linkedBrowser, messages);
|
||||
await waitUntil(
|
||||
() =>
|
||||
resourceWatcher.getAllResources(resourceWatcher.TYPES.CONSOLE_MESSAGE)
|
||||
resourceCommand.getAllResources(resourceCommand.TYPES.CONSOLE_MESSAGE)
|
||||
.length === messages.length
|
||||
);
|
||||
|
||||
info("Check the resources after unwatching");
|
||||
resourceWatcher.unwatchResources([resourceWatcher.TYPES.CONSOLE_MESSAGE], {
|
||||
resourceCommand.unwatchResources([resourceCommand.TYPES.CONSOLE_MESSAGE], {
|
||||
onAvailable,
|
||||
});
|
||||
assertResources(
|
||||
resourceWatcher.getAllResources(resourceWatcher.TYPES.CONSOLE_MESSAGE),
|
||||
resourceCommand.getAllResources(resourceCommand.TYPES.CONSOLE_MESSAGE),
|
||||
[]
|
||||
);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ const REQUEST_STUB = {
|
||||
add_task(async function() {
|
||||
info("Test network stacktraces events");
|
||||
const tab = await addTab(TEST_URI);
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -35,7 +35,7 @@ add_task(async function() {
|
||||
function onResourceAvailable(resources) {
|
||||
for (const resource of resources) {
|
||||
if (
|
||||
resource.resourceType === resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE
|
||||
resource.resourceType === resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE
|
||||
) {
|
||||
ok(
|
||||
!networkEvents.has(resource.resourceId),
|
||||
@@ -57,7 +57,7 @@ add_task(async function() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (resource.resourceType === resourceWatcher.TYPES.NETWORK_EVENT) {
|
||||
if (resource.resourceType === resourceCommand.TYPES.NETWORK_EVENT) {
|
||||
ok(
|
||||
stackTraces.has(resource.stacktraceResourceId),
|
||||
"The stack trace does exists"
|
||||
@@ -70,10 +70,10 @@ add_task(async function() {
|
||||
|
||||
function onResourceUpdated() {}
|
||||
|
||||
await resourceWatcher.watchResources(
|
||||
await resourceCommand.watchResources(
|
||||
[
|
||||
resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||
resourceCommand.TYPES.NETWORK_EVENT,
|
||||
],
|
||||
{
|
||||
onAvailable: onResourceAvailable,
|
||||
@@ -83,10 +83,10 @@ add_task(async function() {
|
||||
|
||||
await triggerNetworkRequests(tab.linkedBrowser, [REQUEST_STUB.code]);
|
||||
|
||||
resourceWatcher.unwatchResources(
|
||||
resourceCommand.unwatchResources(
|
||||
[
|
||||
resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||
resourceCommand.TYPES.NETWORK_EVENT,
|
||||
],
|
||||
{
|
||||
onAvailable: onResourceAvailable,
|
||||
|
||||
@@ -70,7 +70,7 @@ async function testNetworkEventResourcesWithoutExistingResources() {
|
||||
|
||||
async function testNetworkEventResources(options) {
|
||||
const tab = await addTab(TEST_URI);
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -88,7 +88,7 @@ async function testNetworkEventResources(options) {
|
||||
for (const resource of resources) {
|
||||
is(
|
||||
resource.resourceType,
|
||||
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
resourceCommand.TYPES.NETWORK_EVENT,
|
||||
"Received a network event resource"
|
||||
);
|
||||
}
|
||||
@@ -98,15 +98,15 @@ async function testNetworkEventResources(options) {
|
||||
for (const { resource } of updates) {
|
||||
is(
|
||||
resource.resourceType,
|
||||
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
resourceCommand.TYPES.NETWORK_EVENT,
|
||||
"Received a network update event resource"
|
||||
);
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
|
||||
resourceWatcher
|
||||
.watchResources([resourceWatcher.TYPES.NETWORK_EVENT], {
|
||||
resourceCommand
|
||||
.watchResources([resourceCommand.TYPES.NETWORK_EVENT], {
|
||||
onAvailable: onResourceAvailable,
|
||||
onUpdated: onResourceUpdated,
|
||||
})
|
||||
@@ -142,7 +142,7 @@ async function testNetworkEventResources(options) {
|
||||
for (const resource of resources) {
|
||||
is(
|
||||
resource.resourceType,
|
||||
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
resourceCommand.TYPES.NETWORK_EVENT,
|
||||
"Received a network event resource"
|
||||
);
|
||||
actualResourcesOnAvailable[resource.url] = {
|
||||
@@ -158,7 +158,7 @@ async function testNetworkEventResources(options) {
|
||||
for (const { resource } of updates) {
|
||||
is(
|
||||
resource.resourceType,
|
||||
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
resourceCommand.TYPES.NETWORK_EVENT,
|
||||
"Received a network update event resource"
|
||||
);
|
||||
actualResourcesOnUpdated[resource.url] = {
|
||||
@@ -170,7 +170,7 @@ async function testNetworkEventResources(options) {
|
||||
}
|
||||
};
|
||||
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.NETWORK_EVENT], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.NETWORK_EVENT], {
|
||||
onAvailable,
|
||||
onUpdated,
|
||||
ignoreExistingResources,
|
||||
@@ -223,8 +223,8 @@ async function testNetworkEventResources(options) {
|
||||
assertResources(actual, expected);
|
||||
}
|
||||
|
||||
await resourceWatcher.unwatchResources(
|
||||
[resourceWatcher.TYPES.NETWORK_EVENT],
|
||||
await resourceCommand.unwatchResources(
|
||||
[resourceCommand.TYPES.NETWORK_EVENT],
|
||||
{
|
||||
onAvailable,
|
||||
onUpdated,
|
||||
@@ -232,8 +232,8 @@ async function testNetworkEventResources(options) {
|
||||
}
|
||||
);
|
||||
|
||||
await resourceWatcher.unwatchResources(
|
||||
[resourceWatcher.TYPES.NETWORK_EVENT],
|
||||
await resourceCommand.unwatchResources(
|
||||
[resourceCommand.TYPES.NETWORK_EVENT],
|
||||
{
|
||||
onAvailable: onResourceAvailable,
|
||||
onUpdated: onResourceUpdated,
|
||||
@@ -263,7 +263,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
|
||||
const allResourcesOnUpdate = [];
|
||||
|
||||
const tab = await addTab(CSP_URL);
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -286,8 +286,8 @@ async function testNetworkEventResourcesFromTheContentProcess() {
|
||||
}
|
||||
};
|
||||
|
||||
resourceWatcher
|
||||
.watchResources([resourceWatcher.TYPES.NETWORK_EVENT], {
|
||||
resourceCommand
|
||||
.watchResources([resourceCommand.TYPES.NETWORK_EVENT], {
|
||||
onAvailable,
|
||||
onUpdated,
|
||||
})
|
||||
@@ -316,7 +316,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
|
||||
// Assert the data for the CSP blocked JS script file
|
||||
is(
|
||||
availableJSResource.resourceType,
|
||||
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
resourceCommand.TYPES.NETWORK_EVENT,
|
||||
"This is a network event resource"
|
||||
);
|
||||
is(
|
||||
@@ -327,7 +327,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
|
||||
|
||||
is(
|
||||
updateJSResource.resourceType,
|
||||
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
resourceCommand.TYPES.NETWORK_EVENT,
|
||||
"This is a network event resource"
|
||||
);
|
||||
is(
|
||||
@@ -348,7 +348,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
|
||||
// Assert the data for the CSP blocked CSS file
|
||||
is(
|
||||
availableCSSResource.resourceType,
|
||||
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
resourceCommand.TYPES.NETWORK_EVENT,
|
||||
"This is a network event resource"
|
||||
);
|
||||
is(
|
||||
@@ -359,7 +359,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
|
||||
|
||||
is(
|
||||
updateCSSResource.resourceType,
|
||||
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||
resourceCommand.TYPES.NETWORK_EVENT,
|
||||
"This is a network event resource"
|
||||
);
|
||||
is(
|
||||
@@ -368,8 +368,8 @@ async function testNetworkEventResourcesFromTheContentProcess() {
|
||||
"The css resource is blocked by CSP"
|
||||
);
|
||||
|
||||
await resourceWatcher.unwatchResources(
|
||||
[resourceWatcher.TYPES.NETWORK_EVENT],
|
||||
await resourceCommand.unwatchResources(
|
||||
[resourceCommand.TYPES.NETWORK_EVENT],
|
||||
{
|
||||
onAvailable,
|
||||
onUpdated,
|
||||
|
||||
@@ -18,7 +18,7 @@ add_task(async function() {
|
||||
async function testPlatformMessagesResources() {
|
||||
const {
|
||||
client,
|
||||
resourceWatcher,
|
||||
resourceCommand,
|
||||
targetCommand,
|
||||
} = await initMultiProcessResourceCommand();
|
||||
|
||||
@@ -78,8 +78,8 @@ async function testPlatformMessagesResources() {
|
||||
}
|
||||
};
|
||||
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.PLATFORM_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.PLATFORM_MESSAGE],
|
||||
{
|
||||
onAvailable,
|
||||
}
|
||||
@@ -103,7 +103,7 @@ async function testPlatformMessagesResources() {
|
||||
async function testPlatformMessagesResourcesWithIgnoreExistingResources() {
|
||||
const {
|
||||
client,
|
||||
resourceWatcher,
|
||||
resourceCommand,
|
||||
targetCommand,
|
||||
} = await initMultiProcessResourceCommand();
|
||||
|
||||
@@ -115,8 +115,8 @@ async function testPlatformMessagesResourcesWithIgnoreExistingResources() {
|
||||
Services.console.logStringMessage(expectedMessages[1]);
|
||||
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.PLATFORM_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.PLATFORM_MESSAGE],
|
||||
{
|
||||
onAvailable: resources => {
|
||||
for (const resource of resources) {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
/**
|
||||
* The original test still asserts some scenarios using several watchRootNode
|
||||
* call sites, which is not something we intend to support at the moment in the
|
||||
* resource watcher.
|
||||
* resource command.
|
||||
*
|
||||
* Otherwise this test checks the basic behavior of the resource when reloading
|
||||
* an empty page.
|
||||
@@ -17,7 +17,7 @@ add_task(async function() {
|
||||
// Open a test tab
|
||||
const tab = await addTab("data:text/html,Root Node tests");
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -26,7 +26,7 @@ add_task(async function() {
|
||||
info("Call watchResources([ROOT_NODE], ...)");
|
||||
let onAvailableCounter = 0;
|
||||
const onAvailable = resources => (onAvailableCounter += resources.length);
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.ROOT_NODE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.ROOT_NODE], {
|
||||
onAvailable,
|
||||
});
|
||||
|
||||
@@ -45,7 +45,7 @@ add_task(async function() {
|
||||
is(onAvailableCounter, 2, "onAvailable has been called 2 times");
|
||||
|
||||
info("Call unwatchResources([ROOT_NODE], ...) for the onAvailable callback");
|
||||
resourceWatcher.unwatchResources([resourceWatcher.TYPES.ROOT_NODE], {
|
||||
resourceCommand.unwatchResources([resourceCommand.TYPES.ROOT_NODE], {
|
||||
onAvailable,
|
||||
});
|
||||
|
||||
@@ -71,7 +71,7 @@ add_task(async function() {
|
||||
add_task(async function testRootNodeFrontIsCorrect() {
|
||||
const tab = await addTab("data:text/html,<div id=div1>");
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
const browser = gBrowser.selectedBrowser;
|
||||
@@ -81,7 +81,7 @@ add_task(async function testRootNodeFrontIsCorrect() {
|
||||
let rootNodeResolve;
|
||||
let rootNodePromise = new Promise(r => (rootNodeResolve = r));
|
||||
const onAvailable = ([rootNodeFront]) => rootNodeResolve(rootNodeFront);
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.ROOT_NODE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.ROOT_NODE], {
|
||||
onAvailable,
|
||||
});
|
||||
|
||||
@@ -90,7 +90,7 @@ add_task(async function testRootNodeFrontIsCorrect() {
|
||||
ok(!!root1, "onAvailable has been called with a valid argument");
|
||||
is(
|
||||
root1.resourceType,
|
||||
resourceWatcher.TYPES.ROOT_NODE,
|
||||
resourceCommand.TYPES.ROOT_NODE,
|
||||
"The resource has the expected type"
|
||||
);
|
||||
|
||||
@@ -117,7 +117,7 @@ add_task(async function testRootNodeFrontIsCorrect() {
|
||||
is(div3.getAttribute("id"), "div3", "Correct root node retrieved");
|
||||
|
||||
// Cleanup
|
||||
resourceWatcher.unwatchResources([resourceWatcher.TYPES.ROOT_NODE], {
|
||||
resourceCommand.unwatchResources([resourceCommand.TYPES.ROOT_NODE], {
|
||||
onAvailable,
|
||||
});
|
||||
targetCommand.destroy();
|
||||
|
||||
@@ -25,7 +25,7 @@ add_task(async function() {
|
||||
async function testServerSentEventResources(target) {
|
||||
const tab = await addTab(URL_ROOT + "sse_frontend.html");
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -35,8 +35,8 @@ async function testServerSentEventResources(target) {
|
||||
availableResources.push(...resources);
|
||||
}
|
||||
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.SERVER_SENT_EVENT],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.SERVER_SENT_EVENT],
|
||||
{ onAvailable: onResourceAvailable }
|
||||
);
|
||||
|
||||
@@ -69,8 +69,8 @@ async function testServerSentEventResources(target) {
|
||||
httpChannelId,
|
||||
});
|
||||
|
||||
await resourceWatcher.unwatchResources(
|
||||
[resourceWatcher.TYPES.SERVER_SENT_EVENT],
|
||||
await resourceCommand.unwatchResources(
|
||||
[resourceCommand.TYPES.SERVER_SENT_EVENT],
|
||||
{ onAvailable: onResourceAvailable }
|
||||
);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Check that the resource watcher is still properly watching for new targets
|
||||
* Check that the resource command is still properly watching for new targets
|
||||
* after unwatching one resource, if there is still another watched resource.
|
||||
*/
|
||||
add_task(async function() {
|
||||
@@ -19,11 +19,11 @@ add_task(async function() {
|
||||
|
||||
const {
|
||||
client,
|
||||
resourceWatcher,
|
||||
resourceCommand,
|
||||
targetCommand,
|
||||
} = await initMultiProcessResourceCommand();
|
||||
|
||||
const { CONSOLE_MESSAGE, ROOT_NODE } = resourceWatcher.TYPES;
|
||||
const { CONSOLE_MESSAGE, ROOT_NODE } = resourceCommand.TYPES;
|
||||
|
||||
// We are only interested in console messages as a resource, the ROOT_NODE one
|
||||
// is here to test the ResourceCommand::unwatchResources API with several resources.
|
||||
@@ -37,7 +37,7 @@ add_task(async function() {
|
||||
};
|
||||
|
||||
info("Call watchResources([CONSOLE_MESSAGE, ROOT_NODE], ...)");
|
||||
await resourceWatcher.watchResources([CONSOLE_MESSAGE, ROOT_NODE], {
|
||||
await resourceCommand.watchResources([CONSOLE_MESSAGE, ROOT_NODE], {
|
||||
onAvailable,
|
||||
});
|
||||
|
||||
@@ -52,7 +52,7 @@ add_task(async function() {
|
||||
)
|
||||
);
|
||||
|
||||
// Check that the resource watcher captures resources from new targets.
|
||||
// Check that the resource command captures resources from new targets.
|
||||
info("Open a first tab on the example.com domain");
|
||||
const comTab = await addTab(
|
||||
"http://example.com/document-builder.sjs?html=com"
|
||||
@@ -69,7 +69,7 @@ add_task(async function() {
|
||||
);
|
||||
|
||||
info("Stop watching ROOT_NODE resources");
|
||||
await resourceWatcher.unwatchResources([ROOT_NODE], { onAvailable });
|
||||
await resourceCommand.unwatchResources([ROOT_NODE], { onAvailable });
|
||||
|
||||
// Check that messages from new targets are still captured after calling
|
||||
// unwatch for another resource.
|
||||
@@ -89,7 +89,7 @@ add_task(async function() {
|
||||
);
|
||||
|
||||
info("Stop watching CONSOLE_MESSAGE resources");
|
||||
await resourceWatcher.unwatchResources([CONSOLE_MESSAGE], { onAvailable });
|
||||
await resourceCommand.unwatchResources([CONSOLE_MESSAGE], { onAvailable });
|
||||
await logInTab(tab, "test-again");
|
||||
|
||||
// We don't have a specific event to wait for here, so allow some time for
|
||||
@@ -101,7 +101,7 @@ add_task(async function() {
|
||||
resource => resource.message.arguments[0] === "test-again"
|
||||
),
|
||||
undefined,
|
||||
"The resource watcher should not watch CONSOLE_MESSAGE anymore"
|
||||
"The resource command should not watch CONSOLE_MESSAGE anymore"
|
||||
);
|
||||
|
||||
// Cleanup
|
||||
|
||||
@@ -15,7 +15,7 @@ add_task(async function() {
|
||||
const htmlRequest = await fetch(TEST_URL);
|
||||
const htmlContent = await htmlRequest.text();
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -34,7 +34,7 @@ add_task(async function() {
|
||||
|
||||
info("Check already available resources");
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.SOURCE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.SOURCE], {
|
||||
onAvailable: resources => availableResources.push(...resources),
|
||||
});
|
||||
|
||||
|
||||
@@ -103,13 +103,13 @@ async function testResourceAvailableFeature() {
|
||||
|
||||
const tab = await addTab(STYLE_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
info("Check whether ResourceCommand gets existing stylesheet");
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.STYLESHEET], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.STYLESHEET], {
|
||||
onAvailable: resources => availableResources.push(...resources),
|
||||
});
|
||||
|
||||
@@ -172,14 +172,14 @@ async function testResourceUpdateFeature() {
|
||||
|
||||
const tab = await addTab(STYLE_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
info("Setup the watcher");
|
||||
const availableResources = [];
|
||||
const updates = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.STYLESHEET], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.STYLESHEET], {
|
||||
onAvailable: resources => availableResources.push(...resources),
|
||||
onUpdated: newUpdates => updates.push(...newUpdates),
|
||||
});
|
||||
@@ -313,14 +313,14 @@ async function testNestedResourceUpdateFeature() {
|
||||
tab.ownerGlobal.resizeTo(originalWindowWidth, originalWindowHeight);
|
||||
});
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
info("Setup the watcher");
|
||||
const availableResources = [];
|
||||
const updates = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.STYLESHEET], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.STYLESHEET], {
|
||||
onAvailable: resources => availableResources.push(...resources),
|
||||
onUpdated: newUpdates => updates.push(...newUpdates),
|
||||
});
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
|
||||
add_task(async function() {
|
||||
const tab = await addTab("data:text/html,Test");
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
// Start watching for console messages. We don't care about messages here, only the
|
||||
// registration/destroy mechanism, so we make onAvailable a no-op function.
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
await resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
onAvailable: () => {},
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ add_task(async function() {
|
||||
|
||||
const {
|
||||
client,
|
||||
resourceWatcher,
|
||||
resourceCommand,
|
||||
targetCommand,
|
||||
} = await initMultiProcessResourceCommand();
|
||||
|
||||
@@ -38,8 +38,8 @@ add_task(async function() {
|
||||
// We do not await on `watchPromise1` here, in order to simulate simultaneous
|
||||
// calls to watchResources (which could come from 2 separate modules in a real
|
||||
// scenario).
|
||||
const initialWatchPromise = resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CSS_MESSAGE],
|
||||
const initialWatchPromise = resourceCommand.watchResources(
|
||||
[resourceCommand.TYPES.CSS_MESSAGE],
|
||||
{
|
||||
onAvailable: onCssMessageAvailable,
|
||||
}
|
||||
@@ -47,8 +47,8 @@ add_task(async function() {
|
||||
|
||||
// `waitForNextResource` will trigger another call to `watchResources`.
|
||||
const onMessageReceived = waitForNextResource(
|
||||
resourceWatcher,
|
||||
resourceWatcher.TYPES.PLATFORM_MESSAGE,
|
||||
resourceCommand,
|
||||
resourceCommand.TYPES.PLATFORM_MESSAGE,
|
||||
{
|
||||
ignoreExistingResources: false,
|
||||
predicate: r => r.message === expectedPlatformMessage,
|
||||
@@ -63,7 +63,7 @@ add_task(async function() {
|
||||
await initialWatchPromise;
|
||||
|
||||
// Unwatch all resources.
|
||||
resourceWatcher.unwatchResources([resourceWatcher.TYPES.CSS_MESSAGE], {
|
||||
resourceCommand.unwatchResources([resourceCommand.TYPES.CSS_MESSAGE], {
|
||||
onAvailable: onCssMessageAvailable,
|
||||
});
|
||||
|
||||
|
||||
@@ -11,14 +11,14 @@ const TEST_URI =
|
||||
add_task(async function() {
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
const { CONSOLE_MESSAGE, SOURCE } = resourceWatcher.TYPES;
|
||||
const { CONSOLE_MESSAGE, SOURCE } = resourceCommand.TYPES;
|
||||
|
||||
info("Check the resources gotten from getAllResources at initial");
|
||||
is(
|
||||
resourceWatcher.getAllResources(CONSOLE_MESSAGE).length,
|
||||
resourceCommand.getAllResources(CONSOLE_MESSAGE).length,
|
||||
0,
|
||||
"There is no resources before calling watchResources"
|
||||
);
|
||||
@@ -36,7 +36,7 @@ add_task(async function() {
|
||||
})
|
||||
.map(r => availableResources.push(r));
|
||||
};
|
||||
await resourceWatcher.watchResources([CONSOLE_MESSAGE], { onAvailable });
|
||||
await resourceCommand.watchResources([CONSOLE_MESSAGE], { onAvailable });
|
||||
|
||||
is(availableResources.length, 1, "Got the page message");
|
||||
is(
|
||||
@@ -46,16 +46,16 @@ add_task(async function() {
|
||||
);
|
||||
|
||||
// Register another listener before unregistering the console listener
|
||||
// otherwise the resource watcher stop watching for targets
|
||||
// otherwise the resource command stop watching for targets
|
||||
const onSourceAvailable = () => {};
|
||||
await resourceWatcher.watchResources([SOURCE], {
|
||||
await resourceCommand.watchResources([SOURCE], {
|
||||
onAvailable: onSourceAvailable,
|
||||
});
|
||||
|
||||
info(
|
||||
"Unregister the console listener and check that we no longer listen for console messages"
|
||||
);
|
||||
resourceWatcher.unwatchResources([CONSOLE_MESSAGE], {
|
||||
resourceCommand.unwatchResources([CONSOLE_MESSAGE], {
|
||||
onAvailable,
|
||||
});
|
||||
|
||||
@@ -83,12 +83,12 @@ add_task(async function() {
|
||||
"the data:URI fired a message, but we are no longer listening to it, so no new one should be notified"
|
||||
);
|
||||
is(
|
||||
resourceWatcher.getAllResources(CONSOLE_MESSAGE).length,
|
||||
resourceCommand.getAllResources(CONSOLE_MESSAGE).length,
|
||||
0,
|
||||
"As we are no longer listening to CONSOLE message, we should not collect any"
|
||||
);
|
||||
|
||||
resourceWatcher.unwatchResources([SOURCE], {
|
||||
resourceCommand.unwatchResources([SOURCE], {
|
||||
onAvailable: onSourceAvailable,
|
||||
});
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ async function checkBreakpointBeforeWatchResources() {
|
||||
|
||||
const tab = await addTab(BREAKPOINT_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -60,7 +60,7 @@ async function checkBreakpointBeforeWatchResources() {
|
||||
|
||||
info("Call watchResources");
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.THREAD_STATE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.THREAD_STATE], {
|
||||
onAvailable: resources => availableResources.push(...resources),
|
||||
});
|
||||
|
||||
@@ -113,13 +113,13 @@ async function checkBreakpointAfterWatchResources() {
|
||||
|
||||
const tab = await addTab(BREAKPOINT_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
info("Call watchResources");
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.THREAD_STATE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.THREAD_STATE], {
|
||||
onAvailable: resources => availableResources.push(...resources),
|
||||
});
|
||||
|
||||
@@ -185,13 +185,13 @@ async function checkRealBreakpoint() {
|
||||
|
||||
const tab = await addTab(BREAKPOINT_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
info("Call watchResources");
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.THREAD_STATE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.THREAD_STATE], {
|
||||
onAvailable: resources => availableResources.push(...resources),
|
||||
});
|
||||
|
||||
@@ -269,13 +269,13 @@ async function checkPauseOnException() {
|
||||
"data:text/html,<meta charset=utf8><script>a.b.c.d</script>"
|
||||
);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
info("Call watchResources");
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.THREAD_STATE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.THREAD_STATE], {
|
||||
onAvailable: resources => availableResources.push(...resources),
|
||||
});
|
||||
|
||||
@@ -342,7 +342,7 @@ async function checkSetBeforeWatch() {
|
||||
|
||||
const tab = await addTab(BREAKPOINT_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -380,7 +380,7 @@ async function checkSetBeforeWatch() {
|
||||
|
||||
info("Call watchResources");
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.THREAD_STATE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.THREAD_STATE], {
|
||||
onAvailable: resources => availableResources.push(...resources),
|
||||
});
|
||||
|
||||
@@ -429,13 +429,13 @@ async function checkDebuggerStatementInIframes() {
|
||||
|
||||
const tab = await addTab(BREAKPOINT_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
info("Call watchResources");
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.THREAD_STATE], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.THREAD_STATE], {
|
||||
onAvailable: resources => availableResources.push(...resources),
|
||||
});
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@ const TEST_URI = "data:text/html;charset=utf-8,";
|
||||
add_task(async function() {
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
const { CONSOLE_MESSAGE, ROOT_NODE } = resourceWatcher.TYPES;
|
||||
const { CONSOLE_MESSAGE, ROOT_NODE } = resourceCommand.TYPES;
|
||||
|
||||
info("Use console.log in the content page");
|
||||
await logInTab(tab, "msg-1");
|
||||
@@ -28,10 +28,10 @@ add_task(async function() {
|
||||
// resolved.
|
||||
const messages1 = [];
|
||||
const onAvailable1 = createMessageCallback(messages1);
|
||||
const onWatcher1Ready = resourceWatcher.watchResources([CONSOLE_MESSAGE], {
|
||||
const onWatcher1Ready = resourceCommand.watchResources([CONSOLE_MESSAGE], {
|
||||
onAvailable: onAvailable1,
|
||||
});
|
||||
resourceWatcher.unwatchResources([CONSOLE_MESSAGE], {
|
||||
resourceCommand.unwatchResources([CONSOLE_MESSAGE], {
|
||||
onAvailable: onAvailable1,
|
||||
});
|
||||
|
||||
@@ -40,13 +40,13 @@ add_task(async function() {
|
||||
// But unwatchResource is only called for CONSOLE_MESSAGE, not for ROOT_NODE.
|
||||
const messages2 = [];
|
||||
const onAvailable2 = createMessageCallback(messages2);
|
||||
const onWatcher2Ready = resourceWatcher.watchResources(
|
||||
const onWatcher2Ready = resourceCommand.watchResources(
|
||||
[CONSOLE_MESSAGE, ROOT_NODE],
|
||||
{
|
||||
onAvailable: onAvailable2,
|
||||
}
|
||||
);
|
||||
resourceWatcher.unwatchResources([CONSOLE_MESSAGE], {
|
||||
resourceCommand.unwatchResources([CONSOLE_MESSAGE], {
|
||||
onAvailable: onAvailable2,
|
||||
});
|
||||
|
||||
@@ -54,7 +54,7 @@ add_task(async function() {
|
||||
// explicitly for it before the end of test. Used as a reference.
|
||||
const messages3 = [];
|
||||
const onAvailable3 = createMessageCallback(messages3);
|
||||
const onWatcher3Ready = resourceWatcher.watchResources([CONSOLE_MESSAGE], {
|
||||
const onWatcher3Ready = resourceCommand.watchResources([CONSOLE_MESSAGE], {
|
||||
onAvailable: onAvailable3,
|
||||
});
|
||||
|
||||
@@ -91,7 +91,7 @@ function hasMessage(messageResources, text) {
|
||||
);
|
||||
}
|
||||
|
||||
// All resource watcher callbacks share the same pattern here: they add all
|
||||
// All resource command callbacks share the same pattern here: they add all
|
||||
// console message resources to a provided `messages` array.
|
||||
function createMessageCallback(messages) {
|
||||
const { CONSOLE_MESSAGE } = ResourceCommand.TYPES;
|
||||
|
||||
@@ -27,7 +27,7 @@ add_task(async function() {
|
||||
|
||||
async function testWebsocketResources(target) {
|
||||
const tab = await addTab(URL_ROOT + "websocket_frontend.html");
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@ async function testWebsocketResources(target) {
|
||||
availableResources.push(...resources);
|
||||
}
|
||||
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.WEBSOCKET], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.WEBSOCKET], {
|
||||
onAvailable: onResourceAvailable,
|
||||
});
|
||||
|
||||
@@ -153,7 +153,7 @@ async function testWebsocketResources(target) {
|
||||
existingResources.push(...resources);
|
||||
}
|
||||
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.WEBSOCKET], {
|
||||
await resourceCommand.watchResources([resourceCommand.TYPES.WEBSOCKET], {
|
||||
onAvailable: onExsistingResourceAvailable,
|
||||
});
|
||||
|
||||
@@ -170,11 +170,11 @@ async function testWebsocketResources(target) {
|
||||
);
|
||||
}
|
||||
|
||||
await resourceWatcher.unwatchResources([resourceWatcher.TYPES.WEBSOCKET], {
|
||||
await resourceCommand.unwatchResources([resourceCommand.TYPES.WEBSOCKET], {
|
||||
onAvailable: onResourceAvailable,
|
||||
});
|
||||
|
||||
await resourceWatcher.unwatchResources([resourceWatcher.TYPES.WEBSOCKET], {
|
||||
await resourceCommand.unwatchResources([resourceCommand.TYPES.WEBSOCKET], {
|
||||
onAvailable: onExsistingResourceAvailable,
|
||||
});
|
||||
|
||||
|
||||
@@ -25,12 +25,12 @@ async function _initResourceCommandFromCommands(
|
||||
}
|
||||
await targetCommand.startListening();
|
||||
|
||||
//TODO: Stop exporting resourceWatcher and use commands.resourceCommand
|
||||
//Bug 1709065: Stop exporting resourceCommand and use commands.resourceCommand
|
||||
//And rename all these methods
|
||||
return {
|
||||
client: commands.client,
|
||||
commands,
|
||||
resourceWatcher: commands.resourceCommand,
|
||||
resourceCommand: commands.resourceCommand,
|
||||
targetCommand,
|
||||
};
|
||||
}
|
||||
@@ -43,7 +43,7 @@ async function _initResourceCommandFromCommands(
|
||||
* @param {Object} options
|
||||
* @param {Boolean} options.listenForWorkers
|
||||
* @return {Object} object
|
||||
* @return {ResourceCommand} object.resourceWatcher
|
||||
* @return {ResourceCommand} object.resourceCommand
|
||||
* The underlying resource command interface.
|
||||
* @return {Object} object.commands
|
||||
* The commands object defined by modules from devtools/shared/commands.
|
||||
@@ -61,7 +61,7 @@ async function initResourceCommand(tab, options) {
|
||||
* Instantiate a multi-process ResourceCommand, watching all type of targets.
|
||||
*
|
||||
* @return {Object} object
|
||||
* @return {ResourceCommand} object.resourceWatcher
|
||||
* @return {ResourceCommand} object.resourceCommand
|
||||
* The underlying resource command interface.
|
||||
* @return {Object} object.commands
|
||||
* The commands object defined by modules from devtools/shared/commands.
|
||||
|
||||
Reference in New Issue
Block a user