Bug 1533682 - Implements empty domains used by puppeteer. r=ato
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 11 Mar 2019 12:51:09 +0000
changeset 521342 016f24de0fa3b206905f1d0c5365e44d66bc2da4
parent 521341 c5edac4ccac997f4843245ab78a2266fb12486c1
child 521343 f21b07ac7fb7600419842f42992e119a57956e8d
push id10866
push usernerli@mozilla.com
push dateTue, 12 Mar 2019 18:59:09 +0000
treeherdermozilla-beta@445c24a51727 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1533682
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1533682 - Implements empty domains used by puppeteer. r=ato Puppetteer enable all these domains. Implement enable methods in order to prevent it from crashing on that. Depends on D22695 Differential Revision: https://phabricator.services.mozilla.com/D22696
remote/domains/ContentProcessDomains.jsm
remote/domains/content/Emulation.jsm
remote/domains/content/Network.jsm
remote/domains/content/Performance.jsm
remote/domains/content/Runtime.jsm
remote/domains/content/Security.jsm
remote/jar.mn
remote/test/puppeteer-demo.js
--- a/remote/domains/ContentProcessDomains.jsm
+++ b/remote/domains/ContentProcessDomains.jsm
@@ -6,11 +6,16 @@
 
 var EXPORTED_SYMBOLS = ["ContentProcessDomains"];
 
 const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 const ContentProcessDomains = {};
 
 XPCOMUtils.defineLazyModuleGetters(ContentProcessDomains, {
+  Emulation: "chrome://remote/content/domains/content/Emulation.jsm",
   Log: "chrome://remote/content/domains/content/Log.jsm",
+  Network: "chrome://remote/content/domains/content/Network.jsm",
   Page: "chrome://remote/content/domains/content/Page.jsm",
+  Performance: "chrome://remote/content/domains/content/Performance.jsm",
+  Runtime: "chrome://remote/content/domains/content/Runtime.jsm",
+  Security: "chrome://remote/content/domains/content/Security.jsm",
 });
copy from remote/domains/ContentProcessDomains.jsm
copy to remote/domains/content/Emulation.jsm
--- a/remote/domains/ContentProcessDomains.jsm
+++ b/remote/domains/content/Emulation.jsm
@@ -1,16 +1,16 @@
 /* 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 = ["ContentProcessDomains"];
+var EXPORTED_SYMBOLS = ["Emulation"];
 
-const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+const {ContentProcessDomain} = ChromeUtils.import("chrome://remote/content/domains/ContentProcessDomain.jsm");
 
-const ContentProcessDomains = {};
+class Emulation extends ContentProcessDomain {
+  // commands
 
-XPCOMUtils.defineLazyModuleGetters(ContentProcessDomains, {
-  Log: "chrome://remote/content/domains/content/Log.jsm",
-  Page: "chrome://remote/content/domains/content/Page.jsm",
-});
+  setDeviceMetricsOverride() {}
+  setTouchEmulationEnabled() {}
+}
copy from remote/domains/ContentProcessDomains.jsm
copy to remote/domains/content/Network.jsm
--- a/remote/domains/ContentProcessDomains.jsm
+++ b/remote/domains/content/Network.jsm
@@ -1,16 +1,34 @@
 /* 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 = ["ContentProcessDomains"];
+var EXPORTED_SYMBOLS = ["Network"];
+
+const {ContentProcessDomain} = ChromeUtils.import("chrome://remote/content/domains/ContentProcessDomain.jsm");
 
-const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+class Network extends ContentProcessDomain {
+  constructor(session) {
+    super(session);
+    this.enabled = false;
+  }
+
+  destructor() {
+    this.disable();
+  }
 
-const ContentProcessDomains = {};
+  // commands
 
-XPCOMUtils.defineLazyModuleGetters(ContentProcessDomains, {
-  Log: "chrome://remote/content/domains/content/Log.jsm",
-  Page: "chrome://remote/content/domains/content/Page.jsm",
-});
+  async enable() {
+    if (!this.enabled) {
+      this.enabled = true;
+    }
+  }
+
+  disable() {
+    if (this.enabled) {
+      this.enabled = false;
+    }
+  }
+}
copy from remote/domains/ContentProcessDomains.jsm
copy to remote/domains/content/Performance.jsm
--- a/remote/domains/ContentProcessDomains.jsm
+++ b/remote/domains/content/Performance.jsm
@@ -1,16 +1,34 @@
 /* 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 = ["ContentProcessDomains"];
+var EXPORTED_SYMBOLS = ["Performance"];
+
+const {ContentProcessDomain} = ChromeUtils.import("chrome://remote/content/domains/ContentProcessDomain.jsm");
 
-const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+class Performance extends ContentProcessDomain {
+  constructor(session) {
+    super(session);
+    this.enabled = false;
+  }
+
+  destructor() {
+    this.disable();
+  }
 
-const ContentProcessDomains = {};
+  // commands
 
-XPCOMUtils.defineLazyModuleGetters(ContentProcessDomains, {
-  Log: "chrome://remote/content/domains/content/Log.jsm",
-  Page: "chrome://remote/content/domains/content/Page.jsm",
-});
+  async enable() {
+    if (!this.enabled) {
+      this.enabled = true;
+    }
+  }
+
+  disable() {
+    if (this.enabled) {
+      this.enabled = false;
+    }
+  }
+}
copy from remote/domains/ContentProcessDomains.jsm
copy to remote/domains/content/Runtime.jsm
--- a/remote/domains/ContentProcessDomains.jsm
+++ b/remote/domains/content/Runtime.jsm
@@ -1,16 +1,34 @@
 /* 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 = ["ContentProcessDomains"];
+var EXPORTED_SYMBOLS = ["Runtime"];
+
+const {ContentProcessDomain} = ChromeUtils.import("chrome://remote/content/domains/ContentProcessDomain.jsm");
 
-const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+class Runtime extends ContentProcessDomain {
+  constructor(session) {
+    super(session);
+    this.enabled = false;
+  }
+
+  destructor() {
+    this.disable();
+  }
 
-const ContentProcessDomains = {};
+  // commands
 
-XPCOMUtils.defineLazyModuleGetters(ContentProcessDomains, {
-  Log: "chrome://remote/content/domains/content/Log.jsm",
-  Page: "chrome://remote/content/domains/content/Page.jsm",
-});
+  async enable() {
+    if (!this.enabled) {
+      this.enabled = true;
+    }
+  }
+
+  disable() {
+    if (this.enabled) {
+      this.enabled = false;
+    }
+  }
+}
copy from remote/domains/ContentProcessDomains.jsm
copy to remote/domains/content/Security.jsm
--- a/remote/domains/ContentProcessDomains.jsm
+++ b/remote/domains/content/Security.jsm
@@ -1,16 +1,34 @@
 /* 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 = ["ContentProcessDomains"];
+var EXPORTED_SYMBOLS = ["Security"];
+
+const {ContentProcessDomain} = ChromeUtils.import("chrome://remote/content/domains/ContentProcessDomain.jsm");
 
-const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+class Security extends ContentProcessDomain {
+  constructor(session) {
+    super(session);
+    this.enabled = false;
+  }
+
+  destructor() {
+    this.disable();
+  }
 
-const ContentProcessDomains = {};
+  // commands
 
-XPCOMUtils.defineLazyModuleGetters(ContentProcessDomains, {
-  Log: "chrome://remote/content/domains/content/Log.jsm",
-  Page: "chrome://remote/content/domains/content/Page.jsm",
-});
+  async enable() {
+    if (!this.enabled) {
+      this.enabled = true;
+    }
+  }
+
+  disable() {
+    if (this.enabled) {
+      this.enabled = false;
+    }
+  }
+}
--- a/remote/jar.mn
+++ b/remote/jar.mn
@@ -26,18 +26,23 @@ remote.jar:
   content/targets/Targets.jsm (targets/Targets.jsm)
 
   # domains
   content/domains/Domain.jsm (domains/Domain.jsm)
   content/domains/Domains.jsm (domains/Domains.jsm)
   content/domains/ContentProcessDomain.jsm (domains/ContentProcessDomain.jsm)
   content/domains/ContentProcessDomains.jsm (domains/ContentProcessDomains.jsm)
   content/domains/ParentProcessDomains.jsm (domains/ParentProcessDomains.jsm)
+  content/domains/content/Emulation.jsm (domains/content/Emulation.jsm)
   content/domains/content/Log.jsm (domains/content/Log.jsm)
+  content/domains/content/Network.jsm (domains/content/Network.jsm)
   content/domains/content/Page.jsm (domains/content/Page.jsm)
+  content/domains/content/Performance.jsm (domains/content/Performance.jsm)
+  content/domains/content/Runtime.jsm (domains/content/Runtime.jsm)
+  content/domains/content/Security.jsm (domains/content/Security.jsm)
   content/domains/parent/Browser.jsm (domains/parent/Browser.jsm)
   content/domains/parent/Target.jsm (domains/parent/Target.jsm)
 
   # transport layer
   content/server/HTTPD.jsm (../netwerk/test/httpserver/httpd.js)
   content/server/Packet.jsm (server/Packet.jsm)
   content/server/Socket.jsm (server/Socket.jsm)
   content/server/Stream.jsm (server/Stream.jsm)
--- a/remote/test/puppeteer-demo.js
+++ b/remote/test/puppeteer-demo.js
@@ -11,10 +11,14 @@
 /* global require */
 
 const puppeteer = require("puppeteer");
 
 console.log("Calling puppeteer.connect");
 puppeteer.connect({ browserURL: "http://localhost:9000"}).then(async browser => {
   console.log("Connect success!");
 
+  const page = await browser.newPage();
+  console.log("page", !!page);
+  await page.goto("https://www.mozilla.org/");
+
   return browser.close();
 });