Backed out 5 changesets (bug 1701790) for bc failures in browser_ext_devtools_network_targetSwitch.js. CLOSED TREE
Backed out changeset 3fc4edd663d9 (bug 1701790) Backed out changeset 2d3ea7c0d695 (bug 1701790) Backed out changeset 6cb7502fc1a2 (bug 1701790) Backed out changeset 8f4205a1a369 (bug 1701790) Backed out changeset bd3c9b1482c7 (bug 1701790)
This commit is contained in:
@@ -52,7 +52,7 @@ class DebuggerPanel {
|
|||||||
client,
|
client,
|
||||||
} = await this.panelWin.Debugger.bootstrap({
|
} = await this.panelWin.Debugger.bootstrap({
|
||||||
commands: this.commands,
|
commands: this.commands,
|
||||||
resourceCommand: this.toolbox.resourceCommand,
|
resourceWatcher: this.toolbox.resourceWatcher,
|
||||||
devToolsClient: this.toolbox.target.client,
|
devToolsClient: this.toolbox.target.client,
|
||||||
workers: {
|
workers: {
|
||||||
sourceMaps: this.toolbox.sourceMapService,
|
sourceMaps: this.toolbox.sourceMapService,
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ import sourceQueue from "../utils/source-queue";
|
|||||||
|
|
||||||
let actions;
|
let actions;
|
||||||
let targetCommand;
|
let targetCommand;
|
||||||
let resourceCommand;
|
let resourceWatcher;
|
||||||
|
|
||||||
export async function onConnect(commands, _resourceCommand, _actions, store) {
|
export async function onConnect(commands, _resourceWatcher, _actions, store) {
|
||||||
actions = _actions;
|
actions = _actions;
|
||||||
targetCommand = commands.targetCommand;
|
targetCommand = commands.targetCommand;
|
||||||
resourceCommand = _resourceCommand;
|
resourceWatcher = _resourceWatcher;
|
||||||
|
|
||||||
setupCommands(commands);
|
setupCommands(commands);
|
||||||
setupCreate({ store });
|
setupCreate({ store });
|
||||||
@@ -43,13 +43,13 @@ export async function onConnect(commands, _resourceCommand, _actions, store) {
|
|||||||
|
|
||||||
// Use independant listeners for SOURCE and THREAD_STATE in order to ease
|
// 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.
|
// doing batching and notify about a set of SOURCE's in one redux action.
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.SOURCE], {
|
await resourceWatcher.watchResources([resourceWatcher.TYPES.SOURCE], {
|
||||||
onAvailable: onSourceAvailable,
|
onAvailable: onSourceAvailable,
|
||||||
});
|
});
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.THREAD_STATE], {
|
await resourceWatcher.watchResources([resourceWatcher.TYPES.THREAD_STATE], {
|
||||||
onAvailable: onBreakpointAvailable,
|
onAvailable: onBreakpointAvailable,
|
||||||
});
|
});
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.ERROR_MESSAGE], {
|
await resourceWatcher.watchResources([resourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||||
onAvailable: actions.addExceptionFromResources,
|
onAvailable: actions.addExceptionFromResources,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -60,13 +60,13 @@ export function onDisconnect() {
|
|||||||
onTargetAvailable,
|
onTargetAvailable,
|
||||||
onTargetDestroyed
|
onTargetDestroyed
|
||||||
);
|
);
|
||||||
resourceCommand.unwatchResources([resourceCommand.TYPES.SOURCE], {
|
resourceWatcher.unwatchResources([resourceWatcher.TYPES.SOURCE], {
|
||||||
onAvailable: onSourceAvailable,
|
onAvailable: onSourceAvailable,
|
||||||
});
|
});
|
||||||
resourceCommand.unwatchResources([resourceCommand.TYPES.THREAD_STATE], {
|
resourceWatcher.unwatchResources([resourceWatcher.TYPES.THREAD_STATE], {
|
||||||
onAvailable: onBreakpointAvailable,
|
onAvailable: onBreakpointAvailable,
|
||||||
});
|
});
|
||||||
resourceCommand.unwatchResources([resourceCommand.TYPES.ERROR_MESSAGE], {
|
resourceWatcher.unwatchResources([resourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||||
onAvailable: actions.addExceptionFromResources,
|
onAvailable: actions.addExceptionFromResources,
|
||||||
});
|
});
|
||||||
sourceQueue.clear();
|
sourceQueue.clear();
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ async function loadInitialState() {
|
|||||||
|
|
||||||
export async function bootstrap({
|
export async function bootstrap({
|
||||||
commands,
|
commands,
|
||||||
resourceCommand,
|
resourceWatcher,
|
||||||
workers: panelWorkers,
|
workers: panelWorkers,
|
||||||
panel,
|
panel,
|
||||||
}) {
|
}) {
|
||||||
@@ -84,7 +84,7 @@ export async function bootstrap({
|
|||||||
|
|
||||||
const connected = firefox.onConnect(
|
const connected = firefox.onConnect(
|
||||||
commands,
|
commands,
|
||||||
resourceCommand,
|
resourceWatcher,
|
||||||
actions,
|
actions,
|
||||||
store
|
store
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -202,10 +202,10 @@ class SourceMapURLService {
|
|||||||
this._pendingURLSubscriptions.clear();
|
this._pendingURLSubscriptions.clear();
|
||||||
this._urlToIDMap.clear();
|
this._urlToIDMap.clear();
|
||||||
|
|
||||||
const { resourceCommand } = this._toolbox;
|
const { resourceWatcher } = this._toolbox;
|
||||||
try {
|
try {
|
||||||
resourceCommand.unwatchResources(
|
resourceWatcher.unwatchResources(
|
||||||
[resourceCommand.TYPES.STYLESHEET, resourceCommand.TYPES.SOURCE],
|
[resourceWatcher.TYPES.STYLESHEET, resourceWatcher.TYPES.SOURCE],
|
||||||
{ onAvailable: this._onResourceAvailable }
|
{ onAvailable: this._onResourceAvailable }
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -421,10 +421,10 @@ class SourceMapURLService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this._sourcesLoading) {
|
if (!this._sourcesLoading) {
|
||||||
const { resourceCommand } = this._toolbox;
|
const { resourceWatcher } = this._toolbox;
|
||||||
const { STYLESHEET, SOURCE } = resourceCommand.TYPES;
|
const { STYLESHEET, SOURCE } = resourceWatcher.TYPES;
|
||||||
|
|
||||||
this._sourcesLoading = resourceCommand.watchResources(
|
this._sourcesLoading = resourceWatcher.watchResources(
|
||||||
[STYLESHEET, SOURCE],
|
[STYLESHEET, SOURCE],
|
||||||
{
|
{
|
||||||
onAvailable: this._onResourceAvailable,
|
onAvailable: this._onResourceAvailable,
|
||||||
@@ -443,8 +443,8 @@ class SourceMapURLService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_onResourceAvailable(resources) {
|
_onResourceAvailable(resources) {
|
||||||
const { resourceCommand } = this._toolbox;
|
const { resourceWatcher } = this._toolbox;
|
||||||
const { STYLESHEET, SOURCE } = resourceCommand.TYPES;
|
const { STYLESHEET, SOURCE } = resourceWatcher.TYPES;
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
if (resource.resourceType == STYLESHEET) {
|
if (resource.resourceType == STYLESHEET) {
|
||||||
this._onNewStyleSheet(resource);
|
this._onNewStyleSheet(resource);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// The target front holds resources that happend before ResourceCommand addeed listeners.
|
// The target front holds resources that happend before ResourceWatcher addeed listeners.
|
||||||
// Test whether that feature works correctly or not.
|
// Test whether that feature works correctly or not.
|
||||||
const TEST_URI =
|
const TEST_URI =
|
||||||
"http://example.com/browser/devtools/client/framework/test/doc_cached-resource.html";
|
"http://example.com/browser/devtools/client/framework/test/doc_cached-resource.html";
|
||||||
|
|||||||
@@ -120,19 +120,19 @@ function createScript(url) {
|
|||||||
function waitForSourceLoad(toolbox, url) {
|
function waitForSourceLoad(toolbox, url) {
|
||||||
info(`Waiting for source ${url} to be available...`);
|
info(`Waiting for source ${url} to be available...`);
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const { resourceCommand } = toolbox;
|
const { resourceWatcher } = toolbox;
|
||||||
|
|
||||||
function onAvailable(sources) {
|
function onAvailable(sources) {
|
||||||
for (const source of sources) {
|
for (const source of sources) {
|
||||||
if (source.url === url) {
|
if (source.url === url) {
|
||||||
resourceCommand.unwatchResources([resourceCommand.TYPES.SOURCE], {
|
resourceWatcher.unwatchResources([resourceWatcher.TYPES.SOURCE], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resourceCommand.watchResources([resourceCommand.TYPES.SOURCE], {
|
resourceWatcher.watchResources([resourceWatcher.TYPES.SOURCE], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ var Startup = Cc["@mozilla.org/devtools/startup-clh;1"].getService(
|
|||||||
Ci.nsISupports
|
Ci.nsISupports
|
||||||
).wrappedJSObject;
|
).wrappedJSObject;
|
||||||
|
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
const { createCommandsDictionary } = require("devtools/shared/commands/index");
|
const { createCommandsDictionary } = require("devtools/shared/commands/index");
|
||||||
|
|
||||||
const { BrowserLoader } = ChromeUtils.import(
|
const { BrowserLoader } = ChromeUtils.import(
|
||||||
@@ -784,8 +787,7 @@ Toolbox.prototype = {
|
|||||||
this._onTargetThreadFrontResumeWrongOrder.bind(this)
|
this._onTargetThreadFrontResumeWrongOrder.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Bug 1709063: Use commands.resourceCommand instead of toolbox.resourceCommand
|
this.resourceWatcher = new ResourceWatcher(this.commands.targetCommand);
|
||||||
this.resourceCommand = this.commands.resourceCommand;
|
|
||||||
|
|
||||||
// Optimization: fire up a few other things before waiting on
|
// Optimization: fire up a few other things before waiting on
|
||||||
// the iframe being ready (makes startup faster)
|
// the iframe being ready (makes startup faster)
|
||||||
@@ -803,16 +805,16 @@ Toolbox.prototype = {
|
|||||||
|
|
||||||
// Watch for console API messages, errors and network events in order to populate
|
// Watch for console API messages, errors and network events in order to populate
|
||||||
// the error count icon in the toolbox.
|
// the error count icon in the toolbox.
|
||||||
const onResourcesWatched = this.resourceCommand.watchResources(
|
const onResourcesWatched = this.resourceWatcher.watchResources(
|
||||||
[
|
[
|
||||||
this.resourceCommand.TYPES.CONSOLE_MESSAGE,
|
this.resourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||||
this.resourceCommand.TYPES.ERROR_MESSAGE,
|
this.resourceWatcher.TYPES.ERROR_MESSAGE,
|
||||||
// Independently of watching network event resources for the error count icon,
|
// Independently of watching network event resources for the error count icon,
|
||||||
// we need to start tracking network activity on toolbox open for targets such
|
// 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
|
// 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
|
// for network events across the lifetime of the various panels, so stopping
|
||||||
// the resource command from clearing out its cache of network event resources.
|
// the resource watcher from clearing out its cache of network event resources.
|
||||||
this.resourceCommand.TYPES.NETWORK_EVENT,
|
this.resourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onAvailable: this._onResourceAvailable,
|
onAvailable: this._onResourceAvailable,
|
||||||
@@ -3761,11 +3763,11 @@ Toolbox.prototype = {
|
|||||||
this._onTargetAvailable,
|
this._onTargetAvailable,
|
||||||
this._onTargetDestroyed
|
this._onTargetDestroyed
|
||||||
);
|
);
|
||||||
this.resourceCommand.unwatchResources(
|
this.resourceWatcher.unwatchResources(
|
||||||
[
|
[
|
||||||
this.resourceCommand.TYPES.CONSOLE_MESSAGE,
|
this.resourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||||
this.resourceCommand.TYPES.ERROR_MESSAGE,
|
this.resourceWatcher.TYPES.ERROR_MESSAGE,
|
||||||
this.resourceCommand.TYPES.NETWORK_EVENT,
|
this.resourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
],
|
],
|
||||||
{ onAvailable: this._onResourceAvailable }
|
{ onAvailable: this._onResourceAvailable }
|
||||||
);
|
);
|
||||||
@@ -4308,7 +4310,7 @@ Toolbox.prototype = {
|
|||||||
|
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
if (
|
if (
|
||||||
resource.resourceType === this.resourceCommand.TYPES.ERROR_MESSAGE &&
|
resource.resourceType === this.resourceWatcher.TYPES.ERROR_MESSAGE &&
|
||||||
// ERROR_MESSAGE resources can be warnings/info, but here we only want to count errors
|
// ERROR_MESSAGE resources can be warnings/info, but here we only want to count errors
|
||||||
resource.pageError.error
|
resource.pageError.error
|
||||||
) {
|
) {
|
||||||
@@ -4317,7 +4319,7 @@ Toolbox.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
resource.resourceType === this.resourceCommand.TYPES.CONSOLE_MESSAGE
|
resource.resourceType === this.resourceWatcher.TYPES.CONSOLE_MESSAGE
|
||||||
) {
|
) {
|
||||||
const { level } = resource.message;
|
const { level } = resource.message;
|
||||||
if (level === "error" || level === "exception" || level === "assert") {
|
if (level === "error" || level === "exception" || level === "assert") {
|
||||||
@@ -4340,7 +4342,7 @@ Toolbox.prototype = {
|
|||||||
for (const { update } of resources) {
|
for (const { update } of resources) {
|
||||||
// In order to match webconsole behaviour, we treat 4xx and 5xx network calls as errors.
|
// In order to match webconsole behaviour, we treat 4xx and 5xx network calls as errors.
|
||||||
if (
|
if (
|
||||||
update.resourceType === this.resourceCommand.TYPES.NETWORK_EVENT &&
|
update.resourceType === this.resourceWatcher.TYPES.NETWORK_EVENT &&
|
||||||
update.resourceUpdates.status &&
|
update.resourceUpdates.status &&
|
||||||
update.resourceUpdates.status.toString().match(REGEX_4XX_5XX)
|
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
|
// 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
|
// to watch for them before instanciating the pageStyle actor (which does use the
|
||||||
// watcher and assume we're already watching for stylesheets).
|
// watcher and assume we're already watching for stylesheets).
|
||||||
const { resourceCommand } = this.targetFront;
|
const { resourceWatcher } = this.targetFront;
|
||||||
if (
|
if (
|
||||||
resourceCommand?.hasResourceCommandSupport(
|
resourceWatcher?.hasResourceWatcherSupport(
|
||||||
resourceCommand.TYPES.STYLESHEET
|
resourceWatcher.TYPES.STYLESHEET
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.STYLESHEET], {
|
await resourceWatcher.watchResources([resourceWatcher.TYPES.STYLESHEET], {
|
||||||
// we simply want to start the watcher, we don't have to do anything with those resources.
|
// we simply want to start the watcher, we don't have to do anything with those resources.
|
||||||
onAvailable: () => {},
|
onAvailable: () => {},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ function getAdHocFrontOrPrimitiveGrip(packet, parentFront) {
|
|||||||
// actorID, unless:
|
// actorID, unless:
|
||||||
// - it's a Symbol (See Bug 1600299)
|
// - it's a Symbol (See Bug 1600299)
|
||||||
// - it's a mapEntry (the preview.key and preview.value properties can hold actors)
|
// - it's a mapEntry (the preview.key and preview.value properties can hold actors)
|
||||||
// - or it is already a front (happens when we are using the legacy listeners in the ResourceCommand)
|
// - or it is already a front (happens when we are using the legacy listeners in the ResourceWatcher)
|
||||||
const isPacketAnObject = packet && typeof packet === "object";
|
const isPacketAnObject = packet && typeof packet === "object";
|
||||||
const isFront = !!packet.typeName;
|
const isFront = !!packet.typeName;
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -110,14 +110,14 @@ class StyleRuleFront extends FrontClassWithSpec(styleRuleSpec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get parentStyleSheet() {
|
get parentStyleSheet() {
|
||||||
const resourceCommand = this.targetFront.resourceCommand;
|
const resourceWatcher = this.targetFront.resourceWatcher;
|
||||||
if (
|
if (
|
||||||
resourceCommand?.hasResourceCommandSupport(
|
resourceWatcher?.hasResourceWatcherSupport(
|
||||||
resourceCommand.TYPES.STYLESHEET
|
resourceWatcher.TYPES.STYLESHEET
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return resourceCommand.getResourceById(
|
return resourceWatcher.getResourceById(
|
||||||
resourceCommand.TYPES.STYLESHEET,
|
resourceWatcher.TYPES.STYLESHEET,
|
||||||
this._form.parentStyleSheet
|
this._form.parentStyleSheet
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ function TargetMixin(parentClass) {
|
|||||||
this.fronts = new Map();
|
this.fronts = new Map();
|
||||||
|
|
||||||
// `resource-available-form` and `resource-updated-form` events can be emitted
|
// `resource-available-form` and `resource-updated-form` events can be emitted
|
||||||
// by target actors before the ResourceCommand could add event listeners.
|
// by target actors before the ResourceWatcher could add event listeners.
|
||||||
// The target front will cache those events until the ResourceCommand has
|
// The target front will cache those events until the ResourceWatcher has
|
||||||
// added the listeners.
|
// added the listeners.
|
||||||
this._resourceCache = {};
|
this._resourceCache = {};
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class WalkerFront extends FrontClassWithSpec(walkerSpec) {
|
|||||||
this.before("new-mutations", this.onMutations.bind(this));
|
this.before("new-mutations", this.onMutations.bind(this));
|
||||||
|
|
||||||
// Those events will be emitted if watchRootNode was called on the
|
// Those events will be emitted if watchRootNode was called on the
|
||||||
// corresponding WalkerActor, which should be handled by the ResourceCommand
|
// corresponding WalkerActor, which should be handled by the ResourceWatcher
|
||||||
// as long as a consumer is watching for root-node resources.
|
// as long as a consumer is watching for root-node resources.
|
||||||
// This should be fixed by using watchResources directly from the walker
|
// This should be fixed by using watchResources directly from the walker
|
||||||
// front, either with the ROOT_NODE resource, or with the DOCUMENT_EVENT
|
// front, either with the ROOT_NODE resource, or with the DOCUMENT_EVENT
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ class ChangesView {
|
|||||||
return this._contextMenu;
|
return this._contextMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
get resourceCommand() {
|
get resourceWatcher() {
|
||||||
return this.inspector.toolbox.resourceCommand;
|
return this.inspector.toolbox.resourceWatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@@ -101,27 +101,27 @@ class ChangesView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async watchResources() {
|
async watchResources() {
|
||||||
await this.resourceCommand.watchResources(
|
await this.resourceWatcher.watchResources(
|
||||||
[this.resourceCommand.TYPES.DOCUMENT_EVENT],
|
[this.resourceWatcher.TYPES.DOCUMENT_EVENT],
|
||||||
{
|
{
|
||||||
onAvailable: this.onResourceAvailable,
|
onAvailable: this.onResourceAvailable,
|
||||||
// Ignore any DOCUMENT_EVENT resources that have occured in the past
|
// Ignore any DOCUMENT_EVENT resources that have occured in the past
|
||||||
// and are cached by the resource command, otherwise the Changes panel will
|
// and are cached by the resource watcher, otherwise the Changes panel will
|
||||||
// react to them erroneously and interpret that the document is reloading *now*
|
// react to them erroneously and interpret that the document is reloading *now*
|
||||||
// which leads to clearing all stored changes.
|
// which leads to clearing all stored changes.
|
||||||
ignoreExistingResources: true,
|
ignoreExistingResources: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.resourceCommand.watchResources(
|
await this.resourceWatcher.watchResources(
|
||||||
[this.resourceCommand.TYPES.CSS_CHANGE],
|
[this.resourceWatcher.TYPES.CSS_CHANGE],
|
||||||
{ onAvailable: this.onResourceAvailable }
|
{ onAvailable: this.onResourceAvailable }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onResourceAvailable(resources) {
|
onResourceAvailable(resources) {
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
if (resource.resourceType === this.resourceCommand.TYPES.CSS_CHANGE) {
|
if (resource.resourceType === this.resourceWatcher.TYPES.CSS_CHANGE) {
|
||||||
this.onAddChange(resource);
|
this.onAddChange(resource);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -256,10 +256,10 @@ class ChangesView {
|
|||||||
* Destruction function called when the inspector is destroyed.
|
* Destruction function called when the inspector is destroyed.
|
||||||
*/
|
*/
|
||||||
destroy() {
|
destroy() {
|
||||||
this.resourceCommand.unwatchResources(
|
this.resourceWatcher.unwatchResources(
|
||||||
[
|
[
|
||||||
this.resourceCommand.TYPES.CSS_CHANGE,
|
this.resourceWatcher.TYPES.CSS_CHANGE,
|
||||||
this.resourceCommand.TYPES.DOCUMENT_EVENT,
|
this.resourceWatcher.TYPES.DOCUMENT_EVENT,
|
||||||
],
|
],
|
||||||
{ onAvailable: this.onResourceAvailable }
|
{ onAvailable: this.onResourceAvailable }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ class CompatibilityView {
|
|||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
try {
|
try {
|
||||||
this.resourceCommand.unwatchResources(
|
this.resourceWatcher.unwatchResources(
|
||||||
[this.resourceCommand.TYPES.CSS_CHANGE],
|
[this.resourceWatcher.TYPES.CSS_CHANGE],
|
||||||
{
|
{
|
||||||
onAvailable: this._onResourceAvailable,
|
onAvailable: this._onResourceAvailable,
|
||||||
}
|
}
|
||||||
@@ -69,8 +69,8 @@ class CompatibilityView {
|
|||||||
this.inspector = null;
|
this.inspector = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get resourceCommand() {
|
get resourceWatcher() {
|
||||||
return this.inspector.toolbox.resourceCommand;
|
return this.inspector.toolbox.resourceWatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
async _init() {
|
async _init() {
|
||||||
@@ -104,8 +104,8 @@ class CompatibilityView {
|
|||||||
this._onPanelSelected
|
this._onPanelSelected
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.resourceCommand.watchResources(
|
await this.resourceWatcher.watchResources(
|
||||||
[this.resourceCommand.TYPES.CSS_CHANGE],
|
[this.resourceWatcher.TYPES.CSS_CHANGE],
|
||||||
{
|
{
|
||||||
onAvailable: this._onResourceAvailable,
|
onAvailable: this._onResourceAvailable,
|
||||||
// CSS changes made before opening Compatibility View are already applied to
|
// CSS changes made before opening Compatibility View are already applied to
|
||||||
|
|||||||
@@ -208,11 +208,11 @@ Inspector.prototype = {
|
|||||||
this._onTargetDestroyed
|
this._onTargetDestroyed
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.toolbox.resourceCommand.watchResources(
|
await this.toolbox.resourceWatcher.watchResources(
|
||||||
[
|
[
|
||||||
this.toolbox.resourceCommand.TYPES.ROOT_NODE,
|
this.toolbox.resourceWatcher.TYPES.ROOT_NODE,
|
||||||
// To observe CSS change before opening changes view.
|
// To observe CSS change before opening changes view.
|
||||||
this.toolbox.resourceCommand.TYPES.CSS_CHANGE,
|
this.toolbox.resourceWatcher.TYPES.CSS_CHANGE,
|
||||||
],
|
],
|
||||||
{ onAvailable: this.onResourceAvailable }
|
{ onAvailable: this.onResourceAvailable }
|
||||||
);
|
);
|
||||||
@@ -1276,7 +1276,7 @@ Inspector.prototype = {
|
|||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
if (
|
if (
|
||||||
resource.resourceType ===
|
resource.resourceType ===
|
||||||
this.toolbox.resourceCommand.TYPES.ROOT_NODE &&
|
this.toolbox.resourceWatcher.TYPES.ROOT_NODE &&
|
||||||
// It might happen that the ROOT_NODE resource (which is a Front) is already
|
// It might happen that the ROOT_NODE resource (which is a Front) is already
|
||||||
// destroyed, and in such case we want to ignore it.
|
// destroyed, and in such case we want to ignore it.
|
||||||
!resource.isDestroyed()
|
!resource.isDestroyed()
|
||||||
@@ -1679,9 +1679,9 @@ Inspector.prototype = {
|
|||||||
this._onTargetAvailable,
|
this._onTargetAvailable,
|
||||||
this._onTargetDestroyed
|
this._onTargetDestroyed
|
||||||
);
|
);
|
||||||
const { resourceCommand } = this.toolbox;
|
const { resourceWatcher } = this.toolbox;
|
||||||
resourceCommand.unwatchResources(
|
resourceWatcher.unwatchResources(
|
||||||
[resourceCommand.TYPES.ROOT_NODE, resourceCommand.TYPES.CSS_CHANGE],
|
[resourceWatcher.TYPES.ROOT_NODE, resourceWatcher.TYPES.CSS_CHANGE],
|
||||||
{ onAvailable: this.onResourceAvailable }
|
{ onAvailable: this.onResourceAvailable }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -372,8 +372,8 @@ function MarkupView(inspector, frame, controllerWindow) {
|
|||||||
mutations: this._onWalkerMutations,
|
mutations: this._onWalkerMutations,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.resourceCommand = this.inspector.toolbox.resourceCommand;
|
this.resourceWatcher = this.inspector.toolbox.resourceWatcher;
|
||||||
this.resourceCommand.watchResources([this.resourceCommand.TYPES.ROOT_NODE], {
|
this.resourceWatcher.watchResources([this.resourceWatcher.TYPES.ROOT_NODE], {
|
||||||
onAvailable: this._onResourceAvailable,
|
onAvailable: this._onResourceAvailable,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1442,7 +1442,7 @@ MarkupView.prototype = {
|
|||||||
_onResourceAvailable: async function(resources) {
|
_onResourceAvailable: async function(resources) {
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
if (
|
if (
|
||||||
resource.resourceType !== this.resourceCommand.TYPES.ROOT_NODE ||
|
resource.resourceType !== this.resourceWatcher.TYPES.ROOT_NODE ||
|
||||||
resource.isDestroyed()
|
resource.isDestroyed()
|
||||||
) {
|
) {
|
||||||
// Only handle alive root-node resources
|
// Only handle alive root-node resources
|
||||||
@@ -2379,8 +2379,8 @@ MarkupView.prototype = {
|
|||||||
this._elt.removeEventListener("mouseout", this._onMouseOut);
|
this._elt.removeEventListener("mouseout", this._onMouseOut);
|
||||||
this._frame.removeEventListener("focus", this._onFocus);
|
this._frame.removeEventListener("focus", this._onFocus);
|
||||||
this.inspector.selection.off("new-node-front", this._onNewSelection);
|
this.inspector.selection.off("new-node-front", this._onNewSelection);
|
||||||
this.resourceCommand.unwatchResources(
|
this.resourceWatcher.unwatchResources(
|
||||||
[this.resourceCommand.TYPES.ROOT_NODE],
|
[this.resourceWatcher.TYPES.ROOT_NODE],
|
||||||
{ onAvailable: this._onResourceAvailable }
|
{ onAvailable: this._onResourceAvailable }
|
||||||
);
|
);
|
||||||
this.inspector.toolbox.nodePicker.off(
|
this.inspector.toolbox.nodePicker.off(
|
||||||
|
|||||||
@@ -213,9 +213,9 @@ class HighlightersOverlay {
|
|||||||
// Add inspector events, not specific to a given view.
|
// Add inspector events, not specific to a given view.
|
||||||
this.inspector.on("markupmutation", this.onMarkupMutation);
|
this.inspector.on("markupmutation", this.onMarkupMutation);
|
||||||
|
|
||||||
this.resourceCommand = this.inspector.toolbox.resourceCommand;
|
this.resourceWatcher = this.inspector.toolbox.resourceWatcher;
|
||||||
this.resourceCommand.watchResources(
|
this.resourceWatcher.watchResources(
|
||||||
[this.resourceCommand.TYPES.ROOT_NODE],
|
[this.resourceWatcher.TYPES.ROOT_NODE],
|
||||||
{ onAvailable: this._onResourceAvailable }
|
{ onAvailable: this._onResourceAvailable }
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1742,7 +1742,7 @@ class HighlightersOverlay {
|
|||||||
async _onResourceAvailable(resources) {
|
async _onResourceAvailable(resources) {
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
if (
|
if (
|
||||||
resource.resourceType !== this.resourceCommand.TYPES.ROOT_NODE ||
|
resource.resourceType !== this.resourceWatcher.TYPES.ROOT_NODE ||
|
||||||
// It might happen that the ROOT_NODE resource (which is a Front) is already
|
// It might happen that the ROOT_NODE resource (which is a Front) is already
|
||||||
// destroyed, and in such case we want to ignore it.
|
// destroyed, and in such case we want to ignore it.
|
||||||
resource.isDestroyed()
|
resource.isDestroyed()
|
||||||
@@ -1888,8 +1888,8 @@ class HighlightersOverlay {
|
|||||||
*/
|
*/
|
||||||
destroy() {
|
destroy() {
|
||||||
this.inspector.off("markupmutation", this.onMarkupMutation);
|
this.inspector.off("markupmutation", this.onMarkupMutation);
|
||||||
this.resourceCommand.unwatchResources(
|
this.resourceWatcher.unwatchResources(
|
||||||
[this.resourceCommand.TYPES.ROOT_NODE],
|
[this.resourceWatcher.TYPES.ROOT_NODE],
|
||||||
{ onAvailable: this._onResourceAvailable }
|
{ onAvailable: this._onResourceAvailable }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ add_task(async function navigateFrameNotExpandedInMarkupView() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { inspector } = await openInspectorForURL(TEST_ORG_URI);
|
const { inspector } = await openInspectorForURL(TEST_ORG_URI);
|
||||||
const resourceCommand = inspector.toolbox.resourceCommand;
|
const resourceWatcher = inspector.toolbox.resourceWatcher;
|
||||||
|
|
||||||
// At this stage the expected layout of the markup view is
|
// At this stage the expected layout of the markup view is
|
||||||
// v html (expanded)
|
// v html (expanded)
|
||||||
@@ -81,7 +81,7 @@ add_task(async function navigateFrameNotExpandedInMarkupView() {
|
|||||||
|
|
||||||
is(
|
is(
|
||||||
resource.resourceType,
|
resource.resourceType,
|
||||||
resourceCommand.TYPES.ROOT_NODE,
|
resourceWatcher.TYPES.ROOT_NODE,
|
||||||
"A resource with resourceType ROOT_NODE was received when navigating"
|
"A resource with resourceType ROOT_NODE was received when navigating"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -110,12 +110,12 @@ async function navigateIframeTo(inspector, url) {
|
|||||||
info("Navigate the test iframe to " + url);
|
info("Navigate the test iframe to " + url);
|
||||||
|
|
||||||
const { commands } = inspector;
|
const { commands } = inspector;
|
||||||
const { resourceCommand } = inspector.toolbox;
|
const { resourceWatcher } = inspector.toolbox;
|
||||||
const onTargetProcessed = waitForTargetProcessed(commands, url);
|
const onTargetProcessed = waitForTargetProcessed(commands, url);
|
||||||
|
|
||||||
const onNewRoot = waitForNextResource(
|
const onNewRoot = waitForNextResource(
|
||||||
resourceCommand,
|
resourceWatcher,
|
||||||
resourceCommand.TYPES.ROOT_NODE,
|
resourceWatcher.TYPES.ROOT_NODE,
|
||||||
{
|
{
|
||||||
ignoreExistingResources: true,
|
ignoreExistingResources: true,
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ async function navigateIframeTo(inspector, url) {
|
|||||||
/**
|
/**
|
||||||
* Returns a promise that waits until the provided commands's TargetCommand has fully
|
* Returns a promise that waits until the provided commands's TargetCommand has fully
|
||||||
* processed a target with the provided URL.
|
* processed a target with the provided URL.
|
||||||
* This will avoid navigating again before the new resource command have fully
|
* This will avoid navigating again before the new resource watchers have fully
|
||||||
* attached to the new target.
|
* attached to the new target.
|
||||||
*/
|
*/
|
||||||
function waitForTargetProcessed(commands, url) {
|
function waitForTargetProcessed(commands, url) {
|
||||||
|
|||||||
@@ -29,15 +29,15 @@ class FirefoxDataProvider {
|
|||||||
* @param {Object} webConsoleFront represents the client object for Console actor.
|
* @param {Object} webConsoleFront represents the client object for Console actor.
|
||||||
* @param {Object} actions set of actions fired during data fetching process.
|
* @param {Object} actions set of actions fired during data fetching process.
|
||||||
* @param {Object} owner all events are fired on this object.
|
* @param {Object} owner all events are fired on this object.
|
||||||
* @param {Object} resourceCommand enables checking for watcher support
|
* @param {Object} resourceWatcher enables checking for watcher support
|
||||||
*/
|
*/
|
||||||
constructor({ webConsoleFront, actions, owner, resourceCommand }) {
|
constructor({ webConsoleFront, actions, owner, resourceWatcher }) {
|
||||||
// Options
|
// Options
|
||||||
this.webConsoleFront = webConsoleFront;
|
this.webConsoleFront = webConsoleFront;
|
||||||
this.actions = actions || {};
|
this.actions = actions || {};
|
||||||
this.actionsEnabled = true;
|
this.actionsEnabled = true;
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.resourceCommand = resourceCommand;
|
this.resourceWatcher = resourceWatcher;
|
||||||
// Map of all stacktrace resources keyed by network event's resourceId
|
// Map of all stacktrace resources keyed by network event's resourceId
|
||||||
this.stackTraces = new Map();
|
this.stackTraces = new Map();
|
||||||
// Map of the stacktrace information keyed by the actor id's
|
// Map of the stacktrace information keyed by the actor id's
|
||||||
@@ -521,8 +521,8 @@ class FirefoxDataProvider {
|
|||||||
let response;
|
let response;
|
||||||
if (
|
if (
|
||||||
clientMethodName == "getStackTrace" &&
|
clientMethodName == "getStackTrace" &&
|
||||||
this.resourceCommand.hasResourceCommandSupport(
|
this.resourceWatcher.hasResourceWatcherSupport(
|
||||||
this.resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE
|
this.resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
const requestInfo = this.stackTraceRequestInfoByActorID.get(
|
const requestInfo = this.stackTraceRequestInfoByActorID.get(
|
||||||
|
|||||||
@@ -54,14 +54,14 @@ class Connector {
|
|||||||
return this.commands.targetCommand.targetFront;
|
return this.commands.targetCommand.targetFront;
|
||||||
}
|
}
|
||||||
|
|
||||||
get hasResourceCommandSupport() {
|
get hasResourceWatcherSupport() {
|
||||||
return this.toolbox.resourceCommand.hasResourceCommandSupport(
|
return this.toolbox.resourceWatcher.hasResourceWatcherSupport(
|
||||||
this.toolbox.resourceCommand.TYPES.NETWORK_EVENT
|
this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get watcherFront() {
|
get watcherFront() {
|
||||||
return this.toolbox.resourceCommand.watcherFront;
|
return this.toolbox.resourceWatcher.watcherFront;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,8 +85,8 @@ class Connector {
|
|||||||
this.onTargetAvailable
|
this.onTargetAvailable
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.toolbox.resourceCommand.watchResources(
|
await this.toolbox.resourceWatcher.watchResources(
|
||||||
[this.toolbox.resourceCommand.TYPES.DOCUMENT_EVENT],
|
[this.toolbox.resourceWatcher.TYPES.DOCUMENT_EVENT],
|
||||||
{ onAvailable: this.onResourceAvailable }
|
{ onAvailable: this.onResourceAvailable }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -104,8 +104,8 @@ class Connector {
|
|||||||
this.onTargetAvailable
|
this.onTargetAvailable
|
||||||
);
|
);
|
||||||
|
|
||||||
this.toolbox.resourceCommand.unwatchResources(
|
this.toolbox.resourceWatcher.unwatchResources(
|
||||||
[this.toolbox.resourceCommand.TYPES.DOCUMENT_EVENT],
|
[this.toolbox.resourceWatcher.TYPES.DOCUMENT_EVENT],
|
||||||
{ onAvailable: this.onResourceAvailable }
|
{ onAvailable: this.onResourceAvailable }
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ class Connector {
|
|||||||
webConsoleFront: this.webConsoleFront,
|
webConsoleFront: this.webConsoleFront,
|
||||||
actions: this.actions,
|
actions: this.actions,
|
||||||
owner: this.owner,
|
owner: this.owner,
|
||||||
resourceCommand: this.toolbox.resourceCommand,
|
resourceWatcher: this.toolbox.resourceWatcher,
|
||||||
});
|
});
|
||||||
|
|
||||||
// If this is the first top level target, lets register all the listeners
|
// If this is the first top level target, lets register all the listeners
|
||||||
@@ -161,14 +161,14 @@ class Connector {
|
|||||||
|
|
||||||
// Initialize Responsive Emulation front for network throttling.
|
// Initialize Responsive Emulation front for network throttling.
|
||||||
this.responsiveFront = await this.currentTarget.getFront("responsive");
|
this.responsiveFront = await this.currentTarget.getFront("responsive");
|
||||||
if (this.hasResourceCommandSupport) {
|
if (this.hasResourceWatcherSupport) {
|
||||||
this.networkFront = await this.watcherFront.getNetworkParentActor();
|
this.networkFront = await this.watcherFront.getNetworkParentActor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async onResourceAvailable(resources) {
|
async onResourceAvailable(resources) {
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
const { TYPES } = this.toolbox.resourceCommand;
|
const { TYPES } = this.toolbox.resourceWatcher;
|
||||||
|
|
||||||
if (resource.resourceType === TYPES.DOCUMENT_EVENT) {
|
if (resource.resourceType === TYPES.DOCUMENT_EVENT) {
|
||||||
this.onDocEvent(resource);
|
this.onDocEvent(resource);
|
||||||
@@ -249,7 +249,7 @@ class Connector {
|
|||||||
for (const { resource, update } of updates) {
|
for (const { resource, update } of updates) {
|
||||||
if (
|
if (
|
||||||
resource.resourceType ===
|
resource.resourceType ===
|
||||||
this.toolbox.resourceCommand.TYPES.NETWORK_EVENT &&
|
this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT &&
|
||||||
this.listenForNetworkEvents
|
this.listenForNetworkEvents
|
||||||
) {
|
) {
|
||||||
this.dataProvider.onNetworkResourceUpdated(resource, update);
|
this.dataProvider.onNetworkResourceUpdated(resource, update);
|
||||||
@@ -259,11 +259,11 @@ class Connector {
|
|||||||
|
|
||||||
async addListeners(ignoreExistingResources = false) {
|
async addListeners(ignoreExistingResources = false) {
|
||||||
const targetResources = [
|
const targetResources = [
|
||||||
this.toolbox.resourceCommand.TYPES.NETWORK_EVENT,
|
this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
this.toolbox.resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||||
];
|
];
|
||||||
if (Services.prefs.getBoolPref("devtools.netmonitor.features.webSockets")) {
|
if (Services.prefs.getBoolPref("devtools.netmonitor.features.webSockets")) {
|
||||||
targetResources.push(this.toolbox.resourceCommand.TYPES.WEBSOCKET);
|
targetResources.push(this.toolbox.resourceWatcher.TYPES.WEBSOCKET);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -272,11 +272,11 @@ class Connector {
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
targetResources.push(
|
targetResources.push(
|
||||||
this.toolbox.resourceCommand.TYPES.SERVER_SENT_EVENT
|
this.toolbox.resourceWatcher.TYPES.SERVER_SENT_EVENT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.toolbox.resourceCommand.watchResources(targetResources, {
|
await this.toolbox.resourceWatcher.watchResources(targetResources, {
|
||||||
onAvailable: this.onResourceAvailable,
|
onAvailable: this.onResourceAvailable,
|
||||||
onUpdated: this.onResourceUpdated,
|
onUpdated: this.onResourceUpdated,
|
||||||
ignoreExistingResources,
|
ignoreExistingResources,
|
||||||
@@ -284,12 +284,12 @@ class Connector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeListeners() {
|
removeListeners() {
|
||||||
this.toolbox.resourceCommand.unwatchResources(
|
this.toolbox.resourceWatcher.unwatchResources(
|
||||||
[
|
[
|
||||||
this.toolbox.resourceCommand.TYPES.NETWORK_EVENT,
|
this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
this.toolbox.resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||||
this.toolbox.resourceCommand.TYPES.WEBSOCKET,
|
this.toolbox.resourceWatcher.TYPES.WEBSOCKET,
|
||||||
this.toolbox.resourceCommand.TYPES.SERVER_SENT_EVENT,
|
this.toolbox.resourceWatcher.TYPES.SERVER_SENT_EVENT,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onAvailable: this.onResourceAvailable,
|
onAvailable: this.onResourceAvailable,
|
||||||
@@ -390,7 +390,7 @@ class Connector {
|
|||||||
* @param {object} data data payload would like to sent to backend
|
* @param {object} data data payload would like to sent to backend
|
||||||
*/
|
*/
|
||||||
async sendHTTPRequest(data) {
|
async sendHTTPRequest(data) {
|
||||||
if (this.hasResourceCommandSupport && this.currentTarget) {
|
if (this.hasResourceWatcherSupport && this.currentTarget) {
|
||||||
const networkContentFront = await this.currentTarget.getFront(
|
const networkContentFront = await this.currentTarget.getFront(
|
||||||
"networkContent"
|
"networkContent"
|
||||||
);
|
);
|
||||||
@@ -425,7 +425,7 @@ class Connector {
|
|||||||
* Get the list of blocked URLs
|
* Get the list of blocked URLs
|
||||||
*/
|
*/
|
||||||
async getBlockedUrls() {
|
async getBlockedUrls() {
|
||||||
if (this.hasResourceCommandSupport && this.networkFront) {
|
if (this.hasResourceWatcherSupport && this.networkFront) {
|
||||||
return this.networkFront.getBlockedUrls();
|
return this.networkFront.getBlockedUrls();
|
||||||
}
|
}
|
||||||
if (!this.webConsoleFront.traits.blockedUrls) {
|
if (!this.webConsoleFront.traits.blockedUrls) {
|
||||||
@@ -440,7 +440,7 @@ class Connector {
|
|||||||
* @param {object} urls An array of URL strings
|
* @param {object} urls An array of URL strings
|
||||||
*/
|
*/
|
||||||
async setBlockedUrls(urls) {
|
async setBlockedUrls(urls) {
|
||||||
if (this.hasResourceCommandSupport && this.networkFront) {
|
if (this.hasResourceWatcherSupport && this.networkFront) {
|
||||||
return this.networkFront.setBlockedUrls(urls);
|
return this.networkFront.setBlockedUrls(urls);
|
||||||
}
|
}
|
||||||
return this.webConsoleFront.setBlockedUrls(urls);
|
return this.webConsoleFront.setBlockedUrls(urls);
|
||||||
@@ -578,7 +578,7 @@ class Connector {
|
|||||||
|
|
||||||
async updateNetworkThrottling(enabled, profile) {
|
async updateNetworkThrottling(enabled, profile) {
|
||||||
const throttlingFront =
|
const throttlingFront =
|
||||||
this.hasResourceCommandSupport && this.networkFront
|
this.hasResourceWatcherSupport && this.networkFront
|
||||||
? this.networkFront
|
? this.networkFront
|
||||||
: this.responsiveFront;
|
: this.responsiveFront;
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ HarAutomation.prototype = {
|
|||||||
// data from events sent from the backend.
|
// data from events sent from the backend.
|
||||||
this.collector = new HarCollector({
|
this.collector = new HarCollector({
|
||||||
webConsoleFront: this.webConsoleFront,
|
webConsoleFront: this.webConsoleFront,
|
||||||
resourceCommand: this.toolbox.resourceCommand,
|
resourceWatcher: this.toolbox.resourceWatcher,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.collector.start();
|
this.collector.start();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const trace = {
|
|||||||
*/
|
*/
|
||||||
function HarCollector(options) {
|
function HarCollector(options) {
|
||||||
this.webConsoleFront = options.webConsoleFront;
|
this.webConsoleFront = options.webConsoleFront;
|
||||||
this.resourceCommand = options.resourceCommand;
|
this.resourceWatcher = options.resourceWatcher;
|
||||||
|
|
||||||
this.onResourceAvailable = this.onResourceAvailable.bind(this);
|
this.onResourceAvailable = this.onResourceAvailable.bind(this);
|
||||||
this.onResourceUpdated = this.onResourceUpdated.bind(this);
|
this.onResourceUpdated = this.onResourceUpdated.bind(this);
|
||||||
@@ -36,8 +36,8 @@ HarCollector.prototype = {
|
|||||||
// Connection
|
// Connection
|
||||||
|
|
||||||
start: async function() {
|
start: async function() {
|
||||||
await this.resourceCommand.watchResources(
|
await this.resourceWatcher.watchResources(
|
||||||
[this.resourceCommand.TYPES.NETWORK_EVENT],
|
[this.resourceWatcher.TYPES.NETWORK_EVENT],
|
||||||
{
|
{
|
||||||
onAvailable: this.onResourceAvailable,
|
onAvailable: this.onResourceAvailable,
|
||||||
onUpdated: this.onResourceUpdated,
|
onUpdated: this.onResourceUpdated,
|
||||||
@@ -46,8 +46,8 @@ HarCollector.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
stop: async function() {
|
stop: async function() {
|
||||||
await this.resourceCommand.unwatchResources(
|
await this.resourceWatcher.unwatchResources(
|
||||||
[this.resourceCommand.TYPES.NETWORK_EVENT],
|
[this.resourceWatcher.TYPES.NETWORK_EVENT],
|
||||||
{
|
{
|
||||||
onAvailable: this.onResourceAvailable,
|
onAvailable: this.onResourceAvailable,
|
||||||
onUpdated: this.onResourceUpdated,
|
onUpdated: this.onResourceUpdated,
|
||||||
|
|||||||
@@ -488,8 +488,8 @@ function waitForNetworkEvents(monitor, getRequests, options = {}) {
|
|||||||
async function waitForNetworkResource(toolbox, noOfExpectedResources = 1) {
|
async function waitForNetworkResource(toolbox, noOfExpectedResources = 1) {
|
||||||
let countOfAvailableResources = 0;
|
let countOfAvailableResources = 0;
|
||||||
return waitForNextResource(
|
return waitForNextResource(
|
||||||
toolbox.resourceCommand,
|
toolbox.resourceWatcher,
|
||||||
toolbox.resourceCommand.TYPES.NETWORK_EVENT,
|
toolbox.resourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
{
|
{
|
||||||
ignoreExistingResources: true,
|
ignoreExistingResources: true,
|
||||||
predicate: resource =>
|
predicate: resource =>
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ const {
|
|||||||
getOrientation,
|
getOrientation,
|
||||||
} = require("devtools/client/responsive/utils/orientation");
|
} = require("devtools/client/responsive/utils/orientation");
|
||||||
const Constants = require("devtools/client/responsive/constants");
|
const Constants = require("devtools/client/responsive/constants");
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
const {
|
const {
|
||||||
CommandsFactory,
|
CommandsFactory,
|
||||||
} = require("devtools/shared/commands/commands-factory");
|
} = require("devtools/shared/commands/commands-factory");
|
||||||
@@ -114,7 +117,7 @@ class ResponsiveUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get watcherFront() {
|
get watcherFront() {
|
||||||
return this.resourceCommand.watcherFront;
|
return this.resourceWatcher.watcherFront;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -329,8 +332,8 @@ class ResponsiveUI {
|
|||||||
this.onTargetAvailable
|
this.onTargetAvailable
|
||||||
);
|
);
|
||||||
|
|
||||||
this.resourceCommand.unwatchResources(
|
this.resourceWatcher.unwatchResources(
|
||||||
[this.resourceCommand.TYPES.NETWORK_EVENT],
|
[this.resourceWatcher.TYPES.NETWORK_EVENT],
|
||||||
{ onAvailable: this.onNetworkResourceAvailable }
|
{ onAvailable: this.onNetworkResourceAvailable }
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -367,7 +370,7 @@ class ResponsiveUI {
|
|||||||
|
|
||||||
async connectToServer() {
|
async connectToServer() {
|
||||||
this.commands = await CommandsFactory.forTab(this.tab);
|
this.commands = await CommandsFactory.forTab(this.tab);
|
||||||
this.resourceCommand = this.commands.resourceCommand;
|
this.resourceWatcher = new ResourceWatcher(this.commands.targetCommand);
|
||||||
|
|
||||||
await this.commands.targetCommand.startListening();
|
await this.commands.targetCommand.startListening();
|
||||||
|
|
||||||
@@ -376,10 +379,10 @@ class ResponsiveUI {
|
|||||||
this.onTargetAvailable
|
this.onTargetAvailable
|
||||||
);
|
);
|
||||||
|
|
||||||
// To support network throttling the resource command
|
// To support network throttling the resource watcher
|
||||||
// needs to be watching for network resources.
|
// needs to be watching for network resources.
|
||||||
await this.resourceCommand.watchResources(
|
await this.resourceWatcher.watchResources(
|
||||||
[this.resourceCommand.TYPES.NETWORK_EVENT],
|
[this.resourceWatcher.TYPES.NETWORK_EVENT],
|
||||||
{ onAvailable: this.onNetworkResourceAvailable }
|
{ onAvailable: this.onNetworkResourceAvailable }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1194,10 +1194,10 @@ function getCurrentTestFilePath() {
|
|||||||
/**
|
/**
|
||||||
* Wait for a single resource of the provided resourceType.
|
* Wait for a single resource of the provided resourceType.
|
||||||
*
|
*
|
||||||
* @param {ResourceCommand} resourceCommand
|
* @param {ResourceWatcher} resourceWatcher
|
||||||
* The ResourceCommand instance that should emit the expected resource.
|
* The ResourceWatcher instance that should emit the expected resource.
|
||||||
* @param {String} resourceType
|
* @param {String} resourceType
|
||||||
* One of ResourceCommand.TYPES, type of the expected resource.
|
* One of ResourceWatcher.TYPES, type of the expected resource.
|
||||||
* @param {Object} additional options
|
* @param {Object} additional options
|
||||||
* - {Boolean} ignoreExistingResources: ignore existing resources or not.
|
* - {Boolean} ignoreExistingResources: ignore existing resources or not.
|
||||||
* - {Function} predicate: if provided, will wait until a resource makes
|
* - {Function} predicate: if provided, will wait until a resource makes
|
||||||
@@ -1207,7 +1207,7 @@ function getCurrentTestFilePath() {
|
|||||||
* - targetFront {TargetFront} the target which owns the resource
|
* - targetFront {TargetFront} the target which owns the resource
|
||||||
*/
|
*/
|
||||||
function waitForNextResource(
|
function waitForNextResource(
|
||||||
resourceCommand,
|
resourceWatcher,
|
||||||
resourceType,
|
resourceType,
|
||||||
{ ignoreExistingResources = false, predicate } = {}
|
{ ignoreExistingResources = false, predicate } = {}
|
||||||
) {
|
) {
|
||||||
@@ -1220,11 +1220,11 @@ function waitForNextResource(
|
|||||||
const matchingResource = resources.find(resource => predicate(resource));
|
const matchingResource = resources.find(resource => predicate(resource));
|
||||||
if (matchingResource) {
|
if (matchingResource) {
|
||||||
resolve(matchingResource);
|
resolve(matchingResource);
|
||||||
resourceCommand.unwatchResources([resourceType], { onAvailable });
|
resourceWatcher.unwatchResources([resourceType], { onAvailable });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resourceCommand.watchResources([resourceType], {
|
resourceWatcher.watchResources([resourceType], {
|
||||||
ignoreExistingResources,
|
ignoreExistingResources,
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -285,17 +285,17 @@ class StorageUI {
|
|||||||
|
|
||||||
this._onResourceListAvailable = this._onResourceListAvailable.bind(this);
|
this._onResourceListAvailable = this._onResourceListAvailable.bind(this);
|
||||||
|
|
||||||
const { resourceCommand } = this._toolbox;
|
const { resourceWatcher } = this._toolbox;
|
||||||
await this._toolbox.resourceCommand.watchResources(
|
await this._toolbox.resourceWatcher.watchResources(
|
||||||
[
|
[
|
||||||
// The first item in this list will be the first selected storage item
|
// The first item in this list will be the first selected storage item
|
||||||
// Tests assume Cookie -- moving cookie will break tests
|
// Tests assume Cookie -- moving cookie will break tests
|
||||||
resourceCommand.TYPES.COOKIE,
|
resourceWatcher.TYPES.COOKIE,
|
||||||
resourceCommand.TYPES.CACHE_STORAGE,
|
resourceWatcher.TYPES.CACHE_STORAGE,
|
||||||
resourceCommand.TYPES.EXTENSION_STORAGE,
|
resourceWatcher.TYPES.EXTENSION_STORAGE,
|
||||||
resourceCommand.TYPES.INDEXED_DB,
|
resourceWatcher.TYPES.INDEXED_DB,
|
||||||
resourceCommand.TYPES.LOCAL_STORAGE,
|
resourceWatcher.TYPES.LOCAL_STORAGE,
|
||||||
resourceCommand.TYPES.SESSION_STORAGE,
|
resourceWatcher.TYPES.SESSION_STORAGE,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onAvailable: this._onResourceListAvailable,
|
onAvailable: this._onResourceListAvailable,
|
||||||
@@ -376,15 +376,15 @@ class StorageUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
const { resourceCommand } = this._toolbox;
|
const { resourceWatcher } = this._toolbox;
|
||||||
resourceCommand.unwatchResources(
|
resourceWatcher.unwatchResources(
|
||||||
[
|
[
|
||||||
resourceCommand.TYPES.COOKIE,
|
resourceWatcher.TYPES.COOKIE,
|
||||||
resourceCommand.TYPES.CACHE_STORAGE,
|
resourceWatcher.TYPES.CACHE_STORAGE,
|
||||||
resourceCommand.TYPES.EXTENSION_STORAGE,
|
resourceWatcher.TYPES.EXTENSION_STORAGE,
|
||||||
resourceCommand.TYPES.INDEXED_DB,
|
resourceWatcher.TYPES.INDEXED_DB,
|
||||||
resourceCommand.TYPES.LOCAL_STORAGE,
|
resourceWatcher.TYPES.LOCAL_STORAGE,
|
||||||
resourceCommand.TYPES.SESSION_STORAGE,
|
resourceWatcher.TYPES.SESSION_STORAGE,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onAvailable: this._onResourceListAvailable,
|
onAvailable: this._onResourceListAvailable,
|
||||||
|
|||||||
@@ -145,14 +145,14 @@ StyleEditorUI.prototype = {
|
|||||||
this._onTargetAvailable
|
this._onTargetAvailable
|
||||||
);
|
);
|
||||||
|
|
||||||
await this._toolbox.resourceCommand.watchResources(
|
await this._toolbox.resourceWatcher.watchResources(
|
||||||
[this._toolbox.resourceCommand.TYPES.DOCUMENT_EVENT],
|
[this._toolbox.resourceWatcher.TYPES.DOCUMENT_EVENT],
|
||||||
{ onAvailable: this._onResourceAvailable }
|
{ onAvailable: this._onResourceAvailable }
|
||||||
);
|
);
|
||||||
|
|
||||||
this._startLoadingStyleSheets();
|
this._startLoadingStyleSheets();
|
||||||
await this._toolbox.resourceCommand.watchResources(
|
await this._toolbox.resourceWatcher.watchResources(
|
||||||
[this._toolbox.resourceCommand.TYPES.STYLESHEET],
|
[this._toolbox.resourceWatcher.TYPES.STYLESHEET],
|
||||||
{
|
{
|
||||||
onAvailable: this._onResourceAvailable,
|
onAvailable: this._onResourceAvailable,
|
||||||
onUpdated: this._onResourceUpdated,
|
onUpdated: this._onResourceUpdated,
|
||||||
@@ -256,11 +256,11 @@ StyleEditorUI.prototype = {
|
|||||||
async _onOrigSourcesPrefChanged() {
|
async _onOrigSourcesPrefChanged() {
|
||||||
this._clear();
|
this._clear();
|
||||||
// When we toggle the source-map preference, we clear the panel and re-fetch the exact
|
// When we toggle the source-map preference, we clear the panel and re-fetch the exact
|
||||||
// same stylesheet resources from ResourceCommand, but `_addStyleSheet` will trigger
|
// same stylesheet resources from ResourceWatcher, but `_addStyleSheet` will trigger
|
||||||
// or ignore the additional source-map mapping.
|
// or ignore the additional source-map mapping.
|
||||||
this._root.classList.add("loading");
|
this._root.classList.add("loading");
|
||||||
for (const resource of this._toolbox.resourceCommand.getAllResources(
|
for (const resource of this._toolbox.resourceWatcher.getAllResources(
|
||||||
this._toolbox.resourceCommand.TYPES.STYLESHEET
|
this._toolbox.resourceWatcher.TYPES.STYLESHEET
|
||||||
)) {
|
)) {
|
||||||
await this._handleStyleSheetResource(resource);
|
await this._handleStyleSheetResource(resource);
|
||||||
}
|
}
|
||||||
@@ -309,7 +309,7 @@ StyleEditorUI.prototype = {
|
|||||||
* instead (e.g. Sass sources), if applicable.
|
* instead (e.g. Sass sources), if applicable.
|
||||||
*
|
*
|
||||||
* @param {Resource} resource
|
* @param {Resource} resource
|
||||||
* The STYLESHEET resource which is received from resource command.
|
* The STYLESHEET resource which is received from resource watcher.
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* A promise that resolves to the style sheet's editor when the style sheet has
|
* 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
|
* 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.
|
* Add a new editor to the UI for a source.
|
||||||
*
|
*
|
||||||
* @param {Resource} resource
|
* @param {Resource} resource
|
||||||
* The resource which is received from resource command.
|
* The resource which is received from resource watcher.
|
||||||
* @return {Promise} that is resolved with the created StyleSheetEditor when
|
* @return {Promise} that is resolved with the created StyleSheetEditor when
|
||||||
* the editor is fully initialized or rejected on error.
|
* the editor is fully initialized or rejected on error.
|
||||||
*/
|
*/
|
||||||
@@ -1190,7 +1190,7 @@ StyleEditorUI.prototype = {
|
|||||||
const promises = [];
|
const promises = [];
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
if (
|
if (
|
||||||
resource.resourceType === this._toolbox.resourceCommand.TYPES.STYLESHEET
|
resource.resourceType === this._toolbox.resourceWatcher.TYPES.STYLESHEET
|
||||||
) {
|
) {
|
||||||
const onStyleSheetHandled = this._handleStyleSheetResource(resource);
|
const onStyleSheetHandled = this._handleStyleSheetResource(resource);
|
||||||
|
|
||||||
@@ -1235,7 +1235,7 @@ StyleEditorUI.prototype = {
|
|||||||
async _onResourceUpdated(updates) {
|
async _onResourceUpdated(updates) {
|
||||||
for (const { resource, update } of updates) {
|
for (const { resource, update } of updates) {
|
||||||
if (
|
if (
|
||||||
update.resourceType === this._toolbox.resourceCommand.TYPES.STYLESHEET
|
update.resourceType === this._toolbox.resourceWatcher.TYPES.STYLESHEET
|
||||||
) {
|
) {
|
||||||
const editor = this.editors.find(
|
const editor = this.editors.find(
|
||||||
e => e.resourceId === update.resourceId
|
e => e.resourceId === update.resourceId
|
||||||
@@ -1279,10 +1279,10 @@ StyleEditorUI.prototype = {
|
|||||||
this._onTargetAvailable
|
this._onTargetAvailable
|
||||||
);
|
);
|
||||||
|
|
||||||
this._toolbox.resourceCommand.unwatchResources(
|
this._toolbox.resourceWatcher.unwatchResources(
|
||||||
[
|
[
|
||||||
this._toolbox.resourceCommand.TYPES.DOCUMENT_EVENT,
|
this._toolbox.resourceWatcher.TYPES.DOCUMENT_EVENT,
|
||||||
this._toolbox.resourceCommand.TYPES.STYLESHEET,
|
this._toolbox.resourceWatcher.TYPES.STYLESHEET,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onAvailable: this._onResourceAvailable,
|
onAvailable: this._onResourceAvailable,
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ const STYLE_SHEET_UPDATE_CAUSED_BY_STYLE_EDITOR = "styleeditor";
|
|||||||
* 'error': An error has occured
|
* 'error': An error has occured
|
||||||
*
|
*
|
||||||
* @param {Resource} resource
|
* @param {Resource} resource
|
||||||
* The STYLESHEET resource which is received from resource command.
|
* The STYLESHEET resource which is received from resource watcher.
|
||||||
* @param {DOMWindow} win
|
* @param {DOMWindow} win
|
||||||
* panel window for style editor
|
* panel window for style editor
|
||||||
* @param {Walker} walker
|
* @param {Walker} walker
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ const {
|
|||||||
EDITOR_PRETTY_PRINT,
|
EDITOR_PRETTY_PRINT,
|
||||||
} = require("devtools/client/webconsole/constants");
|
} = require("devtools/client/webconsole/constants");
|
||||||
const { getAllPrefs } = require("devtools/client/webconsole/selectors/prefs");
|
const { getAllPrefs } = require("devtools/client/webconsole/selectors/prefs");
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
const l10n = require("devtools/client/webconsole/utils/l10n");
|
const l10n = require("devtools/client/webconsole/utils/l10n");
|
||||||
|
|
||||||
loader.lazyServiceGetter(
|
loader.lazyServiceGetter(
|
||||||
@@ -171,13 +173,13 @@ function handleHelperResult(response) {
|
|||||||
return async ({ dispatch, hud, toolbox, webConsoleUI }) => {
|
return async ({ dispatch, hud, toolbox, webConsoleUI }) => {
|
||||||
const { result, helperResult } = response;
|
const { result, helperResult } = response;
|
||||||
const helperHasRawOutput = !!helperResult?.rawOutput;
|
const helperHasRawOutput = !!helperResult?.rawOutput;
|
||||||
const hasNetworkResourceCommandSupport = hud.resourceCommand.hasResourceCommandSupport(
|
const hasNetworkResourceWatcherSupport = hud.resourceWatcher.hasResourceWatcherSupport(
|
||||||
hud.resourceCommand.TYPES.NETWORK_EVENT
|
hud.resourceWatcher.TYPES.NETWORK_EVENT
|
||||||
);
|
);
|
||||||
let networkFront = null;
|
let networkFront = null;
|
||||||
// @backward-compat { version 86 } default network events watcher support
|
// @backward-compat { version 86 } default network events watcher support
|
||||||
if (hasNetworkResourceCommandSupport) {
|
if (hasNetworkResourceWatcherSupport) {
|
||||||
networkFront = await hud.resourceCommand.watcherFront.getNetworkParentActor();
|
networkFront = await hud.resourceWatcher.watcherFront.getNetworkParentActor();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (helperResult?.type) {
|
if (helperResult?.type) {
|
||||||
@@ -237,7 +239,7 @@ function handleHelperResult(response) {
|
|||||||
level: message.level || "log",
|
level: message.level || "log",
|
||||||
arguments: [message.text],
|
arguments: [message.text],
|
||||||
},
|
},
|
||||||
resourceType: ResourceCommand.TYPES.CONSOLE_MESSAGE,
|
resourceType: ResourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -250,7 +252,7 @@ function handleHelperResult(response) {
|
|||||||
// Then, calling the Netmonitor action will only update the visual state of the Netmonitor,
|
// Then, calling the Netmonitor action will only update the visual state of the Netmonitor,
|
||||||
// but we also have to block the request via the NetworkParentActor.
|
// but we also have to block the request via the NetworkParentActor.
|
||||||
// @backward-compat { version 86 } default network events watcher support
|
// @backward-compat { version 86 } default network events watcher support
|
||||||
if (hasNetworkResourceCommandSupport && networkFront) {
|
if (hasNetworkResourceWatcherSupport && networkFront) {
|
||||||
await networkFront.blockRequest({ url: blockURL });
|
await networkFront.blockRequest({ url: blockURL });
|
||||||
}
|
}
|
||||||
toolbox
|
toolbox
|
||||||
@@ -262,7 +264,7 @@ function handleHelperResult(response) {
|
|||||||
dispatch(
|
dispatch(
|
||||||
messagesActions.messagesAdd([
|
messagesActions.messagesAdd([
|
||||||
{
|
{
|
||||||
resourceType: ResourceCommand.TYPES.PLATFORM_MESSAGE,
|
resourceType: ResourceWatcher.TYPES.PLATFORM_MESSAGE,
|
||||||
message: l10n.getFormatStr(
|
message: l10n.getFormatStr(
|
||||||
"webconsole.message.commands.blockedURL",
|
"webconsole.message.commands.blockedURL",
|
||||||
[blockURL]
|
[blockURL]
|
||||||
@@ -274,7 +276,7 @@ function handleHelperResult(response) {
|
|||||||
case "unblockURL":
|
case "unblockURL":
|
||||||
const unblockURL = helperResult.args.url;
|
const unblockURL = helperResult.args.url;
|
||||||
// @backward-compat { version 86 } see related comments in block url above
|
// @backward-compat { version 86 } see related comments in block url above
|
||||||
if (hasNetworkResourceCommandSupport && networkFront) {
|
if (hasNetworkResourceWatcherSupport && networkFront) {
|
||||||
await networkFront.unblockRequest({ url: unblockURL });
|
await networkFront.unblockRequest({ url: unblockURL });
|
||||||
}
|
}
|
||||||
toolbox
|
toolbox
|
||||||
@@ -286,7 +288,7 @@ function handleHelperResult(response) {
|
|||||||
dispatch(
|
dispatch(
|
||||||
messagesActions.messagesAdd([
|
messagesActions.messagesAdd([
|
||||||
{
|
{
|
||||||
resourceType: ResourceCommand.TYPES.PLATFORM_MESSAGE,
|
resourceType: ResourceWatcher.TYPES.PLATFORM_MESSAGE,
|
||||||
message: l10n.getFormatStr(
|
message: l10n.getFormatStr(
|
||||||
"webconsole.message.commands.unblockedURL",
|
"webconsole.message.commands.unblockedURL",
|
||||||
[unblockURL]
|
[unblockURL]
|
||||||
|
|||||||
@@ -6,6 +6,9 @@
|
|||||||
|
|
||||||
const Services = require("Services");
|
const Services = require("Services");
|
||||||
const WebConsole = require("devtools/client/webconsole/webconsole");
|
const WebConsole = require("devtools/client/webconsole/webconsole");
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
const { Utils } = require("devtools/client/webconsole/utils");
|
const { Utils } = require("devtools/client/webconsole/utils");
|
||||||
|
|
||||||
loader.lazyRequireGetter(this, "Telemetry", "devtools/client/shared/telemetry");
|
loader.lazyRequireGetter(this, "Telemetry", "devtools/client/shared/telemetry");
|
||||||
@@ -41,11 +44,17 @@ class BrowserConsole extends WebConsole {
|
|||||||
constructor(commands, iframeWindow, chromeWindow) {
|
constructor(commands, iframeWindow, chromeWindow) {
|
||||||
super(null, commands, iframeWindow, chromeWindow, true);
|
super(null, commands, iframeWindow, chromeWindow, true);
|
||||||
|
|
||||||
|
// Note that this.commands is being assigned from WebConsole's constructor
|
||||||
|
this._resourceWatcher = new ResourceWatcher(this.commands.targetCommand);
|
||||||
this._telemetry = new Telemetry();
|
this._telemetry = new Telemetry();
|
||||||
this._bcInitializer = null;
|
this._bcInitializer = null;
|
||||||
this._bcDestroyer = null;
|
this._bcDestroyer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get resourceWatcher() {
|
||||||
|
return this._resourceWatcher;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the Browser Console instance.
|
* Initialize the Browser Console instance.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
const {
|
const {
|
||||||
STUBS_UPDATE_ENV,
|
STUBS_UPDATE_ENV,
|
||||||
createCommandsForTab,
|
createCommandsForTab,
|
||||||
|
createResourceWatcherForCommands,
|
||||||
getStubFile,
|
getStubFile,
|
||||||
getCleanedPacket,
|
getCleanedPacket,
|
||||||
getSerializedPacket,
|
getSerializedPacket,
|
||||||
@@ -62,8 +63,7 @@ async function generateConsoleApiStubs() {
|
|||||||
|
|
||||||
const tab = await addTab(TEST_URI);
|
const tab = await addTab(TEST_URI);
|
||||||
const commands = await createCommandsForTab(tab);
|
const commands = await createCommandsForTab(tab);
|
||||||
await commands.targetCommand.startListening();
|
const resourceWatcher = await createResourceWatcherForCommands(commands);
|
||||||
const resourceCommand = commands.resourceCommand;
|
|
||||||
|
|
||||||
// The resource-watcher only supports a single call to watch/unwatch per
|
// The resource-watcher only supports a single call to watch/unwatch per
|
||||||
// instance, so we attach a unique watch callback, which will forward the
|
// instance, so we attach a unique watch callback, which will forward the
|
||||||
@@ -75,8 +75,8 @@ async function generateConsoleApiStubs() {
|
|||||||
handleConsoleMessage(resource);
|
handleConsoleMessage(resource);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: onConsoleMessage,
|
onAvailable: onConsoleMessage,
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ async function generateConsoleApiStubs() {
|
|||||||
await received;
|
await received;
|
||||||
}
|
}
|
||||||
|
|
||||||
resourceCommand.unwatchResources([resourceCommand.TYPES.CONSOLE_MESSAGE], {
|
resourceWatcher.unwatchResources([resourceWatcher.TYPES.CONSOLE_MESSAGE], {
|
||||||
onAvailable: onConsoleMessage,
|
onAvailable: onConsoleMessage,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
const {
|
const {
|
||||||
STUBS_UPDATE_ENV,
|
STUBS_UPDATE_ENV,
|
||||||
createCommandsForTab,
|
createCommandsForTab,
|
||||||
|
createResourceWatcherForCommands,
|
||||||
getCleanedPacket,
|
getCleanedPacket,
|
||||||
getStubFile,
|
getStubFile,
|
||||||
writeStubsToFile,
|
writeStubsToFile,
|
||||||
@@ -62,10 +63,9 @@ async function generateCssMessageStubs() {
|
|||||||
|
|
||||||
const tab = await addTab(TEST_URI);
|
const tab = await addTab(TEST_URI);
|
||||||
const commands = await createCommandsForTab(tab);
|
const commands = await createCommandsForTab(tab);
|
||||||
await commands.targetCommand.startListening();
|
const resourceWatcher = await createResourceWatcherForCommands(commands);
|
||||||
const resourceCommand = commands.resourceCommand;
|
|
||||||
|
|
||||||
// The resource command only supports a single call to watch/unwatch per
|
// The resource-watcher only supports a single call to watch/unwatch per
|
||||||
// instance, so we attach a unique watch callback, which will forward the
|
// instance, so we attach a unique watch callback, which will forward the
|
||||||
// resource to `handleErrorMessage`, dynamically updated for each command.
|
// resource to `handleErrorMessage`, dynamically updated for each command.
|
||||||
let handleCSSMessage = function() {};
|
let handleCSSMessage = function() {};
|
||||||
@@ -76,7 +76,7 @@ async function generateCssMessageStubs() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.CSS_MESSAGE], {
|
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_MESSAGE], {
|
||||||
onAvailable: onCSSMessageAvailable,
|
onAvailable: onCSSMessageAvailable,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ async function generateCssMessageStubs() {
|
|||||||
await received;
|
await received;
|
||||||
}
|
}
|
||||||
|
|
||||||
resourceCommand.unwatchResources([resourceCommand.TYPES.CSS_MESSAGE], {
|
resourceWatcher.unwatchResources([resourceWatcher.TYPES.CSS_MESSAGE], {
|
||||||
onAvailable: onCSSMessageAvailable,
|
onAvailable: onCSSMessageAvailable,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
createCommandsForTab,
|
createCommandsForTab,
|
||||||
|
createResourceWatcherForCommands,
|
||||||
STUBS_UPDATE_ENV,
|
STUBS_UPDATE_ENV,
|
||||||
getStubFile,
|
getStubFile,
|
||||||
getCleanedPacket,
|
getCleanedPacket,
|
||||||
@@ -58,16 +59,14 @@ async function generateNetworkEventStubs() {
|
|||||||
const stubs = new Map();
|
const stubs = new Map();
|
||||||
const tab = await addTab(TEST_URI);
|
const tab = await addTab(TEST_URI);
|
||||||
const commands = await createCommandsForTab(tab);
|
const commands = await createCommandsForTab(tab);
|
||||||
await commands.targetCommand.startListening();
|
const resourceWatcher = await createResourceWatcherForCommands(commands);
|
||||||
const resourceCommand = commands.resourceCommand;
|
|
||||||
|
|
||||||
const stacktraces = new Map();
|
const stacktraces = new Map();
|
||||||
let addNetworkStub = function() {};
|
let addNetworkStub = function() {};
|
||||||
let addNetworkUpdateStub = function() {};
|
let addNetworkUpdateStub = function() {};
|
||||||
|
|
||||||
const onAvailable = resources => {
|
const onAvailable = resources => {
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
if (resource.resourceType == resourceCommand.TYPES.NETWORK_EVENT) {
|
if (resource.resourceType == resourceWatcher.TYPES.NETWORK_EVENT) {
|
||||||
if (stacktraces.has(resource.channelId)) {
|
if (stacktraces.has(resource.channelId)) {
|
||||||
const { stacktraceAvailable, lastFrame } = stacktraces.get(
|
const { stacktraceAvailable, lastFrame } = stacktraces.get(
|
||||||
resource.channelId
|
resource.channelId
|
||||||
@@ -80,7 +79,7 @@ async function generateNetworkEventStubs() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
resource.resourceType == resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE
|
resource.resourceType == resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE
|
||||||
) {
|
) {
|
||||||
stacktraces.set(resource.channelId, resource);
|
stacktraces.set(resource.channelId, resource);
|
||||||
}
|
}
|
||||||
@@ -92,10 +91,10 @@ async function generateNetworkEventStubs() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[
|
[
|
||||||
resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||||
resourceCommand.TYPES.NETWORK_EVENT,
|
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onAvailable,
|
onAvailable,
|
||||||
@@ -138,10 +137,10 @@ async function generateNetworkEventStubs() {
|
|||||||
});
|
});
|
||||||
await Promise.all([networkEventDone, networkEventUpdateDone]);
|
await Promise.all([networkEventDone, networkEventUpdateDone]);
|
||||||
}
|
}
|
||||||
resourceCommand.unwatchResources(
|
resourceWatcher.unwatchResources(
|
||||||
[
|
[
|
||||||
resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||||
resourceCommand.TYPES.NETWORK_EVENT,
|
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onAvailable,
|
onAvailable,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
const {
|
const {
|
||||||
STUBS_UPDATE_ENV,
|
STUBS_UPDATE_ENV,
|
||||||
createCommandsForTab,
|
createCommandsForTab,
|
||||||
|
createResourceWatcherForCommands,
|
||||||
getCleanedPacket,
|
getCleanedPacket,
|
||||||
getSerializedPacket,
|
getSerializedPacket,
|
||||||
getStubFile,
|
getStubFile,
|
||||||
@@ -64,8 +65,7 @@ async function generatePageErrorStubs() {
|
|||||||
|
|
||||||
const tab = await addTab(TEST_URI);
|
const tab = await addTab(TEST_URI);
|
||||||
const commands = await createCommandsForTab(tab);
|
const commands = await createCommandsForTab(tab);
|
||||||
await commands.targetCommand.startListening();
|
const resourceWatcher = await createResourceWatcherForCommands(commands);
|
||||||
const resourceCommand = commands.resourceCommand;
|
|
||||||
|
|
||||||
// The resource-watcher only supports a single call to watch/unwatch per
|
// The resource-watcher only supports a single call to watch/unwatch per
|
||||||
// instance, so we attach a unique watch callback, which will forward the
|
// instance, so we attach a unique watch callback, which will forward the
|
||||||
@@ -77,7 +77,7 @@ async function generatePageErrorStubs() {
|
|||||||
handleErrorMessage(resource);
|
handleErrorMessage(resource);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.ERROR_MESSAGE], {
|
await resourceWatcher.watchResources([resourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||||
onAvailable: onErrorMessageAvailable,
|
onAvailable: onErrorMessageAvailable,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
const {
|
const {
|
||||||
STUBS_UPDATE_ENV,
|
STUBS_UPDATE_ENV,
|
||||||
createCommandsForMainProcess,
|
createCommandsForMainProcess,
|
||||||
|
createResourceWatcherForCommands,
|
||||||
getCleanedPacket,
|
getCleanedPacket,
|
||||||
getSerializedPacket,
|
getSerializedPacket,
|
||||||
getStubFile,
|
getStubFile,
|
||||||
@@ -60,8 +61,7 @@ async function generatePlatformMessagesStubs() {
|
|||||||
const stubs = new Map();
|
const stubs = new Map();
|
||||||
|
|
||||||
const commands = await createCommandsForMainProcess();
|
const commands = await createCommandsForMainProcess();
|
||||||
await commands.targetCommand.startListening();
|
const resourceWatcher = await createResourceWatcherForCommands(commands);
|
||||||
const resourceCommand = commands.resourceCommand;
|
|
||||||
|
|
||||||
// The resource-watcher only supports a single call to watch/unwatch per
|
// The resource-watcher only supports a single call to watch/unwatch per
|
||||||
// instance, so we attach a unique watch callback, which will forward the
|
// instance, so we attach a unique watch callback, which will forward the
|
||||||
@@ -73,8 +73,8 @@ async function generatePlatformMessagesStubs() {
|
|||||||
handlePlatformMessage(resource);
|
handlePlatformMessage(resource);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.PLATFORM_MESSAGE],
|
[resourceWatcher.TYPES.PLATFORM_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: onPlatformMessageAvailable,
|
onAvailable: onPlatformMessageAvailable,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,16 @@ async function createCommandsForMainProcess() {
|
|||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function createResourceWatcherForCommands(commands) {
|
||||||
|
// Avoid mocha to try to load these module and fail while doing it when running node tests
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
|
await commands.targetCommand.startListening();
|
||||||
|
return new ResourceWatcher(commands.targetCommand);
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line complexity
|
// eslint-disable-next-line complexity
|
||||||
function getCleanedPacket(key, packet) {
|
function getCleanedPacket(key, packet) {
|
||||||
const { stubPackets } = require(CHROME_PREFIX + STUBS_FOLDER + "index");
|
const { stubPackets } = require(CHROME_PREFIX + STUBS_FOLDER + "index");
|
||||||
@@ -536,6 +546,7 @@ module.exports = {
|
|||||||
STUBS_UPDATE_ENV,
|
STUBS_UPDATE_ENV,
|
||||||
createCommandsForTab,
|
createCommandsForTab,
|
||||||
createCommandsForMainProcess,
|
createCommandsForMainProcess,
|
||||||
|
createResourceWatcherForCommands,
|
||||||
getStubFile,
|
getStubFile,
|
||||||
getCleanedPacket,
|
getCleanedPacket,
|
||||||
getSerializedPacket,
|
getSerializedPacket,
|
||||||
|
|||||||
@@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
const Services = require("Services");
|
const Services = require("Services");
|
||||||
const l10n = require("devtools/client/webconsole/utils/l10n");
|
const l10n = require("devtools/client/webconsole/utils/l10n");
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
// URL Regex, common idioms:
|
// URL Regex, common idioms:
|
||||||
//
|
//
|
||||||
@@ -94,23 +96,23 @@ function prepareMessage(resource, idGenerator) {
|
|||||||
*/
|
*/
|
||||||
function transformResource(resource) {
|
function transformResource(resource) {
|
||||||
switch (resource.resourceType || resource.type) {
|
switch (resource.resourceType || resource.type) {
|
||||||
case ResourceCommand.TYPES.CONSOLE_MESSAGE: {
|
case ResourceWatcher.TYPES.CONSOLE_MESSAGE: {
|
||||||
return transformConsoleAPICallResource(resource);
|
return transformConsoleAPICallResource(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
case ResourceCommand.TYPES.PLATFORM_MESSAGE: {
|
case ResourceWatcher.TYPES.PLATFORM_MESSAGE: {
|
||||||
return transformPlatformMessageResource(resource);
|
return transformPlatformMessageResource(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
case ResourceCommand.TYPES.ERROR_MESSAGE: {
|
case ResourceWatcher.TYPES.ERROR_MESSAGE: {
|
||||||
return transformPageErrorResource(resource);
|
return transformPageErrorResource(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
case ResourceCommand.TYPES.CSS_MESSAGE: {
|
case ResourceWatcher.TYPES.CSS_MESSAGE: {
|
||||||
return transformCSSMessageResource(resource);
|
return transformCSSMessageResource(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
case ResourceCommand.TYPES.NETWORK_EVENT: {
|
case ResourceWatcher.TYPES.NETWORK_EVENT: {
|
||||||
return transformNetworkEventResource(resource);
|
return transformNetworkEventResource(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -202,21 +202,21 @@ class WebConsoleUI {
|
|||||||
this._onTargetDestroy
|
this._onTargetDestroy
|
||||||
);
|
);
|
||||||
|
|
||||||
const resourceCommand = this.hud.resourceCommand;
|
const resourceWatcher = this.hud.resourceWatcher;
|
||||||
resourceCommand.unwatchResources(
|
resourceWatcher.unwatchResources(
|
||||||
[
|
[
|
||||||
resourceCommand.TYPES.CONSOLE_MESSAGE,
|
resourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||||
resourceCommand.TYPES.ERROR_MESSAGE,
|
resourceWatcher.TYPES.ERROR_MESSAGE,
|
||||||
resourceCommand.TYPES.PLATFORM_MESSAGE,
|
resourceWatcher.TYPES.PLATFORM_MESSAGE,
|
||||||
resourceCommand.TYPES.NETWORK_EVENT,
|
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onAvailable: this._onResourceAvailable,
|
onAvailable: this._onResourceAvailable,
|
||||||
onUpdated: this._onResourceUpdated,
|
onUpdated: this._onResourceUpdated,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
resourceCommand.unwatchResources([resourceCommand.TYPES.CSS_MESSAGE], {
|
resourceWatcher.unwatchResources([resourceWatcher.TYPES.CSS_MESSAGE], {
|
||||||
onAvailable: this._onResourceAvailable,
|
onAvailable: this._onResourceAvailable,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -339,7 +339,7 @@ class WebConsoleUI {
|
|||||||
// We can call it from here, as `_attchTargets` is called after the UI is initialized.
|
// We can call it from here, as `_attchTargets` is called after the UI is initialized.
|
||||||
// Bug 1642599:
|
// Bug 1642599:
|
||||||
// TargetCommand.startListening ought to be called before watching for resources,
|
// TargetCommand.startListening ought to be called before watching for resources,
|
||||||
// in order to set TargetCommand.watcherFront which is used by ResourceCommand.watchResources.
|
// in order to set TargetCommand.watcherFront which is used by ResourceWatcher.watchResources.
|
||||||
await this.hud.commands.targetCommand.startListening();
|
await this.hud.commands.targetCommand.startListening();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,15 +355,15 @@ class WebConsoleUI {
|
|||||||
this._onTargetDestroy
|
this._onTargetDestroy
|
||||||
);
|
);
|
||||||
|
|
||||||
const resourceCommand = this.hud.resourceCommand;
|
const resourceWatcher = this.hud.resourceWatcher;
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[
|
[
|
||||||
resourceCommand.TYPES.CONSOLE_MESSAGE,
|
resourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||||
resourceCommand.TYPES.ERROR_MESSAGE,
|
resourceWatcher.TYPES.ERROR_MESSAGE,
|
||||||
resourceCommand.TYPES.PLATFORM_MESSAGE,
|
resourceWatcher.TYPES.PLATFORM_MESSAGE,
|
||||||
resourceCommand.TYPES.NETWORK_EVENT,
|
resourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||||
resourceCommand.TYPES.CLONED_CONTENT_PROCESS_MESSAGE,
|
resourceWatcher.TYPES.CLONED_CONTENT_PROCESS_MESSAGE,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onAvailable: this._onResourceAvailable,
|
onAvailable: this._onResourceAvailable,
|
||||||
@@ -373,8 +373,8 @@ class WebConsoleUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async watchCssMessages() {
|
async watchCssMessages() {
|
||||||
const { resourceCommand } = this.hud;
|
const { resourceWatcher } = this.hud;
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.CSS_MESSAGE], {
|
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_MESSAGE], {
|
||||||
onAvailable: this._onResourceAvailable,
|
onAvailable: this._onResourceAvailable,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -385,7 +385,7 @@ class WebConsoleUI {
|
|||||||
}
|
}
|
||||||
const messages = [];
|
const messages = [];
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
const { TYPES } = this.hud.resourceCommand;
|
const { TYPES } = this.hud.resourceWatcher;
|
||||||
// Ignore messages forwarded from content processes if we're in fission browser toolbox.
|
// Ignore messages forwarded from content processes if we're in fission browser toolbox.
|
||||||
if (
|
if (
|
||||||
!this.wrapper ||
|
!this.wrapper ||
|
||||||
@@ -426,7 +426,7 @@ class WebConsoleUI {
|
|||||||
const messageUpdates = updates
|
const messageUpdates = updates
|
||||||
.filter(
|
.filter(
|
||||||
({ resource }) =>
|
({ resource }) =>
|
||||||
resource.resourceType == this.hud.resourceCommand.TYPES.NETWORK_EVENT
|
resource.resourceType == this.hud.resourceWatcher.TYPES.NETWORK_EVENT
|
||||||
)
|
)
|
||||||
.map(({ resource }) => {
|
.map(({ resource }) => {
|
||||||
this.wrapper.networkDataProvider?.onNetworkResourceUpdated(resource);
|
this.wrapper.networkDataProvider?.onNetworkResourceUpdated(resource);
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class WebConsoleWrapper {
|
|||||||
updateRequest: (id, data) => this.batchedRequestUpdates({ id, data }),
|
updateRequest: (id, data) => this.batchedRequestUpdates({ id, data }),
|
||||||
},
|
},
|
||||||
webConsoleFront,
|
webConsoleFront,
|
||||||
resourceCommand: this.hud.resourceCommand,
|
resourceWatcher: this.hud.resourceWatcher,
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ class WebConsole {
|
|||||||
return this.commands.targetCommand.targetFront;
|
return this.commands.targetCommand.targetFront;
|
||||||
}
|
}
|
||||||
|
|
||||||
get resourceCommand() {
|
get resourceWatcher() {
|
||||||
return this.commands.resourceCommand;
|
return this.toolbox.resourceWatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ const NetworkEventActor = protocol.ActorClassWithSpec(networkEventSpec, {
|
|||||||
* Returns a grip for this actor.
|
* Returns a grip for this actor.
|
||||||
*/
|
*/
|
||||||
asResource() {
|
asResource() {
|
||||||
// The browsingContextID is used by the ResourceCommand on the client
|
// The browsingContextID is used by the ResourceWatcher on the client
|
||||||
// to find the related Target Front.
|
// to find the related Target Front.
|
||||||
const browsingContextID = this._browsingContextID
|
const browsingContextID = this._browsingContextID
|
||||||
? this._browsingContextID
|
? this._browsingContextID
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class ContentProcessStorage {
|
|||||||
await this.actor.preListStores();
|
await this.actor.preListStores();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have to manage the actor manually, because ResourceCommand doesn't
|
// We have to manage the actor manually, because ResourceWatcher doesn't
|
||||||
// use the protocol.js specification.
|
// use the protocol.js specification.
|
||||||
// resource-available-form is typed as "json"
|
// resource-available-form is typed as "json"
|
||||||
// So that we have to manually handle stuff that would normally be
|
// So that we have to manually handle stuff that would normally be
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class ParentProcessStorage {
|
|||||||
await this.actor.preListStores();
|
await this.actor.preListStores();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have to manage the actor manually, because ResourceCommand doesn't
|
// We have to manage the actor manually, because ResourceWatcher doesn't
|
||||||
// use the protocol.js specification.
|
// use the protocol.js specification.
|
||||||
// resource-available-form is typed as "json"
|
// resource-available-form is typed as "json"
|
||||||
// So that we have to manually handle stuff that would normally be
|
// So that we have to manually handle stuff that would normally be
|
||||||
@@ -67,7 +67,7 @@ class ParentProcessStorage {
|
|||||||
storage.resourceType = this.storageType;
|
storage.resourceType = this.storageType;
|
||||||
storage.resourceId = `${this.storageType}-${browsingContext.id}`;
|
storage.resourceId = `${this.storageType}-${browsingContext.id}`;
|
||||||
storage.resourceKey = this.storageKey;
|
storage.resourceKey = this.storageKey;
|
||||||
// NOTE: the resource command needs this attribute
|
// NOTE: the resource watcher needs this attribute
|
||||||
storage.browsingContextID = browsingContext.id;
|
storage.browsingContextID = browsingContext.id;
|
||||||
|
|
||||||
onAvailable([storage]);
|
onAvailable([storage]);
|
||||||
|
|||||||
@@ -3437,7 +3437,7 @@ function trimHttpHttpsPort(url) {
|
|||||||
*
|
*
|
||||||
* This class is meant to be dropped once we implement all storage
|
* This class is meant to be dropped once we implement all storage
|
||||||
* types via a Watcher class. (bug 1644192)
|
* types via a Watcher class. (bug 1644192)
|
||||||
* listStores will have been replaced by the ResourceCommand API
|
* listStores will have been replaced by the ResourceWatcher API
|
||||||
* which will distribute all storage type specific actors.
|
* which will distribute all storage type specific actors.
|
||||||
*/
|
*/
|
||||||
const StorageActor = protocol.ActorClassWithSpec(specs.storageSpec, {
|
const StorageActor = protocol.ActorClassWithSpec(specs.storageSpec, {
|
||||||
|
|||||||
@@ -14,20 +14,22 @@ add_task(async function() {
|
|||||||
const browser = await addTab(TEST_URI);
|
const browser = await addTab(TEST_URI);
|
||||||
const tab = gBrowser.getTabForBrowser(browser);
|
const tab = gBrowser.getTabForBrowser(browser);
|
||||||
|
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const commands = await CommandsFactory.forTab(tab);
|
const commands = await CommandsFactory.forTab(tab);
|
||||||
await commands.targetCommand.startListening();
|
await commands.targetCommand.startListening();
|
||||||
const target = commands.targetCommand.targetFront;
|
const target = commands.targetCommand.targetFront;
|
||||||
|
const resourceWatcher = new ResourceWatcher(commands.targetCommand);
|
||||||
|
|
||||||
const styleSheetsFront = await target.getFront("stylesheets");
|
const styleSheetsFront = await target.getFront("stylesheets");
|
||||||
ok(styleSheetsFront, "The StyleSheetsFront was created.");
|
ok(styleSheetsFront, "The StyleSheetsFront was created.");
|
||||||
|
|
||||||
const sheets = [];
|
const sheets = [];
|
||||||
await commands.resourceCommand.watchResources(
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.STYLESHEET], {
|
||||||
[commands.resourceCommand.TYPES.STYLESHEET],
|
onAvailable: resources => sheets.push(...resources),
|
||||||
{
|
});
|
||||||
onAvailable: resources => sheets.push(...resources),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
is(sheets.length, 1, "watchResources returned the correct number of sheets");
|
is(sheets.length, 1, "watchResources returned the correct number of sheets");
|
||||||
|
|
||||||
const { resourceId } = sheets[0];
|
const { resourceId } = sheets[0];
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
/* exported attachURL, promiseDone,
|
/* exported attachURL, promiseDone,
|
||||||
promiseOnce,
|
promiseOnce,
|
||||||
addTest, addAsyncTest,
|
addTest, addAsyncTest,
|
||||||
runNextTest, _documentWalker */
|
runNextTest, _documentWalker,
|
||||||
|
createResourceWatcher */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
|
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
|
||||||
@@ -16,6 +17,10 @@ const {
|
|||||||
DocumentWalker: _documentWalker,
|
DocumentWalker: _documentWalker,
|
||||||
} = require("devtools/server/actors/inspector/document-walker");
|
} = require("devtools/server/actors/inspector/document-walker");
|
||||||
|
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const Services = require("Services");
|
const Services = require("Services");
|
||||||
|
|
||||||
// Always log packets when running tests.
|
// Always log packets when running tests.
|
||||||
@@ -129,3 +134,7 @@ function runNextTest() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function createResourceWatcher(commands) {
|
||||||
|
return new ResourceWatcher(commands.targetCommand);
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ window.onload = function() {
|
|||||||
|
|
||||||
let gWalker = null;
|
let gWalker = null;
|
||||||
let gDoc = null;
|
let gDoc = null;
|
||||||
let gResourceCommand = null;
|
let gResourceWatcher = null;
|
||||||
let gRootNodeResolve = null;
|
let gRootNodeResolve = null;
|
||||||
|
|
||||||
async function reloadTarget() {
|
async function reloadTarget() {
|
||||||
@@ -36,12 +36,12 @@ addAsyncTest(async function() {
|
|||||||
gDoc = doc;
|
gDoc = doc;
|
||||||
const inspector = await target.getFront("inspector");
|
const inspector = await target.getFront("inspector");
|
||||||
gWalker = inspector.walker;
|
gWalker = inspector.walker;
|
||||||
gResourceCommand = commands.resourceCommand;
|
gResourceWatcher = await createResourceWatcher(commands);
|
||||||
|
|
||||||
info("Start watching for root nodes and wait for the initial root node");
|
info("Start watching for root nodes and wait for the initial root node");
|
||||||
const rootNodePromise = new Promise(r => (gRootNodeResolve = r));
|
const rootNodePromise = new Promise(r => (gRootNodeResolve = r));
|
||||||
const onAvailable = rootNodeFront => gRootNodeResolve(rootNodeFront);
|
const onAvailable = rootNodeFront => gRootNodeResolve(rootNodeFront);
|
||||||
await gResourceCommand.watchResources([gResourceCommand.TYPES.ROOT_NODE], {
|
await gResourceWatcher.watchResources([gResourceWatcher.TYPES.ROOT_NODE], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
await rootNodePromise;
|
await rootNodePromise;
|
||||||
@@ -315,7 +315,7 @@ addAsyncTest(async function() {
|
|||||||
addTest(function cleanup() {
|
addTest(function cleanup() {
|
||||||
gWalker = null;
|
gWalker = null;
|
||||||
gDoc = null;
|
gDoc = null;
|
||||||
gResourceCommand = null;
|
gResourceWatcher = null;
|
||||||
runNextTest();
|
runNextTest();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ window.onload = function() {
|
|||||||
|
|
||||||
let gInspectee = null;
|
let gInspectee = null;
|
||||||
let gWalker = null;
|
let gWalker = null;
|
||||||
let gResourceCommand = null;
|
let gResourceWatcher = null;
|
||||||
|
|
||||||
addTest(async function setup() {
|
addTest(async function setup() {
|
||||||
const url = document.getElementById("inspectorContent").href;
|
const url = document.getElementById("inspectorContent").href;
|
||||||
@@ -30,7 +30,7 @@ addTest(async function setup() {
|
|||||||
gInspectee = doc;
|
gInspectee = doc;
|
||||||
const walker = inspector.walker;
|
const walker = inspector.walker;
|
||||||
gWalker = await inspector.getWalker();
|
gWalker = await inspector.getWalker();
|
||||||
gResourceCommand = commands.resourceCommand;
|
gResourceWatcher = await createResourceWatcher(commands);
|
||||||
|
|
||||||
ok(walker === gWalker, "getWalker() twice should return the same walker.");
|
ok(walker === gWalker, "getWalker() twice should return the same walker.");
|
||||||
runNextTest();
|
runNextTest();
|
||||||
@@ -43,7 +43,7 @@ addTest(async function testReload() {
|
|||||||
let rootNodeResolve;
|
let rootNodeResolve;
|
||||||
let rootNodePromise = new Promise(r => (rootNodeResolve = r));
|
let rootNodePromise = new Promise(r => (rootNodeResolve = r));
|
||||||
const onAvailable = rootNodeFront => rootNodeResolve(rootNodeFront);
|
const onAvailable = rootNodeFront => rootNodeResolve(rootNodeFront);
|
||||||
await gResourceCommand.watchResources([gResourceCommand.TYPES.ROOT_NODE], {
|
await gResourceWatcher.watchResources([gResourceWatcher.TYPES.ROOT_NODE], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
await rootNodePromise;
|
await rootNodePromise;
|
||||||
@@ -69,7 +69,7 @@ addTest(async function testReload() {
|
|||||||
addTest(function cleanup() {
|
addTest(function cleanup() {
|
||||||
gWalker = null;
|
gWalker = null;
|
||||||
gInspectee = null;
|
gInspectee = null;
|
||||||
gResourceCommand = null;
|
gResourceWatcher = null;
|
||||||
runNextTest();
|
runNextTest();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ addTest(async function setup() {
|
|||||||
const url = document.getElementById("inspectorContent").href;
|
const url = document.getElementById("inspectorContent").href;
|
||||||
const { commands, target } = await attachURL(url);
|
const { commands, target } = await attachURL(url);
|
||||||
|
|
||||||
// We need an active resource command before initializing the inspector front.
|
// We need an active resource watcher before initializing the inspector front.
|
||||||
const resourceCommand = commands.resourceCommand;
|
const resourceWatcher = await createResourceWatcher(commands);
|
||||||
// We don't listen for specific resources, we only need to trigger the resource command
|
// We don't listen for specific resources, we only need to trigger the resource watcher
|
||||||
// onTargetAvailable callback so the resourceCommand is set on the target front.
|
// onTargetAvailable callback so the resourceWatcher is set on the target front.
|
||||||
await resourceCommand.watchResources([], { onAvailable: () => {} });
|
await resourceWatcher.watchResources([], { onAvailable: () => {} });
|
||||||
|
|
||||||
const inspector = await target.getFront("inspector");
|
const inspector = await target.getFront("inspector");
|
||||||
gWalker = inspector.walker;
|
gWalker = inspector.walker;
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ addTest(async function setup() {
|
|||||||
const { commands, target, doc } = await attachURL(url);
|
const { commands, target, doc } = await attachURL(url);
|
||||||
gInspectee = doc;
|
gInspectee = doc;
|
||||||
|
|
||||||
// We need an active resource command before initializing the inspector front.
|
// We need an active resource watcher before initializing the inspector front.
|
||||||
const resourceCommand = commands.resourceCommand;
|
const resourceWatcher = await createResourceWatcher(commands);
|
||||||
// We don't listen for specific resources, we only need to trigger the resource command
|
// We don't listen for specific resources, we only need to trigger the resource watcher
|
||||||
// onTargetAvailable callback so the resourceCommand is set on the target front.
|
// onTargetAvailable callback so the resourceWatcher is set on the target front.
|
||||||
await resourceCommand.watchResources([], { onAvailable: () => {} });
|
await resourceWatcher.watchResources([], { onAvailable: () => {} });
|
||||||
|
|
||||||
const inspector = await target.getFront("inspector");
|
const inspector = await target.getFront("inspector");
|
||||||
gWalker = inspector.walker;
|
gWalker = inspector.walker;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ add_task(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// And then listen for resource RDP event.
|
// And then listen for resource RDP event.
|
||||||
// Bug 1646677: But we should probably migrate this test to ResourceCommand so that
|
// Bug 1646677: But we should probably migrate this test to ResourceWatcher so that
|
||||||
// we don't have to hack the server side via Resource.watchResources call.
|
// we don't have to hack the server side via Resource.watchResources call.
|
||||||
targetActor.on("resource-available-form", resources => {
|
targetActor.on("resource-available-form", resources => {
|
||||||
if (resources[0].resourceType == Resources.TYPES.CONSOLE_MESSAGE) {
|
if (resources[0].resourceType == Resources.TYPES.CONSOLE_MESSAGE) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ add_task(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// And then listen for resource RDP event.
|
// And then listen for resource RDP event.
|
||||||
// Bug 1646677: But we should probably migrate this test to ResourceCommand so that
|
// Bug 1646677: But we should probably migrate this test to ResourceWatcher so that
|
||||||
// we don't have to hack the server side via Resource.watchResources call.
|
// we don't have to hack the server side via Resource.watchResources call.
|
||||||
targetActor.on("resource-available-form", resources => {
|
targetActor.on("resource-available-form", resources => {
|
||||||
if (resources[0].resourceType == Resources.TYPES.CONSOLE_MESSAGE) {
|
if (resources[0].resourceType == Resources.TYPES.CONSOLE_MESSAGE) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ add_task(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// And then listen for resource RDP event.
|
// And then listen for resource RDP event.
|
||||||
// Bug 1646677: But we should probably migrate this test to ResourceCommand so that
|
// Bug 1646677: But we should probably migrate this test to ResourceWatcher so that
|
||||||
// we don't have to hack the server side via Resource.watchResources call.
|
// we don't have to hack the server side via Resource.watchResources call.
|
||||||
targetActor.on("resource-available-form", resources => {
|
targetActor.on("resource-available-form", resources => {
|
||||||
if (resources[0].resourceType == Resources.TYPES.CONSOLE_MESSAGE) {
|
if (resources[0].resourceType == Resources.TYPES.CONSOLE_MESSAGE) {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ const Commands = {
|
|||||||
inspectedWindowCommand:
|
inspectedWindowCommand:
|
||||||
"devtools/shared/commands/inspected-window/inspected-window-command",
|
"devtools/shared/commands/inspected-window/inspected-window-command",
|
||||||
inspectorCommand: "devtools/shared/commands/inspector/inspector-command",
|
inspectorCommand: "devtools/shared/commands/inspector/inspector-command",
|
||||||
resourceCommand: "devtools/shared/commands/resource/resource-command",
|
|
||||||
targetCommand: "devtools/shared/commands/target/target-command",
|
targetCommand: "devtools/shared/commands/target/target-command",
|
||||||
targetConfigurationCommand:
|
targetConfigurationCommand:
|
||||||
"devtools/shared/commands/target-configuration/target-configuration-command",
|
"devtools/shared/commands/target-configuration/target-configuration-command",
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
DIRS += [
|
DIRS += [
|
||||||
"inspected-window",
|
"inspected-window",
|
||||||
"inspector",
|
"inspector",
|
||||||
"resource",
|
|
||||||
"target",
|
"target",
|
||||||
"target-configuration",
|
"target-configuration",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ class TargetCommand extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cache the Watcher once for all, the first time we call `startListening()`.
|
// Cache the Watcher once for all, the first time we call `startListening()`.
|
||||||
// This `watcherFront` attribute may be then used in any function in TargetCommand or ResourceCommand after this.
|
// This `watcherFront` attribute may be then used in any function in TargetCommand or ResourceWatcher after this.
|
||||||
if (!this.watcherFront) {
|
if (!this.watcherFront) {
|
||||||
// Bug 1675763: Watcher actor is not available in all situations yet.
|
// Bug 1675763: Watcher actor is not available in all situations yet.
|
||||||
const supportsWatcher = this.descriptorFront.traits?.watcher;
|
const supportsWatcher = this.descriptorFront.traits?.watcher;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ DIRS += [
|
|||||||
"platform",
|
"platform",
|
||||||
"protocol",
|
"protocol",
|
||||||
"qrcode",
|
"qrcode",
|
||||||
|
"resources",
|
||||||
"security",
|
"security",
|
||||||
"sprintfjs",
|
"sprintfjs",
|
||||||
"specs",
|
"specs",
|
||||||
|
|||||||
@@ -4,13 +4,15 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
makeStorageLegacyListener,
|
makeStorageLegacyListener,
|
||||||
} = require("devtools/shared/commands/resource/legacy-listeners/storage-utils");
|
} = require("devtools/shared/resources/legacy-listeners/storage-utils");
|
||||||
|
|
||||||
module.exports = makeStorageLegacyListener(
|
module.exports = makeStorageLegacyListener(
|
||||||
"Cache",
|
"Cache",
|
||||||
ResourceCommand.TYPES.CACHE_STORAGE
|
ResourceWatcher.TYPES.CACHE_STORAGE
|
||||||
);
|
);
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const Services = require("Services");
|
const Services = require("Services");
|
||||||
|
|
||||||
@@ -43,7 +45,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
|||||||
if (!packet.clonedFromContentProcess) {
|
if (!packet.clonedFromContentProcess) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
packet.resourceType = ResourceCommand.TYPES.CONSOLE_MESSAGE;
|
packet.resourceType = ResourceWatcher.TYPES.CONSOLE_MESSAGE;
|
||||||
onAvailable([packet]);
|
onAvailable([packet]);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
||||||
// Allow the top level target unconditionnally.
|
// Allow the top level target unconditionnally.
|
||||||
@@ -40,7 +42,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
|||||||
const { messages } = await webConsoleFront.getCachedMessages(["ConsoleAPI"]);
|
const { messages } = await webConsoleFront.getCachedMessages(["ConsoleAPI"]);
|
||||||
|
|
||||||
for (const message of messages) {
|
for (const message of messages) {
|
||||||
message.resourceType = ResourceCommand.TYPES.CONSOLE_MESSAGE;
|
message.resourceType = ResourceWatcher.TYPES.CONSOLE_MESSAGE;
|
||||||
}
|
}
|
||||||
onAvailable(messages);
|
onAvailable(messages);
|
||||||
|
|
||||||
@@ -52,7 +54,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
message.resourceType = ResourceCommand.TYPES.CONSOLE_MESSAGE;
|
message.resourceType = ResourceWatcher.TYPES.CONSOLE_MESSAGE;
|
||||||
onAvailable([message]);
|
onAvailable([message]);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -4,13 +4,15 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
makeStorageLegacyListener,
|
makeStorageLegacyListener,
|
||||||
} = require("devtools/shared/commands/resource/legacy-listeners/storage-utils");
|
} = require("devtools/shared/resources/legacy-listeners/storage-utils");
|
||||||
|
|
||||||
module.exports = makeStorageLegacyListener(
|
module.exports = makeStorageLegacyListener(
|
||||||
"cookies",
|
"cookies",
|
||||||
ResourceCommand.TYPES.COOKIE
|
ResourceWatcher.TYPES.COOKIE
|
||||||
);
|
);
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
module.exports = async function({ targetFront, onAvailable }) {
|
module.exports = async function({ targetFront, onAvailable }) {
|
||||||
if (!targetFront.hasActor("changes")) {
|
if (!targetFront.hasActor("changes")) {
|
||||||
@@ -23,6 +25,6 @@ module.exports = async function({ targetFront, onAvailable }) {
|
|||||||
|
|
||||||
function toResource(change) {
|
function toResource(change) {
|
||||||
return Object.assign(change, {
|
return Object.assign(change, {
|
||||||
resourceType: ResourceCommand.TYPES.CSS_CHANGE,
|
resourceType: ResourceWatcher.TYPES.CSS_CHANGE,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
const { MESSAGE_CATEGORY } = require("devtools/shared/constants");
|
const { MESSAGE_CATEGORY } = require("devtools/shared/constants");
|
||||||
|
|
||||||
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
||||||
@@ -37,7 +39,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
message.resourceType = ResourceCommand.TYPES.CSS_MESSAGE;
|
message.resourceType = ResourceWatcher.TYPES.CSS_MESSAGE;
|
||||||
message.cssSelectors = message.pageError.cssSelectors;
|
message.cssSelectors = message.pageError.cssSelectors;
|
||||||
delete message.pageError.cssSelectors;
|
delete message.pageError.cssSelectors;
|
||||||
cachedMessages.push(message);
|
cachedMessages.push(message);
|
||||||
@@ -52,7 +54,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
message.resourceType = ResourceCommand.TYPES.CSS_MESSAGE;
|
message.resourceType = ResourceWatcher.TYPES.CSS_MESSAGE;
|
||||||
message.cssSelectors = message.pageError.cssSelectors;
|
message.cssSelectors = message.pageError.cssSelectors;
|
||||||
delete message.pageError.cssSelectors;
|
delete message.pageError.cssSelectors;
|
||||||
onAvailable([message]);
|
onAvailable([message]);
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
const { MESSAGE_CATEGORY } = require("devtools/shared/constants");
|
const { MESSAGE_CATEGORY } = require("devtools/shared/constants");
|
||||||
|
|
||||||
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
||||||
@@ -44,7 +46,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
messages.forEach(message => {
|
messages.forEach(message => {
|
||||||
message.resourceType = ResourceCommand.TYPES.ERROR_MESSAGE;
|
message.resourceType = ResourceWatcher.TYPES.ERROR_MESSAGE;
|
||||||
});
|
});
|
||||||
// Cached messages don't have the same shape as live messages,
|
// Cached messages don't have the same shape as live messages,
|
||||||
// so we need to transform them.
|
// so we need to transform them.
|
||||||
@@ -56,7 +58,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
message.resourceType = ResourceCommand.TYPES.ERROR_MESSAGE;
|
message.resourceType = ResourceWatcher.TYPES.ERROR_MESSAGE;
|
||||||
onAvailable([message]);
|
onAvailable([message]);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -4,13 +4,15 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
makeStorageLegacyListener,
|
makeStorageLegacyListener,
|
||||||
} = require("devtools/shared/commands/resource/legacy-listeners/storage-utils");
|
} = require("devtools/shared/resources/legacy-listeners/storage-utils");
|
||||||
|
|
||||||
module.exports = makeStorageLegacyListener(
|
module.exports = makeStorageLegacyListener(
|
||||||
"extensionStorage",
|
"extensionStorage",
|
||||||
ResourceCommand.TYPES.EXTENSION_STORAGE
|
ResourceWatcher.TYPES.EXTENSION_STORAGE
|
||||||
);
|
);
|
||||||
@@ -4,13 +4,16 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
// getFilteredStorageEvents,
|
||||||
makeStorageLegacyListener,
|
makeStorageLegacyListener,
|
||||||
} = require("devtools/shared/commands/resource/legacy-listeners/storage-utils");
|
} = require("devtools/shared/resources/legacy-listeners/storage-utils");
|
||||||
|
|
||||||
module.exports = makeStorageLegacyListener(
|
module.exports = makeStorageLegacyListener(
|
||||||
"indexedDB",
|
"indexedDB",
|
||||||
ResourceCommand.TYPES.INDEXED_DB
|
ResourceWatcher.TYPES.INDEXED_DB
|
||||||
);
|
);
|
||||||
@@ -4,13 +4,15 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
makeStorageLegacyListener,
|
makeStorageLegacyListener,
|
||||||
} = require("devtools/shared/commands/resource/legacy-listeners/storage-utils");
|
} = require("devtools/shared/resources/legacy-listeners/storage-utils");
|
||||||
|
|
||||||
module.exports = makeStorageLegacyListener(
|
module.exports = makeStorageLegacyListener(
|
||||||
"localStorage",
|
"localStorage",
|
||||||
ResourceCommand.TYPES.LOCAL_STORAGE
|
ResourceWatcher.TYPES.LOCAL_STORAGE
|
||||||
);
|
);
|
||||||
@@ -4,14 +4,16 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
||||||
function onNetworkEventStackTrace(packet) {
|
function onNetworkEventStackTrace(packet) {
|
||||||
const actor = packet.eventActor;
|
const actor = packet.eventActor;
|
||||||
onAvailable([
|
onAvailable([
|
||||||
{
|
{
|
||||||
resourceType: ResourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
resourceType: ResourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||||
resourceId: actor.channelId,
|
resourceId: actor.channelId,
|
||||||
stacktraceAvailable: actor.cause.stacktraceAvailable,
|
stacktraceAvailable: actor.cause.stacktraceAvailable,
|
||||||
lastFrame: actor.cause.lastFrame,
|
lastFrame: actor.cause.lastFrame,
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
module.exports = async function({
|
module.exports = async function({
|
||||||
targetCommand,
|
targetCommand,
|
||||||
@@ -35,7 +37,7 @@ module.exports = async function({
|
|||||||
|
|
||||||
resources.set(actor.actor, {
|
resources.set(actor.actor, {
|
||||||
resourceId: actor.channelId,
|
resourceId: actor.channelId,
|
||||||
resourceType: ResourceCommand.TYPES.NETWORK_EVENT,
|
resourceType: ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
isBlocked: !!actor.blockedReason,
|
isBlocked: !!actor.blockedReason,
|
||||||
types: [],
|
types: [],
|
||||||
resourceUpdates: {},
|
resourceUpdates: {},
|
||||||
@@ -44,7 +46,7 @@ module.exports = async function({
|
|||||||
onAvailable([
|
onAvailable([
|
||||||
{
|
{
|
||||||
resourceId: actor.channelId,
|
resourceId: actor.channelId,
|
||||||
resourceType: ResourceCommand.TYPES.NETWORK_EVENT,
|
resourceType: ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
timeStamp: actor.timeStamp,
|
timeStamp: actor.timeStamp,
|
||||||
actor: actor.actor,
|
actor: actor.actor,
|
||||||
startedDateTime: actor.startedDateTime,
|
startedDateTime: actor.startedDateTime,
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
||||||
// Only allow the top level target and processes.
|
// Only allow the top level target and processes.
|
||||||
@@ -33,12 +35,12 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
|||||||
const { messages } = await webConsoleFront.getCachedMessages(["LogMessage"]);
|
const { messages } = await webConsoleFront.getCachedMessages(["LogMessage"]);
|
||||||
|
|
||||||
for (const message of messages) {
|
for (const message of messages) {
|
||||||
message.resourceType = ResourceCommand.TYPES.PLATFORM_MESSAGE;
|
message.resourceType = ResourceWatcher.TYPES.PLATFORM_MESSAGE;
|
||||||
}
|
}
|
||||||
onAvailable(messages);
|
onAvailable(messages);
|
||||||
|
|
||||||
webConsoleFront.on("logMessage", message => {
|
webConsoleFront.on("logMessage", message => {
|
||||||
message.resourceType = ResourceCommand.TYPES.PLATFORM_MESSAGE;
|
message.resourceType = ResourceWatcher.TYPES.PLATFORM_MESSAGE;
|
||||||
onAvailable([message]);
|
onAvailable([message]);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
module.exports = async function({ targetFront, onAvailable, onDestroyed }) {
|
module.exports = async function({ targetFront, onAvailable, onDestroyed }) {
|
||||||
// XXX: When watching root node for a non top-level target, this will also
|
// XXX: When watching root node for a non top-level target, this will also
|
||||||
@@ -48,12 +50,12 @@ module.exports = async function({ targetFront, onAvailable, onDestroyed }) {
|
|||||||
|
|
||||||
const inspectorFront = await targetFront.getFront("inspector");
|
const inspectorFront = await targetFront.getFront("inspector");
|
||||||
inspectorFront.walker.on("root-available", node => {
|
inspectorFront.walker.on("root-available", node => {
|
||||||
node.resourceType = ResourceCommand.TYPES.ROOT_NODE;
|
node.resourceType = ResourceWatcher.TYPES.ROOT_NODE;
|
||||||
return onAvailable([node]);
|
return onAvailable([node]);
|
||||||
});
|
});
|
||||||
|
|
||||||
inspectorFront.walker.on("root-destroyed", node => {
|
inspectorFront.walker.on("root-destroyed", node => {
|
||||||
node.resourceType = ResourceCommand.TYPES.ROOT_NODE;
|
node.resourceType = ResourceWatcher.TYPES.ROOT_NODE;
|
||||||
return onDestroyed([node]);
|
return onDestroyed([node]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
module.exports = async function({ targetFront, onAvailable }) {
|
module.exports = async function({ targetFront, onAvailable }) {
|
||||||
const eventSourceFront = await targetFront.getFront("eventSource");
|
const eventSourceFront = await targetFront.getFront("eventSource");
|
||||||
@@ -25,7 +27,7 @@ module.exports = async function({ targetFront, onAvailable }) {
|
|||||||
|
|
||||||
function createResource(messageType, eventParams) {
|
function createResource(messageType, eventParams) {
|
||||||
return {
|
return {
|
||||||
resourceType: ResourceCommand.TYPES.SERVER_SENT_EVENT,
|
resourceType: ResourceWatcher.TYPES.SERVER_SENT_EVENT,
|
||||||
messageType,
|
messageType,
|
||||||
...eventParams,
|
...eventParams,
|
||||||
};
|
};
|
||||||
@@ -4,13 +4,15 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
makeStorageLegacyListener,
|
makeStorageLegacyListener,
|
||||||
} = require("devtools/shared/commands/resource/legacy-listeners/storage-utils");
|
} = require("devtools/shared/resources/legacy-listeners/storage-utils");
|
||||||
|
|
||||||
module.exports = makeStorageLegacyListener(
|
module.exports = makeStorageLegacyListener(
|
||||||
"sessionStorage",
|
"sessionStorage",
|
||||||
ResourceCommand.TYPES.SESSION_STORAGE
|
ResourceWatcher.TYPES.SESSION_STORAGE
|
||||||
);
|
);
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emit SOURCE resources, which represents a Javascript source and has the following attributes set on "available":
|
* Emit SOURCE resources, which represents a Javascript source and has the following attributes set on "available":
|
||||||
@@ -50,7 +52,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
|||||||
}
|
}
|
||||||
sourcesActorIDCache.add(source.actor);
|
sourcesActorIDCache.add(source.actor);
|
||||||
// source is a SourceActor's form, add the resourceType attribute on it
|
// source is a SourceActor's form, add the resourceType attribute on it
|
||||||
source.resourceType = ResourceCommand.TYPES.SOURCE;
|
source.resourceType = ResourceWatcher.TYPES.SOURCE;
|
||||||
onAvailable([source]);
|
onAvailable([source]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -81,7 +83,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
|||||||
for (const source of sources) {
|
for (const source of sources) {
|
||||||
sourcesActorIDCache.add(source.actor);
|
sourcesActorIDCache.add(source.actor);
|
||||||
// source is a SourceActor's form, add the resourceType attribute on it
|
// source is a SourceActor's form, add the resourceType attribute on it
|
||||||
source.resourceType = ResourceCommand.TYPES.SOURCE;
|
source.resourceType = ResourceWatcher.TYPES.SOURCE;
|
||||||
}
|
}
|
||||||
onAvailable(sources);
|
onAvailable(sources);
|
||||||
};
|
};
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
module.exports = async function({ targetFront, onAvailable, onUpdated }) {
|
module.exports = async function({ targetFront, onAvailable, onUpdated }) {
|
||||||
if (!targetFront.hasActor("styleSheets")) {
|
if (!targetFront.hasActor("styleSheets")) {
|
||||||
@@ -123,7 +125,7 @@ module.exports = async function({ targetFront, onAvailable, onUpdated }) {
|
|||||||
function toResource(styleSheet, isNew, fileName) {
|
function toResource(styleSheet, isNew, fileName) {
|
||||||
Object.assign(styleSheet, {
|
Object.assign(styleSheet, {
|
||||||
resourceId: styleSheet.actorID,
|
resourceId: styleSheet.actorID,
|
||||||
resourceType: ResourceCommand.TYPES.STYLESHEET,
|
resourceType: ResourceWatcher.TYPES.STYLESHEET,
|
||||||
isNew,
|
isNew,
|
||||||
fileName,
|
fileName,
|
||||||
});
|
});
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
||||||
const isBrowserToolbox = targetCommand.targetFront.isParentProcess;
|
const isBrowserToolbox = targetCommand.targetFront.isParentProcess;
|
||||||
@@ -46,7 +48,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
|||||||
|
|
||||||
onAvailable([
|
onAvailable([
|
||||||
{
|
{
|
||||||
resourceType: ResourceCommand.TYPES.THREAD_STATE,
|
resourceType: ResourceWatcher.TYPES.THREAD_STATE,
|
||||||
state: "paused",
|
state: "paused",
|
||||||
why,
|
why,
|
||||||
frame: packet.frame,
|
frame: packet.frame,
|
||||||
@@ -66,7 +68,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
|||||||
|
|
||||||
onAvailable([
|
onAvailable([
|
||||||
{
|
{
|
||||||
resourceType: ResourceCommand.TYPES.THREAD_STATE,
|
resourceType: ResourceWatcher.TYPES.THREAD_STATE,
|
||||||
state: "resumed",
|
state: "resumed",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
module.exports = async function({ targetFront, onAvailable }) {
|
module.exports = async function({ targetFront, onAvailable }) {
|
||||||
if (!targetFront.hasActor("webSocket")) {
|
if (!targetFront.hasActor("webSocket")) {
|
||||||
@@ -53,7 +55,7 @@ module.exports = async function({ targetFront, onAvailable }) {
|
|||||||
|
|
||||||
function toResource(wsMessageType, eventParams) {
|
function toResource(wsMessageType, eventParams) {
|
||||||
return {
|
return {
|
||||||
resourceType: ResourceCommand.TYPES.WEBSOCKET,
|
resourceType: ResourceWatcher.TYPES.WEBSOCKET,
|
||||||
wsMessageType,
|
wsMessageType,
|
||||||
...eventParams,
|
...eventParams,
|
||||||
};
|
};
|
||||||
@@ -8,7 +8,7 @@ DIRS += [
|
|||||||
]
|
]
|
||||||
|
|
||||||
DevToolsModules(
|
DevToolsModules(
|
||||||
"resource-command.js",
|
"resource-watcher.js",
|
||||||
)
|
)
|
||||||
|
|
||||||
if CONFIG["MOZ_BUILD_APP"] != "mobile/android":
|
if CONFIG["MOZ_BUILD_APP"] != "mobile/android":
|
||||||
@@ -9,7 +9,7 @@ const { throttle } = require("devtools/shared/throttle");
|
|||||||
|
|
||||||
const BROWSERTOOLBOX_FISSION_ENABLED = "devtools.browsertoolbox.fission";
|
const BROWSERTOOLBOX_FISSION_ENABLED = "devtools.browsertoolbox.fission";
|
||||||
|
|
||||||
class ResourceCommand {
|
class ResourceWatcher {
|
||||||
/**
|
/**
|
||||||
* This class helps retrieving existing and listening to resources.
|
* This class helps retrieving existing and listening to resources.
|
||||||
* A resource is something that:
|
* A resource is something that:
|
||||||
@@ -18,11 +18,13 @@ class ResourceCommand {
|
|||||||
* - can already exist, or will be created later on
|
* - can already exist, or will be created later on
|
||||||
* - doesn't require any user data to be fetched, only a type/category
|
* - doesn't require any user data to be fetched, only a type/category
|
||||||
*
|
*
|
||||||
* @param object commands
|
* @param {TargetCommand} targetCommand
|
||||||
* The commands object with all interfaces defined from devtools/shared/commands/
|
* A TargetCommand instance, which helps communicating to the backend
|
||||||
|
* in order to iterate and listen over the requested resources.
|
||||||
*/
|
*/
|
||||||
constructor({ commands }) {
|
|
||||||
this.targetCommand = commands.targetCommand;
|
constructor(targetCommand) {
|
||||||
|
this.targetCommand = targetCommand;
|
||||||
|
|
||||||
this._onTargetAvailable = this._onTargetAvailable.bind(this);
|
this._onTargetAvailable = this._onTargetAvailable.bind(this);
|
||||||
this._onTargetDestroyed = this._onTargetDestroyed.bind(this);
|
this._onTargetDestroyed = this._onTargetDestroyed.bind(this);
|
||||||
@@ -115,7 +117,7 @@ class ResourceCommand {
|
|||||||
|
|
||||||
if (typeof onAvailable !== "function") {
|
if (typeof onAvailable !== "function") {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"ResourceCommand.watchResources expects an onAvailable function as argument"
|
"ResourceWatcher.watchResources expects an onAvailable function as argument"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +217,7 @@ class ResourceCommand {
|
|||||||
|
|
||||||
if (typeof onAvailable !== "function") {
|
if (typeof onAvailable !== "function") {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"ResourceCommand.unwatchResources expects an onAvailable function as argument"
|
"ResourceWatcher.unwatchResources expects an onAvailable function as argument"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,11 +301,11 @@ class ResourceCommand {
|
|||||||
* composed of a BrowsingContextTargetFront or ContentProcessTargetFront.
|
* composed of a BrowsingContextTargetFront or ContentProcessTargetFront.
|
||||||
*/
|
*/
|
||||||
async _onTargetAvailable({ targetFront, isTargetSwitching }) {
|
async _onTargetAvailable({ targetFront, isTargetSwitching }) {
|
||||||
// We put the resourceCommand on the targetFront so it can be retrieved in the
|
// We put the resourceWatcher 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
|
// inspector and style-rule fronts. This might be removed in the future if/when we
|
||||||
// turn the resourceCommand into a Command.
|
// turn the resourceWatcher into a Command.
|
||||||
// ⚠️ This shouldn't be used anywhere else ⚠️
|
// ⚠️ This shouldn't be used anywhere else ⚠️
|
||||||
targetFront.resourceCommand = this;
|
targetFront.resourceWatcher = this;
|
||||||
|
|
||||||
const resources = [];
|
const resources = [];
|
||||||
if (isTargetSwitching) {
|
if (isTargetSwitching) {
|
||||||
@@ -315,7 +317,7 @@ class ResourceCommand {
|
|||||||
// Watcher actor, we have to unregister and re-register the resource
|
// Watcher actor, we have to unregister and re-register the resource
|
||||||
// types. This will force calling `Resources.watchResources` on the new top
|
// types. This will force calling `Resources.watchResources` on the new top
|
||||||
// level target.
|
// level target.
|
||||||
for (const resourceType of Object.values(ResourceCommand.TYPES)) {
|
for (const resourceType of Object.values(ResourceWatcher.TYPES)) {
|
||||||
// ...which has at least one listener...
|
// ...which has at least one listener...
|
||||||
if (!this._listenerCount.get(resourceType)) {
|
if (!this._listenerCount.get(resourceType)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -340,7 +342,7 @@ class ResourceCommand {
|
|||||||
// currently monitored resources.
|
// currently monitored resources.
|
||||||
if (!isTargetSwitching) {
|
if (!isTargetSwitching) {
|
||||||
// For each resource type...
|
// For each resource type...
|
||||||
for (const resourceType of Object.values(ResourceCommand.TYPES)) {
|
for (const resourceType of Object.values(ResourceWatcher.TYPES)) {
|
||||||
// ...which has at least one listener...
|
// ...which has at least one listener...
|
||||||
if (!this._listenerCount.get(resourceType)) {
|
if (!this._listenerCount.get(resourceType)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -389,7 +391,7 @@ class ResourceCommand {
|
|||||||
|
|
||||||
// For top-level targets created from the server, only restart legacy
|
// For top-level targets created from the server, only restart legacy
|
||||||
// listeners.
|
// listeners.
|
||||||
return !this.hasResourceCommandSupport(resourceType);
|
return !this.hasResourceWatcherSupport(resourceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -430,7 +432,7 @@ class ResourceCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// isAlreadyExistingResource indicates that the resources already existed before
|
// isAlreadyExistingResource indicates that the resources already existed before
|
||||||
// the resource command started watching for this type of resource.
|
// the resource watcher started watching for this type of resource.
|
||||||
resource.isAlreadyExistingResource = this._processingExistingResources.has(
|
resource.isAlreadyExistingResource = this._processingExistingResources.has(
|
||||||
resourceType
|
resourceType
|
||||||
);
|
);
|
||||||
@@ -635,7 +637,7 @@ class ResourceCommand {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(
|
console.error(
|
||||||
"Exception while calling a ResourceCommand",
|
"Exception while calling a ResourceWatcher",
|
||||||
callbackType,
|
callbackType,
|
||||||
"callback",
|
"callback",
|
||||||
":",
|
":",
|
||||||
@@ -688,7 +690,7 @@ class ResourceCommand {
|
|||||||
*
|
*
|
||||||
* @return {Boolean} True, if the server supports this type.
|
* @return {Boolean} True, if the server supports this type.
|
||||||
*/
|
*/
|
||||||
hasResourceCommandSupport(resourceType) {
|
hasResourceWatcherSupport(resourceType) {
|
||||||
// If the targetCommand top level target is a parent process, we're in the browser console or browser toolbox.
|
// If the targetCommand top level target is a parent process, we're in the browser console or browser toolbox.
|
||||||
// In such case, if the browser toolbox fission pref is disabled, we don't want to use watchers
|
// In such case, if the browser toolbox fission pref is disabled, we don't want to use watchers
|
||||||
// (even if traits on the server are enabled).
|
// (even if traits on the server are enabled).
|
||||||
@@ -709,14 +711,14 @@ class ResourceCommand {
|
|||||||
*
|
*
|
||||||
* @return {Boolean} True, if the server supports this type.
|
* @return {Boolean} True, if the server supports this type.
|
||||||
*/
|
*/
|
||||||
_hasResourceCommandSupportForTarget(resourceType, targetFront) {
|
_hasResourceWatcherSupportForTarget(resourceType, targetFront) {
|
||||||
// First check if the watcher supports this target type.
|
// First check if the watcher supports this target type.
|
||||||
// If it doesn't, no resource type can be listened via the Watcher actor for this target.
|
// If it doesn't, no resource type can be listened via the Watcher actor for this target.
|
||||||
if (!this.targetCommand.hasTargetWatcherSupport(targetFront.targetType)) {
|
if (!this.targetCommand.hasTargetWatcherSupport(targetFront.targetType)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.hasResourceCommandSupport(resourceType);
|
return this.hasResourceWatcherSupport(resourceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -725,7 +727,7 @@ class ResourceCommand {
|
|||||||
* each individual target
|
* each individual target
|
||||||
*
|
*
|
||||||
* @param {String} resourceType
|
* @param {String} resourceType
|
||||||
* One string of ResourceCommand.TYPES, which designates the types of resources
|
* One string of ResourceWatcher.TYPES, which designates the types of resources
|
||||||
* to be listened.
|
* to be listened.
|
||||||
* @param {Object}
|
* @param {Object}
|
||||||
* - {Boolean} bypassListenerCount
|
* - {Boolean} bypassListenerCount
|
||||||
@@ -748,7 +750,7 @@ class ResourceCommand {
|
|||||||
|
|
||||||
// If the server supports the Watcher API and the Watcher supports
|
// If the server supports the Watcher API and the Watcher supports
|
||||||
// this resource type, use this API
|
// this resource type, use this API
|
||||||
if (this.hasResourceCommandSupport(resourceType)) {
|
if (this.hasResourceWatcherSupport(resourceType)) {
|
||||||
await this.watcherFront.watchResources([resourceType]);
|
await this.watcherFront.watchResources([resourceType]);
|
||||||
|
|
||||||
const shouldRunLegacyListeners = this._shouldRunLegacyListenerEvenWithWatcherSupport(
|
const shouldRunLegacyListeners = this._shouldRunLegacyListenerEvenWithWatcherSupport(
|
||||||
@@ -791,8 +793,8 @@ class ResourceCommand {
|
|||||||
*/
|
*/
|
||||||
_shouldRunLegacyListenerEvenWithWatcherSupport(resourceType) {
|
_shouldRunLegacyListenerEvenWithWatcherSupport(resourceType) {
|
||||||
return (
|
return (
|
||||||
resourceType == ResourceCommand.TYPES.SOURCE ||
|
resourceType == ResourceWatcher.TYPES.SOURCE ||
|
||||||
resourceType == ResourceCommand.TYPES.THREAD_STATE
|
resourceType == ResourceWatcher.TYPES.THREAD_STATE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -810,7 +812,7 @@ class ResourceCommand {
|
|||||||
* type of resource from a given target.
|
* type of resource from a given target.
|
||||||
*/
|
*/
|
||||||
async _watchResourcesForTarget(targetFront, resourceType) {
|
async _watchResourcesForTarget(targetFront, resourceType) {
|
||||||
if (this._hasResourceCommandSupportForTarget(resourceType, targetFront)) {
|
if (this._hasResourceWatcherSupportForTarget(resourceType, targetFront)) {
|
||||||
// This resource / target pair should already be handled by the watcher,
|
// This resource / target pair should already be handled by the watcher,
|
||||||
// no need to start legacy listeners.
|
// no need to start legacy listeners.
|
||||||
return;
|
return;
|
||||||
@@ -890,7 +892,7 @@ class ResourceCommand {
|
|||||||
|
|
||||||
// If the server supports the Watcher API and the Watcher supports
|
// If the server supports the Watcher API and the Watcher supports
|
||||||
// this resource type, use this API
|
// this resource type, use this API
|
||||||
if (this.hasResourceCommandSupport(resourceType)) {
|
if (this.hasResourceWatcherSupport(resourceType)) {
|
||||||
if (!this.watcherFront.isDestroyed()) {
|
if (!this.watcherFront.isDestroyed()) {
|
||||||
this.watcherFront.unwatchResources([resourceType]);
|
this.watcherFront.unwatchResources([resourceType]);
|
||||||
}
|
}
|
||||||
@@ -918,7 +920,7 @@ class ResourceCommand {
|
|||||||
* Backward compatibility code, reverse of _watchResourcesForTarget.
|
* Backward compatibility code, reverse of _watchResourcesForTarget.
|
||||||
*/
|
*/
|
||||||
_unwatchResourcesForTarget(targetFront, resourceType) {
|
_unwatchResourcesForTarget(targetFront, resourceType) {
|
||||||
if (this._hasResourceCommandSupportForTarget(resourceType, targetFront)) {
|
if (this._hasResourceWatcherSupportForTarget(resourceType, targetFront)) {
|
||||||
// This resource / target pair should already be handled by the watcher,
|
// This resource / target pair should already be handled by the watcher,
|
||||||
// no need to stop legacy listeners.
|
// no need to stop legacy listeners.
|
||||||
}
|
}
|
||||||
@@ -944,7 +946,7 @@ class ResourceCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceCommand.TYPES = ResourceCommand.prototype.TYPES = {
|
ResourceWatcher.TYPES = ResourceWatcher.prototype.TYPES = {
|
||||||
CONSOLE_MESSAGE: "console-message",
|
CONSOLE_MESSAGE: "console-message",
|
||||||
CSS_CHANGE: "css-change",
|
CSS_CHANGE: "css-change",
|
||||||
CSS_MESSAGE: "css-message",
|
CSS_MESSAGE: "css-message",
|
||||||
@@ -968,25 +970,25 @@ ResourceCommand.TYPES = ResourceCommand.prototype.TYPES = {
|
|||||||
THREAD_STATE: "thread-state",
|
THREAD_STATE: "thread-state",
|
||||||
SERVER_SENT_EVENT: "server-sent-event",
|
SERVER_SENT_EVENT: "server-sent-event",
|
||||||
};
|
};
|
||||||
module.exports = ResourceCommand;
|
module.exports = { ResourceWatcher, TYPES: ResourceWatcher.TYPES };
|
||||||
|
|
||||||
// Backward compat code for each type of resource.
|
// Backward compat code for each type of resource.
|
||||||
// Each section added here should eventually be removed once the equivalent server
|
// Each section added here should eventually be removed once the equivalent server
|
||||||
// code is implement in Firefox, in its release channel.
|
// code is implement in Firefox, in its release channel.
|
||||||
const LegacyListeners = {
|
const LegacyListeners = {
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.CONSOLE_MESSAGE]: require("devtools/shared/commands/resource/legacy-listeners/console-messages"),
|
.CONSOLE_MESSAGE]: require("devtools/shared/resources/legacy-listeners/console-messages"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.CSS_CHANGE]: require("devtools/shared/commands/resource/legacy-listeners/css-changes"),
|
.CSS_CHANGE]: require("devtools/shared/resources/legacy-listeners/css-changes"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.CSS_MESSAGE]: require("devtools/shared/commands/resource/legacy-listeners/css-messages"),
|
.CSS_MESSAGE]: require("devtools/shared/resources/legacy-listeners/css-messages"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.ERROR_MESSAGE]: require("devtools/shared/commands/resource/legacy-listeners/error-messages"),
|
.ERROR_MESSAGE]: require("devtools/shared/resources/legacy-listeners/error-messages"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.PLATFORM_MESSAGE]: require("devtools/shared/commands/resource/legacy-listeners/platform-messages"),
|
.PLATFORM_MESSAGE]: require("devtools/shared/resources/legacy-listeners/platform-messages"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.CLONED_CONTENT_PROCESS_MESSAGE]: require("devtools/shared/commands/resource/legacy-listeners/cloned-content-process-messages"),
|
.CLONED_CONTENT_PROCESS_MESSAGE]: require("devtools/shared/resources/legacy-listeners/cloned-content-process-messages"),
|
||||||
async [ResourceCommand.TYPES.DOCUMENT_EVENT]({
|
async [ResourceWatcher.TYPES.DOCUMENT_EVENT]({
|
||||||
targetCommand,
|
targetCommand,
|
||||||
targetFront,
|
targetFront,
|
||||||
onAvailable,
|
onAvailable,
|
||||||
@@ -998,39 +1000,39 @@ const LegacyListeners = {
|
|||||||
|
|
||||||
const webConsoleFront = await targetFront.getFront("console");
|
const webConsoleFront = await targetFront.getFront("console");
|
||||||
webConsoleFront.on("documentEvent", event => {
|
webConsoleFront.on("documentEvent", event => {
|
||||||
event.resourceType = ResourceCommand.TYPES.DOCUMENT_EVENT;
|
event.resourceType = ResourceWatcher.TYPES.DOCUMENT_EVENT;
|
||||||
onAvailable([event]);
|
onAvailable([event]);
|
||||||
});
|
});
|
||||||
await webConsoleFront.startListeners(["DocumentEvents"]);
|
await webConsoleFront.startListeners(["DocumentEvents"]);
|
||||||
},
|
},
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.ROOT_NODE]: require("devtools/shared/commands/resource/legacy-listeners/root-node"),
|
.ROOT_NODE]: require("devtools/shared/resources/legacy-listeners/root-node"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.STYLESHEET]: require("devtools/shared/commands/resource/legacy-listeners/stylesheet"),
|
.STYLESHEET]: require("devtools/shared/resources/legacy-listeners/stylesheet"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.NETWORK_EVENT]: require("devtools/shared/commands/resource/legacy-listeners/network-events"),
|
.NETWORK_EVENT]: require("devtools/shared/resources/legacy-listeners/network-events"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.WEBSOCKET]: require("devtools/shared/commands/resource/legacy-listeners/websocket"),
|
.WEBSOCKET]: require("devtools/shared/resources/legacy-listeners/websocket"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.COOKIE]: require("devtools/shared/commands/resource/legacy-listeners/cookie"),
|
.COOKIE]: require("devtools/shared/resources/legacy-listeners/cookie"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.CACHE_STORAGE]: require("devtools/shared/commands/resource/legacy-listeners/cache-storage"),
|
.CACHE_STORAGE]: require("devtools/shared/resources/legacy-listeners/cache-storage"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.LOCAL_STORAGE]: require("devtools/shared/commands/resource/legacy-listeners/local-storage"),
|
.LOCAL_STORAGE]: require("devtools/shared/resources/legacy-listeners/local-storage"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.SESSION_STORAGE]: require("devtools/shared/commands/resource/legacy-listeners/session-storage"),
|
.SESSION_STORAGE]: require("devtools/shared/resources/legacy-listeners/session-storage"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.EXTENSION_STORAGE]: require("devtools/shared/commands/resource/legacy-listeners/extension-storage"),
|
.EXTENSION_STORAGE]: require("devtools/shared/resources/legacy-listeners/extension-storage"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.INDEXED_DB]: require("devtools/shared/commands/resource/legacy-listeners/indexed-db"),
|
.INDEXED_DB]: require("devtools/shared/resources/legacy-listeners/indexed-db"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.NETWORK_EVENT_STACKTRACE]: require("devtools/shared/commands/resource/legacy-listeners/network-event-stacktraces"),
|
.NETWORK_EVENT_STACKTRACE]: require("devtools/shared/resources/legacy-listeners/network-event-stacktraces"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.SOURCE]: require("devtools/shared/commands/resource/legacy-listeners/source"),
|
.SOURCE]: require("devtools/shared/resources/legacy-listeners/source"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.THREAD_STATE]: require("devtools/shared/commands/resource/legacy-listeners/thread-states"),
|
.THREAD_STATE]: require("devtools/shared/resources/legacy-listeners/thread-states"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.SERVER_SENT_EVENT]: require("devtools/shared/commands/resource/legacy-listeners/server-sent-events"),
|
.SERVER_SENT_EVENT]: require("devtools/shared/resources/legacy-listeners/server-sent-events"),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Optional transformers for each type of resource.
|
// Optional transformers for each type of resource.
|
||||||
@@ -1038,22 +1040,22 @@ const LegacyListeners = {
|
|||||||
// and perform some transformation on the resource before it will be emitted.
|
// and perform some transformation on the resource before it will be emitted.
|
||||||
// This is a good place to handle backward compatibility and manual resource marshalling.
|
// This is a good place to handle backward compatibility and manual resource marshalling.
|
||||||
const ResourceTransformers = {
|
const ResourceTransformers = {
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.CONSOLE_MESSAGE]: require("devtools/shared/commands/resource/transformers/console-messages"),
|
.CONSOLE_MESSAGE]: require("devtools/shared/resources/transformers/console-messages"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.ERROR_MESSAGE]: require("devtools/shared/commands/resource/transformers/error-messages"),
|
.ERROR_MESSAGE]: require("devtools/shared/resources/transformers/error-messages"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.CACHE_STORAGE]: require("devtools/shared/commands/resource/transformers/storage-cache.js"),
|
.CACHE_STORAGE]: require("devtools/shared/resources/transformers/storage-cache.js"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.COOKIE]: require("devtools/shared/commands/resource/transformers/storage-cookie.js"),
|
.COOKIE]: require("devtools/shared/resources/transformers/storage-cookie.js"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.INDEXED_DB]: require("devtools/shared/commands/resource/transformers/storage-indexed-db.js"),
|
.INDEXED_DB]: require("devtools/shared/resources/transformers/storage-indexed-db.js"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.LOCAL_STORAGE]: require("devtools/shared/commands/resource/transformers/storage-local-storage.js"),
|
.LOCAL_STORAGE]: require("devtools/shared/resources/transformers/storage-local-storage.js"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.SESSION_STORAGE]: require("devtools/shared/commands/resource/transformers/storage-session-storage.js"),
|
.SESSION_STORAGE]: require("devtools/shared/resources/transformers/storage-session-storage.js"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.NETWORK_EVENT]: require("devtools/shared/commands/resource/transformers/network-events"),
|
.NETWORK_EVENT]: require("devtools/shared/resources/transformers/network-events"),
|
||||||
[ResourceCommand.TYPES
|
[ResourceWatcher.TYPES
|
||||||
.THREAD_STATE]: require("devtools/shared/commands/resource/transformers/thread-states"),
|
.THREAD_STATE]: require("devtools/shared/resources/transformers/thread-states"),
|
||||||
};
|
};
|
||||||
@@ -3,7 +3,11 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Test the ResourceCommand API around CONSOLE_MESSAGE for the whole browser
|
// Test the ResourceWatcher API around CONSOLE_MESSAGE for the whole browser
|
||||||
|
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const TEST_URL = URL_ROOT_SSL + "early_console_document.html";
|
const TEST_URL = URL_ROOT_SSL + "early_console_document.html";
|
||||||
|
|
||||||
@@ -13,20 +17,20 @@ add_task(async function() {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
client,
|
client,
|
||||||
resourceCommand,
|
resourceWatcher,
|
||||||
targetCommand,
|
targetCommand,
|
||||||
} = await initMultiProcessResourceCommand();
|
} = await initMultiProcessResourceWatcher();
|
||||||
|
|
||||||
info(
|
info(
|
||||||
"Log some messages *before* calling ResourceCommand.watchResources in order to " +
|
"Log some messages *before* calling ResourceWatcher.watchResources in order to " +
|
||||||
"assert the behavior of already existing messages."
|
"assert the behavior of already existing messages."
|
||||||
);
|
);
|
||||||
console.log("foobar");
|
console.log("foobar");
|
||||||
|
|
||||||
info("Wait for existing browser mochitest log");
|
info("Wait for existing browser mochitest log");
|
||||||
const existingMsg = await waitForNextResource(
|
const existingMsg = await waitForNextResource(
|
||||||
resourceCommand,
|
resourceWatcher,
|
||||||
resourceCommand.TYPES.CONSOLE_MESSAGE,
|
ResourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||||
{
|
{
|
||||||
ignoreExistingResources: false,
|
ignoreExistingResources: false,
|
||||||
predicate({ message }) {
|
predicate({ message }) {
|
||||||
@@ -52,15 +56,15 @@ add_task(async function() {
|
|||||||
resource => resource.message.arguments[0] == "foobar2"
|
resource => resource.message.arguments[0] == "foobar2"
|
||||||
);
|
);
|
||||||
if (runtimeLogResource) {
|
if (runtimeLogResource) {
|
||||||
resourceCommand.unwatchResources(
|
resourceWatcher.unwatchResources(
|
||||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{ onAvailable }
|
{ onAvailable }
|
||||||
);
|
);
|
||||||
resolveMochitestRuntimeLog(runtimeLogResource);
|
resolveMochitestRuntimeLog(runtimeLogResource);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
ignoreExistingResources: true,
|
ignoreExistingResources: true,
|
||||||
onAvailable,
|
onAvailable,
|
||||||
@@ -78,8 +82,8 @@ add_task(async function() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const onEarlyLog = waitForNextResource(
|
const onEarlyLog = waitForNextResource(
|
||||||
resourceCommand,
|
resourceWatcher,
|
||||||
resourceCommand.TYPES.CONSOLE_MESSAGE,
|
ResourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||||
{
|
{
|
||||||
ignoreExistingResources: true,
|
ignoreExistingResources: true,
|
||||||
predicate({ message }) {
|
predicate({ message }) {
|
||||||
@@ -3,7 +3,11 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Test the cache mechanism of the ResourceCommand.
|
// Test the cache mechanism of the ResourceWatcher.
|
||||||
|
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const TEST_URI = "data:text/html;charset=utf-8,Cache Test";
|
const TEST_URI = "data:text/html;charset=utf-8,Cache Test";
|
||||||
|
|
||||||
@@ -12,7 +16,7 @@ add_task(async function() {
|
|||||||
|
|
||||||
const tab = await addTab(TEST_URI);
|
const tab = await addTab(TEST_URI);
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -22,8 +26,8 @@ add_task(async function() {
|
|||||||
|
|
||||||
info("Register first listener");
|
info("Register first listener");
|
||||||
const cachedResources1 = [];
|
const cachedResources1 = [];
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => cachedResources1.push(...resources),
|
onAvailable: resources => cachedResources1.push(...resources),
|
||||||
}
|
}
|
||||||
@@ -31,8 +35,8 @@ add_task(async function() {
|
|||||||
|
|
||||||
info("Register second listener");
|
info("Register second listener");
|
||||||
const cachedResources2 = [];
|
const cachedResources2 = [];
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => cachedResources2.push(...resources),
|
onAvailable: resources => cachedResources2.push(...resources),
|
||||||
}
|
}
|
||||||
@@ -52,7 +56,7 @@ add_task(async function() {
|
|||||||
|
|
||||||
const tab = await addTab(TEST_URI);
|
const tab = await addTab(TEST_URI);
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -62,8 +66,8 @@ add_task(async function() {
|
|||||||
|
|
||||||
info("Register first listener to get all available resources");
|
info("Register first listener to get all available resources");
|
||||||
const availableResources = [];
|
const availableResources = [];
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => availableResources.push(...resources),
|
onAvailable: resources => availableResources.push(...resources),
|
||||||
}
|
}
|
||||||
@@ -79,8 +83,8 @@ add_task(async function() {
|
|||||||
|
|
||||||
info("Register second listener to get the cached resources");
|
info("Register second listener to get the cached resources");
|
||||||
const cachedResources = [];
|
const cachedResources = [];
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => cachedResources.push(...resources),
|
onAvailable: resources => cachedResources.push(...resources),
|
||||||
}
|
}
|
||||||
@@ -98,7 +102,7 @@ add_task(async function() {
|
|||||||
|
|
||||||
const tab = await addTab(TEST_URI);
|
const tab = await addTab(TEST_URI);
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -107,8 +111,8 @@ add_task(async function() {
|
|||||||
await logMessages(tab.linkedBrowser, existingMessages);
|
await logMessages(tab.linkedBrowser, existingMessages);
|
||||||
|
|
||||||
info("Register first listener");
|
info("Register first listener");
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: () => {},
|
onAvailable: () => {},
|
||||||
}
|
}
|
||||||
@@ -121,14 +125,14 @@ add_task(async function() {
|
|||||||
|
|
||||||
info("Register second listener");
|
info("Register second listener");
|
||||||
const cachedResources = [];
|
const cachedResources = [];
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => cachedResources.push(...resources),
|
onAvailable: resources => cachedResources.push(...resources),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
is(cachedResources.length, 0, "The cache in ResourceCommand is cleared");
|
is(cachedResources.length, 0, "The cache in ResourceWatcher is cleared");
|
||||||
|
|
||||||
targetCommand.destroy();
|
targetCommand.destroy();
|
||||||
await client.close();
|
await client.close();
|
||||||
@@ -139,16 +143,16 @@ add_task(async function() {
|
|||||||
|
|
||||||
const tab = await addTab(TEST_URI);
|
const tab = await addTab(TEST_URI);
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
info("Register first listener to get all available resources");
|
info("Register first listener to get all available resources");
|
||||||
const availableResources = [];
|
const availableResources = [];
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[
|
[
|
||||||
resourceCommand.TYPES.CONSOLE_MESSAGE,
|
ResourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||||
resourceCommand.TYPES.ERROR_MESSAGE,
|
ResourceWatcher.TYPES.ERROR_MESSAGE,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onAvailable: resources => availableResources.push(...resources),
|
onAvailable: resources => availableResources.push(...resources),
|
||||||
@@ -176,10 +180,10 @@ add_task(async function() {
|
|||||||
|
|
||||||
info("Register listener to get the cached resources");
|
info("Register listener to get the cached resources");
|
||||||
const cachedResources = [];
|
const cachedResources = [];
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[
|
[
|
||||||
resourceCommand.TYPES.CONSOLE_MESSAGE,
|
ResourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||||
resourceCommand.TYPES.ERROR_MESSAGE,
|
ResourceWatcher.TYPES.ERROR_MESSAGE,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onAvailable: resources => cachedResources.push(...resources),
|
onAvailable: resources => cachedResources.push(...resources),
|
||||||
@@ -201,7 +205,7 @@ add_task(async function() {
|
|||||||
async function testIgnoreExistingResources(isFirstListenerIgnoreExisting) {
|
async function testIgnoreExistingResources(isFirstListenerIgnoreExisting) {
|
||||||
const tab = await addTab(TEST_URI);
|
const tab = await addTab(TEST_URI);
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -211,8 +215,8 @@ async function testIgnoreExistingResources(isFirstListenerIgnoreExisting) {
|
|||||||
|
|
||||||
info("Register first listener");
|
info("Register first listener");
|
||||||
const cachedResources1 = [];
|
const cachedResources1 = [];
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => cachedResources1.push(...resources),
|
onAvailable: resources => cachedResources1.push(...resources),
|
||||||
ignoreExistingResources: isFirstListenerIgnoreExisting,
|
ignoreExistingResources: isFirstListenerIgnoreExisting,
|
||||||
@@ -221,8 +225,8 @@ async function testIgnoreExistingResources(isFirstListenerIgnoreExisting) {
|
|||||||
|
|
||||||
info("Register second listener");
|
info("Register second listener");
|
||||||
const cachedResources2 = [];
|
const cachedResources2 = [];
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => cachedResources2.push(...resources),
|
onAvailable: resources => cachedResources2.push(...resources),
|
||||||
ignoreExistingResources: !isFirstListenerIgnoreExisting,
|
ignoreExistingResources: !isFirstListenerIgnoreExisting,
|
||||||
@@ -266,7 +270,7 @@ add_task(async function() {
|
|||||||
|
|
||||||
const tab = await addTab(TEST_URI);
|
const tab = await addTab(TEST_URI);
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -282,8 +286,8 @@ add_task(async function() {
|
|||||||
onAvailableCallCount++;
|
onAvailableCallCount++;
|
||||||
};
|
};
|
||||||
|
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{ onAvailable }
|
{ onAvailable }
|
||||||
);
|
);
|
||||||
is(availableResources.length, 0, "availableResources array is empty");
|
is(availableResources.length, 0, "availableResources array is empty");
|
||||||
@@ -301,7 +305,7 @@ add_task(async function() {
|
|||||||
"onAvailable was called with the expected resource"
|
"onAvailable was called with the expected resource"
|
||||||
);
|
);
|
||||||
|
|
||||||
resourceCommand.unwatchResources([resourceCommand.TYPES.CONSOLE_MESSAGE], {
|
resourceWatcher.unwatchResources([ResourceWatcher.TYPES.CONSOLE_MESSAGE], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
targetCommand.destroy();
|
targetCommand.destroy();
|
||||||
@@ -3,12 +3,16 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Test the ResourceCommand API around CONSOLE_MESSAGE
|
// Test the ResourceWatcher API around CONSOLE_MESSAGE
|
||||||
//
|
//
|
||||||
// Reproduces assertions from: devtools/shared/webconsole/test/chrome/test_cached_messages.html
|
// Reproduces assertions from: devtools/shared/webconsole/test/chrome/test_cached_messages.html
|
||||||
// And now more. Once we remove the console actor's startListeners in favor of watcher class
|
// And now more. Once we remove the console actor's startListeners in favor of watcher class
|
||||||
// We could remove that other old test.
|
// We could remove that other old test.
|
||||||
|
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const FISSION_TEST_URL = URL_ROOT_SSL + "fission_document.html";
|
const FISSION_TEST_URL = URL_ROOT_SSL + "fission_document.html";
|
||||||
const IFRAME_URL = URL_ROOT_ORG_SSL + "fission_iframe.html";
|
const IFRAME_URL = URL_ROOT_ORG_SSL + "fission_iframe.html";
|
||||||
|
|
||||||
@@ -25,12 +29,12 @@ add_task(async function() {
|
|||||||
async function testTabConsoleMessagesResources(executeInIframe) {
|
async function testTabConsoleMessagesResources(executeInIframe) {
|
||||||
const tab = await addTab(FISSION_TEST_URL);
|
const tab = await addTab(FISSION_TEST_URL);
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
info(
|
info(
|
||||||
"Log some messages *before* calling ResourceCommand.watchResources in order to " +
|
"Log some messages *before* calling ResourceWatcher.watchResources in order to " +
|
||||||
"assert the behavior of already existing messages."
|
"assert the behavior of already existing messages."
|
||||||
);
|
);
|
||||||
await logExistingMessages(tab.linkedBrowser, executeInIframe);
|
await logExistingMessages(tab.linkedBrowser, executeInIframe);
|
||||||
@@ -55,7 +59,7 @@ async function testTabConsoleMessagesResources(executeInIframe) {
|
|||||||
|
|
||||||
is(
|
is(
|
||||||
resource.resourceType,
|
resource.resourceType,
|
||||||
resourceCommand.TYPES.CONSOLE_MESSAGE,
|
ResourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||||
"Received a message"
|
"Received a message"
|
||||||
);
|
);
|
||||||
ok(resource.message, "message is wrapped into a message attribute");
|
ok(resource.message, "message is wrapped into a message attribute");
|
||||||
@@ -77,8 +81,8 @@ async function testTabConsoleMessagesResources(executeInIframe) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable,
|
onAvailable,
|
||||||
}
|
}
|
||||||
@@ -90,7 +94,7 @@ async function testTabConsoleMessagesResources(executeInIframe) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
info(
|
info(
|
||||||
"Now log messages *after* the call to ResourceCommand.watchResources and after having received all existing messages"
|
"Now log messages *after* the call to ResourceWatcher.watchResources and after having received all existing messages"
|
||||||
);
|
);
|
||||||
await logRuntimeMessages(tab.linkedBrowser, executeInIframe);
|
await logRuntimeMessages(tab.linkedBrowser, executeInIframe);
|
||||||
|
|
||||||
@@ -119,7 +123,7 @@ async function testTabConsoleMessagesResourcesWithIgnoreExistingResources(
|
|||||||
info("Test ignoreExistingResources option for console messages");
|
info("Test ignoreExistingResources option for console messages");
|
||||||
const tab = await addTab(FISSION_TEST_URL);
|
const tab = await addTab(FISSION_TEST_URL);
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -129,8 +133,8 @@ async function testTabConsoleMessagesResourcesWithIgnoreExistingResources(
|
|||||||
await logExistingMessages(tab.linkedBrowser, executeInIframe);
|
await logExistingMessages(tab.linkedBrowser, executeInIframe);
|
||||||
|
|
||||||
const availableResources = [];
|
const availableResources = [];
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => availableResources.push(...resources),
|
onAvailable: resources => availableResources.push(...resources),
|
||||||
ignoreExistingResources: true,
|
ignoreExistingResources: true,
|
||||||
@@ -3,7 +3,11 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Test the ResourceCommand API around CONSOLE_MESSAGE in workers
|
// Test the ResourceWatcher API around CONSOLE_MESSAGE in workers
|
||||||
|
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const FISSION_TEST_URL = URL_ROOT_SSL + "fission_document.html";
|
const FISSION_TEST_URL = URL_ROOT_SSL + "fission_document.html";
|
||||||
const WORKER_FILE = "test_worker.js";
|
const WORKER_FILE = "test_worker.js";
|
||||||
@@ -18,9 +22,9 @@ add_task(async function() {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
client,
|
client,
|
||||||
resourceCommand,
|
resourceWatcher,
|
||||||
targetCommand,
|
targetCommand,
|
||||||
} = await initResourceCommand(tab, { listenForWorkers: true });
|
} = await initResourceWatcher(tab, { listenForWorkers: true });
|
||||||
|
|
||||||
info("Wait for the workers (from the main page and the iframe) to be ready");
|
info("Wait for the workers (from the main page and the iframe) to be ready");
|
||||||
const targets = [];
|
const targets = [];
|
||||||
@@ -51,8 +55,8 @@ add_task(async function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable,
|
onAvailable,
|
||||||
}
|
}
|
||||||
@@ -80,7 +84,7 @@ add_task(async function() {
|
|||||||
let messageCount = resources.length;
|
let messageCount = resources.length;
|
||||||
|
|
||||||
info(
|
info(
|
||||||
"Now log messages *after* the call to ResourceCommand.watchResources and after having received all existing messages"
|
"Now log messages *after* the call to ResourceWatcher.watchResources and after having received all existing messages"
|
||||||
);
|
);
|
||||||
|
|
||||||
await SpecialPowers.spawn(tab.linkedBrowser, [], () => {
|
await SpecialPowers.spawn(tab.linkedBrowser, [], () => {
|
||||||
@@ -3,7 +3,11 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Test the ResourceCommand API around CSS_CHANGE.
|
// Test the ResourceWatcher API around CSS_CHANGE.
|
||||||
|
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
// Open a test tab
|
// Open a test tab
|
||||||
@@ -11,13 +15,13 @@ add_task(async function() {
|
|||||||
"data:text/html,<body style='color: lime;'>CSS Changes</body>"
|
"data:text/html,<body style='color: lime;'>CSS Changes</body>"
|
||||||
);
|
);
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
// CSS_CHANGE watcher doesn't record modification made before watching,
|
// CSS_CHANGE watcher doesn't record modification made before watching,
|
||||||
// so we have to start watching before doing any DOM mutation.
|
// so we have to start watching before doing any DOM mutation.
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.CSS_CHANGE], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.CSS_CHANGE], {
|
||||||
onAvailable: () => {},
|
onAvailable: () => {},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -31,12 +35,12 @@ add_task(async function() {
|
|||||||
)[0];
|
)[0];
|
||||||
|
|
||||||
info(
|
info(
|
||||||
"Check whether ResourceCommand catches CSS change that fired before starting to watch"
|
"Check whether ResourceWatcher catches CSS change that fired before starting to watch"
|
||||||
);
|
);
|
||||||
await setProperty(style.rule, 0, "color", "black");
|
await setProperty(style.rule, 0, "color", "black");
|
||||||
|
|
||||||
const availableResources = [];
|
const availableResources = [];
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.CSS_CHANGE], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.CSS_CHANGE], {
|
||||||
onAvailable: resources => availableResources.push(...resources),
|
onAvailable: resources => availableResources.push(...resources),
|
||||||
});
|
});
|
||||||
assertResource(
|
assertResource(
|
||||||
@@ -46,7 +50,7 @@ add_task(async function() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
info(
|
info(
|
||||||
"Check whether ResourceCommand catches CSS change after the property changed"
|
"Check whether ResourceWatcher catches CSS change after the property changed"
|
||||||
);
|
);
|
||||||
await setProperty(style.rule, 0, "background-color", "pink");
|
await setProperty(style.rule, 0, "background-color", "pink");
|
||||||
await waitUntil(() => availableResources.length === 2);
|
await waitUntil(() => availableResources.length === 2);
|
||||||
@@ -56,7 +60,7 @@ add_task(async function() {
|
|||||||
{ index: 0, property: "color", value: "black" }
|
{ index: 0, property: "color", value: "black" }
|
||||||
);
|
);
|
||||||
|
|
||||||
info("Check whether ResourceCommand catches CSS change of disabling");
|
info("Check whether ResourceWatcher catches CSS change of disabling");
|
||||||
await setPropertyEnabled(style.rule, 0, "background-color", false);
|
await setPropertyEnabled(style.rule, 0, "background-color", false);
|
||||||
await waitUntil(() => availableResources.length === 3);
|
await waitUntil(() => availableResources.length === 3);
|
||||||
assertResource(availableResources[2], null, {
|
assertResource(availableResources[2], null, {
|
||||||
@@ -65,7 +69,7 @@ add_task(async function() {
|
|||||||
value: "pink",
|
value: "pink",
|
||||||
});
|
});
|
||||||
|
|
||||||
info("Check whether ResourceCommand catches CSS change of new property");
|
info("Check whether ResourceWatcher catches CSS change of new property");
|
||||||
await createProperty(style.rule, 1, "font-size", "100px");
|
await createProperty(style.rule, 1, "font-size", "100px");
|
||||||
await waitUntil(() => availableResources.length === 4);
|
await waitUntil(() => availableResources.length === 4);
|
||||||
assertResource(
|
assertResource(
|
||||||
@@ -74,9 +78,9 @@ add_task(async function() {
|
|||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
info("Check whether ResourceCommand sends all resources added in this test");
|
info("Check whether ResourceWatcher sends all resources added in this test");
|
||||||
const existingResources = [];
|
const existingResources = [];
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.CSS_CHANGE], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.CSS_CHANGE], {
|
||||||
onAvailable: resources => existingResources.push(...resources),
|
onAvailable: resources => existingResources.push(...resources),
|
||||||
});
|
});
|
||||||
await waitUntil(() => existingResources.length === 4);
|
await waitUntil(() => existingResources.length === 4);
|
||||||
@@ -3,9 +3,12 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Test the ResourceCommand API around CSS_MESSAGE
|
// Test the ResourceWatcher API around CSS_MESSAGE
|
||||||
// Reproduces the CSS message assertions from devtools/shared/webconsole/test/chrome/test_page_errors.html
|
// Reproduces the CSS message assertions from devtools/shared/webconsole/test/chrome/test_page_errors.html
|
||||||
|
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
const { MESSAGE_CATEGORY } = require("devtools/shared/constants");
|
const { MESSAGE_CATEGORY } = require("devtools/shared/constants");
|
||||||
|
|
||||||
// Create a simple server so we have a nice sourceName in the resources packets.
|
// Create a simple server so we have a nice sourceName in the resources packets.
|
||||||
@@ -35,7 +38,7 @@ async function testWatchingCssMessages() {
|
|||||||
// Open a test tab
|
// Open a test tab
|
||||||
const tab = await addTab(TEST_URI);
|
const tab = await addTab(TEST_URI);
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -45,12 +48,12 @@ async function testWatchingCssMessages() {
|
|||||||
receivedMessages,
|
receivedMessages,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.CSS_MESSAGE], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.CSS_MESSAGE], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
|
|
||||||
info(
|
info(
|
||||||
"Now log CSS warning *after* the call to ResourceCommand.watchResources and after " +
|
"Now log CSS warning *after* the call to ResourceWatcher.watchResources and after " +
|
||||||
"having received the existing message"
|
"having received the existing message"
|
||||||
);
|
);
|
||||||
// We need to wait for the first CSS Warning as it is not a cached message; when we
|
// We need to wait for the first CSS Warning as it is not a cached message; when we
|
||||||
@@ -98,7 +101,7 @@ async function testWatchingCachedCssMessages() {
|
|||||||
|
|
||||||
// At this point, all messages should be in the ConsoleService cache, and we can begin
|
// 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.
|
// to watch and check that we do retrieve those messages.
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -108,7 +111,7 @@ async function testWatchingCachedCssMessages() {
|
|||||||
receivedMessages,
|
receivedMessages,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.CSS_MESSAGE], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.CSS_MESSAGE], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
is(receivedMessages.length, 3, "Cached messages were retrieved as expected");
|
is(receivedMessages.length, 3, "Cached messages were retrieved as expected");
|
||||||
@@ -3,7 +3,11 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Test the ResourceCommand API around DOCUMENT_EVENT
|
// Test the ResourceWatcher API around DOCUMENT_EVENT
|
||||||
|
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
await testDocumentEventResources();
|
await testDocumentEventResources();
|
||||||
@@ -16,13 +20,13 @@ add_task(async function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function testDocumentEventResources() {
|
async function testDocumentEventResources() {
|
||||||
info("Test ResourceCommand for DOCUMENT_EVENT");
|
info("Test ResourceWatcher for DOCUMENT_EVENT");
|
||||||
|
|
||||||
// Open a test tab
|
// Open a test tab
|
||||||
const tab = await addTab("data:text/html,Document Events");
|
const tab = await addTab("data:text/html,Document Events");
|
||||||
|
|
||||||
const listener = new ResourceListener();
|
const listener = new ResourceListener();
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -32,7 +36,7 @@ async function testDocumentEventResources() {
|
|||||||
const onLoadingAtInit = listener.once("dom-loading");
|
const onLoadingAtInit = listener.once("dom-loading");
|
||||||
const onInteractiveAtInit = listener.once("dom-interactive");
|
const onInteractiveAtInit = listener.once("dom-interactive");
|
||||||
const onCompleteAtInit = listener.once("dom-complete");
|
const onCompleteAtInit = listener.once("dom-complete");
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.DOCUMENT_EVENT], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.DOCUMENT_EVENT], {
|
||||||
onAvailable: parameters => listener.dispatch(parameters),
|
onAvailable: parameters => listener.dispatch(parameters),
|
||||||
});
|
});
|
||||||
await assertPromises(onLoadingAtInit, onInteractiveAtInit, onCompleteAtInit);
|
await assertPromises(onLoadingAtInit, onInteractiveAtInit, onCompleteAtInit);
|
||||||
@@ -75,13 +79,13 @@ async function testDocumentEventResourcesWithIgnoreExistingResources() {
|
|||||||
|
|
||||||
const tab = await addTab("data:text/html,Document Events");
|
const tab = await addTab("data:text/html,Document Events");
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
info("Check whether the existing document events will not be fired");
|
info("Check whether the existing document events will not be fired");
|
||||||
const documentEvents = [];
|
const documentEvents = [];
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.DOCUMENT_EVENT], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.DOCUMENT_EVENT], {
|
||||||
onAvailable: resources => documentEvents.push(...resources),
|
onAvailable: resources => documentEvents.push(...resources),
|
||||||
ignoreExistingResources: true,
|
ignoreExistingResources: true,
|
||||||
});
|
});
|
||||||
@@ -102,12 +106,12 @@ async function testCrossOriginNavigation() {
|
|||||||
|
|
||||||
const tab = await addTab("http://example.com/document-builder.sjs?html=com");
|
const tab = await addTab("http://example.com/document-builder.sjs?html=com");
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
const documentEvents = [];
|
const documentEvents = [];
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.DOCUMENT_EVENT], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.DOCUMENT_EVENT], {
|
||||||
onAvailable: resources => documentEvents.push(...resources),
|
onAvailable: resources => documentEvents.push(...resources),
|
||||||
ignoreExistingResources: true,
|
ignoreExistingResources: true,
|
||||||
});
|
});
|
||||||
@@ -3,9 +3,13 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Test the ResourceCommand API around ERROR_MESSAGE
|
// Test the ResourceWatcher API around ERROR_MESSAGE
|
||||||
// Reproduces assertions from devtools/shared/webconsole/test/chrome/test_page_errors.html
|
// Reproduces assertions from devtools/shared/webconsole/test/chrome/test_page_errors.html
|
||||||
|
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
// Create a simple server so we have a nice sourceName in the resources packets.
|
// Create a simple server so we have a nice sourceName in the resources packets.
|
||||||
const httpServer = createTestHTTPServer();
|
const httpServer = createTestHTTPServer();
|
||||||
httpServer.registerPathHandler(`/test_page_errors.html`, (req, res) => {
|
httpServer.registerPathHandler(`/test_page_errors.html`, (req, res) => {
|
||||||
@@ -28,7 +32,7 @@ async function testErrorMessagesResources() {
|
|||||||
// Open a test tab
|
// Open a test tab
|
||||||
const tab = await addTab(TEST_URI);
|
const tab = await addTab(TEST_URI);
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -39,7 +43,7 @@ async function testErrorMessagesResources() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
info(
|
info(
|
||||||
"Log some errors *before* calling ResourceCommand.watchResources in order to assert" +
|
"Log some errors *before* calling ResourceWatcher.watchResources in order to assert" +
|
||||||
" the behavior of already existing messages."
|
" the behavior of already existing messages."
|
||||||
);
|
);
|
||||||
await triggerErrors(tab);
|
await triggerErrors(tab);
|
||||||
@@ -82,7 +86,7 @@ async function testErrorMessagesResources() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.ERROR_MESSAGE], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -91,7 +95,7 @@ async function testErrorMessagesResources() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
info(
|
info(
|
||||||
"Now log errors *after* the call to ResourceCommand.watchResources and after having" +
|
"Now log errors *after* the call to ResourceWatcher.watchResources and after having" +
|
||||||
" received all existing messages"
|
" received all existing messages"
|
||||||
);
|
);
|
||||||
await triggerErrors(tab);
|
await triggerErrors(tab);
|
||||||
@@ -109,7 +113,7 @@ async function testErrorMessagesResourcesWithIgnoreExistingResources() {
|
|||||||
info("Test ignoreExistingResources option for ERROR_MESSAGE");
|
info("Test ignoreExistingResources option for ERROR_MESSAGE");
|
||||||
const tab = await addTab(TEST_URI);
|
const tab = await addTab(TEST_URI);
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -119,7 +123,7 @@ async function testErrorMessagesResourcesWithIgnoreExistingResources() {
|
|||||||
await triggerErrors(tab);
|
await triggerErrors(tab);
|
||||||
|
|
||||||
const availableResources = [];
|
const availableResources = [];
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.ERROR_MESSAGE], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||||
onAvailable: resources => availableResources.push(...resources),
|
onAvailable: resources => availableResources.push(...resources),
|
||||||
ignoreExistingResources: true,
|
ignoreExistingResources: true,
|
||||||
});
|
});
|
||||||
@@ -3,20 +3,24 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Test getAllResources function of the ResourceCommand.
|
// Test getAllResources function of the ResourceWatcher.
|
||||||
|
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const TEST_URI = "data:text/html;charset=utf-8,getAllResources test";
|
const TEST_URI = "data:text/html;charset=utf-8,getAllResources test";
|
||||||
|
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
const tab = await addTab(TEST_URI);
|
const tab = await addTab(TEST_URI);
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
info("Check the resources gotten from getAllResources at initial");
|
info("Check the resources gotten from getAllResources at initial");
|
||||||
is(
|
is(
|
||||||
resourceCommand.getAllResources(resourceCommand.TYPES.CONSOLE_MESSAGE)
|
resourceWatcher.getAllResources(ResourceWatcher.TYPES.CONSOLE_MESSAGE)
|
||||||
.length,
|
.length,
|
||||||
0,
|
0,
|
||||||
"There is no resources at initial"
|
"There is no resources at initial"
|
||||||
@@ -27,8 +31,8 @@ add_task(async function() {
|
|||||||
);
|
);
|
||||||
const availableResources = [];
|
const availableResources = [];
|
||||||
const onAvailable = resources => availableResources.push(...resources);
|
const onAvailable = resources => availableResources.push(...resources);
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.CONSOLE_MESSAGE],
|
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||||
{ onAvailable }
|
{ onAvailable }
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -37,11 +41,11 @@ add_task(async function() {
|
|||||||
await logMessages(tab.linkedBrowser, messages);
|
await logMessages(tab.linkedBrowser, messages);
|
||||||
await waitUntil(() => availableResources.length >= messages.length);
|
await waitUntil(() => availableResources.length >= messages.length);
|
||||||
assertResources(
|
assertResources(
|
||||||
resourceCommand.getAllResources(resourceCommand.TYPES.CONSOLE_MESSAGE),
|
resourceWatcher.getAllResources(ResourceWatcher.TYPES.CONSOLE_MESSAGE),
|
||||||
availableResources
|
availableResources
|
||||||
);
|
);
|
||||||
assertResources(
|
assertResources(
|
||||||
resourceCommand.getAllResources(resourceCommand.TYPES.STYLESHEET),
|
resourceWatcher.getAllResources(ResourceWatcher.TYPES.STYLESHEET),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -50,7 +54,7 @@ add_task(async function() {
|
|||||||
gBrowser.reloadTab(tab);
|
gBrowser.reloadTab(tab);
|
||||||
await onReloaded;
|
await onReloaded;
|
||||||
assertResources(
|
assertResources(
|
||||||
resourceCommand.getAllResources(resourceCommand.TYPES.CONSOLE_MESSAGE),
|
resourceWatcher.getAllResources(ResourceWatcher.TYPES.CONSOLE_MESSAGE),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -58,16 +62,16 @@ add_task(async function() {
|
|||||||
await logMessages(tab.linkedBrowser, messages);
|
await logMessages(tab.linkedBrowser, messages);
|
||||||
await waitUntil(
|
await waitUntil(
|
||||||
() =>
|
() =>
|
||||||
resourceCommand.getAllResources(resourceCommand.TYPES.CONSOLE_MESSAGE)
|
resourceWatcher.getAllResources(ResourceWatcher.TYPES.CONSOLE_MESSAGE)
|
||||||
.length === messages.length
|
.length === messages.length
|
||||||
);
|
);
|
||||||
|
|
||||||
info("Check the resources after unwatching");
|
info("Check the resources after unwatching");
|
||||||
resourceCommand.unwatchResources([resourceCommand.TYPES.CONSOLE_MESSAGE], {
|
resourceWatcher.unwatchResources([ResourceWatcher.TYPES.CONSOLE_MESSAGE], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
assertResources(
|
assertResources(
|
||||||
resourceCommand.getAllResources(resourceCommand.TYPES.CONSOLE_MESSAGE),
|
resourceWatcher.getAllResources(ResourceWatcher.TYPES.CONSOLE_MESSAGE),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -3,7 +3,11 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Test the ResourceCommand API around NETWORK_EVENT_STACKTRACE
|
// Test the ResourceWatcher API around NETWORK_EVENT_STACKTRACE
|
||||||
|
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const TEST_URI = `${URL_ROOT_SSL}network_document.html`;
|
const TEST_URI = `${URL_ROOT_SSL}network_document.html`;
|
||||||
|
|
||||||
@@ -13,7 +17,7 @@ const REQUEST_STUB = {
|
|||||||
stacktraceAvailable: true,
|
stacktraceAvailable: true,
|
||||||
lastFrame: {
|
lastFrame: {
|
||||||
filename:
|
filename:
|
||||||
"https://example.com/browser/devtools/shared/commands/resource/tests/network_document.html",
|
"https://example.com/browser/devtools/shared/resources/tests/network_document.html",
|
||||||
lineNumber: 1,
|
lineNumber: 1,
|
||||||
columnNumber: 40,
|
columnNumber: 40,
|
||||||
functionName: "triggerRequest",
|
functionName: "triggerRequest",
|
||||||
@@ -25,7 +29,7 @@ const REQUEST_STUB = {
|
|||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
info("Test network stacktraces events");
|
info("Test network stacktraces events");
|
||||||
const tab = await addTab(TEST_URI);
|
const tab = await addTab(TEST_URI);
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -35,7 +39,7 @@ add_task(async function() {
|
|||||||
function onResourceAvailable(resources) {
|
function onResourceAvailable(resources) {
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
if (
|
if (
|
||||||
resource.resourceType === resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE
|
resource.resourceType === ResourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE
|
||||||
) {
|
) {
|
||||||
ok(
|
ok(
|
||||||
!networkEvents.has(resource.resourceId),
|
!networkEvents.has(resource.resourceId),
|
||||||
@@ -57,7 +61,7 @@ add_task(async function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resource.resourceType === resourceCommand.TYPES.NETWORK_EVENT) {
|
if (resource.resourceType === ResourceWatcher.TYPES.NETWORK_EVENT) {
|
||||||
ok(
|
ok(
|
||||||
stackTraces.has(resource.stacktraceResourceId),
|
stackTraces.has(resource.stacktraceResourceId),
|
||||||
"The stack trace does exists"
|
"The stack trace does exists"
|
||||||
@@ -70,10 +74,10 @@ add_task(async function() {
|
|||||||
|
|
||||||
function onResourceUpdated() {}
|
function onResourceUpdated() {}
|
||||||
|
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[
|
[
|
||||||
resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
ResourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||||
resourceCommand.TYPES.NETWORK_EVENT,
|
ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onAvailable: onResourceAvailable,
|
onAvailable: onResourceAvailable,
|
||||||
@@ -83,10 +87,10 @@ add_task(async function() {
|
|||||||
|
|
||||||
await triggerNetworkRequests(tab.linkedBrowser, [REQUEST_STUB.code]);
|
await triggerNetworkRequests(tab.linkedBrowser, [REQUEST_STUB.code]);
|
||||||
|
|
||||||
resourceCommand.unwatchResources(
|
resourceWatcher.unwatchResources(
|
||||||
[
|
[
|
||||||
resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
|
ResourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
|
||||||
resourceCommand.TYPES.NETWORK_EVENT,
|
ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onAvailable: onResourceAvailable,
|
onAvailable: onResourceAvailable,
|
||||||
@@ -2,10 +2,11 @@
|
|||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
// Test the ResourceWatcher API around NETWORK_EVENT
|
||||||
|
|
||||||
// Test the ResourceCommand API around NETWORK_EVENT
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const EXAMPLE_DOMAIN = "https://example.com/";
|
const EXAMPLE_DOMAIN = "https://example.com/";
|
||||||
const TEST_URI = `${URL_ROOT_SSL}network_document.html`;
|
const TEST_URI = `${URL_ROOT_SSL}network_document.html`;
|
||||||
@@ -28,17 +29,17 @@ async function testNetworkEventResourcesWithExistingResources() {
|
|||||||
totalExpectedOnUpdatedCounts: 1,
|
totalExpectedOnUpdatedCounts: 1,
|
||||||
expectedResourcesOnAvailable: {
|
expectedResourcesOnAvailable: {
|
||||||
[`${EXAMPLE_DOMAIN}cached_post.html`]: {
|
[`${EXAMPLE_DOMAIN}cached_post.html`]: {
|
||||||
resourceType: ResourceCommand.TYPES.NETWORK_EVENT,
|
resourceType: ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
},
|
},
|
||||||
[`${EXAMPLE_DOMAIN}live_get.html`]: {
|
[`${EXAMPLE_DOMAIN}live_get.html`]: {
|
||||||
resourceType: ResourceCommand.TYPES.NETWORK_EVENT,
|
resourceType: ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResourcesOnUpdated: {
|
expectedResourcesOnUpdated: {
|
||||||
[`${EXAMPLE_DOMAIN}live_get.html`]: {
|
[`${EXAMPLE_DOMAIN}live_get.html`]: {
|
||||||
resourceType: ResourceCommand.TYPES.NETWORK_EVENT,
|
resourceType: ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -55,13 +56,13 @@ async function testNetworkEventResourcesWithoutExistingResources() {
|
|||||||
totalExpectedOnUpdatedCounts: 1,
|
totalExpectedOnUpdatedCounts: 1,
|
||||||
expectedResourcesOnAvailable: {
|
expectedResourcesOnAvailable: {
|
||||||
[`${EXAMPLE_DOMAIN}live_get.html`]: {
|
[`${EXAMPLE_DOMAIN}live_get.html`]: {
|
||||||
resourceType: ResourceCommand.TYPES.NETWORK_EVENT,
|
resourceType: ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResourcesOnUpdated: {
|
expectedResourcesOnUpdated: {
|
||||||
[`${EXAMPLE_DOMAIN}live_get.html`]: {
|
[`${EXAMPLE_DOMAIN}live_get.html`]: {
|
||||||
resourceType: ResourceCommand.TYPES.NETWORK_EVENT,
|
resourceType: ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -70,12 +71,12 @@ async function testNetworkEventResourcesWithoutExistingResources() {
|
|||||||
|
|
||||||
async function testNetworkEventResources(options) {
|
async function testNetworkEventResources(options) {
|
||||||
const tab = await addTab(TEST_URI);
|
const tab = await addTab(TEST_URI);
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
info(
|
info(
|
||||||
`Trigger some network requests *before* calling ResourceCommand.watchResources
|
`Trigger some network requests *before* calling ResourceWatcher.watchResources
|
||||||
in order to assert the behavior of already existing network events.`
|
in order to assert the behavior of already existing network events.`
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -83,12 +84,12 @@ async function testNetworkEventResources(options) {
|
|||||||
let onResourceUpdated = () => {};
|
let onResourceUpdated = () => {};
|
||||||
|
|
||||||
// Lets make sure there is already a network event resource in the cache.
|
// Lets make sure there is already a network event resource in the cache.
|
||||||
const waitOnRequestForResourceCommandCache = new Promise(resolve => {
|
const waitOnRequestForResourceWatcherCache = new Promise(resolve => {
|
||||||
onResourceAvailable = resources => {
|
onResourceAvailable = resources => {
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
is(
|
is(
|
||||||
resource.resourceType,
|
resource.resourceType,
|
||||||
resourceCommand.TYPES.NETWORK_EVENT,
|
ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
"Received a network event resource"
|
"Received a network event resource"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -98,15 +99,15 @@ async function testNetworkEventResources(options) {
|
|||||||
for (const { resource } of updates) {
|
for (const { resource } of updates) {
|
||||||
is(
|
is(
|
||||||
resource.resourceType,
|
resource.resourceType,
|
||||||
resourceCommand.TYPES.NETWORK_EVENT,
|
ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
"Received a network update event resource"
|
"Received a network update event resource"
|
||||||
);
|
);
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resourceCommand
|
resourceWatcher
|
||||||
.watchResources([resourceCommand.TYPES.NETWORK_EVENT], {
|
.watchResources([ResourceWatcher.TYPES.NETWORK_EVENT], {
|
||||||
onAvailable: onResourceAvailable,
|
onAvailable: onResourceAvailable,
|
||||||
onUpdated: onResourceUpdated,
|
onUpdated: onResourceUpdated,
|
||||||
})
|
})
|
||||||
@@ -117,7 +118,7 @@ async function testNetworkEventResources(options) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
await waitOnRequestForResourceCommandCache;
|
await waitOnRequestForResourceWatcherCache;
|
||||||
|
|
||||||
const actualResourcesOnAvailable = {};
|
const actualResourcesOnAvailable = {};
|
||||||
const actualResourcesOnUpdated = {};
|
const actualResourcesOnUpdated = {};
|
||||||
@@ -142,7 +143,7 @@ async function testNetworkEventResources(options) {
|
|||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
is(
|
is(
|
||||||
resource.resourceType,
|
resource.resourceType,
|
||||||
resourceCommand.TYPES.NETWORK_EVENT,
|
ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
"Received a network event resource"
|
"Received a network event resource"
|
||||||
);
|
);
|
||||||
actualResourcesOnAvailable[resource.url] = {
|
actualResourcesOnAvailable[resource.url] = {
|
||||||
@@ -158,7 +159,7 @@ async function testNetworkEventResources(options) {
|
|||||||
for (const { resource } of updates) {
|
for (const { resource } of updates) {
|
||||||
is(
|
is(
|
||||||
resource.resourceType,
|
resource.resourceType,
|
||||||
resourceCommand.TYPES.NETWORK_EVENT,
|
ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
"Received a network update event resource"
|
"Received a network update event resource"
|
||||||
);
|
);
|
||||||
actualResourcesOnUpdated[resource.url] = {
|
actualResourcesOnUpdated[resource.url] = {
|
||||||
@@ -170,14 +171,14 @@ async function testNetworkEventResources(options) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.NETWORK_EVENT], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.NETWORK_EVENT], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
onUpdated,
|
onUpdated,
|
||||||
ignoreExistingResources,
|
ignoreExistingResources,
|
||||||
});
|
});
|
||||||
|
|
||||||
info(
|
info(
|
||||||
`Trigger the rest of the requests *after* calling ResourceCommand.watchResources
|
`Trigger the rest of the requests *after* calling ResourceWatcher.watchResources
|
||||||
in order to assert the behavior of live network events.`
|
in order to assert the behavior of live network events.`
|
||||||
);
|
);
|
||||||
await triggerNetworkRequests(tab.linkedBrowser, [liveRequest]);
|
await triggerNetworkRequests(tab.linkedBrowser, [liveRequest]);
|
||||||
@@ -223,8 +224,8 @@ async function testNetworkEventResources(options) {
|
|||||||
assertResources(actual, expected);
|
assertResources(actual, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
await resourceCommand.unwatchResources(
|
await resourceWatcher.unwatchResources(
|
||||||
[resourceCommand.TYPES.NETWORK_EVENT],
|
[ResourceWatcher.TYPES.NETWORK_EVENT],
|
||||||
{
|
{
|
||||||
onAvailable,
|
onAvailable,
|
||||||
onUpdated,
|
onUpdated,
|
||||||
@@ -232,8 +233,8 @@ async function testNetworkEventResources(options) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
await resourceCommand.unwatchResources(
|
await resourceWatcher.unwatchResources(
|
||||||
[resourceCommand.TYPES.NETWORK_EVENT],
|
[ResourceWatcher.TYPES.NETWORK_EVENT],
|
||||||
{
|
{
|
||||||
onAvailable: onResourceAvailable,
|
onAvailable: onResourceAvailable,
|
||||||
onUpdated: onResourceUpdated,
|
onUpdated: onResourceUpdated,
|
||||||
@@ -263,7 +264,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
|
|||||||
const allResourcesOnUpdate = [];
|
const allResourcesOnUpdate = [];
|
||||||
|
|
||||||
const tab = await addTab(CSP_URL);
|
const tab = await addTab(CSP_URL);
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -286,8 +287,8 @@ async function testNetworkEventResourcesFromTheContentProcess() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resourceCommand
|
resourceWatcher
|
||||||
.watchResources([resourceCommand.TYPES.NETWORK_EVENT], {
|
.watchResources([ResourceWatcher.TYPES.NETWORK_EVENT], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
onUpdated,
|
onUpdated,
|
||||||
})
|
})
|
||||||
@@ -316,7 +317,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
|
|||||||
// Assert the data for the CSP blocked JS script file
|
// Assert the data for the CSP blocked JS script file
|
||||||
is(
|
is(
|
||||||
availableJSResource.resourceType,
|
availableJSResource.resourceType,
|
||||||
resourceCommand.TYPES.NETWORK_EVENT,
|
ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
"This is a network event resource"
|
"This is a network event resource"
|
||||||
);
|
);
|
||||||
is(
|
is(
|
||||||
@@ -327,7 +328,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
|
|||||||
|
|
||||||
is(
|
is(
|
||||||
updateJSResource.resourceType,
|
updateJSResource.resourceType,
|
||||||
resourceCommand.TYPES.NETWORK_EVENT,
|
ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
"This is a network event resource"
|
"This is a network event resource"
|
||||||
);
|
);
|
||||||
is(
|
is(
|
||||||
@@ -348,7 +349,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
|
|||||||
// Assert the data for the CSP blocked CSS file
|
// Assert the data for the CSP blocked CSS file
|
||||||
is(
|
is(
|
||||||
availableCSSResource.resourceType,
|
availableCSSResource.resourceType,
|
||||||
resourceCommand.TYPES.NETWORK_EVENT,
|
ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
"This is a network event resource"
|
"This is a network event resource"
|
||||||
);
|
);
|
||||||
is(
|
is(
|
||||||
@@ -359,7 +360,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
|
|||||||
|
|
||||||
is(
|
is(
|
||||||
updateCSSResource.resourceType,
|
updateCSSResource.resourceType,
|
||||||
resourceCommand.TYPES.NETWORK_EVENT,
|
ResourceWatcher.TYPES.NETWORK_EVENT,
|
||||||
"This is a network event resource"
|
"This is a network event resource"
|
||||||
);
|
);
|
||||||
is(
|
is(
|
||||||
@@ -368,8 +369,8 @@ async function testNetworkEventResourcesFromTheContentProcess() {
|
|||||||
"The css resource is blocked by CSP"
|
"The css resource is blocked by CSP"
|
||||||
);
|
);
|
||||||
|
|
||||||
await resourceCommand.unwatchResources(
|
await resourceWatcher.unwatchResources(
|
||||||
[resourceCommand.TYPES.NETWORK_EVENT],
|
[ResourceWatcher.TYPES.NETWORK_EVENT],
|
||||||
{
|
{
|
||||||
onAvailable,
|
onAvailable,
|
||||||
onUpdated,
|
onUpdated,
|
||||||
@@ -3,9 +3,13 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Test the ResourceCommand API around PLATFORM_MESSAGE
|
// Test the ResourceWatcher API around PLATFORM_MESSAGE
|
||||||
// Reproduces assertions from: devtools/shared/webconsole/test/chrome/test_nsiconsolemessage.html
|
// Reproduces assertions from: devtools/shared/webconsole/test/chrome/test_nsiconsolemessage.html
|
||||||
|
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
// Disable the preloaded process as it creates processes intermittently
|
// Disable the preloaded process as it creates processes intermittently
|
||||||
// which forces the emission of RDP requests we aren't correctly waiting for.
|
// which forces the emission of RDP requests we aren't correctly waiting for.
|
||||||
@@ -18,9 +22,9 @@ add_task(async function() {
|
|||||||
async function testPlatformMessagesResources() {
|
async function testPlatformMessagesResources() {
|
||||||
const {
|
const {
|
||||||
client,
|
client,
|
||||||
resourceCommand,
|
resourceWatcher,
|
||||||
targetCommand,
|
targetCommand,
|
||||||
} = await initMultiProcessResourceCommand();
|
} = await initMultiProcessResourceWatcher();
|
||||||
|
|
||||||
const cachedMessages = [
|
const cachedMessages = [
|
||||||
"This is a cached message",
|
"This is a cached message",
|
||||||
@@ -34,7 +38,7 @@ async function testPlatformMessagesResources() {
|
|||||||
const receivedMessages = [];
|
const receivedMessages = [];
|
||||||
|
|
||||||
info(
|
info(
|
||||||
"Log some messages *before* calling ResourceCommand.watchResources in order to assert the behavior of already existing messages."
|
"Log some messages *before* calling ResourceWatcher.watchResources in order to assert the behavior of already existing messages."
|
||||||
);
|
);
|
||||||
Services.console.logStringMessage(expectedMessages[0]);
|
Services.console.logStringMessage(expectedMessages[0]);
|
||||||
Services.console.logStringMessage(expectedMessages[1]);
|
Services.console.logStringMessage(expectedMessages[1]);
|
||||||
@@ -78,15 +82,15 @@ async function testPlatformMessagesResources() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.PLATFORM_MESSAGE],
|
[ResourceWatcher.TYPES.PLATFORM_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable,
|
onAvailable,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
info(
|
info(
|
||||||
"Now log messages *after* the call to ResourceCommand.watchResources and after having received all existing messages"
|
"Now log messages *after* the call to ResourceWatcher.watchResources and after having received all existing messages"
|
||||||
);
|
);
|
||||||
Services.console.logStringMessage(expectedMessages[2]);
|
Services.console.logStringMessage(expectedMessages[2]);
|
||||||
Services.console.logStringMessage(expectedMessages[3]);
|
Services.console.logStringMessage(expectedMessages[3]);
|
||||||
@@ -103,9 +107,9 @@ async function testPlatformMessagesResources() {
|
|||||||
async function testPlatformMessagesResourcesWithIgnoreExistingResources() {
|
async function testPlatformMessagesResourcesWithIgnoreExistingResources() {
|
||||||
const {
|
const {
|
||||||
client,
|
client,
|
||||||
resourceCommand,
|
resourceWatcher,
|
||||||
targetCommand,
|
targetCommand,
|
||||||
} = await initMultiProcessResourceCommand();
|
} = await initMultiProcessResourceWatcher();
|
||||||
|
|
||||||
info(
|
info(
|
||||||
"Check whether onAvailable will not be called with existing platform messages"
|
"Check whether onAvailable will not be called with existing platform messages"
|
||||||
@@ -115,8 +119,8 @@ async function testPlatformMessagesResourcesWithIgnoreExistingResources() {
|
|||||||
Services.console.logStringMessage(expectedMessages[1]);
|
Services.console.logStringMessage(expectedMessages[1]);
|
||||||
|
|
||||||
const availableResources = [];
|
const availableResources = [];
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.PLATFORM_MESSAGE],
|
[ResourceWatcher.TYPES.PLATFORM_MESSAGE],
|
||||||
{
|
{
|
||||||
onAvailable: resources => {
|
onAvailable: resources => {
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
@@ -3,12 +3,16 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Test the ResourceCommand API around ROOT_NODE
|
// Test the ResourceWatcher API around ROOT_NODE
|
||||||
|
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The original test still asserts some scenarios using several watchRootNode
|
* 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
|
* call sites, which is not something we intend to support at the moment in the
|
||||||
* resource command.
|
* resource watcher.
|
||||||
*
|
*
|
||||||
* Otherwise this test checks the basic behavior of the resource when reloading
|
* Otherwise this test checks the basic behavior of the resource when reloading
|
||||||
* an empty page.
|
* an empty page.
|
||||||
@@ -17,7 +21,7 @@ add_task(async function() {
|
|||||||
// Open a test tab
|
// Open a test tab
|
||||||
const tab = await addTab("data:text/html,Root Node tests");
|
const tab = await addTab("data:text/html,Root Node tests");
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -26,7 +30,7 @@ add_task(async function() {
|
|||||||
info("Call watchResources([ROOT_NODE], ...)");
|
info("Call watchResources([ROOT_NODE], ...)");
|
||||||
let onAvailableCounter = 0;
|
let onAvailableCounter = 0;
|
||||||
const onAvailable = resources => (onAvailableCounter += resources.length);
|
const onAvailable = resources => (onAvailableCounter += resources.length);
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.ROOT_NODE], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ROOT_NODE], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -45,7 +49,7 @@ add_task(async function() {
|
|||||||
is(onAvailableCounter, 2, "onAvailable has been called 2 times");
|
is(onAvailableCounter, 2, "onAvailable has been called 2 times");
|
||||||
|
|
||||||
info("Call unwatchResources([ROOT_NODE], ...) for the onAvailable callback");
|
info("Call unwatchResources([ROOT_NODE], ...) for the onAvailable callback");
|
||||||
resourceCommand.unwatchResources([resourceCommand.TYPES.ROOT_NODE], {
|
resourceWatcher.unwatchResources([ResourceWatcher.TYPES.ROOT_NODE], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -71,7 +75,7 @@ add_task(async function() {
|
|||||||
add_task(async function testRootNodeFrontIsCorrect() {
|
add_task(async function testRootNodeFrontIsCorrect() {
|
||||||
const tab = await addTab("data:text/html,<div id=div1>");
|
const tab = await addTab("data:text/html,<div id=div1>");
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
const browser = gBrowser.selectedBrowser;
|
const browser = gBrowser.selectedBrowser;
|
||||||
@@ -81,7 +85,7 @@ add_task(async function testRootNodeFrontIsCorrect() {
|
|||||||
let rootNodeResolve;
|
let rootNodeResolve;
|
||||||
let rootNodePromise = new Promise(r => (rootNodeResolve = r));
|
let rootNodePromise = new Promise(r => (rootNodeResolve = r));
|
||||||
const onAvailable = ([rootNodeFront]) => rootNodeResolve(rootNodeFront);
|
const onAvailable = ([rootNodeFront]) => rootNodeResolve(rootNodeFront);
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.ROOT_NODE], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ROOT_NODE], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -90,7 +94,7 @@ add_task(async function testRootNodeFrontIsCorrect() {
|
|||||||
ok(!!root1, "onAvailable has been called with a valid argument");
|
ok(!!root1, "onAvailable has been called with a valid argument");
|
||||||
is(
|
is(
|
||||||
root1.resourceType,
|
root1.resourceType,
|
||||||
resourceCommand.TYPES.ROOT_NODE,
|
ResourceWatcher.TYPES.ROOT_NODE,
|
||||||
"The resource has the expected type"
|
"The resource has the expected type"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -117,7 +121,7 @@ add_task(async function testRootNodeFrontIsCorrect() {
|
|||||||
is(div3.getAttribute("id"), "div3", "Correct root node retrieved");
|
is(div3.getAttribute("id"), "div3", "Correct root node retrieved");
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
resourceCommand.unwatchResources([resourceCommand.TYPES.ROOT_NODE], {
|
resourceWatcher.unwatchResources([ResourceWatcher.TYPES.ROOT_NODE], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
targetCommand.destroy();
|
targetCommand.destroy();
|
||||||
@@ -2,10 +2,11 @@
|
|||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
// Test the ResourceWatcher API around SERVER SENT EVENTS.
|
||||||
|
|
||||||
// Test the ResourceCommand API around SERVER SENT EVENTS.
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const targets = {
|
const targets = {
|
||||||
TOP_LEVEL_DOCUMENT: "top-level-document",
|
TOP_LEVEL_DOCUMENT: "top-level-document",
|
||||||
@@ -25,7 +26,7 @@ add_task(async function() {
|
|||||||
async function testServerSentEventResources(target) {
|
async function testServerSentEventResources(target) {
|
||||||
const tab = await addTab(URL_ROOT + "sse_frontend.html");
|
const tab = await addTab(URL_ROOT + "sse_frontend.html");
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -35,8 +36,8 @@ async function testServerSentEventResources(target) {
|
|||||||
availableResources.push(...resources);
|
availableResources.push(...resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
await resourceCommand.watchResources(
|
await resourceWatcher.watchResources(
|
||||||
[resourceCommand.TYPES.SERVER_SENT_EVENT],
|
[ResourceWatcher.TYPES.SERVER_SENT_EVENT],
|
||||||
{ onAvailable: onResourceAvailable }
|
{ onAvailable: onResourceAvailable }
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -69,8 +70,8 @@ async function testServerSentEventResources(target) {
|
|||||||
httpChannelId,
|
httpChannelId,
|
||||||
});
|
});
|
||||||
|
|
||||||
await resourceCommand.unwatchResources(
|
await resourceWatcher.unwatchResources(
|
||||||
[resourceCommand.TYPES.SERVER_SENT_EVENT],
|
[ResourceWatcher.TYPES.SERVER_SENT_EVENT],
|
||||||
{ onAvailable: onResourceAvailable }
|
{ onAvailable: onResourceAvailable }
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -82,7 +83,7 @@ async function testServerSentEventResources(target) {
|
|||||||
function assertResource(resource, expected) {
|
function assertResource(resource, expected) {
|
||||||
is(
|
is(
|
||||||
resource.resourceType,
|
resource.resourceType,
|
||||||
ResourceCommand.TYPES.SERVER_SENT_EVENT,
|
ResourceWatcher.TYPES.SERVER_SENT_EVENT,
|
||||||
"Resource type is correct"
|
"Resource type is correct"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -3,8 +3,12 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that the resource command is still properly watching for new targets
|
* Check that the resource watcher is still properly watching for new targets
|
||||||
* after unwatching one resource, if there is still another watched resource.
|
* after unwatching one resource, if there is still another watched resource.
|
||||||
*/
|
*/
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
@@ -19,14 +23,14 @@ add_task(async function() {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
client,
|
client,
|
||||||
resourceCommand,
|
resourceWatcher,
|
||||||
targetCommand,
|
targetCommand,
|
||||||
} = await initMultiProcessResourceCommand();
|
} = await initMultiProcessResourceWatcher();
|
||||||
|
|
||||||
const { CONSOLE_MESSAGE, ROOT_NODE } = resourceCommand.TYPES;
|
const { CONSOLE_MESSAGE, ROOT_NODE } = ResourceWatcher.TYPES;
|
||||||
|
|
||||||
// We are only interested in console messages as a resource, the ROOT_NODE one
|
// We are only interested in console messages as a resource, the ROOT_NODE one
|
||||||
// is here to test the ResourceCommand::unwatchResources API with several resources.
|
// is here to test the ResourceWatcher::unwatchResources API with several resources.
|
||||||
const receivedMessages = [];
|
const receivedMessages = [];
|
||||||
const onAvailable = resources => {
|
const onAvailable = resources => {
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
@@ -37,7 +41,7 @@ add_task(async function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
info("Call watchResources([CONSOLE_MESSAGE, ROOT_NODE], ...)");
|
info("Call watchResources([CONSOLE_MESSAGE, ROOT_NODE], ...)");
|
||||||
await resourceCommand.watchResources([CONSOLE_MESSAGE, ROOT_NODE], {
|
await resourceWatcher.watchResources([CONSOLE_MESSAGE, ROOT_NODE], {
|
||||||
onAvailable,
|
onAvailable,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -52,7 +56,7 @@ add_task(async function() {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check that the resource command captures resources from new targets.
|
// Check that the resource watcher captures resources from new targets.
|
||||||
info("Open a first tab on the example.com domain");
|
info("Open a first tab on the example.com domain");
|
||||||
const comTab = await addTab(
|
const comTab = await addTab(
|
||||||
"http://example.com/document-builder.sjs?html=com"
|
"http://example.com/document-builder.sjs?html=com"
|
||||||
@@ -69,7 +73,7 @@ add_task(async function() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
info("Stop watching ROOT_NODE resources");
|
info("Stop watching ROOT_NODE resources");
|
||||||
await resourceCommand.unwatchResources([ROOT_NODE], { onAvailable });
|
await resourceWatcher.unwatchResources([ROOT_NODE], { onAvailable });
|
||||||
|
|
||||||
// Check that messages from new targets are still captured after calling
|
// Check that messages from new targets are still captured after calling
|
||||||
// unwatch for another resource.
|
// unwatch for another resource.
|
||||||
@@ -89,7 +93,7 @@ add_task(async function() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
info("Stop watching CONSOLE_MESSAGE resources");
|
info("Stop watching CONSOLE_MESSAGE resources");
|
||||||
await resourceCommand.unwatchResources([CONSOLE_MESSAGE], { onAvailable });
|
await resourceWatcher.unwatchResources([CONSOLE_MESSAGE], { onAvailable });
|
||||||
await logInTab(tab, "test-again");
|
await logInTab(tab, "test-again");
|
||||||
|
|
||||||
// We don't have a specific event to wait for here, so allow some time for
|
// We don't have a specific event to wait for here, so allow some time for
|
||||||
@@ -101,7 +105,7 @@ add_task(async function() {
|
|||||||
resource => resource.message.arguments[0] === "test-again"
|
resource => resource.message.arguments[0] === "test-again"
|
||||||
),
|
),
|
||||||
undefined,
|
undefined,
|
||||||
"The resource command should not watch CONSOLE_MESSAGE anymore"
|
"The resource watcher should not watch CONSOLE_MESSAGE anymore"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
@@ -3,9 +3,11 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Test the ResourceCommand API around SOURCE.
|
// Test the ResourceWatcher API around SOURCE.
|
||||||
|
|
||||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
const {
|
||||||
|
ResourceWatcher,
|
||||||
|
} = require("devtools/shared/resources/resource-watcher");
|
||||||
|
|
||||||
const TEST_URL = URL_ROOT_SSL + "sources.html";
|
const TEST_URL = URL_ROOT_SSL + "sources.html";
|
||||||
|
|
||||||
@@ -15,7 +17,7 @@ add_task(async function() {
|
|||||||
const htmlRequest = await fetch(TEST_URL);
|
const htmlRequest = await fetch(TEST_URL);
|
||||||
const htmlContent = await htmlRequest.text();
|
const htmlContent = await htmlRequest.text();
|
||||||
|
|
||||||
const { client, resourceCommand, targetCommand } = await initResourceCommand(
|
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||||
tab
|
tab
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -34,7 +36,7 @@ add_task(async function() {
|
|||||||
|
|
||||||
info("Check already available resources");
|
info("Check already available resources");
|
||||||
const availableResources = [];
|
const availableResources = [];
|
||||||
await resourceCommand.watchResources([resourceCommand.TYPES.SOURCE], {
|
await resourceWatcher.watchResources([ResourceWatcher.TYPES.SOURCE], {
|
||||||
onAvailable: resources => availableResources.push(...resources),
|
onAvailable: resources => availableResources.push(...resources),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -44,9 +46,9 @@ add_task(async function() {
|
|||||||
sourceForm: {
|
sourceForm: {
|
||||||
introductionType: "scriptElement",
|
introductionType: "scriptElement",
|
||||||
sourceMapBaseURL:
|
sourceMapBaseURL:
|
||||||
"https://example.com/browser/devtools/shared/commands/resource/tests/sources.js",
|
"https://example.com/browser/devtools/shared/resources/tests/sources.js",
|
||||||
url:
|
url:
|
||||||
"https://example.com/browser/devtools/shared/commands/resource/tests/sources.js",
|
"https://example.com/browser/devtools/shared/resources/tests/sources.js",
|
||||||
isBlackBoxed: false,
|
isBlackBoxed: false,
|
||||||
sourceMapURL: null,
|
sourceMapURL: null,
|
||||||
extensionName: null,
|
extensionName: null,
|
||||||
@@ -61,7 +63,7 @@ add_task(async function() {
|
|||||||
sourceForm: {
|
sourceForm: {
|
||||||
introductionType: "eval",
|
introductionType: "eval",
|
||||||
sourceMapBaseURL:
|
sourceMapBaseURL:
|
||||||
"https://example.com/browser/devtools/shared/commands/resource/tests/sources.html",
|
"https://example.com/browser/devtools/shared/resources/tests/sources.html",
|
||||||
url: null,
|
url: null,
|
||||||
isBlackBoxed: false,
|
isBlackBoxed: false,
|
||||||
sourceMapURL: null,
|
sourceMapURL: null,
|
||||||
@@ -77,9 +79,9 @@ add_task(async function() {
|
|||||||
sourceForm: {
|
sourceForm: {
|
||||||
introductionType: "scriptElement",
|
introductionType: "scriptElement",
|
||||||
sourceMapBaseURL:
|
sourceMapBaseURL:
|
||||||
"https://example.com/browser/devtools/shared/commands/resource/tests/sources.html",
|
"https://example.com/browser/devtools/shared/resources/tests/sources.html",
|
||||||
url:
|
url:
|
||||||
"https://example.com/browser/devtools/shared/commands/resource/tests/sources.html",
|
"https://example.com/browser/devtools/shared/resources/tests/sources.html",
|
||||||
isBlackBoxed: false,
|
isBlackBoxed: false,
|
||||||
sourceMapURL: null,
|
sourceMapURL: null,
|
||||||
extensionName: null,
|
extensionName: null,
|
||||||
@@ -94,9 +96,9 @@ add_task(async function() {
|
|||||||
sourceForm: {
|
sourceForm: {
|
||||||
introductionType: undefined,
|
introductionType: undefined,
|
||||||
sourceMapBaseURL:
|
sourceMapBaseURL:
|
||||||
"https://example.com/browser/devtools/shared/commands/resource/tests/worker-sources.js",
|
"https://example.com/browser/devtools/shared/resources/tests/worker-sources.js",
|
||||||
url:
|
url:
|
||||||
"https://example.com/browser/devtools/shared/commands/resource/tests/worker-sources.js",
|
"https://example.com/browser/devtools/shared/resources/tests/worker-sources.js",
|
||||||
isBlackBoxed: false,
|
isBlackBoxed: false,
|
||||||
sourceMapURL: null,
|
sourceMapURL: null,
|
||||||
extensionName: null,
|
extensionName: null,
|
||||||
@@ -111,9 +113,9 @@ add_task(async function() {
|
|||||||
sourceForm: {
|
sourceForm: {
|
||||||
introductionType: undefined,
|
introductionType: undefined,
|
||||||
sourceMapBaseURL:
|
sourceMapBaseURL:
|
||||||
"https://example.com/browser/devtools/shared/commands/resource/tests/service-worker-sources.js",
|
"https://example.com/browser/devtools/shared/resources/tests/service-worker-sources.js",
|
||||||
url:
|
url:
|
||||||
"https://example.com/browser/devtools/shared/commands/resource/tests/service-worker-sources.js",
|
"https://example.com/browser/devtools/shared/resources/tests/service-worker-sources.js",
|
||||||
isBlackBoxed: false,
|
isBlackBoxed: false,
|
||||||
sourceMapURL: null,
|
sourceMapURL: null,
|
||||||
extensionName: null,
|
extensionName: null,
|
||||||
@@ -152,7 +154,7 @@ async function assertResource(source, expected) {
|
|||||||
|
|
||||||
is(
|
is(
|
||||||
source.resourceType,
|
source.resourceType,
|
||||||
ResourceCommand.TYPES.SOURCE,
|
ResourceWatcher.TYPES.SOURCE,
|
||||||
"Resource type is correct"
|
"Resource type is correct"
|
||||||
);
|
);
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user