Bug 1594871 - [remote] Callers of loadURL() in browser_captureScreenshot.js have to use await. r=remote-protocol-reviewers,ato
authorHenrik Skupin <mail@hskupin.info>
Fri, 08 Nov 2019 13:35:24 +0000
changeset 501272 e7c129480d82196a8f7eb892d01540074e63bd9c
parent 501271 b78631b2bccdd0b08e3b701c88b03088a7823701
child 501273 0be1ccb7d919bd33e287c7485d262b894b96a2cc
push id114168
push userdluca@mozilla.com
push dateSun, 10 Nov 2019 03:08:55 +0000
treeherdermozilla-inbound@33f64c1ef3e4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersremote-protocol-reviewers, ato
bugs1594871
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 1594871 - [remote] Callers of loadURL() in browser_captureScreenshot.js have to use await. r=remote-protocol-reviewers,ato Differential Revision: https://phabricator.services.mozilla.com/D52353
remote/test/browser/page/browser_captureScreenshot.js
--- a/remote/test/browser/page/browser_captureScreenshot.js
+++ b/remote/test/browser/page/browser_captureScreenshot.js
@@ -1,15 +1,15 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 add_task(async function documentSmallerThanViewport({ Page }) {
-  loadURL(toDataURL("<div>Hello world"));
+  await loadURL(toDataURL("<div>Hello world"));
 
   info("Check that captureScreenshot() captures the viewport by default");
   const { data } = await Page.captureScreenshot();
   ok(!!data, "Screenshot data is not empty");
 
   const scale = await getDevicePixelRatio();
   const viewportRect = await getViewportRect();
   const { mimeType, width, height } = await getImageDetails(data);
@@ -23,17 +23,17 @@ add_task(async function documentSmallerT
   is(
     height,
     (viewportRect.height - viewportRect.top) * scale,
     "Image has expected height"
   );
 });
 
 add_task(async function documentLargerThanViewport({ Page }) {
-  loadURL(toDataURL("<div style='margin: 100vh 100vw'>Hello world"));
+  await loadURL(toDataURL("<div style='margin: 100vh 100vw'>Hello world"));
 
   info("Check that captureScreenshot() captures the viewport by default");
   const { data } = await Page.captureScreenshot();
   ok(!!data, "Screenshot data is not empty");
 
   const scale = await getDevicePixelRatio();
   const viewportRect = await getViewportRect();
   const { mimeType, width, height } = await getImageDetails(data);
@@ -47,45 +47,45 @@ add_task(async function documentLargerTh
   is(
     height,
     (viewportRect.height - viewportRect.top) * scale,
     "Image has expected height"
   );
 });
 
 add_task(async function invalidFormat({ Page }) {
-  loadURL(toDataURL("<div>Hello world"));
+  await loadURL(toDataURL("<div>Hello world"));
 
   let errorThrown = false;
   try {
     await Page.captureScreenshot({ format: "foo" });
   } catch (e) {
     errorThrown = true;
   }
   ok(errorThrown, "captureScreenshot raised error for invalid image format");
 });
 
 add_task(async function asJPEGFormat({ Page }) {
-  loadURL(toDataURL("<div>Hello world"));
+  await loadURL(toDataURL("<div>Hello world"));
 
   info("Check that captureScreenshot() captures as JPEG format");
   const { data } = await Page.captureScreenshot({ format: "jpeg" });
   ok(!!data, "Screenshot data is not empty");
 
   const scale = await getDevicePixelRatio();
   const viewportRect = await getViewportRect();
   const { mimeType, height, width } = await getImageDetails(data);
 
   is(mimeType, "image/jpeg", "Screenshot has correct MIME type");
   is(width, (viewportRect.width - viewportRect.left) * scale);
   is(height, (viewportRect.height - viewportRect.top) * scale);
 });
 
 add_task(async function asJPEGFormatAndQuality({ Page }) {
-  loadURL(toDataURL("<div>Hello world"));
+  await loadURL(toDataURL("<div>Hello world"));
 
   info("Check that captureScreenshot() captures as JPEG format");
   const imageDefault = await Page.captureScreenshot({ format: "jpeg" });
   ok(!!imageDefault, "Screenshot data with default quality is not empty");
 
   const image100 = await Page.captureScreenshot({
     format: "jpeg",
     quality: 100,
@@ -132,21 +132,20 @@ add_task(async function asJPEGFormatAndQ
   is(info10.width, (viewportRect.width - viewportRect.left) * scale);
   is(info10.height, (viewportRect.height - viewportRect.top) * scale);
 
   // Images of different quality result in different content sizes
   ok(
     info100.length > infoDefault.length,
     "Size of quality 100 is larger than default"
   );
-  // Disabled due to bug 1594871
-  // ok(
-  //   info10.length < infoDefault.length,
-  //   "Size of quality 10 is smaller than default"
-  // );
+  ok(
+    info10.length < infoDefault.length,
+    "Size of quality 10 is smaller than default"
+  );
 });
 
 async function getDevicePixelRatio() {
   return ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
     return content.devicePixelRatio;
   });
 }