Bug 1595528 - [remote] Vendor in latest puppeteer changes. r=remote-protocol-reviewers,maja_zf
authorHenrik Skupin <mail@hskupin.info>
Tue, 12 Nov 2019 21:18:49 +0000
changeset 501668 bf5bee09a2fccd063b071395355ecd48856d6c69
parent 501667 b7dc2082925ee821199b92c1d48edfd0da0b6aef
child 501669 ac269d3b31551eb918685c274bb07b5e6db3511d
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersremote-protocol-reviewers, maja_zf
bugs1595528
milestone72.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 1595528 - [remote] Vendor in latest puppeteer changes. r=remote-protocol-reviewers,maja_zf Differential Revision: https://phabricator.services.mozilla.com/D52740
remote/test/puppeteer/lib/Launcher.js
remote/test/puppeteer/moz.yaml
remote/test/puppeteer/test/fixtures.spec.js
remote/test/puppeteer/test/puppeteer.spec.js
--- a/remote/test/puppeteer/lib/Launcher.js
+++ b/remote/test/puppeteer/lib/Launcher.js
@@ -156,20 +156,22 @@ class BrowserRunner {
    *
    * @return {!Promise<!Connection>}
    */
   async setupConnection(options) {
     const {
       usePipe,
       timeout,
       slowMo,
-      preferredRevision
+      preferredRevision,
+      use_stdout,
     } = options;
     if (!usePipe) {
-      const browserWSEndpoint = await waitForWSEndpoint(this.proc, timeout, preferredRevision);
+      const browserWSEndpoint = await waitForWSEndpoint(
+        this.proc, timeout, preferredRevision, use_stdout);
       const transport = await WebSocketTransport.create(browserWSEndpoint);
       this.connection = new Connection(browserWSEndpoint, transport, slowMo);
     } else {
       const transport = new PipeTransport(/** @type {!NodeJS.WritableStream} */(this.proc.stdio[3]), /** @type {!NodeJS.ReadableStream} */ (this.proc.stdio[4]));
       this.connection = new Connection('', transport, slowMo);
     }
     return this.connection;
   }
@@ -234,17 +236,17 @@ class ChromeLauncher {
       chromeExecutable = executablePath;
     }
 
     const usePipe = chromeArguments.includes('--remote-debugging-pipe');
     const runner = new BrowserRunner(chromeExecutable, chromeArguments, temporaryUserDataDir);
     runner.start({handleSIGHUP, handleSIGTERM, handleSIGINT, dumpio, env, pipe: usePipe});
 
     try {
-      const connection = await runner.setupConnection({usePipe, timeout, slowMo, preferredRevision: this._preferredRevision});
+      const connection = await runner.setupConnection({usePipe, timeout, slowMo, preferredRevision: this._preferredRevision, use_stdout: false});
       const browser = await Browser.create(connection, [], ignoreHTTPSErrors, defaultViewport, runner.proc, runner.close.bind(runner));
       await browser.waitForTarget(t => t.type() === 'page');
       return browser;
     } catch (e) {
       runner.kill();
       throw e;
     }
   }
@@ -402,17 +404,17 @@ class FirefoxLauncher {
         throw new Error(missingText);
       executable = executablePath;
     }
 
     const runner = new BrowserRunner(executable, firefoxArguments, temporaryUserDataDir);
     runner.start({handleSIGHUP, handleSIGTERM, handleSIGINT, dumpio, env, pipe});
 
     try {
-      const connection = await runner.setupConnection({usePipe: pipe, timeout, slowMo, preferredRevision: this._preferredRevision});
+      const connection = await runner.setupConnection({usePipe: pipe, timeout, slowMo, preferredRevision: this._preferredRevision, use_stdout: true});
       const browser = await Browser.create(connection, [], ignoreHTTPSErrors, defaultViewport, runner.proc, runner.close.bind(runner));
       await browser.waitForTarget(t => t.type() === 'page');
       return browser;
     } catch (e) {
       runner.kill();
       throw e;
     }
   }
@@ -513,21 +515,23 @@ class FirefoxLauncher {
   }
 }
 
 
 /**
  * @param {!Puppeteer.ChildProcess} browserProcess
  * @param {number} timeout
  * @param {string} preferredRevision
+ * @param {boolean} use_stdout
  * @return {!Promise<string>}
  */
-function waitForWSEndpoint(browserProcess, timeout, preferredRevision) {
+function waitForWSEndpoint(browserProcess, timeout, preferredRevision, use_stdout) {
   return new Promise((resolve, reject) => {
-    const rl = readline.createInterface({ input: browserProcess.stdout });
+    const input = use_stdout ? browserProcess.stdout : browserProcess.stderr;
+    const rl = readline.createInterface({ input });
     let stderr = '';
     const listeners = [
       helper.addEventListener(rl, 'line', onLine),
       helper.addEventListener(rl, 'close', () => onClose()),
       helper.addEventListener(browserProcess, 'exit', () => onClose()),
       helper.addEventListener(browserProcess, 'error', error => onClose(error))
     ];
     const timeoutId = timeout ? setTimeout(onTimeout, timeout) : 0;
--- a/remote/test/puppeteer/moz.yaml
+++ b/remote/test/puppeteer/moz.yaml
@@ -1,10 +1,10 @@
 bugzilla:
   component: Agent
   product: Remote Protocol
 origin:
   description: Headless Chrome Node API
   license: Apache-2.0
   name: puppeteer
-  release: d26ff10
-  url: https://github.com/mjzffr/puppeteer.git
+  release: firefox
+  url: https://github.com/andreastt/puppeteer.git
 schema: 1
--- a/remote/test/puppeteer/test/fixtures.spec.js
+++ b/remote/test/puppeteer/test/fixtures.spec.js
@@ -11,17 +11,17 @@
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 const path = require('path');
 
-module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, puppeteer, puppeteerPath, CHROME}) {
+module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, puppeteer, puppeteerPath, JUGGLER}) {
   const {describe, xdescribe, fdescribe, describe_fails_ffox} = testRunner;
   const {it, fit, xit, it_fails_ffox} = testRunner;
   const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
 
   describe('Fixtures', function() {
     it_fails_ffox('dumpio option should work with pipe option ', async({server}) => {
       let dumpioData = '';
       const {spawn} = require('child_process');
@@ -33,26 +33,26 @@ module.exports.addTests = function({test
       expect(dumpioData).toContain('message from dumpio');
     });
     it('should dump browser process stderr', async({server}) => {
       let dumpioData = '';
       const {spawn} = require('child_process');
       const options = Object.assign({}, defaultBrowserOptions, {dumpio: true});
       const res = spawn('node',
           [path.join(__dirname, 'fixtures', 'dumpio.js'), puppeteerPath, JSON.stringify(options)]);
-      if (CHROME)
+      if (JUGGLER)
+        res.stdout.on('data', data => dumpioData += data.toString('utf8'));
+      else
         res.stderr.on('data', data => dumpioData += data.toString('utf8'));
-      else
-        res.stdout.on('data', data => dumpioData += data.toString('utf8'));
       await new Promise(resolve => res.on('close', resolve));
 
-      if (CHROME)
+      if (JUGGLER)
+        expect(dumpioData).toContain('Juggler listening on ws://');
+      else
         expect(dumpioData).toContain('DevTools listening on ws://');
-      else
-        expect(dumpioData).toContain('Juggler listening on ws://');
     });
     it('should close the browser when the node process closes', async({ server }) => {
       const {spawn, execSync} = require('child_process');
       const options = Object.assign({}, defaultBrowserOptions, {
         // Disable DUMPIO to cleanly read stdout.
         dumpio: false,
       });
       const res = spawn('node', [path.join(__dirname, 'fixtures', 'closeme.js'), puppeteerPath, JSON.stringify(options)]);
--- a/remote/test/puppeteer/test/puppeteer.spec.js
+++ b/remote/test/puppeteer/test/puppeteer.spec.js
@@ -68,16 +68,17 @@ module.exports.addTests = ({testRunner, 
     toBeGolden: GoldenUtils.compare.bind(null, GOLDEN_DIR, OUTPUT_DIR)
   });
 
   const testOptions = {
     testRunner,
     product,
     FFOX,
     CHROME,
+    JUGGLER,
     puppeteer,
     expect,
     defaultBrowserOptions,
     puppeteerPath,
     headless: !!defaultBrowserOptions.headless,
   };
 
   beforeAll(async() => {