Skip to content

Commit

Permalink
Bug 1731790 - [cdp] Add blank implementation of Fetch.disable to prev…
Browse files Browse the repository at this point in the history
…ent unknown method errors. r=webdriver-reviewers,jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D126317
  • Loading branch information
whimboo committed Sep 23, 2021
1 parent a6ca0dc commit e94a529
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions remote/cdp/domains/ParentProcessDomains.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const ParentProcessDomains = {};
XPCOMUtils.defineLazyModuleGetters(ParentProcessDomains, {
Browser: "chrome://remote/content/cdp/domains/parent/Browser.jsm",
Emulation: "chrome://remote/content/cdp/domains/parent/Emulation.jsm",
Fetch: "chrome://remote/content/cdp/domains/parent/Fetch.jsm",
Input: "chrome://remote/content/cdp/domains/parent/Input.jsm",
IO: "chrome://remote/content/cdp/domains/parent/IO.jsm",
Network: "chrome://remote/content/cdp/domains/parent/Network.jsm",
Expand Down
40 changes: 40 additions & 0 deletions remote/cdp/domains/parent/Fetch.jsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

var EXPORTED_SYMBOLS = ["Fetch"];

const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);

XPCOMUtils.defineLazyModuleGetters(this, {
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
});

// Note: For now this domain has only been added so that clients using CDP
// (like Selenium) don't break when trying to disable Fetch events.

class Fetch extends Domain {
constructor(session) {
super(session);

this.enabled = false;
}

destructor() {
this.disable();

super.destructor();
}

disable() {
if (!this.enabled) {
return;
}

this.enabled = false;
}
}
1 change: 1 addition & 0 deletions remote/cdp/jar.mn
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ remote.jar:
content/cdp/domains/content/Security.jsm (domains/content/Security.jsm)
content/cdp/domains/parent/Browser.jsm (domains/parent/Browser.jsm)
content/cdp/domains/parent/Emulation.jsm (domains/parent/Emulation.jsm)
content/cdp/domains/parent/Fetch.jsm (domains/parent/Fetch.jsm)
content/cdp/domains/parent/Input.jsm (domains/parent/Input.jsm)
content/cdp/domains/parent/IO.jsm (domains/parent/IO.jsm)
content/cdp/domains/parent/Network.jsm (domains/parent/Network.jsm)
Expand Down
1 change: 1 addition & 0 deletions remote/cdp/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ BROWSER_CHROME_MANIFESTS += [
"test/browser/component/browser.ini",
"test/browser/dom/browser.ini",
"test/browser/emulation/browser.ini",
"test/browser/fetch/browser.ini",
"test/browser/input/browser.ini",
"test/browser/io/browser.ini",
"test/browser/log/browser.ini",
Expand Down
10 changes: 10 additions & 0 deletions remote/cdp/test/browser/fetch/browser.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[DEFAULT]
tags = remote
subsuite = remote
skip-if = fission # Bug 1600054: Make cdp Fission compatible
support-files =
!/remote/cdp/test/browser/chrome-remote-interface.js
!/remote/cdp/test/browser/head.js
head.js

[browser_disable.js]
11 changes: 11 additions & 0 deletions remote/cdp/test/browser/fetch/browser_disable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

add_task(async function fetchDomainDisabled({ client }) {
const { Fetch } = client;

await Fetch.disable();
ok("Disabling Fetch domain successful");
});
11 changes: 11 additions & 0 deletions remote/cdp/test/browser/fetch/head.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/* import-globals-from ../head.js */

Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/remote/cdp/test/browser/head.js",
this
);

0 comments on commit e94a529

Please sign in to comment.