Bug 1701790 - Stop using ResourceWatcher symbol for fetch resource types. r=nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D113931
This commit is contained in:
Alexandre Poirot 2021-05-03 18:07:30 +00:00
Родитель 7cd058657a
Коммит a5dbcad9f2
50 изменённых файлов: 175 добавлений и 294 удалений

Просмотреть файл

@ -12,9 +12,7 @@ const {
EDITOR_PRETTY_PRINT,
} = require("devtools/client/webconsole/constants");
const { getAllPrefs } = require("devtools/client/webconsole/selectors/prefs");
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const l10n = require("devtools/client/webconsole/utils/l10n");
loader.lazyServiceGetter(
@ -239,7 +237,7 @@ function handleHelperResult(response) {
level: message.level || "log",
arguments: [message.text],
},
resourceType: ResourceWatcher.TYPES.CONSOLE_MESSAGE,
resourceType: ResourceCommand.TYPES.CONSOLE_MESSAGE,
}))
)
);
@ -264,7 +262,7 @@ function handleHelperResult(response) {
dispatch(
messagesActions.messagesAdd([
{
resourceType: ResourceWatcher.TYPES.PLATFORM_MESSAGE,
resourceType: ResourceCommand.TYPES.PLATFORM_MESSAGE,
message: l10n.getFormatStr(
"webconsole.message.commands.blockedURL",
[blockURL]
@ -288,7 +286,7 @@ function handleHelperResult(response) {
dispatch(
messagesActions.messagesAdd([
{
resourceType: ResourceWatcher.TYPES.PLATFORM_MESSAGE,
resourceType: ResourceCommand.TYPES.PLATFORM_MESSAGE,
message: l10n.getFormatStr(
"webconsole.message.commands.unblockedURL",
[unblockURL]

Просмотреть файл

@ -6,9 +6,7 @@
const Services = require("Services");
const l10n = require("devtools/client/webconsole/utils/l10n");
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
// URL Regex, common idioms:
//
@ -96,23 +94,23 @@ function prepareMessage(resource, idGenerator) {
*/
function transformResource(resource) {
switch (resource.resourceType || resource.type) {
case ResourceWatcher.TYPES.CONSOLE_MESSAGE: {
case ResourceCommand.TYPES.CONSOLE_MESSAGE: {
return transformConsoleAPICallResource(resource);
}
case ResourceWatcher.TYPES.PLATFORM_MESSAGE: {
case ResourceCommand.TYPES.PLATFORM_MESSAGE: {
return transformPlatformMessageResource(resource);
}
case ResourceWatcher.TYPES.ERROR_MESSAGE: {
case ResourceCommand.TYPES.ERROR_MESSAGE: {
return transformPageErrorResource(resource);
}
case ResourceWatcher.TYPES.CSS_MESSAGE: {
case ResourceCommand.TYPES.CSS_MESSAGE: {
return transformCSSMessageResource(resource);
}
case ResourceWatcher.TYPES.NETWORK_EVENT: {
case ResourceCommand.TYPES.NETWORK_EVENT: {
return transformNetworkEventResource(resource);
}

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const {
makeStorageLegacyListener,
@ -14,5 +12,5 @@ const {
module.exports = makeStorageLegacyListener(
"Cache",
ResourceWatcher.TYPES.CACHE_STORAGE
ResourceCommand.TYPES.CACHE_STORAGE
);

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const Services = require("Services");
@ -45,7 +43,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
if (!packet.clonedFromContentProcess) {
return;
}
packet.resourceType = ResourceWatcher.TYPES.CONSOLE_MESSAGE;
packet.resourceType = ResourceCommand.TYPES.CONSOLE_MESSAGE;
onAvailable([packet]);
});
};

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
// Allow the top level target unconditionnally.
@ -42,7 +40,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
const { messages } = await webConsoleFront.getCachedMessages(["ConsoleAPI"]);
for (const message of messages) {
message.resourceType = ResourceWatcher.TYPES.CONSOLE_MESSAGE;
message.resourceType = ResourceCommand.TYPES.CONSOLE_MESSAGE;
}
onAvailable(messages);
@ -54,7 +52,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
return;
}
message.resourceType = ResourceWatcher.TYPES.CONSOLE_MESSAGE;
message.resourceType = ResourceCommand.TYPES.CONSOLE_MESSAGE;
onAvailable([message]);
});
};

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const {
makeStorageLegacyListener,
@ -14,5 +12,5 @@ const {
module.exports = makeStorageLegacyListener(
"cookies",
ResourceWatcher.TYPES.COOKIE
ResourceCommand.TYPES.COOKIE
);

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
module.exports = async function({ targetFront, onAvailable }) {
if (!targetFront.hasActor("changes")) {
@ -25,6 +23,6 @@ module.exports = async function({ targetFront, onAvailable }) {
function toResource(change) {
return Object.assign(change, {
resourceType: ResourceWatcher.TYPES.CSS_CHANGE,
resourceType: ResourceCommand.TYPES.CSS_CHANGE,
});
}

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const { MESSAGE_CATEGORY } = require("devtools/shared/constants");
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
@ -39,7 +37,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
continue;
}
message.resourceType = ResourceWatcher.TYPES.CSS_MESSAGE;
message.resourceType = ResourceCommand.TYPES.CSS_MESSAGE;
message.cssSelectors = message.pageError.cssSelectors;
delete message.pageError.cssSelectors;
cachedMessages.push(message);
@ -54,7 +52,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
return;
}
message.resourceType = ResourceWatcher.TYPES.CSS_MESSAGE;
message.resourceType = ResourceCommand.TYPES.CSS_MESSAGE;
message.cssSelectors = message.pageError.cssSelectors;
delete message.pageError.cssSelectors;
onAvailable([message]);

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const { MESSAGE_CATEGORY } = require("devtools/shared/constants");
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
@ -46,7 +44,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
);
messages.forEach(message => {
message.resourceType = ResourceWatcher.TYPES.ERROR_MESSAGE;
message.resourceType = ResourceCommand.TYPES.ERROR_MESSAGE;
});
// Cached messages don't have the same shape as live messages,
// so we need to transform them.
@ -58,7 +56,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
return;
}
message.resourceType = ResourceWatcher.TYPES.ERROR_MESSAGE;
message.resourceType = ResourceCommand.TYPES.ERROR_MESSAGE;
onAvailable([message]);
});
};

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const {
makeStorageLegacyListener,
@ -14,5 +12,5 @@ const {
module.exports = makeStorageLegacyListener(
"extensionStorage",
ResourceWatcher.TYPES.EXTENSION_STORAGE
ResourceCommand.TYPES.EXTENSION_STORAGE
);

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const {
makeStorageLegacyListener,
@ -14,5 +12,5 @@ const {
module.exports = makeStorageLegacyListener(
"indexedDB",
ResourceWatcher.TYPES.INDEXED_DB
ResourceCommand.TYPES.INDEXED_DB
);

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const {
makeStorageLegacyListener,
@ -14,5 +12,5 @@ const {
module.exports = makeStorageLegacyListener(
"localStorage",
ResourceWatcher.TYPES.LOCAL_STORAGE
ResourceCommand.TYPES.LOCAL_STORAGE
);

Просмотреть файл

@ -4,16 +4,14 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
function onNetworkEventStackTrace(packet) {
const actor = packet.eventActor;
onAvailable([
{
resourceType: ResourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
resourceType: ResourceCommand.TYPES.NETWORK_EVENT_STACKTRACE,
resourceId: actor.channelId,
stacktraceAvailable: actor.cause.stacktraceAvailable,
lastFrame: actor.cause.lastFrame,

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
module.exports = async function({
targetCommand,
@ -37,7 +35,7 @@ module.exports = async function({
resources.set(actor.actor, {
resourceId: actor.channelId,
resourceType: ResourceWatcher.TYPES.NETWORK_EVENT,
resourceType: ResourceCommand.TYPES.NETWORK_EVENT,
isBlocked: !!actor.blockedReason,
types: [],
resourceUpdates: {},
@ -46,7 +44,7 @@ module.exports = async function({
onAvailable([
{
resourceId: actor.channelId,
resourceType: ResourceWatcher.TYPES.NETWORK_EVENT,
resourceType: ResourceCommand.TYPES.NETWORK_EVENT,
timeStamp: actor.timeStamp,
actor: actor.actor,
startedDateTime: actor.startedDateTime,

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
// Only allow the top level target and processes.
@ -35,12 +33,12 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
const { messages } = await webConsoleFront.getCachedMessages(["LogMessage"]);
for (const message of messages) {
message.resourceType = ResourceWatcher.TYPES.PLATFORM_MESSAGE;
message.resourceType = ResourceCommand.TYPES.PLATFORM_MESSAGE;
}
onAvailable(messages);
webConsoleFront.on("logMessage", message => {
message.resourceType = ResourceWatcher.TYPES.PLATFORM_MESSAGE;
message.resourceType = ResourceCommand.TYPES.PLATFORM_MESSAGE;
onAvailable([message]);
});
};

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
module.exports = async function({ targetFront, onAvailable, onDestroyed }) {
// XXX: When watching root node for a non top-level target, this will also
@ -50,12 +48,12 @@ module.exports = async function({ targetFront, onAvailable, onDestroyed }) {
const inspectorFront = await targetFront.getFront("inspector");
inspectorFront.walker.on("root-available", node => {
node.resourceType = ResourceWatcher.TYPES.ROOT_NODE;
node.resourceType = ResourceCommand.TYPES.ROOT_NODE;
return onAvailable([node]);
});
inspectorFront.walker.on("root-destroyed", node => {
node.resourceType = ResourceWatcher.TYPES.ROOT_NODE;
node.resourceType = ResourceCommand.TYPES.ROOT_NODE;
return onDestroyed([node]);
});

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
module.exports = async function({ targetFront, onAvailable }) {
const eventSourceFront = await targetFront.getFront("eventSource");
@ -27,7 +25,7 @@ module.exports = async function({ targetFront, onAvailable }) {
function createResource(messageType, eventParams) {
return {
resourceType: ResourceWatcher.TYPES.SERVER_SENT_EVENT,
resourceType: ResourceCommand.TYPES.SERVER_SENT_EVENT,
messageType,
...eventParams,
};

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const {
makeStorageLegacyListener,
@ -14,5 +12,5 @@ const {
module.exports = makeStorageLegacyListener(
"sessionStorage",
ResourceWatcher.TYPES.SESSION_STORAGE
ResourceCommand.TYPES.SESSION_STORAGE
);

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
/**
* Emit SOURCE resources, which represents a Javascript source and has the following attributes set on "available":
@ -52,7 +50,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
}
sourcesActorIDCache.add(source.actor);
// source is a SourceActor's form, add the resourceType attribute on it
source.resourceType = ResourceWatcher.TYPES.SOURCE;
source.resourceType = ResourceCommand.TYPES.SOURCE;
onAvailable([source]);
});
@ -83,7 +81,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
for (const source of sources) {
sourcesActorIDCache.add(source.actor);
// source is a SourceActor's form, add the resourceType attribute on it
source.resourceType = ResourceWatcher.TYPES.SOURCE;
source.resourceType = ResourceCommand.TYPES.SOURCE;
}
onAvailable(sources);
};

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
module.exports = async function({ targetFront, onAvailable, onUpdated }) {
if (!targetFront.hasActor("styleSheets")) {
@ -125,7 +123,7 @@ module.exports = async function({ targetFront, onAvailable, onUpdated }) {
function toResource(styleSheet, isNew, fileName) {
Object.assign(styleSheet, {
resourceId: styleSheet.actorID,
resourceType: ResourceWatcher.TYPES.STYLESHEET,
resourceType: ResourceCommand.TYPES.STYLESHEET,
isNew,
fileName,
});

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
const isBrowserToolbox = targetCommand.targetFront.isParentProcess;
@ -48,7 +46,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
onAvailable([
{
resourceType: ResourceWatcher.TYPES.THREAD_STATE,
resourceType: ResourceCommand.TYPES.THREAD_STATE,
state: "paused",
why,
frame: packet.frame,
@ -68,7 +66,7 @@ module.exports = async function({ targetCommand, targetFront, onAvailable }) {
onAvailable([
{
resourceType: ResourceWatcher.TYPES.THREAD_STATE,
resourceType: ResourceCommand.TYPES.THREAD_STATE,
state: "resumed",
},
]);

Просмотреть файл

@ -4,9 +4,7 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
module.exports = async function({ targetFront, onAvailable }) {
if (!targetFront.hasActor("webSocket")) {
@ -55,7 +53,7 @@ module.exports = async function({ targetFront, onAvailable }) {
function toResource(wsMessageType, eventParams) {
return {
resourceType: ResourceWatcher.TYPES.WEBSOCKET,
resourceType: ResourceCommand.TYPES.WEBSOCKET,
wsMessageType,
...eventParams,
};

Просмотреть файл

@ -6,7 +6,7 @@
const {
TYPES: { CACHE_STORAGE },
} = require("devtools/shared/resources/resource-watcher");
} = require("devtools/shared/commands/resource/resource-command");
const { Front, types } = require("devtools/shared/protocol.js");

Просмотреть файл

@ -6,7 +6,7 @@
const {
TYPES: { COOKIE },
} = require("devtools/shared/resources/resource-watcher");
} = require("devtools/shared/commands/resource/resource-command");
const { Front, types } = require("devtools/shared/protocol.js");

Просмотреть файл

@ -6,7 +6,7 @@
const {
TYPES: { INDEXED_DB },
} = require("devtools/shared/resources/resource-watcher");
} = require("devtools/shared/commands/resource/resource-command");
const { Front, types } = require("devtools/shared/protocol.js");

Просмотреть файл

@ -6,7 +6,7 @@
const {
TYPES: { LOCAL_STORAGE },
} = require("devtools/shared/resources/resource-watcher");
} = require("devtools/shared/commands/resource/resource-command");
const { Front, types } = require("devtools/shared/protocol.js");

Просмотреть файл

@ -6,7 +6,7 @@
const {
TYPES: { SESSION_STORAGE },
} = require("devtools/shared/resources/resource-watcher");
} = require("devtools/shared/commands/resource/resource-command");
const { Front, types } = require("devtools/shared/protocol.js");

Просмотреть файл

@ -5,10 +5,6 @@
// 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";
add_task(async function() {
@ -30,7 +26,7 @@ add_task(async function() {
info("Wait for existing browser mochitest log");
const existingMsg = await waitForNextResource(
resourceWatcher,
ResourceWatcher.TYPES.CONSOLE_MESSAGE,
resourceWatcher.TYPES.CONSOLE_MESSAGE,
{
ignoreExistingResources: false,
predicate({ message }) {
@ -57,14 +53,14 @@ add_task(async function() {
);
if (runtimeLogResource) {
resourceWatcher.unwatchResources(
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
{ onAvailable }
);
resolveMochitestRuntimeLog(runtimeLogResource);
}
};
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
{
ignoreExistingResources: true,
onAvailable,
@ -83,7 +79,7 @@ add_task(async function() {
const onEarlyLog = waitForNextResource(
resourceWatcher,
ResourceWatcher.TYPES.CONSOLE_MESSAGE,
resourceWatcher.TYPES.CONSOLE_MESSAGE,
{
ignoreExistingResources: true,
predicate({ message }) {

Просмотреть файл

@ -5,10 +5,6 @@
// 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";
add_task(async function() {
@ -27,7 +23,7 @@ add_task(async function() {
info("Register first listener");
const cachedResources1 = [];
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
{
onAvailable: resources => cachedResources1.push(...resources),
}
@ -36,7 +32,7 @@ add_task(async function() {
info("Register second listener");
const cachedResources2 = [];
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
{
onAvailable: resources => cachedResources2.push(...resources),
}
@ -67,7 +63,7 @@ add_task(async function() {
info("Register first listener to get all available resources");
const availableResources = [];
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
{
onAvailable: resources => availableResources.push(...resources),
}
@ -84,7 +80,7 @@ add_task(async function() {
info("Register second listener to get the cached resources");
const cachedResources = [];
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
{
onAvailable: resources => cachedResources.push(...resources),
}
@ -112,7 +108,7 @@ add_task(async function() {
info("Register first listener");
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
{
onAvailable: () => {},
}
@ -126,7 +122,7 @@ add_task(async function() {
info("Register second listener");
const cachedResources = [];
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
{
onAvailable: resources => cachedResources.push(...resources),
}
@ -151,8 +147,8 @@ add_task(async function() {
const availableResources = [];
await resourceWatcher.watchResources(
[
ResourceWatcher.TYPES.CONSOLE_MESSAGE,
ResourceWatcher.TYPES.ERROR_MESSAGE,
resourceWatcher.TYPES.CONSOLE_MESSAGE,
resourceWatcher.TYPES.ERROR_MESSAGE,
],
{
onAvailable: resources => availableResources.push(...resources),
@ -182,8 +178,8 @@ add_task(async function() {
const cachedResources = [];
await resourceWatcher.watchResources(
[
ResourceWatcher.TYPES.CONSOLE_MESSAGE,
ResourceWatcher.TYPES.ERROR_MESSAGE,
resourceWatcher.TYPES.CONSOLE_MESSAGE,
resourceWatcher.TYPES.ERROR_MESSAGE,
],
{
onAvailable: resources => cachedResources.push(...resources),
@ -216,7 +212,7 @@ async function testIgnoreExistingResources(isFirstListenerIgnoreExisting) {
info("Register first listener");
const cachedResources1 = [];
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
{
onAvailable: resources => cachedResources1.push(...resources),
ignoreExistingResources: isFirstListenerIgnoreExisting,
@ -226,7 +222,7 @@ async function testIgnoreExistingResources(isFirstListenerIgnoreExisting) {
info("Register second listener");
const cachedResources2 = [];
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
{
onAvailable: resources => cachedResources2.push(...resources),
ignoreExistingResources: !isFirstListenerIgnoreExisting,
@ -287,7 +283,7 @@ add_task(async function() {
};
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
{ onAvailable }
);
is(availableResources.length, 0, "availableResources array is empty");
@ -305,7 +301,7 @@ add_task(async function() {
"onAvailable was called with the expected resource"
);
resourceWatcher.unwatchResources([ResourceWatcher.TYPES.CONSOLE_MESSAGE], {
resourceWatcher.unwatchResources([resourceWatcher.TYPES.CONSOLE_MESSAGE], {
onAvailable,
});
targetCommand.destroy();

Просмотреть файл

@ -9,10 +9,6 @@
// And now more. Once we remove the console actor's startListeners in favor of watcher class
// 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 IFRAME_URL = URL_ROOT_ORG_SSL + "fission_iframe.html";
@ -59,7 +55,7 @@ async function testTabConsoleMessagesResources(executeInIframe) {
is(
resource.resourceType,
ResourceWatcher.TYPES.CONSOLE_MESSAGE,
resourceWatcher.TYPES.CONSOLE_MESSAGE,
"Received a message"
);
ok(resource.message, "message is wrapped into a message attribute");
@ -82,7 +78,7 @@ async function testTabConsoleMessagesResources(executeInIframe) {
};
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
{
onAvailable,
}
@ -134,7 +130,7 @@ async function testTabConsoleMessagesResourcesWithIgnoreExistingResources(
const availableResources = [];
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
{
onAvailable: resources => availableResources.push(...resources),
ignoreExistingResources: true,

Просмотреть файл

@ -5,10 +5,6 @@
// 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 WORKER_FILE = "test_worker.js";
const IFRAME_FILE = `${URL_ROOT_ORG_SSL}fission_iframe.html`;
@ -56,7 +52,7 @@ add_task(async function() {
};
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
{
onAvailable,
}

Просмотреть файл

@ -5,10 +5,6 @@
// Test the ResourceWatcher API around CSS_CHANGE.
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
add_task(async function() {
// Open a test tab
const tab = await addTab(
@ -21,7 +17,7 @@ add_task(async function() {
// CSS_CHANGE watcher doesn't record modification made before watching,
// so we have to start watching before doing any DOM mutation.
await resourceWatcher.watchResources([ResourceWatcher.TYPES.CSS_CHANGE], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_CHANGE], {
onAvailable: () => {},
});
@ -40,7 +36,7 @@ add_task(async function() {
await setProperty(style.rule, 0, "color", "black");
const availableResources = [];
await resourceWatcher.watchResources([ResourceWatcher.TYPES.CSS_CHANGE], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_CHANGE], {
onAvailable: resources => availableResources.push(...resources),
});
assertResource(
@ -80,7 +76,7 @@ add_task(async function() {
info("Check whether ResourceWatcher sends all resources added in this test");
const existingResources = [];
await resourceWatcher.watchResources([ResourceWatcher.TYPES.CSS_CHANGE], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_CHANGE], {
onAvailable: resources => existingResources.push(...resources),
});
await waitUntil(() => existingResources.length === 4);

Просмотреть файл

@ -6,9 +6,6 @@
// Test the ResourceWatcher API around CSS_MESSAGE
// 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");
// Create a simple server so we have a nice sourceName in the resources packets.
@ -48,7 +45,7 @@ async function testWatchingCssMessages() {
receivedMessages,
false
);
await resourceWatcher.watchResources([ResourceWatcher.TYPES.CSS_MESSAGE], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_MESSAGE], {
onAvailable,
});
@ -111,7 +108,7 @@ async function testWatchingCachedCssMessages() {
receivedMessages,
true
);
await resourceWatcher.watchResources([ResourceWatcher.TYPES.CSS_MESSAGE], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.CSS_MESSAGE], {
onAvailable,
});
is(receivedMessages.length, 3, "Cached messages were retrieved as expected");

Просмотреть файл

@ -5,10 +5,6 @@
// Test the ResourceWatcher API around DOCUMENT_EVENT
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
add_task(async function() {
await testDocumentEventResources();
await testDocumentEventResourcesWithIgnoreExistingResources();
@ -36,7 +32,7 @@ async function testDocumentEventResources() {
const onLoadingAtInit = listener.once("dom-loading");
const onInteractiveAtInit = listener.once("dom-interactive");
const onCompleteAtInit = listener.once("dom-complete");
await resourceWatcher.watchResources([ResourceWatcher.TYPES.DOCUMENT_EVENT], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.DOCUMENT_EVENT], {
onAvailable: parameters => listener.dispatch(parameters),
});
await assertPromises(onLoadingAtInit, onInteractiveAtInit, onCompleteAtInit);
@ -85,7 +81,7 @@ async function testDocumentEventResourcesWithIgnoreExistingResources() {
info("Check whether the existing document events will not be fired");
const documentEvents = [];
await resourceWatcher.watchResources([ResourceWatcher.TYPES.DOCUMENT_EVENT], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.DOCUMENT_EVENT], {
onAvailable: resources => documentEvents.push(...resources),
ignoreExistingResources: true,
});
@ -111,7 +107,7 @@ async function testCrossOriginNavigation() {
);
const documentEvents = [];
await resourceWatcher.watchResources([ResourceWatcher.TYPES.DOCUMENT_EVENT], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.DOCUMENT_EVENT], {
onAvailable: resources => documentEvents.push(...resources),
ignoreExistingResources: true,
});

Просмотреть файл

@ -6,10 +6,6 @@
// Test the ResourceWatcher API around ERROR_MESSAGE
// 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.
const httpServer = createTestHTTPServer();
httpServer.registerPathHandler(`/test_page_errors.html`, (req, res) => {
@ -86,7 +82,7 @@ async function testErrorMessagesResources() {
}
};
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ERROR_MESSAGE], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.ERROR_MESSAGE], {
onAvailable,
});
@ -123,7 +119,7 @@ async function testErrorMessagesResourcesWithIgnoreExistingResources() {
await triggerErrors(tab);
const availableResources = [];
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ERROR_MESSAGE], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.ERROR_MESSAGE], {
onAvailable: resources => availableResources.push(...resources),
ignoreExistingResources: true,
});

Просмотреть файл

@ -5,10 +5,6 @@
// 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";
add_task(async function() {
@ -20,7 +16,7 @@ add_task(async function() {
info("Check the resources gotten from getAllResources at initial");
is(
resourceWatcher.getAllResources(ResourceWatcher.TYPES.CONSOLE_MESSAGE)
resourceWatcher.getAllResources(resourceWatcher.TYPES.CONSOLE_MESSAGE)
.length,
0,
"There is no resources at initial"
@ -32,7 +28,7 @@ add_task(async function() {
const availableResources = [];
const onAvailable = resources => availableResources.push(...resources);
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
{ onAvailable }
);
@ -41,11 +37,11 @@ add_task(async function() {
await logMessages(tab.linkedBrowser, messages);
await waitUntil(() => availableResources.length >= messages.length);
assertResources(
resourceWatcher.getAllResources(ResourceWatcher.TYPES.CONSOLE_MESSAGE),
resourceWatcher.getAllResources(resourceWatcher.TYPES.CONSOLE_MESSAGE),
availableResources
);
assertResources(
resourceWatcher.getAllResources(ResourceWatcher.TYPES.STYLESHEET),
resourceWatcher.getAllResources(resourceWatcher.TYPES.STYLESHEET),
[]
);
@ -54,7 +50,7 @@ add_task(async function() {
gBrowser.reloadTab(tab);
await onReloaded;
assertResources(
resourceWatcher.getAllResources(ResourceWatcher.TYPES.CONSOLE_MESSAGE),
resourceWatcher.getAllResources(resourceWatcher.TYPES.CONSOLE_MESSAGE),
[]
);
@ -62,16 +58,16 @@ add_task(async function() {
await logMessages(tab.linkedBrowser, messages);
await waitUntil(
() =>
resourceWatcher.getAllResources(ResourceWatcher.TYPES.CONSOLE_MESSAGE)
resourceWatcher.getAllResources(resourceWatcher.TYPES.CONSOLE_MESSAGE)
.length === messages.length
);
info("Check the resources after unwatching");
resourceWatcher.unwatchResources([ResourceWatcher.TYPES.CONSOLE_MESSAGE], {
resourceWatcher.unwatchResources([resourceWatcher.TYPES.CONSOLE_MESSAGE], {
onAvailable,
});
assertResources(
resourceWatcher.getAllResources(ResourceWatcher.TYPES.CONSOLE_MESSAGE),
resourceWatcher.getAllResources(resourceWatcher.TYPES.CONSOLE_MESSAGE),
[]
);

Просмотреть файл

@ -5,10 +5,6 @@
// 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 REQUEST_STUB = {
@ -39,7 +35,7 @@ add_task(async function() {
function onResourceAvailable(resources) {
for (const resource of resources) {
if (
resource.resourceType === ResourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE
resource.resourceType === resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE
) {
ok(
!networkEvents.has(resource.resourceId),
@ -61,7 +57,7 @@ add_task(async function() {
return;
}
if (resource.resourceType === ResourceWatcher.TYPES.NETWORK_EVENT) {
if (resource.resourceType === resourceWatcher.TYPES.NETWORK_EVENT) {
ok(
stackTraces.has(resource.stacktraceResourceId),
"The stack trace does exists"
@ -76,8 +72,8 @@ add_task(async function() {
await resourceWatcher.watchResources(
[
ResourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
ResourceWatcher.TYPES.NETWORK_EVENT,
resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
resourceWatcher.TYPES.NETWORK_EVENT,
],
{
onAvailable: onResourceAvailable,
@ -89,8 +85,8 @@ add_task(async function() {
resourceWatcher.unwatchResources(
[
ResourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
ResourceWatcher.TYPES.NETWORK_EVENT,
resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
resourceWatcher.TYPES.NETWORK_EVENT,
],
{
onAvailable: onResourceAvailable,

Просмотреть файл

@ -2,11 +2,10 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test the ResourceWatcher API around NETWORK_EVENT
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const EXAMPLE_DOMAIN = "https://example.com/";
const TEST_URI = `${URL_ROOT_SSL}network_document.html`;
@ -29,17 +28,17 @@ async function testNetworkEventResourcesWithExistingResources() {
totalExpectedOnUpdatedCounts: 1,
expectedResourcesOnAvailable: {
[`${EXAMPLE_DOMAIN}cached_post.html`]: {
resourceType: ResourceWatcher.TYPES.NETWORK_EVENT,
resourceType: ResourceCommand.TYPES.NETWORK_EVENT,
method: "POST",
},
[`${EXAMPLE_DOMAIN}live_get.html`]: {
resourceType: ResourceWatcher.TYPES.NETWORK_EVENT,
resourceType: ResourceCommand.TYPES.NETWORK_EVENT,
method: "GET",
},
},
expectedResourcesOnUpdated: {
[`${EXAMPLE_DOMAIN}live_get.html`]: {
resourceType: ResourceWatcher.TYPES.NETWORK_EVENT,
resourceType: ResourceCommand.TYPES.NETWORK_EVENT,
method: "GET",
},
},
@ -56,13 +55,13 @@ async function testNetworkEventResourcesWithoutExistingResources() {
totalExpectedOnUpdatedCounts: 1,
expectedResourcesOnAvailable: {
[`${EXAMPLE_DOMAIN}live_get.html`]: {
resourceType: ResourceWatcher.TYPES.NETWORK_EVENT,
resourceType: ResourceCommand.TYPES.NETWORK_EVENT,
method: "GET",
},
},
expectedResourcesOnUpdated: {
[`${EXAMPLE_DOMAIN}live_get.html`]: {
resourceType: ResourceWatcher.TYPES.NETWORK_EVENT,
resourceType: ResourceCommand.TYPES.NETWORK_EVENT,
method: "GET",
},
},
@ -89,7 +88,7 @@ async function testNetworkEventResources(options) {
for (const resource of resources) {
is(
resource.resourceType,
ResourceWatcher.TYPES.NETWORK_EVENT,
resourceWatcher.TYPES.NETWORK_EVENT,
"Received a network event resource"
);
}
@ -99,7 +98,7 @@ async function testNetworkEventResources(options) {
for (const { resource } of updates) {
is(
resource.resourceType,
ResourceWatcher.TYPES.NETWORK_EVENT,
resourceWatcher.TYPES.NETWORK_EVENT,
"Received a network update event resource"
);
resolve();
@ -107,7 +106,7 @@ async function testNetworkEventResources(options) {
};
resourceWatcher
.watchResources([ResourceWatcher.TYPES.NETWORK_EVENT], {
.watchResources([resourceWatcher.TYPES.NETWORK_EVENT], {
onAvailable: onResourceAvailable,
onUpdated: onResourceUpdated,
})
@ -143,7 +142,7 @@ async function testNetworkEventResources(options) {
for (const resource of resources) {
is(
resource.resourceType,
ResourceWatcher.TYPES.NETWORK_EVENT,
resourceWatcher.TYPES.NETWORK_EVENT,
"Received a network event resource"
);
actualResourcesOnAvailable[resource.url] = {
@ -159,7 +158,7 @@ async function testNetworkEventResources(options) {
for (const { resource } of updates) {
is(
resource.resourceType,
ResourceWatcher.TYPES.NETWORK_EVENT,
resourceWatcher.TYPES.NETWORK_EVENT,
"Received a network update event resource"
);
actualResourcesOnUpdated[resource.url] = {
@ -171,7 +170,7 @@ async function testNetworkEventResources(options) {
}
};
await resourceWatcher.watchResources([ResourceWatcher.TYPES.NETWORK_EVENT], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.NETWORK_EVENT], {
onAvailable,
onUpdated,
ignoreExistingResources,
@ -225,7 +224,7 @@ async function testNetworkEventResources(options) {
}
await resourceWatcher.unwatchResources(
[ResourceWatcher.TYPES.NETWORK_EVENT],
[resourceWatcher.TYPES.NETWORK_EVENT],
{
onAvailable,
onUpdated,
@ -234,7 +233,7 @@ async function testNetworkEventResources(options) {
);
await resourceWatcher.unwatchResources(
[ResourceWatcher.TYPES.NETWORK_EVENT],
[resourceWatcher.TYPES.NETWORK_EVENT],
{
onAvailable: onResourceAvailable,
onUpdated: onResourceUpdated,
@ -288,7 +287,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
};
resourceWatcher
.watchResources([ResourceWatcher.TYPES.NETWORK_EVENT], {
.watchResources([resourceWatcher.TYPES.NETWORK_EVENT], {
onAvailable,
onUpdated,
})
@ -317,7 +316,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
// Assert the data for the CSP blocked JS script file
is(
availableJSResource.resourceType,
ResourceWatcher.TYPES.NETWORK_EVENT,
resourceWatcher.TYPES.NETWORK_EVENT,
"This is a network event resource"
);
is(
@ -328,7 +327,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
is(
updateJSResource.resourceType,
ResourceWatcher.TYPES.NETWORK_EVENT,
resourceWatcher.TYPES.NETWORK_EVENT,
"This is a network event resource"
);
is(
@ -349,7 +348,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
// Assert the data for the CSP blocked CSS file
is(
availableCSSResource.resourceType,
ResourceWatcher.TYPES.NETWORK_EVENT,
resourceWatcher.TYPES.NETWORK_EVENT,
"This is a network event resource"
);
is(
@ -360,7 +359,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
is(
updateCSSResource.resourceType,
ResourceWatcher.TYPES.NETWORK_EVENT,
resourceWatcher.TYPES.NETWORK_EVENT,
"This is a network event resource"
);
is(
@ -370,7 +369,7 @@ async function testNetworkEventResourcesFromTheContentProcess() {
);
await resourceWatcher.unwatchResources(
[ResourceWatcher.TYPES.NETWORK_EVENT],
[resourceWatcher.TYPES.NETWORK_EVENT],
{
onAvailable,
onUpdated,

Просмотреть файл

@ -6,10 +6,6 @@
// Test the ResourceWatcher API around PLATFORM_MESSAGE
// Reproduces assertions from: devtools/shared/webconsole/test/chrome/test_nsiconsolemessage.html
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
add_task(async function() {
// Disable the preloaded process as it creates processes intermittently
// which forces the emission of RDP requests we aren't correctly waiting for.
@ -83,7 +79,7 @@ async function testPlatformMessagesResources() {
};
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.PLATFORM_MESSAGE],
[resourceWatcher.TYPES.PLATFORM_MESSAGE],
{
onAvailable,
}
@ -120,7 +116,7 @@ async function testPlatformMessagesResourcesWithIgnoreExistingResources() {
const availableResources = [];
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.PLATFORM_MESSAGE],
[resourceWatcher.TYPES.PLATFORM_MESSAGE],
{
onAvailable: resources => {
for (const resource of resources) {

Просмотреть файл

@ -5,10 +5,6 @@
// 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
* call sites, which is not something we intend to support at the moment in the
@ -30,7 +26,7 @@ add_task(async function() {
info("Call watchResources([ROOT_NODE], ...)");
let onAvailableCounter = 0;
const onAvailable = resources => (onAvailableCounter += resources.length);
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ROOT_NODE], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.ROOT_NODE], {
onAvailable,
});
@ -49,7 +45,7 @@ add_task(async function() {
is(onAvailableCounter, 2, "onAvailable has been called 2 times");
info("Call unwatchResources([ROOT_NODE], ...) for the onAvailable callback");
resourceWatcher.unwatchResources([ResourceWatcher.TYPES.ROOT_NODE], {
resourceWatcher.unwatchResources([resourceWatcher.TYPES.ROOT_NODE], {
onAvailable,
});
@ -85,7 +81,7 @@ add_task(async function testRootNodeFrontIsCorrect() {
let rootNodeResolve;
let rootNodePromise = new Promise(r => (rootNodeResolve = r));
const onAvailable = ([rootNodeFront]) => rootNodeResolve(rootNodeFront);
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ROOT_NODE], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.ROOT_NODE], {
onAvailable,
});
@ -94,7 +90,7 @@ add_task(async function testRootNodeFrontIsCorrect() {
ok(!!root1, "onAvailable has been called with a valid argument");
is(
root1.resourceType,
ResourceWatcher.TYPES.ROOT_NODE,
resourceWatcher.TYPES.ROOT_NODE,
"The resource has the expected type"
);
@ -121,7 +117,7 @@ add_task(async function testRootNodeFrontIsCorrect() {
is(div3.getAttribute("id"), "div3", "Correct root node retrieved");
// Cleanup
resourceWatcher.unwatchResources([ResourceWatcher.TYPES.ROOT_NODE], {
resourceWatcher.unwatchResources([resourceWatcher.TYPES.ROOT_NODE], {
onAvailable,
});
targetCommand.destroy();

Просмотреть файл

@ -2,11 +2,10 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test the ResourceWatcher API around SERVER SENT EVENTS.
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const targets = {
TOP_LEVEL_DOCUMENT: "top-level-document",
@ -37,7 +36,7 @@ async function testServerSentEventResources(target) {
}
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.SERVER_SENT_EVENT],
[resourceWatcher.TYPES.SERVER_SENT_EVENT],
{ onAvailable: onResourceAvailable }
);
@ -71,7 +70,7 @@ async function testServerSentEventResources(target) {
});
await resourceWatcher.unwatchResources(
[ResourceWatcher.TYPES.SERVER_SENT_EVENT],
[resourceWatcher.TYPES.SERVER_SENT_EVENT],
{ onAvailable: onResourceAvailable }
);
@ -83,7 +82,7 @@ async function testServerSentEventResources(target) {
function assertResource(resource, expected) {
is(
resource.resourceType,
ResourceWatcher.TYPES.SERVER_SENT_EVENT,
ResourceCommand.TYPES.SERVER_SENT_EVENT,
"Resource type is correct"
);

Просмотреть файл

@ -3,10 +3,6 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
/**
* Check that the resource watcher is still properly watching for new targets
* after unwatching one resource, if there is still another watched resource.
@ -27,7 +23,7 @@ add_task(async function() {
targetCommand,
} = await initMultiProcessResourceWatcher();
const { CONSOLE_MESSAGE, ROOT_NODE } = ResourceWatcher.TYPES;
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.

Просмотреть файл

@ -5,9 +5,7 @@
// Test the ResourceWatcher API around SOURCE.
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const TEST_URL = URL_ROOT_SSL + "sources.html";
@ -36,7 +34,7 @@ add_task(async function() {
info("Check already available resources");
const availableResources = [];
await resourceWatcher.watchResources([ResourceWatcher.TYPES.SOURCE], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.SOURCE], {
onAvailable: resources => availableResources.push(...resources),
});
@ -154,7 +152,7 @@ async function assertResource(source, expected) {
is(
source.resourceType,
ResourceWatcher.TYPES.SOURCE,
ResourceCommand.TYPES.SOURCE,
"Resource type is correct"
);

Просмотреть файл

@ -5,9 +5,7 @@
// Test the ResourceWatcher API around STYLESHEET.
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const STYLE_TEST_URL = URL_ROOT_SSL + "style_document.html";
@ -111,7 +109,7 @@ async function testResourceAvailableFeature() {
info("Check whether ResourceWatcher gets existing stylesheet");
const availableResources = [];
await resourceWatcher.watchResources([ResourceWatcher.TYPES.STYLESHEET], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.STYLESHEET], {
onAvailable: resources => availableResources.push(...resources),
});
@ -181,7 +179,7 @@ async function testResourceUpdateFeature() {
info("Setup the watcher");
const availableResources = [];
const updates = [];
await resourceWatcher.watchResources([ResourceWatcher.TYPES.STYLESHEET], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.STYLESHEET], {
onAvailable: resources => availableResources.push(...resources),
onUpdated: newUpdates => updates.push(...newUpdates),
});
@ -322,7 +320,7 @@ async function testNestedResourceUpdateFeature() {
info("Setup the watcher");
const availableResources = [];
const updates = [];
await resourceWatcher.watchResources([ResourceWatcher.TYPES.STYLESHEET], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.STYLESHEET], {
onAvailable: resources => availableResources.push(...resources),
onUpdated: newUpdates => updates.push(...newUpdates),
});
@ -463,7 +461,7 @@ function assertMediaRules(mediaRules, expected) {
async function assertResource(resource, expected) {
is(
resource.resourceType,
ResourceWatcher.TYPES.STYLESHEET,
ResourceCommand.TYPES.STYLESHEET,
"Resource type is correct"
);
const styleSheetsFront = await resource.targetFront.getFront("stylesheets");
@ -482,7 +480,7 @@ async function assertResource(resource, expected) {
function assertUpdate(update, expected) {
is(
update.resourceType,
ResourceWatcher.TYPES.STYLESHEET,
ResourceCommand.TYPES.STYLESHEET,
"Resource type is correct"
);
is(update.resourceId, expected.resourceId, "resourceId is correct");

Просмотреть файл

@ -6,10 +6,6 @@
// Test that the server ResourceWatcher are destroyed when the associated target actors
// are destroyed.
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
add_task(async function() {
const tab = await addTab("data:text/html,Test");
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
@ -19,7 +15,7 @@ add_task(async function() {
// Start watching for console messages. We don't care about messages here, only the
// registration/destroy mechanism, so we make onAvailable a no-op function.
await resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
{
onAvailable: () => {},
}

Просмотреть файл

@ -3,10 +3,6 @@
"use strict";
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
/**
* Test initial target resources are correctly retrieved even when several calls
* to watchResources are made simultaneously.
@ -43,7 +39,7 @@ add_task(async function() {
// calls to watchResources (which could come from 2 separate modules in a real
// scenario).
const initialWatchPromise = resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CSS_MESSAGE],
[resourceWatcher.TYPES.CSS_MESSAGE],
{
onAvailable: onCssMessageAvailable,
}
@ -52,7 +48,7 @@ add_task(async function() {
// `waitForNextResource` will trigger another call to `watchResources`.
const onMessageReceived = waitForNextResource(
resourceWatcher,
ResourceWatcher.TYPES.PLATFORM_MESSAGE,
resourceWatcher.TYPES.PLATFORM_MESSAGE,
{
ignoreExistingResources: false,
predicate: r => r.message === expectedPlatformMessage,
@ -67,7 +63,7 @@ add_task(async function() {
await initialWatchPromise;
// Unwatch all resources.
resourceWatcher.unwatchResources([ResourceWatcher.TYPES.CSS_MESSAGE], {
resourceWatcher.unwatchResources([resourceWatcher.TYPES.CSS_MESSAGE], {
onAvailable: onCssMessageAvailable,
});

Просмотреть файл

@ -5,11 +5,6 @@
// Test the behavior of ResourceWatcher when the top level target changes
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const { CONSOLE_MESSAGE, SOURCE } = ResourceWatcher.TYPES;
const TEST_URI =
"data:text/html;charset=utf-8,<script>console.log('foo');</script>";
@ -19,6 +14,7 @@ add_task(async function() {
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
tab
);
const { CONSOLE_MESSAGE, SOURCE } = resourceWatcher.TYPES;
info("Check the resources gotten from getAllResources at initial");
is(

Просмотреть файл

@ -5,9 +5,7 @@
// Test the ResourceWatcher API around THREAD_STATE
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const BREAKPOINT_TEST_URL = URL_ROOT_SSL + "breakpoint_document.html";
const REMOTE_IFRAME_URL =
@ -62,7 +60,7 @@ async function checkBreakpointBeforeWatchResources() {
info("Call watchResources");
const availableResources = [];
await resourceWatcher.watchResources([ResourceWatcher.TYPES.THREAD_STATE], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.THREAD_STATE], {
onAvailable: resources => availableResources.push(...resources),
});
@ -121,7 +119,7 @@ async function checkBreakpointAfterWatchResources() {
info("Call watchResources");
const availableResources = [];
await resourceWatcher.watchResources([ResourceWatcher.TYPES.THREAD_STATE], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.THREAD_STATE], {
onAvailable: resources => availableResources.push(...resources),
});
@ -193,7 +191,7 @@ async function checkRealBreakpoint() {
info("Call watchResources");
const availableResources = [];
await resourceWatcher.watchResources([ResourceWatcher.TYPES.THREAD_STATE], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.THREAD_STATE], {
onAvailable: resources => availableResources.push(...resources),
});
@ -277,7 +275,7 @@ async function checkPauseOnException() {
info("Call watchResources");
const availableResources = [];
await resourceWatcher.watchResources([ResourceWatcher.TYPES.THREAD_STATE], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.THREAD_STATE], {
onAvailable: resources => availableResources.push(...resources),
});
@ -382,7 +380,7 @@ async function checkSetBeforeWatch() {
info("Call watchResources");
const availableResources = [];
await resourceWatcher.watchResources([ResourceWatcher.TYPES.THREAD_STATE], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.THREAD_STATE], {
onAvailable: resources => availableResources.push(...resources),
});
@ -437,7 +435,7 @@ async function checkDebuggerStatementInIframes() {
info("Call watchResources");
const availableResources = [];
await resourceWatcher.watchResources([ResourceWatcher.TYPES.THREAD_STATE], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.THREAD_STATE], {
onAvailable: resources => availableResources.push(...resources),
});
@ -518,7 +516,7 @@ async function checkDebuggerStatementInIframes() {
async function assertPausedResource(resource, expected) {
is(
resource.resourceType,
ResourceWatcher.TYPES.THREAD_STATE,
ResourceCommand.TYPES.THREAD_STATE,
"Resource type is correct"
);
is(resource.state, "paused", "state attribute is correct");
@ -558,7 +556,7 @@ async function assertPausedResource(resource, expected) {
async function assertResumedResource(resource) {
is(
resource.resourceType,
ResourceWatcher.TYPES.THREAD_STATE,
ResourceCommand.TYPES.THREAD_STATE,
"Resource type is correct"
);
is(resource.state, "resumed", "state attribute is correct");

Просмотреть файл

@ -6,9 +6,7 @@
// Test that calling unwatchResources before watchResources could resolve still
// removes watcher entries correctly.
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const TEST_URI = "data:text/html;charset=utf-8,";
@ -18,7 +16,7 @@ add_task(async function() {
const { client, resourceWatcher, targetCommand } = await initResourceWatcher(
tab
);
const { CONSOLE_MESSAGE, ROOT_NODE } = ResourceWatcher.TYPES;
const { CONSOLE_MESSAGE, ROOT_NODE } = resourceWatcher.TYPES;
info("Use console.log in the content page");
await logInTab(tab, "msg-1");
@ -96,7 +94,7 @@ function hasMessage(messageResources, text) {
// All resource watcher callbacks share the same pattern here: they add all
// console message resources to a provided `messages` array.
function createMessageCallback(messages) {
const { CONSOLE_MESSAGE } = ResourceWatcher.TYPES;
const { CONSOLE_MESSAGE } = ResourceCommand.TYPES;
return async resources => {
for (const resource of resources) {
if (resource.resourceType === CONSOLE_MESSAGE) {

Просмотреть файл

@ -5,9 +5,7 @@
// Test the ResourceWatcher API around WEBSOCKET.
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
const IS_NUMBER = "IS_NUMBER";
const SHOULD_EXIST = "SHOULD_EXIST";
@ -38,7 +36,7 @@ async function testWebsocketResources(target) {
availableResources.push(...resources);
}
await resourceWatcher.watchResources([ResourceWatcher.TYPES.WEBSOCKET], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.WEBSOCKET], {
onAvailable: onResourceAvailable,
});
@ -155,7 +153,7 @@ async function testWebsocketResources(target) {
existingResources.push(...resources);
}
await resourceWatcher.watchResources([ResourceWatcher.TYPES.WEBSOCKET], {
await resourceWatcher.watchResources([resourceWatcher.TYPES.WEBSOCKET], {
onAvailable: onExsistingResourceAvailable,
});
@ -172,11 +170,11 @@ async function testWebsocketResources(target) {
);
}
await resourceWatcher.unwatchResources([ResourceWatcher.TYPES.WEBSOCKET], {
await resourceWatcher.unwatchResources([resourceWatcher.TYPES.WEBSOCKET], {
onAvailable: onResourceAvailable,
});
await resourceWatcher.unwatchResources([ResourceWatcher.TYPES.WEBSOCKET], {
await resourceWatcher.unwatchResources([resourceWatcher.TYPES.WEBSOCKET], {
onAvailable: onExsistingResourceAvailable,
});
@ -220,7 +218,7 @@ async function executeFunctionInContext(tab, target, funcName, ...funcArgs) {
function assertResource(resource, expected) {
is(
resource.resourceType,
ResourceWatcher.TYPES.WEBSOCKET,
ResourceCommand.TYPES.WEBSOCKET,
"Resource type is correct"
);