mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1641151 - Rename ResourceWatcher TYPES to their singular counterpart. r=jdescottes.
Differential Revision: https://phabricator.services.mozilla.com/D77030
This commit is contained in:
parent
861b7dcfe7
commit
550a3cb3f4
@ -74,7 +74,7 @@ class FirefoxConnector {
|
||||
);
|
||||
|
||||
await this.toolbox.resourceWatcher.watchResources(
|
||||
[this.toolbox.resourceWatcher.TYPES.DOCUMENT_EVENTS],
|
||||
[this.toolbox.resourceWatcher.TYPES.DOCUMENT_EVENT],
|
||||
{ onAvailable: this.onResourceAvailable }
|
||||
);
|
||||
}
|
||||
@ -93,7 +93,7 @@ class FirefoxConnector {
|
||||
);
|
||||
|
||||
this.toolbox.resourceWatcher.unwatchResources(
|
||||
[this.toolbox.resourceWatcher.TYPES.DOCUMENT_EVENTS],
|
||||
[this.toolbox.resourceWatcher.TYPES.DOCUMENT_EVENT],
|
||||
{ onAvailable: this.onResourceAvailable }
|
||||
);
|
||||
|
||||
@ -154,7 +154,7 @@ class FirefoxConnector {
|
||||
}
|
||||
|
||||
async onResourceAvailable({ resourceType, targetFront, resource }) {
|
||||
if (resourceType === this.toolbox.resourceWatcher.TYPES.DOCUMENT_EVENTS) {
|
||||
if (resourceType === this.toolbox.resourceWatcher.TYPES.DOCUMENT_EVENT) {
|
||||
this.onDocEvent(resource);
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ async function generateConsoleApiStubs() {
|
||||
handleConsoleMessage(resource);
|
||||
};
|
||||
await resourceWatcher.watchResources(
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGES],
|
||||
[resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
onAvailable: onConsoleMessage,
|
||||
}
|
||||
@ -112,7 +112,7 @@ async function generateConsoleApiStubs() {
|
||||
await received;
|
||||
}
|
||||
|
||||
resourceWatcher.unwatchResources([resourceWatcher.TYPES.CONSOLE_MESSAGES], {
|
||||
resourceWatcher.unwatchResources([resourceWatcher.TYPES.CONSOLE_MESSAGE], {
|
||||
onAvailable: onConsoleMessage,
|
||||
});
|
||||
|
||||
|
@ -76,7 +76,7 @@ async function generateCssMessageStubs() {
|
||||
};
|
||||
|
||||
/* CSS errors are considered as pageError on the server */
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.ERROR_MESSAGES], {
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||
onAvailable: onErrorMessageAvailable,
|
||||
});
|
||||
|
||||
@ -101,7 +101,7 @@ async function generateCssMessageStubs() {
|
||||
await received;
|
||||
}
|
||||
|
||||
resourceWatcher.unwatchResources([resourceWatcher.TYPES.ERROR_MESSAGES], {
|
||||
resourceWatcher.unwatchResources([resourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||
onAvailable: onErrorMessageAvailable,
|
||||
});
|
||||
|
||||
|
@ -77,7 +77,7 @@ async function generatePageErrorStubs() {
|
||||
const onErrorMessageAvailable = ({ resource }) => {
|
||||
handleErrorMessage(resource);
|
||||
};
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.ERROR_MESSAGES], {
|
||||
await resourceWatcher.watchResources([resourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||
onAvailable: onErrorMessageAvailable,
|
||||
});
|
||||
|
||||
|
@ -198,7 +198,7 @@ class WebConsoleUI {
|
||||
// TODO: Re-enable as part of Bug 1627167.
|
||||
// const resourceWatcher = this.hud.resourceWatcher;
|
||||
// resourceWatcher.unwatchResources(
|
||||
// [resourceWatcher.TYPES.CONSOLE_MESSAGES],
|
||||
// [resourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
// this._onResourceAvailable
|
||||
// );
|
||||
|
||||
@ -334,9 +334,9 @@ class WebConsoleUI {
|
||||
const resourceWatcher = this.hud.resourceWatcher;
|
||||
await resourceWatcher.watchResources(
|
||||
[
|
||||
resourceWatcher.TYPES.CONSOLE_MESSAGES,
|
||||
resourceWatcher.TYPES.ERROR_MESSAGES,
|
||||
resourceWatcher.TYPES.PLATFORM_MESSAGES,
|
||||
resourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||
resourceWatcher.TYPES.ERROR_MESSAGE,
|
||||
resourceWatcher.TYPES.PLATFORM_MESSAGE,
|
||||
],
|
||||
{ onAvailable: this._onResourceAvailable }
|
||||
);
|
||||
@ -344,7 +344,7 @@ class WebConsoleUI {
|
||||
|
||||
_onResourceAvailable({ resourceType, targetFront, resource }) {
|
||||
const resourceWatcher = this.hud.resourceWatcher;
|
||||
if (resourceType == resourceWatcher.TYPES.CONSOLE_MESSAGES) {
|
||||
if (resourceType == resourceWatcher.TYPES.CONSOLE_MESSAGE) {
|
||||
// resource is the packet sent from `ConsoleActor.getCachedMessages().messages`
|
||||
// or via ConsoleActor's `consoleAPICall` event.
|
||||
resource.type = "consoleAPICall";
|
||||
@ -352,7 +352,7 @@ class WebConsoleUI {
|
||||
return;
|
||||
}
|
||||
|
||||
if (resourceType == resourceWatcher.TYPES.ERROR_MESSAGES) {
|
||||
if (resourceType == resourceWatcher.TYPES.ERROR_MESSAGE) {
|
||||
// resource is the packet sent from `ConsoleActor.getCachedMessages().messages`
|
||||
// or via ConsoleActor's `pageError` event.
|
||||
resource.type = "pageError";
|
||||
@ -360,7 +360,7 @@ class WebConsoleUI {
|
||||
return;
|
||||
}
|
||||
|
||||
if (resourceType == resourceWatcher.TYPES.PLATFORM_MESSAGES) {
|
||||
if (resourceType == resourceWatcher.TYPES.PLATFORM_MESSAGE) {
|
||||
// resource is the packet sent from `ConsoleActor.getCachedMessages().messages`
|
||||
// or via ConsoleActor's `logMessage` event.
|
||||
resource.type = "logMessage";
|
||||
|
@ -245,7 +245,7 @@ class ResourceWatcher {
|
||||
*/
|
||||
async _startListening(resourceType) {
|
||||
const isDocumentEvent =
|
||||
resourceType === ResourceWatcher.TYPES.DOCUMENT_EVENTS;
|
||||
resourceType === ResourceWatcher.TYPES.DOCUMENT_EVENT;
|
||||
|
||||
let listeners = this._listenerCount.get(resourceType) || 0;
|
||||
listeners++;
|
||||
@ -253,7 +253,7 @@ class ResourceWatcher {
|
||||
// If there are several calls to watch, only the first caller receives
|
||||
// "existing" resources. Throw to avoid inconsistent behaviors
|
||||
if (isDocumentEvent) {
|
||||
// For DOCUMENT_EVENTS, return without throwing because this is already
|
||||
// For DOCUMENT_EVENT, return without throwing because this is already
|
||||
// used by several callsites in the netmonitor.
|
||||
// This should be reviewed in Bug 1625909.
|
||||
this._listenerCount.set(resourceType, listeners);
|
||||
@ -356,10 +356,10 @@ class ResourceWatcher {
|
||||
}
|
||||
|
||||
ResourceWatcher.TYPES = ResourceWatcher.prototype.TYPES = {
|
||||
CONSOLE_MESSAGES: "console-messages",
|
||||
ERROR_MESSAGES: "error-messages",
|
||||
PLATFORM_MESSAGES: "platform-messages",
|
||||
DOCUMENT_EVENTS: "document-events",
|
||||
CONSOLE_MESSAGE: "console-message",
|
||||
ERROR_MESSAGE: "error-message",
|
||||
PLATFORM_MESSAGE: "platform-message",
|
||||
DOCUMENT_EVENT: "document-event",
|
||||
ROOT_NODE: "root-node",
|
||||
};
|
||||
module.exports = { ResourceWatcher };
|
||||
@ -369,12 +369,12 @@ module.exports = { ResourceWatcher };
|
||||
// code is implement in Firefox, in its release channel.
|
||||
const LegacyListeners = {
|
||||
[ResourceWatcher.TYPES
|
||||
.CONSOLE_MESSAGES]: require("devtools/shared/resources/legacy-listeners/console-messages"),
|
||||
.CONSOLE_MESSAGE]: require("devtools/shared/resources/legacy-listeners/console-messages"),
|
||||
[ResourceWatcher.TYPES
|
||||
.ERROR_MESSAGES]: require("devtools/shared/resources/legacy-listeners/error-messages"),
|
||||
.ERROR_MESSAGE]: require("devtools/shared/resources/legacy-listeners/error-messages"),
|
||||
[ResourceWatcher.TYPES
|
||||
.PLATFORM_MESSAGES]: require("devtools/shared/resources/legacy-listeners/platform-messages"),
|
||||
async [ResourceWatcher.TYPES.DOCUMENT_EVENTS]({
|
||||
.PLATFORM_MESSAGE]: require("devtools/shared/resources/legacy-listeners/platform-messages"),
|
||||
async [ResourceWatcher.TYPES.DOCUMENT_EVENT]({
|
||||
targetList,
|
||||
targetFront,
|
||||
onAvailable,
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around CONSOLE_MESSAGES
|
||||
// Test the ResourceWatcher API around CONSOLE_MESSAGE
|
||||
//
|
||||
// Reproduces assertions from: devtools/shared/webconsole/test/chrome/test_cached_messages.html
|
||||
|
||||
@ -29,7 +29,7 @@ add_task(async function() {
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
info("Test ignoreExistingResources option for CONSOLE_MESSAGES");
|
||||
info("Test ignoreExistingResources option for CONSOLE_MESSAGE");
|
||||
|
||||
const tab = await addTab("data:text/html,Console Messages");
|
||||
|
||||
@ -46,7 +46,7 @@ add_task(async function() {
|
||||
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources(
|
||||
[ResourceWatcher.TYPES.CONSOLE_MESSAGES],
|
||||
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
onAvailable: ({ resource }) => availableResources.push(resource),
|
||||
ignoreExistingResources: true,
|
||||
@ -94,7 +94,7 @@ async function testMessages(browser, resourceWatcher) {
|
||||
const onAvailable = ({ resourceType, targetFront, resource }) => {
|
||||
is(
|
||||
resourceType,
|
||||
ResourceWatcher.TYPES.CONSOLE_MESSAGES,
|
||||
ResourceWatcher.TYPES.CONSOLE_MESSAGE,
|
||||
"Received a message"
|
||||
);
|
||||
ok(resource.message, "message is wrapped into a message attribute");
|
||||
@ -109,7 +109,7 @@ async function testMessages(browser, resourceWatcher) {
|
||||
};
|
||||
|
||||
await resourceWatcher.watchResources(
|
||||
[ResourceWatcher.TYPES.CONSOLE_MESSAGES],
|
||||
[ResourceWatcher.TYPES.CONSOLE_MESSAGE],
|
||||
{
|
||||
onAvailable,
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around DOCUMENT_EVENTS
|
||||
// Test the ResourceWatcher API around DOCUMENT_EVENT
|
||||
|
||||
const { TargetList } = require("devtools/shared/resources/target-list");
|
||||
const {
|
||||
@ -11,7 +11,7 @@ const {
|
||||
} = require("devtools/shared/resources/resource-watcher");
|
||||
|
||||
add_task(async function() {
|
||||
info("Test ResourceWatcher for DOCUMENT_EVENTS");
|
||||
info("Test ResourceWatcher for DOCUMENT_EVENT");
|
||||
|
||||
// Open a test tab
|
||||
const tab = await addTab("data:text/html,Document Events");
|
||||
@ -33,12 +33,9 @@ add_task(async function() {
|
||||
const onLoadingAtInit = listener.once("dom-loading");
|
||||
const onInteractiveAtInit = listener.once("dom-interactive");
|
||||
const onCompleteAtInit = listener.once("dom-complete");
|
||||
await resourceWatcher.watchResources(
|
||||
[ResourceWatcher.TYPES.DOCUMENT_EVENTS],
|
||||
{
|
||||
onAvailable: parameters => listener.dispatch(parameters),
|
||||
}
|
||||
);
|
||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.DOCUMENT_EVENT], {
|
||||
onAvailable: parameters => listener.dispatch(parameters),
|
||||
});
|
||||
await assertPromises(onLoadingAtInit, onInteractiveAtInit, onCompleteAtInit);
|
||||
ok(
|
||||
true,
|
||||
@ -62,7 +59,7 @@ add_task(async function() {
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
info("Test ignoreExistingResources option for DOCUMENT_EVENTS");
|
||||
info("Test ignoreExistingResources option for DOCUMENT_EVENT");
|
||||
|
||||
const tab = await addTab("data:text/html,Document Events");
|
||||
|
||||
@ -74,13 +71,10 @@ add_task(async function() {
|
||||
|
||||
info("Check whether the existing document events will not be fired");
|
||||
const documentEvents = [];
|
||||
await resourceWatcher.watchResources(
|
||||
[ResourceWatcher.TYPES.DOCUMENT_EVENTS],
|
||||
{
|
||||
onAvailable: ({ resource }) => documentEvents.push(resource),
|
||||
ignoreExistingResources: true,
|
||||
}
|
||||
);
|
||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.DOCUMENT_EVENT], {
|
||||
onAvailable: ({ resource }) => documentEvents.push(resource),
|
||||
ignoreExistingResources: true,
|
||||
});
|
||||
is(documentEvents.length, 0, "Existing document events are not fired");
|
||||
|
||||
info("Check whether the future document events are fired");
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around ERROR_MESSAGES
|
||||
// Test the ResourceWatcher API around ERROR_MESSAGE
|
||||
// Reproduces assertions from devtools/shared/webconsole/test/chrome/test_page_errors.html
|
||||
|
||||
const {
|
||||
@ -74,7 +74,7 @@ add_task(async function() {
|
||||
}
|
||||
};
|
||||
|
||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ERROR_MESSAGES], {
|
||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||
onAvailable,
|
||||
});
|
||||
|
||||
@ -97,7 +97,7 @@ add_task(async function() {
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
info("Test ignoreExistingResources option for ERROR_MESSAGES");
|
||||
info("Test ignoreExistingResources option for ERROR_MESSAGE");
|
||||
|
||||
// Disable the preloaded process as it creates processes intermittently
|
||||
// which forces the emission of RDP requests we aren't correctly waiting for.
|
||||
@ -117,7 +117,7 @@ add_task(async function() {
|
||||
await triggerErrors(tab);
|
||||
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ERROR_MESSAGES], {
|
||||
await resourceWatcher.watchResources([ResourceWatcher.TYPES.ERROR_MESSAGE], {
|
||||
onAvailable: ({ resource }) => availableResources.push(resource),
|
||||
ignoreExistingResources: true,
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
// Test the ResourceWatcher API around PLATFORM_MESSAGES
|
||||
// Test the ResourceWatcher API around PLATFORM_MESSAGE
|
||||
// Reproduces assertions from: devtools/shared/webconsole/test/chrome/test_nsiconsolemessage.html
|
||||
|
||||
const {
|
||||
@ -66,7 +66,7 @@ add_task(async function() {
|
||||
};
|
||||
|
||||
await resourceWatcher.watchResources(
|
||||
[ResourceWatcher.TYPES.PLATFORM_MESSAGES],
|
||||
[ResourceWatcher.TYPES.PLATFORM_MESSAGE],
|
||||
{
|
||||
onAvailable,
|
||||
}
|
||||
@ -88,7 +88,7 @@ add_task(async function() {
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
info("Test ignoreExistingResources option for PLATFORM_MESSAGES");
|
||||
info("Test ignoreExistingResources option for PLATFORM_MESSAGE");
|
||||
|
||||
// Disable the preloaded process as it creates processes intermittently
|
||||
// which forces the emission of RDP requests we aren't correctly waiting for.
|
||||
@ -109,7 +109,7 @@ add_task(async function() {
|
||||
|
||||
const availableResources = [];
|
||||
await resourceWatcher.watchResources(
|
||||
[ResourceWatcher.TYPES.PLATFORM_MESSAGES],
|
||||
[ResourceWatcher.TYPES.PLATFORM_MESSAGE],
|
||||
{
|
||||
onAvailable: ({ resource }) => {
|
||||
if (!expectedMessages.includes(resource.message)) {
|
||||
|
@ -28,25 +28,25 @@ add_task(async function() {
|
||||
targetList,
|
||||
} = await initResourceWatcherAndTarget();
|
||||
|
||||
const { CONSOLE_MESSAGES, 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.
|
||||
let receivedMessages = 0;
|
||||
const onAvailable = ({ resourceType }) => {
|
||||
if (resourceType === CONSOLE_MESSAGES) {
|
||||
if (resourceType === CONSOLE_MESSAGE) {
|
||||
receivedMessages++;
|
||||
}
|
||||
};
|
||||
|
||||
info("Call watchResources([CONSOLE_MESSAGES, ROOT_NODE], ...)");
|
||||
await resourceWatcher.watchResources([CONSOLE_MESSAGES, ROOT_NODE], {
|
||||
info("Call watchResources([CONSOLE_MESSAGE, ROOT_NODE], ...)");
|
||||
await resourceWatcher.watchResources([CONSOLE_MESSAGE, ROOT_NODE], {
|
||||
onAvailable,
|
||||
});
|
||||
|
||||
info("Use console.log in the content page");
|
||||
logInTab(tab, "test");
|
||||
info("Wait until onAvailable received 1 resource of type CONSOLE_MESSAGES");
|
||||
info("Wait until onAvailable received 1 resource of type CONSOLE_MESSAGE");
|
||||
await waitUntil(() => receivedMessages === 1);
|
||||
|
||||
// Check that the resource watcher captures resources from new targets.
|
||||
@ -56,7 +56,7 @@ add_task(async function() {
|
||||
);
|
||||
info("Use console.log in the example.com page");
|
||||
logInTab(comTab, "test-from-example-com");
|
||||
info("Wait until onAvailable received 2 resources of type CONSOLE_MESSAGES");
|
||||
info("Wait until onAvailable received 2 resources of type CONSOLE_MESSAGE");
|
||||
await waitUntil(() => receivedMessages === 2);
|
||||
|
||||
info("Stop watching ROOT_NODE resources");
|
||||
@ -70,11 +70,11 @@ add_task(async function() {
|
||||
);
|
||||
info("Use console.log in the example.net page");
|
||||
logInTab(netTab, "test-from-example-net");
|
||||
info("Wait until onAvailable received 3 resources of type CONSOLE_MESSAGES");
|
||||
info("Wait until onAvailable received 3 resources of type CONSOLE_MESSAGE");
|
||||
await waitUntil(() => receivedMessages === 3);
|
||||
|
||||
info("Stop watching CONSOLE_MESSAGES resources");
|
||||
await resourceWatcher.unwatchResources([CONSOLE_MESSAGES], { onAvailable });
|
||||
info("Stop watching CONSOLE_MESSAGE resources");
|
||||
await resourceWatcher.unwatchResources([CONSOLE_MESSAGE], { onAvailable });
|
||||
await logInTab(tab, "test-again");
|
||||
|
||||
// We don't have a specific event to wait for here, so allow some time for
|
||||
@ -84,7 +84,7 @@ add_task(async function() {
|
||||
is(
|
||||
receivedMessages,
|
||||
3,
|
||||
"The resource watcher should not watch CONSOLE_MESSAGES anymore"
|
||||
"The resource watcher should not watch CONSOLE_MESSAGE anymore"
|
||||
);
|
||||
|
||||
// Cleanup
|
||||
|
Loading…
Reference in New Issue
Block a user