зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1701790 - Mass replace ResourceWatcher by ResourceCommand r=nchevobbe
$ sed -i 's/ResourceWatcher/ResourceCommand/g' $(egrep -rl 'ResourceWatcher' devtools/) Differential Revision: https://phabricator.services.mozilla.com/D113932
This commit is contained in:
Родитель
a5dbcad9f2
Коммит
eecbcc37c6
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// The target front holds resources that happend before ResourceWatcher addeed listeners.
|
||||
// The target front holds resources that happend before ResourceCommand addeed listeners.
|
||||
// Test whether that feature works correctly or not.
|
||||
const TEST_URI =
|
||||
"http://example.com/browser/devtools/client/framework/test/doc_cached-resource.html";
|
||||
|
|
|
@ -56,7 +56,7 @@ class InspectorFront extends FrontClassWithSpec(inspectorSpec) {
|
|||
// watcher and assume we're already watching for stylesheets).
|
||||
const { resourceWatcher } = this.targetFront;
|
||||
if (
|
||||
resourceWatcher?.hasResourceWatcherSupport(
|
||||
resourceWatcher?.hasResourceCommandSupport(
|
||||
resourceWatcher.TYPES.STYLESHEET
|
||||
)
|
||||
) {
|
||||
|
|
|
@ -330,7 +330,7 @@ function getAdHocFrontOrPrimitiveGrip(packet, parentFront) {
|
|||
// actorID, unless:
|
||||
// - it's a Symbol (See Bug 1600299)
|
||||
// - 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 ResourceWatcher)
|
||||
// - or it is already a front (happens when we are using the legacy listeners in the ResourceCommand)
|
||||
const isPacketAnObject = packet && typeof packet === "object";
|
||||
const isFront = !!packet.typeName;
|
||||
if (
|
||||
|
|
|
@ -112,7 +112,7 @@ class StyleRuleFront extends FrontClassWithSpec(styleRuleSpec) {
|
|||
get parentStyleSheet() {
|
||||
const resourceWatcher = this.targetFront.resourceWatcher;
|
||||
if (
|
||||
resourceWatcher?.hasResourceWatcherSupport(
|
||||
resourceWatcher?.hasResourceCommandSupport(
|
||||
resourceWatcher.TYPES.STYLESHEET
|
||||
)
|
||||
) {
|
||||
|
|
|
@ -52,8 +52,8 @@ function TargetMixin(parentClass) {
|
|||
this.fronts = new Map();
|
||||
|
||||
// `resource-available-form` and `resource-updated-form` events can be emitted
|
||||
// by target actors before the ResourceWatcher could add event listeners.
|
||||
// The target front will cache those events until the ResourceWatcher has
|
||||
// by target actors before the ResourceCommand could add event listeners.
|
||||
// The target front will cache those events until the ResourceCommand has
|
||||
// added the listeners.
|
||||
this._resourceCache = {};
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class WalkerFront extends FrontClassWithSpec(walkerSpec) {
|
|||
this.before("new-mutations", this.onMutations.bind(this));
|
||||
|
||||
// Those events will be emitted if watchRootNode was called on the
|
||||
// corresponding WalkerActor, which should be handled by the ResourceWatcher
|
||||
// corresponding WalkerActor, which should be handled by the ResourceCommand
|
||||
// as long as a consumer is watching for root-node resources.
|
||||
// This should be fixed by using watchResources directly from the walker
|
||||
// front, either with the ROOT_NODE resource, or with the DOCUMENT_EVENT
|
||||
|
|
|
@ -521,7 +521,7 @@ class FirefoxDataProvider {
|
|||
let response;
|
||||
if (
|
||||
clientMethodName == "getStackTrace" &&
|
||||
this.resourceWatcher.hasResourceWatcherSupport(
|
||||
this.resourceWatcher.hasResourceCommandSupport(
|
||||
this.resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE
|
||||
)
|
||||
) {
|
||||
|
|
|
@ -54,8 +54,8 @@ class Connector {
|
|||
return this.commands.targetCommand.targetFront;
|
||||
}
|
||||
|
||||
get hasResourceWatcherSupport() {
|
||||
return this.toolbox.resourceWatcher.hasResourceWatcherSupport(
|
||||
get hasResourceCommandSupport() {
|
||||
return this.toolbox.resourceWatcher.hasResourceCommandSupport(
|
||||
this.toolbox.resourceWatcher.TYPES.NETWORK_EVENT
|
||||
);
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ class Connector {
|
|||
|
||||
// Initialize Responsive Emulation front for network throttling.
|
||||
this.responsiveFront = await this.currentTarget.getFront("responsive");
|
||||
if (this.hasResourceWatcherSupport) {
|
||||
if (this.hasResourceCommandSupport) {
|
||||
this.networkFront = await this.watcherFront.getNetworkParentActor();
|
||||
}
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ class Connector {
|
|||
* @param {object} data data payload would like to sent to backend
|
||||
*/
|
||||
async sendHTTPRequest(data) {
|
||||
if (this.hasResourceWatcherSupport && this.currentTarget) {
|
||||
if (this.hasResourceCommandSupport && this.currentTarget) {
|
||||
const networkContentFront = await this.currentTarget.getFront(
|
||||
"networkContent"
|
||||
);
|
||||
|
@ -425,7 +425,7 @@ class Connector {
|
|||
* Get the list of blocked URLs
|
||||
*/
|
||||
async getBlockedUrls() {
|
||||
if (this.hasResourceWatcherSupport && this.networkFront) {
|
||||
if (this.hasResourceCommandSupport && this.networkFront) {
|
||||
return this.networkFront.getBlockedUrls();
|
||||
}
|
||||
if (!this.webConsoleFront.traits.blockedUrls) {
|
||||
|
@ -440,7 +440,7 @@ class Connector {
|
|||
* @param {object} urls An array of URL strings
|
||||
*/
|
||||
async setBlockedUrls(urls) {
|
||||
if (this.hasResourceWatcherSupport && this.networkFront) {
|
||||
if (this.hasResourceCommandSupport && this.networkFront) {
|
||||
return this.networkFront.setBlockedUrls(urls);
|
||||
}
|
||||
return this.webConsoleFront.setBlockedUrls(urls);
|
||||
|
@ -578,7 +578,7 @@ class Connector {
|
|||
|
||||
async updateNetworkThrottling(enabled, profile) {
|
||||
const throttlingFront =
|
||||
this.hasResourceWatcherSupport && this.networkFront
|
||||
this.hasResourceCommandSupport && this.networkFront
|
||||
? this.networkFront
|
||||
: this.responsiveFront;
|
||||
|
||||
|
|
|
@ -1194,10 +1194,10 @@ function getCurrentTestFilePath() {
|
|||
/**
|
||||
* Wait for a single resource of the provided resourceType.
|
||||
*
|
||||
* @param {ResourceWatcher} resourceWatcher
|
||||
* The ResourceWatcher instance that should emit the expected resource.
|
||||
* @param {ResourceCommand} resourceWatcher
|
||||
* The ResourceCommand instance that should emit the expected resource.
|
||||
* @param {String} resourceType
|
||||
* One of ResourceWatcher.TYPES, type of the expected resource.
|
||||
* One of ResourceCommand.TYPES, type of the expected resource.
|
||||
* @param {Object} additional options
|
||||
* - {Boolean} ignoreExistingResources: ignore existing resources or not.
|
||||
* - {Function} predicate: if provided, will wait until a resource makes
|
||||
|
|
|
@ -256,7 +256,7 @@ StyleEditorUI.prototype = {
|
|||
async _onOrigSourcesPrefChanged() {
|
||||
this._clear();
|
||||
// When we toggle the source-map preference, we clear the panel and re-fetch the exact
|
||||
// same stylesheet resources from ResourceWatcher, but `_addStyleSheet` will trigger
|
||||
// same stylesheet resources from ResourceCommand, but `_addStyleSheet` will trigger
|
||||
// or ignore the additional source-map mapping.
|
||||
this._root.classList.add("loading");
|
||||
for (const resource of this._toolbox.resourceWatcher.getAllResources(
|
||||
|
|
|
@ -171,12 +171,12 @@ function handleHelperResult(response) {
|
|||
return async ({ dispatch, hud, toolbox, webConsoleUI }) => {
|
||||
const { result, helperResult } = response;
|
||||
const helperHasRawOutput = !!helperResult?.rawOutput;
|
||||
const hasNetworkResourceWatcherSupport = hud.resourceWatcher.hasResourceWatcherSupport(
|
||||
const hasNetworkResourceCommandSupport = hud.resourceWatcher.hasResourceCommandSupport(
|
||||
hud.resourceWatcher.TYPES.NETWORK_EVENT
|
||||
);
|
||||
let networkFront = null;
|
||||
// @backward-compat { version 86 } default network events watcher support
|
||||
if (hasNetworkResourceWatcherSupport) {
|
||||
if (hasNetworkResourceCommandSupport) {
|
||||
networkFront = await hud.resourceWatcher.watcherFront.getNetworkParentActor();
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ function handleHelperResult(response) {
|
|||
// 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.
|
||||
// @backward-compat { version 86 } default network events watcher support
|
||||
if (hasNetworkResourceWatcherSupport && networkFront) {
|
||||
if (hasNetworkResourceCommandSupport && networkFront) {
|
||||
await networkFront.blockRequest({ url: blockURL });
|
||||
}
|
||||
toolbox
|
||||
|
@ -274,7 +274,7 @@ function handleHelperResult(response) {
|
|||
case "unblockURL":
|
||||
const unblockURL = helperResult.args.url;
|
||||
// @backward-compat { version 86 } see related comments in block url above
|
||||
if (hasNetworkResourceWatcherSupport && networkFront) {
|
||||
if (hasNetworkResourceCommandSupport && networkFront) {
|
||||
await networkFront.unblockRequest({ url: unblockURL });
|
||||
}
|
||||
toolbox
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
const {
|
||||
STUBS_UPDATE_ENV,
|
||||
createCommandsForTab,
|
||||
createResourceWatcherForCommands,
|
||||
getStubFile,
|
||||
getCleanedPacket,
|
||||
getSerializedPacket,
|
||||
|
@ -63,7 +62,8 @@ async function generateConsoleApiStubs() {
|
|||
|
||||
const tab = await addTab(TEST_URI);
|
||||
const commands = await createCommandsForTab(tab);
|
||||
const resourceWatcher = await createResourceWatcherForCommands(commands);
|
||||
await commands.targetCommand.startListening();
|
||||
const resourceWatcher = commands.resourceCommand;
|
||||
|
||||
// The resource-watcher only supports a single call to watch/unwatch per
|
||||
// instance, so we attach a unique watch callback, which will forward the
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
const {
|
||||
STUBS_UPDATE_ENV,
|
||||
createCommandsForTab,
|
||||
createResourceWatcherForCommands,
|
||||
getCleanedPacket,
|
||||
getStubFile,
|
||||
writeStubsToFile,
|
||||
|
@ -63,7 +62,8 @@ async function generateCssMessageStubs() {
|
|||
|
||||
const tab = await addTab(TEST_URI);
|
||||
const commands = await createCommandsForTab(tab);
|
||||
const resourceWatcher = await createResourceWatcherForCommands(commands);
|
||||
await commands.targetCommand.startListening();
|
||||
const resourceWatcher = commands.resourceCommand;
|
||||
|
||||
// The resource-watcher only supports a single call to watch/unwatch per
|
||||
// instance, so we attach a unique watch callback, which will forward the
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
const {
|
||||
createCommandsForTab,
|
||||
createResourceWatcherForCommands,
|
||||
STUBS_UPDATE_ENV,
|
||||
getStubFile,
|
||||
getCleanedPacket,
|
||||
|
@ -59,7 +58,9 @@ async function generateNetworkEventStubs() {
|
|||
const stubs = new Map();
|
||||
const tab = await addTab(TEST_URI);
|
||||
const commands = await createCommandsForTab(tab);
|
||||
const resourceWatcher = await createResourceWatcherForCommands(commands);
|
||||
await commands.targetCommand.startListening();
|
||||
const resourceWatcher = commands.resourceCommand;
|
||||
|
||||
const stacktraces = new Map();
|
||||
let addNetworkStub = function() {};
|
||||
let addNetworkUpdateStub = function() {};
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
const {
|
||||
STUBS_UPDATE_ENV,
|
||||
createCommandsForTab,
|
||||
createResourceWatcherForCommands,
|
||||
getCleanedPacket,
|
||||
getSerializedPacket,
|
||||
getStubFile,
|
||||
|
@ -65,7 +64,8 @@ async function generatePageErrorStubs() {
|
|||
|
||||
const tab = await addTab(TEST_URI);
|
||||
const commands = await createCommandsForTab(tab);
|
||||
const resourceWatcher = await createResourceWatcherForCommands(commands);
|
||||
await commands.targetCommand.startListening();
|
||||
const resourceWatcher = commands.resourceCommand;
|
||||
|
||||
// The resource-watcher only supports a single call to watch/unwatch per
|
||||
// instance, so we attach a unique watch callback, which will forward the
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
const {
|
||||
STUBS_UPDATE_ENV,
|
||||
createCommandsForMainProcess,
|
||||
createResourceWatcherForCommands,
|
||||
getCleanedPacket,
|
||||
getSerializedPacket,
|
||||
getStubFile,
|
||||
|
@ -61,7 +60,8 @@ async function generatePlatformMessagesStubs() {
|
|||
const stubs = new Map();
|
||||
|
||||
const commands = await createCommandsForMainProcess();
|
||||
const resourceWatcher = await createResourceWatcherForCommands(commands);
|
||||
await commands.targetCommand.startListening();
|
||||
const resourceWatcher = commands.resourceCommand;
|
||||
|
||||
// The resource-watcher only supports a single call to watch/unwatch per
|
||||
// instance, so we attach a unique watch callback, which will forward the
|
||||
|
|
|
@ -30,12 +30,6 @@ async function createCommandsForMainProcess() {
|
|||
return commands;
|
||||
}
|
||||
|
||||
// TODO: rename this method to createResourceCommandForCommands?
|
||||
async function createResourceWatcherForCommands(commands) {
|
||||
await commands.targetCommand.startListening();
|
||||
return commands.resourceCommand;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
function getCleanedPacket(key, packet) {
|
||||
const { stubPackets } = require(CHROME_PREFIX + STUBS_FOLDER + "index");
|
||||
|
@ -542,7 +536,6 @@ module.exports = {
|
|||
STUBS_UPDATE_ENV,
|
||||
createCommandsForTab,
|
||||
createCommandsForMainProcess,
|
||||
createResourceWatcherForCommands,
|
||||
getStubFile,
|
||||
getCleanedPacket,
|
||||
getSerializedPacket,
|
||||
|
|
|
@ -339,7 +339,7 @@ class WebConsoleUI {
|
|||
// We can call it from here, as `_attchTargets` is called after the UI is initialized.
|
||||
// Bug 1642599:
|
||||
// TargetCommand.startListening ought to be called before watching for resources,
|
||||
// in order to set TargetCommand.watcherFront which is used by ResourceWatcher.watchResources.
|
||||
// in order to set TargetCommand.watcherFront which is used by ResourceCommand.watchResources.
|
||||
await this.hud.commands.targetCommand.startListening();
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ const NetworkEventActor = protocol.ActorClassWithSpec(networkEventSpec, {
|
|||
* Returns a grip for this actor.
|
||||
*/
|
||||
asResource() {
|
||||
// The browsingContextID is used by the ResourceWatcher on the client
|
||||
// The browsingContextID is used by the ResourceCommand on the client
|
||||
// to find the related Target Front.
|
||||
const browsingContextID = this._browsingContextID
|
||||
? this._browsingContextID
|
||||
|
|
|
@ -52,7 +52,7 @@ class ContentProcessStorage {
|
|||
await this.actor.preListStores();
|
||||
}
|
||||
|
||||
// We have to manage the actor manually, because ResourceWatcher doesn't
|
||||
// We have to manage the actor manually, because ResourceCommand doesn't
|
||||
// use the protocol.js specification.
|
||||
// resource-available-form is typed as "json"
|
||||
// So that we have to manually handle stuff that would normally be
|
||||
|
|
|
@ -52,7 +52,7 @@ class ParentProcessStorage {
|
|||
await this.actor.preListStores();
|
||||
}
|
||||
|
||||
// We have to manage the actor manually, because ResourceWatcher doesn't
|
||||
// We have to manage the actor manually, because ResourceCommand doesn't
|
||||
// use the protocol.js specification.
|
||||
// resource-available-form is typed as "json"
|
||||
// So that we have to manually handle stuff that would normally be
|
||||
|
|
|
@ -3437,7 +3437,7 @@ function trimHttpHttpsPort(url) {
|
|||
*
|
||||
* This class is meant to be dropped once we implement all storage
|
||||
* types via a Watcher class. (bug 1644192)
|
||||
* listStores will have been replaced by the ResourceWatcher API
|
||||
* listStores will have been replaced by the ResourceCommand API
|
||||
* which will distribute all storage type specific actors.
|
||||
*/
|
||||
const StorageActor = protocol.ActorClassWithSpec(specs.storageSpec, {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
/* exported attachURL, promiseDone,
|
||||
promiseOnce,
|
||||
addTest, addAsyncTest,
|
||||
runNextTest, _documentWalker,
|
||||
createResourceWatcher */
|
||||
runNextTest, _documentWalker */
|
||||
"use strict";
|
||||
|
||||
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
|
||||
|
@ -130,8 +129,3 @@ function runNextTest() {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: renamed to createResourceCommand
|
||||
async function createResourceWatcher(commands) {
|
||||
return commands.resourceCommand;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ window.onload = function() {
|
|||
|
||||
let gWalker = null;
|
||||
let gDoc = null;
|
||||
let gResourceWatcher = null;
|
||||
let gResourceCommand = null;
|
||||
let gRootNodeResolve = null;
|
||||
|
||||
async function reloadTarget() {
|
||||
|
@ -36,12 +36,12 @@ addAsyncTest(async function() {
|
|||
gDoc = doc;
|
||||
const inspector = await target.getFront("inspector");
|
||||
gWalker = inspector.walker;
|
||||
gResourceWatcher = await createResourceWatcher(commands);
|
||||
gResourceCommand = commands.resourceCommand;
|
||||
|
||||
info("Start watching for root nodes and wait for the initial root node");
|
||||
const rootNodePromise = new Promise(r => (gRootNodeResolve = r));
|
||||
const onAvailable = rootNodeFront => gRootNodeResolve(rootNodeFront);
|
||||
await gResourceWatcher.watchResources([gResourceWatcher.TYPES.ROOT_NODE], {
|
||||
await gResourceCommand.watchResources([gResourceCommand.TYPES.ROOT_NODE], {
|
||||
onAvailable,
|
||||
});
|
||||
await rootNodePromise;
|
||||
|
@ -315,7 +315,7 @@ addAsyncTest(async function() {
|
|||
addTest(function cleanup() {
|
||||
gWalker = null;
|
||||
gDoc = null;
|
||||
gResourceWatcher = null;
|
||||
gResourceCommand = null;
|
||||
runNextTest();
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -20,7 +20,7 @@ window.onload = function() {
|
|||
|
||||
let gInspectee = null;
|
||||
let gWalker = null;
|
||||
let gResourceWatcher = null;
|
||||
let gResourceCommand = null;
|
||||
|
||||
addTest(async function setup() {
|
||||
const url = document.getElementById("inspectorContent").href;
|
||||
|
@ -30,7 +30,7 @@ addTest(async function setup() {
|
|||
gInspectee = doc;
|
||||
const walker = inspector.walker;
|
||||
gWalker = await inspector.getWalker();
|
||||
gResourceWatcher = await createResourceWatcher(commands);
|
||||
gResourceCommand = commands.resourceCommand;
|
||||
|
||||
ok(walker === gWalker, "getWalker() twice should return the same walker.");
|
||||
runNextTest();
|
||||
|
@ -43,7 +43,7 @@ addTest(async function testReload() {
|
|||
let rootNodeResolve;
|
||||
let rootNodePromise = new Promise(r => (rootNodeResolve = r));
|
||||
const onAvailable = rootNodeFront => rootNodeResolve(rootNodeFront);
|
||||
await gResourceWatcher.watchResources([gResourceWatcher.TYPES.ROOT_NODE], {
|
||||
await gResourceCommand.watchResources([gResourceCommand.TYPES.ROOT_NODE], {
|
||||
onAvailable,
|
||||
});
|
||||
await rootNodePromise;
|
||||
|
@ -69,7 +69,7 @@ addTest(async function testReload() {
|
|||
addTest(function cleanup() {
|
||||
gWalker = null;
|
||||
gInspectee = null;
|
||||
gResourceWatcher = null;
|
||||
gResourceCommand = null;
|
||||
runNextTest();
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -25,9 +25,9 @@ addTest(async function setup() {
|
|||
const url = document.getElementById("inspectorContent").href;
|
||||
const { commands, target } = await attachURL(url);
|
||||
|
||||
// We need an active resource watcher before initializing the inspector front.
|
||||
const resourceWatcher = await createResourceWatcher(commands);
|
||||
// We don't listen for specific resources, we only need to trigger the resource watcher
|
||||
// We need an active resource command before initializing the inspector front.
|
||||
const resourceWatcher = commands.resourceCommand;
|
||||
// We don't listen for specific resources, we only need to trigger the resource command
|
||||
// onTargetAvailable callback so the resourceWatcher is set on the target front.
|
||||
await resourceWatcher.watchResources([], { onAvailable: () => {} });
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ addTest(async function setup() {
|
|||
const { commands, target, doc } = await attachURL(url);
|
||||
gInspectee = doc;
|
||||
|
||||
// We need an active resource watcher before initializing the inspector front.
|
||||
const resourceWatcher = await createResourceWatcher(commands);
|
||||
// We don't listen for specific resources, we only need to trigger the resource watcher
|
||||
// We need an active resource command before initializing the inspector front.
|
||||
const resourceWatcher = commands.resourceCommand;
|
||||
// We don't listen for specific resources, we only need to trigger the resource command
|
||||
// onTargetAvailable callback so the resourceWatcher is set on the target front.
|
||||
await resourceWatcher.watchResources([], { onAvailable: () => {} });
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ add_task(
|
|||
};
|
||||
|
||||
// And then listen for resource RDP event.
|
||||
// Bug 1646677: But we should probably migrate this test to ResourceWatcher so that
|
||||
// Bug 1646677: But we should probably migrate this test to ResourceCommand so that
|
||||
// we don't have to hack the server side via Resource.watchResources call.
|
||||
targetActor.on("resource-available-form", resources => {
|
||||
if (resources[0].resourceType == Resources.TYPES.CONSOLE_MESSAGE) {
|
||||
|
|
|
@ -23,7 +23,7 @@ add_task(
|
|||
};
|
||||
|
||||
// And then listen for resource RDP event.
|
||||
// Bug 1646677: But we should probably migrate this test to ResourceWatcher so that
|
||||
// Bug 1646677: But we should probably migrate this test to ResourceCommand so that
|
||||
// we don't have to hack the server side via Resource.watchResources call.
|
||||
targetActor.on("resource-available-form", resources => {
|
||||
if (resources[0].resourceType == Resources.TYPES.CONSOLE_MESSAGE) {
|
||||
|
|
|
@ -23,7 +23,7 @@ add_task(
|
|||
};
|
||||
|
||||
// And then listen for resource RDP event.
|
||||
// Bug 1646677: But we should probably migrate this test to ResourceWatcher so that
|
||||
// Bug 1646677: But we should probably migrate this test to ResourceCommand so that
|
||||
// we don't have to hack the server side via Resource.watchResources call.
|
||||
targetActor.on("resource-available-form", resources => {
|
||||
if (resources[0].resourceType == Resources.TYPES.CONSOLE_MESSAGE) {
|
||||
|
|
|
@ -326,7 +326,7 @@ class TargetCommand extends EventEmitter {
|
|||
}
|
||||
|
||||
// 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 ResourceWatcher after this.
|
||||
// This `watcherFront` attribute may be then used in any function in TargetCommand or ResourceCommand after this.
|
||||
if (!this.watcherFront) {
|
||||
// Bug 1675763: Watcher actor is not available in all situations yet.
|
||||
const supportsWatcher = this.descriptorFront.traits?.watcher;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around CONSOLE_MESSAGE for the whole browser
|
||||
// Test the ResourceCommand API around CONSOLE_MESSAGE for the whole browser
|
||||
|
||||
const TEST_URL = URL_ROOT_SSL + "early_console_document.html";
|
||||
|
||||
|
@ -15,10 +15,10 @@ add_task(async function() {
|
|||
client,
|
||||
resourceWatcher,
|
||||
targetCommand,
|
||||
} = await initMultiProcessResourceWatcher();
|
||||
} = await initMultiProcessResourceCommand();
|
||||
|
||||
info(
|
||||
"Log some messages *before* calling ResourceWatcher.watchResources in order to " +
|
||||
"Log some messages *before* calling ResourceCommand.watchResources in order to " +
|
||||
"assert the behavior of already existing messages."
|
||||
);
|
||||
console.log("foobar");
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the cache mechanism of the ResourceWatcher.
|
||||
// Test the cache mechanism of the ResourceCommand.
|
||||
|
||||
const TEST_URI = "data:text/html;charset=utf-8,Cache Test";
|
||||
|
||||
|
@ -12,7 +12,7 @@ add_task(async function() {
|
|||
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -52,7 +52,7 @@ add_task(async function() {
|
|||
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -98,7 +98,7 @@ add_task(async function() {
|
|||
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -128,7 +128,7 @@ add_task(async function() {
|
|||
}
|
||||
);
|
||||
|
||||
is(cachedResources.length, 0, "The cache in ResourceWatcher is cleared");
|
||||
is(cachedResources.length, 0, "The cache in ResourceCommand is cleared");
|
||||
|
||||
targetCommand.destroy();
|
||||
await client.close();
|
||||
|
@ -139,7 +139,7 @@ add_task(async function() {
|
|||
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -201,7 +201,7 @@ add_task(async function() {
|
|||
async function testIgnoreExistingResources(isFirstListenerIgnoreExisting) {
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -266,7 +266,7 @@ add_task(async function() {
|
|||
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around CONSOLE_MESSAGE
|
||||
// Test the ResourceCommand API around CONSOLE_MESSAGE
|
||||
//
|
||||
// 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
|
||||
|
@ -25,12 +25,12 @@ add_task(async function() {
|
|||
async function testTabConsoleMessagesResources(executeInIframe) {
|
||||
const tab = await addTab(FISSION_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
info(
|
||||
"Log some messages *before* calling ResourceWatcher.watchResources in order to " +
|
||||
"Log some messages *before* calling ResourceCommand.watchResources in order to " +
|
||||
"assert the behavior of already existing messages."
|
||||
);
|
||||
await logExistingMessages(tab.linkedBrowser, executeInIframe);
|
||||
|
@ -90,7 +90,7 @@ async function testTabConsoleMessagesResources(executeInIframe) {
|
|||
);
|
||||
|
||||
info(
|
||||
"Now log messages *after* the call to ResourceWatcher.watchResources and after having received all existing messages"
|
||||
"Now log messages *after* the call to ResourceCommand.watchResources and after having received all existing messages"
|
||||
);
|
||||
await logRuntimeMessages(tab.linkedBrowser, executeInIframe);
|
||||
|
||||
|
@ -119,7 +119,7 @@ async function testTabConsoleMessagesResourcesWithIgnoreExistingResources(
|
|||
info("Test ignoreExistingResources option for console messages");
|
||||
const tab = await addTab(FISSION_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around CONSOLE_MESSAGE in workers
|
||||
// Test the ResourceCommand API around CONSOLE_MESSAGE in workers
|
||||
|
||||
const FISSION_TEST_URL = URL_ROOT_SSL + "fission_document.html";
|
||||
const WORKER_FILE = "test_worker.js";
|
||||
|
@ -20,7 +20,7 @@ add_task(async function() {
|
|||
client,
|
||||
resourceWatcher,
|
||||
targetCommand,
|
||||
} = await initResourceWatcher(tab, { listenForWorkers: true });
|
||||
} = await initResourceCommand(tab, { listenForWorkers: true });
|
||||
|
||||
info("Wait for the workers (from the main page and the iframe) to be ready");
|
||||
const targets = [];
|
||||
|
@ -80,7 +80,7 @@ add_task(async function() {
|
|||
let messageCount = resources.length;
|
||||
|
||||
info(
|
||||
"Now log messages *after* the call to ResourceWatcher.watchResources and after having received all existing messages"
|
||||
"Now log messages *after* the call to ResourceCommand.watchResources and after having received all existing messages"
|
||||
);
|
||||
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], () => {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around CSS_CHANGE.
|
||||
// Test the ResourceCommand API around CSS_CHANGE.
|
||||
|
||||
add_task(async function() {
|
||||
// Open a test tab
|
||||
|
@ -11,7 +11,7 @@ add_task(async function() {
|
|||
"data:text/html,<body style='color: lime;'>CSS Changes</body>"
|
||||
);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -31,7 +31,7 @@ add_task(async function() {
|
|||
)[0];
|
||||
|
||||
info(
|
||||
"Check whether ResourceWatcher catches CSS change that fired before starting to watch"
|
||||
"Check whether ResourceCommand catches CSS change that fired before starting to watch"
|
||||
);
|
||||
await setProperty(style.rule, 0, "color", "black");
|
||||
|
||||
|
@ -46,7 +46,7 @@ add_task(async function() {
|
|||
);
|
||||
|
||||
info(
|
||||
"Check whether ResourceWatcher catches CSS change after the property changed"
|
||||
"Check whether ResourceCommand catches CSS change after the property changed"
|
||||
);
|
||||
await setProperty(style.rule, 0, "background-color", "pink");
|
||||
await waitUntil(() => availableResources.length === 2);
|
||||
|
@ -56,7 +56,7 @@ add_task(async function() {
|
|||
{ index: 0, property: "color", value: "black" }
|
||||
);
|
||||
|
||||
info("Check whether ResourceWatcher catches CSS change of disabling");
|
||||
info("Check whether ResourceCommand catches CSS change of disabling");
|
||||
await setPropertyEnabled(style.rule, 0, "background-color", false);
|
||||
await waitUntil(() => availableResources.length === 3);
|
||||
assertResource(availableResources[2], null, {
|
||||
|
@ -65,7 +65,7 @@ add_task(async function() {
|
|||
value: "pink",
|
||||
});
|
||||
|
||||
info("Check whether ResourceWatcher catches CSS change of new property");
|
||||
info("Check whether ResourceCommand catches CSS change of new property");
|
||||
await createProperty(style.rule, 1, "font-size", "100px");
|
||||
await waitUntil(() => availableResources.length === 4);
|
||||
assertResource(
|
||||
|
@ -74,7 +74,7 @@ add_task(async function() {
|
|||
null
|
||||
);
|
||||
|
||||
info("Check whether ResourceWatcher sends all resources added in this test");
|
||||
info("Check whether ResourceCommand sends all resources added in this test");
|
||||
const existingResources = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_CHANGE], {
|
||||
onAvailable: resources => existingResources.push(...resources),
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around CSS_MESSAGE
|
||||
// Test the ResourceCommand API around CSS_MESSAGE
|
||||
// Reproduces the CSS message assertions from devtools/shared/webconsole/test/chrome/test_page_errors.html
|
||||
|
||||
const { MESSAGE_CATEGORY } = require("devtools/shared/constants");
|
||||
|
@ -35,7 +35,7 @@ async function testWatchingCssMessages() {
|
|||
// Open a test tab
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -50,7 +50,7 @@ async function testWatchingCssMessages() {
|
|||
});
|
||||
|
||||
info(
|
||||
"Now log CSS warning *after* the call to ResourceWatcher.watchResources and after " +
|
||||
"Now log CSS warning *after* the call to ResourceCommand.watchResources and after " +
|
||||
"having received the existing message"
|
||||
);
|
||||
// We need to wait for the first CSS Warning as it is not a cached message; when we
|
||||
|
@ -98,7 +98,7 @@ async function testWatchingCachedCssMessages() {
|
|||
|
||||
// At this point, all messages should be in the ConsoleService cache, and we can begin
|
||||
// to watch and check that we do retrieve those messages.
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around DOCUMENT_EVENT
|
||||
// Test the ResourceCommand API around DOCUMENT_EVENT
|
||||
|
||||
add_task(async function() {
|
||||
await testDocumentEventResources();
|
||||
|
@ -16,13 +16,13 @@ add_task(async function() {
|
|||
});
|
||||
|
||||
async function testDocumentEventResources() {
|
||||
info("Test ResourceWatcher for DOCUMENT_EVENT");
|
||||
info("Test ResourceCommand for DOCUMENT_EVENT");
|
||||
|
||||
// Open a test tab
|
||||
const tab = await addTab("data:text/html,Document Events");
|
||||
|
||||
const listener = new ResourceListener();
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -75,7 +75,7 @@ async function testDocumentEventResourcesWithIgnoreExistingResources() {
|
|||
|
||||
const tab = await addTab("data:text/html,Document Events");
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -102,7 +102,7 @@ async function testCrossOriginNavigation() {
|
|||
|
||||
const tab = await addTab("http://example.com/document-builder.sjs?html=com");
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around ERROR_MESSAGE
|
||||
// Test the ResourceCommand API around ERROR_MESSAGE
|
||||
// Reproduces assertions from devtools/shared/webconsole/test/chrome/test_page_errors.html
|
||||
|
||||
// Create a simple server so we have a nice sourceName in the resources packets.
|
||||
|
@ -28,7 +28,7 @@ async function testErrorMessagesResources() {
|
|||
// Open a test tab
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -39,7 +39,7 @@ async function testErrorMessagesResources() {
|
|||
);
|
||||
|
||||
info(
|
||||
"Log some errors *before* calling ResourceWatcher.watchResources in order to assert" +
|
||||
"Log some errors *before* calling ResourceCommand.watchResources in order to assert" +
|
||||
" the behavior of already existing messages."
|
||||
);
|
||||
await triggerErrors(tab);
|
||||
|
@ -91,7 +91,7 @@ async function testErrorMessagesResources() {
|
|||
);
|
||||
|
||||
info(
|
||||
"Now log errors *after* the call to ResourceWatcher.watchResources and after having" +
|
||||
"Now log errors *after* the call to ResourceCommand.watchResources and after having" +
|
||||
" received all existing messages"
|
||||
);
|
||||
await triggerErrors(tab);
|
||||
|
@ -109,7 +109,7 @@ async function testErrorMessagesResourcesWithIgnoreExistingResources() {
|
|||
info("Test ignoreExistingResources option for ERROR_MESSAGE");
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test getAllResources function of the ResourceWatcher.
|
||||
// Test getAllResources function of the ResourceCommand.
|
||||
|
||||
const TEST_URI = "data:text/html;charset=utf-8,getAllResources test";
|
||||
|
||||
add_task(async function() {
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around NETWORK_EVENT_STACKTRACE
|
||||
// Test the ResourceCommand API around NETWORK_EVENT_STACKTRACE
|
||||
|
||||
const TEST_URI = `${URL_ROOT_SSL}network_document.html`;
|
||||
|
||||
|
@ -25,7 +25,7 @@ const REQUEST_STUB = {
|
|||
add_task(async function() {
|
||||
info("Test network stacktraces events");
|
||||
const tab = await addTab(TEST_URI);
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around NETWORK_EVENT
|
||||
// Test the ResourceCommand API around NETWORK_EVENT
|
||||
|
||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
||||
|
||||
|
@ -70,12 +70,12 @@ async function testNetworkEventResourcesWithoutExistingResources() {
|
|||
|
||||
async function testNetworkEventResources(options) {
|
||||
const tab = await addTab(TEST_URI);
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
info(
|
||||
`Trigger some network requests *before* calling ResourceWatcher.watchResources
|
||||
`Trigger some network requests *before* calling ResourceCommand.watchResources
|
||||
in order to assert the behavior of already existing network events.`
|
||||
);
|
||||
|
||||
|
@ -83,7 +83,7 @@ async function testNetworkEventResources(options) {
|
|||
let onResourceUpdated = () => {};
|
||||
|
||||
// Lets make sure there is already a network event resource in the cache.
|
||||
const waitOnRequestForResourceWatcherCache = new Promise(resolve => {
|
||||
const waitOnRequestForResourceCommandCache = new Promise(resolve => {
|
||||
onResourceAvailable = resources => {
|
||||
for (const resource of resources) {
|
||||
is(
|
||||
|
@ -117,7 +117,7 @@ async function testNetworkEventResources(options) {
|
|||
});
|
||||
});
|
||||
|
||||
await waitOnRequestForResourceWatcherCache;
|
||||
await waitOnRequestForResourceCommandCache;
|
||||
|
||||
const actualResourcesOnAvailable = {};
|
||||
const actualResourcesOnUpdated = {};
|
||||
|
@ -177,7 +177,7 @@ async function testNetworkEventResources(options) {
|
|||
});
|
||||
|
||||
info(
|
||||
`Trigger the rest of the requests *after* calling ResourceWatcher.watchResources
|
||||
`Trigger the rest of the requests *after* calling ResourceCommand.watchResources
|
||||
in order to assert the behavior of live network events.`
|
||||
);
|
||||
await triggerNetworkRequests(tab.linkedBrowser, [liveRequest]);
|
||||
|
@ -263,7 +263,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
|
|||
const allResourcesOnUpdate = [];
|
||||
|
||||
const tab = await addTab(CSP_URL);
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around PLATFORM_MESSAGE
|
||||
// Test the ResourceCommand API around PLATFORM_MESSAGE
|
||||
// Reproduces assertions from: devtools/shared/webconsole/test/chrome/test_nsiconsolemessage.html
|
||||
|
||||
add_task(async function() {
|
||||
|
@ -20,7 +20,7 @@ async function testPlatformMessagesResources() {
|
|||
client,
|
||||
resourceWatcher,
|
||||
targetCommand,
|
||||
} = await initMultiProcessResourceWatcher();
|
||||
} = await initMultiProcessResourceCommand();
|
||||
|
||||
const cachedMessages = [
|
||||
"This is a cached message",
|
||||
|
@ -34,7 +34,7 @@ async function testPlatformMessagesResources() {
|
|||
const receivedMessages = [];
|
||||
|
||||
info(
|
||||
"Log some messages *before* calling ResourceWatcher.watchResources in order to assert the behavior of already existing messages."
|
||||
"Log some messages *before* calling ResourceCommand.watchResources in order to assert the behavior of already existing messages."
|
||||
);
|
||||
Services.console.logStringMessage(expectedMessages[0]);
|
||||
Services.console.logStringMessage(expectedMessages[1]);
|
||||
|
@ -86,7 +86,7 @@ async function testPlatformMessagesResources() {
|
|||
);
|
||||
|
||||
info(
|
||||
"Now log messages *after* the call to ResourceWatcher.watchResources and after having received all existing messages"
|
||||
"Now log messages *after* the call to ResourceCommand.watchResources and after having received all existing messages"
|
||||
);
|
||||
Services.console.logStringMessage(expectedMessages[2]);
|
||||
Services.console.logStringMessage(expectedMessages[3]);
|
||||
|
@ -105,7 +105,7 @@ async function testPlatformMessagesResourcesWithIgnoreExistingResources() {
|
|||
client,
|
||||
resourceWatcher,
|
||||
targetCommand,
|
||||
} = await initMultiProcessResourceWatcher();
|
||||
} = await initMultiProcessResourceCommand();
|
||||
|
||||
info(
|
||||
"Check whether onAvailable will not be called with existing platform messages"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around ROOT_NODE
|
||||
// Test the ResourceCommand API around ROOT_NODE
|
||||
|
||||
/**
|
||||
* The original test still asserts some scenarios using several watchRootNode
|
||||
|
@ -17,7 +17,7 @@ add_task(async function() {
|
|||
// Open a test tab
|
||||
const tab = await addTab("data:text/html,Root Node tests");
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -71,7 +71,7 @@ add_task(async function() {
|
|||
add_task(async function testRootNodeFrontIsCorrect() {
|
||||
const tab = await addTab("data:text/html,<div id=div1>");
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
const browser = gBrowser.selectedBrowser;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around SERVER SENT EVENTS.
|
||||
// Test the ResourceCommand API around SERVER SENT EVENTS.
|
||||
|
||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
||||
|
||||
|
@ -25,7 +25,7 @@ add_task(async function() {
|
|||
async function testServerSentEventResources(target) {
|
||||
const tab = await addTab(URL_ROOT + "sse_frontend.html");
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
|
|
@ -21,12 +21,12 @@ add_task(async function() {
|
|||
client,
|
||||
resourceWatcher,
|
||||
targetCommand,
|
||||
} = await initMultiProcessResourceWatcher();
|
||||
} = await initMultiProcessResourceCommand();
|
||||
|
||||
const { CONSOLE_MESSAGE, ROOT_NODE } = resourceWatcher.TYPES;
|
||||
|
||||
// We are only interested in console messages as a resource, the ROOT_NODE one
|
||||
// is here to test the ResourceWatcher::unwatchResources API with several resources.
|
||||
// is here to test the ResourceCommand::unwatchResources API with several resources.
|
||||
const receivedMessages = [];
|
||||
const onAvailable = resources => {
|
||||
for (const resource of resources) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around SOURCE.
|
||||
// Test the ResourceCommand API around SOURCE.
|
||||
|
||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
||||
|
||||
|
@ -15,7 +15,7 @@ add_task(async function() {
|
|||
const htmlRequest = await fetch(TEST_URL);
|
||||
const htmlContent = await htmlRequest.text();
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around STYLESHEET.
|
||||
// Test the ResourceCommand API around STYLESHEET.
|
||||
|
||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
||||
|
||||
|
@ -99,15 +99,15 @@ add_task(async function() {
|
|||
});
|
||||
|
||||
async function testResourceAvailableFeature() {
|
||||
info("Check resource available feature of the ResourceWatcher");
|
||||
info("Check resource available feature of the ResourceCommand");
|
||||
|
||||
const tab = await addTab(STYLE_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
info("Check whether ResourceWatcher gets existing stylesheet");
|
||||
info("Check whether ResourceCommand gets existing stylesheet");
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.STYLESHEET], {
|
||||
onAvailable: resources => availableResources.push(...resources),
|
||||
|
@ -127,7 +127,7 @@ async function testResourceAvailableFeature() {
|
|||
await assertResource(availableResource, expectedResource);
|
||||
}
|
||||
|
||||
info("Check whether ResourceWatcher gets additonal stylesheet");
|
||||
info("Check whether ResourceCommand gets additonal stylesheet");
|
||||
await ContentTask.spawn(
|
||||
tab.linkedBrowser,
|
||||
ADDITIONAL_RESOURCE.styleText,
|
||||
|
@ -147,7 +147,7 @@ async function testResourceAvailableFeature() {
|
|||
);
|
||||
|
||||
info(
|
||||
"Check whether ResourceWatcher gets additonal stylesheet which is added by DevTool"
|
||||
"Check whether ResourceCommand gets additonal stylesheet which is added by DevTool"
|
||||
);
|
||||
const styleSheetsFront = await targetCommand.targetFront.getFront(
|
||||
"stylesheets"
|
||||
|
@ -168,11 +168,11 @@ async function testResourceAvailableFeature() {
|
|||
}
|
||||
|
||||
async function testResourceUpdateFeature() {
|
||||
info("Check resource update feature of the ResourceWatcher");
|
||||
info("Check resource update feature of the ResourceCommand");
|
||||
|
||||
const tab = await addTab(STYLE_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -300,7 +300,7 @@ async function testResourceUpdateFeature() {
|
|||
}
|
||||
|
||||
async function testNestedResourceUpdateFeature() {
|
||||
info("Check nested resource update feature of the ResourceWatcher");
|
||||
info("Check nested resource update feature of the ResourceCommand");
|
||||
|
||||
const tab = await addTab(STYLE_TEST_URL);
|
||||
|
||||
|
@ -313,7 +313,7 @@ async function testNestedResourceUpdateFeature() {
|
|||
tab.ownerGlobal.resizeTo(originalWindowWidth, originalWindowHeight);
|
||||
});
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test that the server ResourceWatcher are destroyed when the associated target actors
|
||||
// Test that the server ResourceCommand are destroyed when the associated target actors
|
||||
// are destroyed.
|
||||
|
||||
add_task(async function() {
|
||||
const tab = await addTab("data:text/html,Test");
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
|
|
@ -21,11 +21,11 @@ add_task(async function() {
|
|||
client,
|
||||
resourceWatcher,
|
||||
targetCommand,
|
||||
} = await initMultiProcessResourceWatcher();
|
||||
} = await initMultiProcessResourceCommand();
|
||||
|
||||
const expectedPlatformMessage = "expectedMessage";
|
||||
|
||||
info("Log a message *before* calling ResourceWatcher.watchResources");
|
||||
info("Log a message *before* calling ResourceCommand.watchResources");
|
||||
Services.console.logStringMessage(expectedPlatformMessage);
|
||||
|
||||
info("Call watchResources from 2 separate call sites consecutively");
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the behavior of ResourceWatcher when the top level target changes
|
||||
// Test the behavior of ResourceCommand when the top level target changes
|
||||
|
||||
const TEST_URI =
|
||||
"data:text/html;charset=utf-8,<script>console.log('foo');</script>";
|
||||
|
@ -11,7 +11,7 @@ const TEST_URI =
|
|||
add_task(async function() {
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
const { CONSOLE_MESSAGE, SOURCE } = resourceWatcher.TYPES;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around THREAD_STATE
|
||||
// Test the ResourceCommand API around THREAD_STATE
|
||||
|
||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
||||
|
||||
|
@ -34,12 +34,12 @@ add_task(async function() {
|
|||
|
||||
async function checkBreakpointBeforeWatchResources() {
|
||||
info(
|
||||
"Check whether ResourceWatcher gets existing breakpoint, being hit before calling watchResources"
|
||||
"Check whether ResourceCommand gets existing breakpoint, being hit before calling watchResources"
|
||||
);
|
||||
|
||||
const tab = await addTab(BREAKPOINT_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -108,12 +108,12 @@ async function checkBreakpointBeforeWatchResources() {
|
|||
|
||||
async function checkBreakpointAfterWatchResources() {
|
||||
info(
|
||||
"Check whether ResourceWatcher gets breakpoint hit after calling watchResources"
|
||||
"Check whether ResourceCommand gets breakpoint hit after calling watchResources"
|
||||
);
|
||||
|
||||
const tab = await addTab(BREAKPOINT_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -180,12 +180,12 @@ async function checkBreakpointAfterWatchResources() {
|
|||
|
||||
async function checkRealBreakpoint() {
|
||||
info(
|
||||
"Check whether ResourceWatcher gets breakpoint set via the thread Front (instead of just debugger statements)"
|
||||
"Check whether ResourceCommand gets breakpoint set via the thread Front (instead of just debugger statements)"
|
||||
);
|
||||
|
||||
const tab = await addTab(BREAKPOINT_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -262,14 +262,14 @@ async function checkRealBreakpoint() {
|
|||
|
||||
async function checkPauseOnException() {
|
||||
info(
|
||||
"Check whether ResourceWatcher gets breakpoint for exception (when explicitly requested)"
|
||||
"Check whether ResourceCommand gets breakpoint for exception (when explicitly requested)"
|
||||
);
|
||||
|
||||
const tab = await addTab(
|
||||
"data:text/html,<meta charset=utf8><script>a.b.c.d</script>"
|
||||
);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -342,7 +342,7 @@ async function checkSetBeforeWatch() {
|
|||
|
||||
const tab = await addTab(BREAKPOINT_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
@ -425,11 +425,11 @@ async function checkSetBeforeWatch() {
|
|||
}
|
||||
|
||||
async function checkDebuggerStatementInIframes() {
|
||||
info("Check whether ResourceWatcher gets breakpoint for (remote) iframes");
|
||||
info("Check whether ResourceCommand gets breakpoint for (remote) iframes");
|
||||
|
||||
const tab = await addTab(BREAKPOINT_TEST_URL);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ const TEST_URI = "data:text/html;charset=utf-8,";
|
|||
add_task(async function() {
|
||||
const tab = await addTab(TEST_URI);
|
||||
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
const { CONSOLE_MESSAGE, ROOT_NODE } = resourceWatcher.TYPES;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around WEBSOCKET.
|
||||
// Test the ResourceCommand API around WEBSOCKET.
|
||||
|
||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
||||
|
||||
|
@ -27,7 +27,7 @@ add_task(async function() {
|
|||
|
||||
async function testWebsocketResources(target) {
|
||||
const tab = await addTab(URL_ROOT + "websocket_frontend.html");
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
|
||||
const { client, resourceWatcher, targetCommand } = await initResourceCommand(
|
||||
tab
|
||||
);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ Services.scriptloader.loadSubScript(
|
|||
const { DevToolsClient } = require("devtools/client/devtools-client");
|
||||
const { DevToolsServer } = require("devtools/server/devtools-server");
|
||||
|
||||
async function _initResourceWatcherFromCommands(
|
||||
async function _initResourceCommandFromCommands(
|
||||
commands,
|
||||
{ listenForWorkers = false } = {}
|
||||
) {
|
||||
|
@ -36,15 +36,15 @@ async function _initResourceWatcherFromCommands(
|
|||
}
|
||||
|
||||
/**
|
||||
* Instantiate a ResourceWatcher for the given tab.
|
||||
* Instantiate a ResourceCommand for the given tab.
|
||||
*
|
||||
* @param {Tab} tab
|
||||
* The browser frontend's tab to connect to.
|
||||
* @param {Object} options
|
||||
* @param {Boolean} options.listenForWorkers
|
||||
* @return {Object} object
|
||||
* @return {ResourceWatcher} object.resourceWatcher
|
||||
* The underlying resource watcher interface.
|
||||
* @return {ResourceCommand} object.resourceWatcher
|
||||
* The underlying resource command interface.
|
||||
* @return {Object} object.commands
|
||||
* The commands object defined by modules from devtools/shared/commands.
|
||||
* @return {DevToolsClient} object.client
|
||||
|
@ -52,17 +52,17 @@ async function _initResourceWatcherFromCommands(
|
|||
* @return {TargetCommand} object.targetCommand
|
||||
* The underlying target list instance.
|
||||
*/
|
||||
async function initResourceWatcher(tab, options) {
|
||||
async function initResourceCommand(tab, options) {
|
||||
const commands = await CommandsFactory.forTab(tab);
|
||||
return _initResourceWatcherFromCommands(commands, options);
|
||||
return _initResourceCommandFromCommands(commands, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a multi-process ResourceWatcher, watching all type of targets.
|
||||
* Instantiate a multi-process ResourceCommand, watching all type of targets.
|
||||
*
|
||||
* @return {Object} object
|
||||
* @return {ResourceWatcher} object.resourceWatcher
|
||||
* The underlying resource watcher interface.
|
||||
* @return {ResourceCommand} object.resourceWatcher
|
||||
* The underlying resource command interface.
|
||||
* @return {Object} object.commands
|
||||
* The commands object defined by modules from devtools/shared/commands.
|
||||
* @return {DevToolsClient} object.client
|
||||
|
@ -70,9 +70,9 @@ async function initResourceWatcher(tab, options) {
|
|||
* @return {DevToolsClient} object.targetCommand
|
||||
* The underlying target list instance.
|
||||
*/
|
||||
async function initMultiProcessResourceWatcher() {
|
||||
async function initMultiProcessResourceCommand() {
|
||||
const commands = await CommandsFactory.forMainProcess();
|
||||
return _initResourceWatcherFromCommands(commands);
|
||||
return _initResourceCommandFromCommands(commands);
|
||||
}
|
||||
|
||||
// Copied from devtools/shared/webconsole/test/chrome/common.js
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
/* exported attachConsole, attachConsoleToTab, attachConsoleToWorker,
|
||||
closeDebugger, checkConsoleAPICalls, checkRawHeaders, runTests, nextTest, Ci, Cc,
|
||||
withActiveServiceWorker, Services, consoleAPICall, createResourceWatcherForTab */
|
||||
withActiveServiceWorker, Services, consoleAPICall, createCommandsForTab */
|
||||
|
||||
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
|
||||
const { DevToolsServer } = require("devtools/server/devtools-server");
|
||||
|
@ -115,13 +115,10 @@ var _attachConsole = async function(listeners, attachToTab, attachToWorker) {
|
|||
return null;
|
||||
};
|
||||
|
||||
async function createResourceWatcherForTab() {
|
||||
async function createCommandsForTab() {
|
||||
const commands = await CommandsFactory.forMainProcess();
|
||||
await commands.targetCommand.startListening();
|
||||
const target = commands.targetCommand.targetFront;
|
||||
|
||||
// TODO: return commands and use commands.resourceCommand directly
|
||||
return { resourceWatcher: commands.resourceCommand, target };
|
||||
return commands;
|
||||
}
|
||||
|
||||
function closeDebugger(state, callback) {
|
||||
|
|
|
@ -20,12 +20,14 @@ SimpleTest.waitForExplicitFinish();
|
|||
|
||||
async function startTest()
|
||||
{
|
||||
const { resourceWatcher, target } = await createResourceWatcherForTab();
|
||||
const commands = await createCommandsForTab();
|
||||
const target = commands.targetCommand.targetFront;
|
||||
const resourceCommand = commands.resourceCommand;
|
||||
|
||||
info("test network GET request");
|
||||
const resource = await new Promise(resolve => {
|
||||
resourceWatcher
|
||||
.watchResources([resourceWatcher.TYPES.NETWORK_EVENT], {
|
||||
resourceCommand
|
||||
.watchResources([resourceCommand.TYPES.NETWORK_EVENT], {
|
||||
onAvailable: () => {},
|
||||
onUpdated: resourceUpdate => {
|
||||
resolve(resourceUpdate[0].resource);
|
||||
|
@ -112,7 +114,7 @@ async function startTest()
|
|||
totalTime: /^\d+$/,
|
||||
});
|
||||
|
||||
await target.client.close();
|
||||
await commands.destroy();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,12 +20,14 @@ SimpleTest.waitForExplicitFinish();
|
|||
|
||||
async function startTest()
|
||||
{
|
||||
const { resourceWatcher, target } = await createResourceWatcherForTab();
|
||||
const commands = await createCommandsForTab();
|
||||
const target = commands.targetCommand.targetFront;
|
||||
const resourceCommand = commands.resourceCommand;
|
||||
|
||||
info("test network POST request");
|
||||
const resource = await new Promise(resolve => {
|
||||
resourceWatcher
|
||||
.watchResources([resourceWatcher.TYPES.NETWORK_EVENT], {
|
||||
resourceCommand
|
||||
.watchResources([resourceCommand.TYPES.NETWORK_EVENT], {
|
||||
onAvailable: () => {},
|
||||
onUpdated: resourceUpdate => {
|
||||
resolve(resourceUpdate[0].resource);
|
||||
|
@ -123,7 +125,7 @@ async function startTest()
|
|||
totalTime: /^\d+$/,
|
||||
});
|
||||
|
||||
await target.client.close();
|
||||
await commands.destroy();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -54,10 +54,13 @@ async function startTest()
|
|||
|
||||
async function checkHSTS({desc, url, usesHSTS}) {
|
||||
info("Testing HSTS for " + url);
|
||||
const { resourceWatcher, target } = await createResourceWatcherForTab();
|
||||
const commands = await createCommandsForTab();
|
||||
const target = commands.targetCommand.targetFront;
|
||||
const resourceCommand = commands.resourceCommand;
|
||||
|
||||
const resource = await new Promise(resolve => {
|
||||
resourceWatcher
|
||||
.watchResources([resourceWatcher.TYPES.NETWORK_EVENT], {
|
||||
resourceCommand
|
||||
.watchResources([resourceCommand.TYPES.NETWORK_EVENT], {
|
||||
onAvailable: () => {},
|
||||
onUpdated: resourceUpdate => {
|
||||
resolve(resourceUpdate[0].resource);
|
||||
|
@ -77,7 +80,7 @@ async function checkHSTS({desc, url, usesHSTS}) {
|
|||
usesHSTS,
|
||||
"Strict Transport Security detected correctly for " + url
|
||||
);
|
||||
await target.client.close();
|
||||
await commands.destroy();
|
||||
}
|
||||
|
||||
addEventListener("load", startTest, { once: true });
|
||||
|
|
Загрузка…
Ссылка в новой задаче