Bug 1547069 - [raptor] Refactoring screen capturing code in web extension. r=perftest-reviewers,rwood
authorHenrik Skupin <mail@hskupin.info>
Tue, 30 Apr 2019 07:59:11 +0000
changeset 530715 3e2c790195768de837c9487d5d8aef5975bf5fd2
parent 530714 6d5bec8df2bcf4694a3f4c99b7d048dd776e300b
child 530716 29e3098206eae2c48d7852823325e909de015a6b
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersperftest-reviewers, rwood
bugs1547069
milestone68.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 1547069 - [raptor] Refactoring screen capturing code in web extension. r=perftest-reviewers,rwood Differential Revision: https://phabricator.services.mozilla.com/D29177
testing/raptor/webext/raptor/runner.js
--- a/testing/raptor/webext/raptor/runner.js
+++ b/testing/raptor/webext/raptor/runner.js
@@ -276,44 +276,33 @@ async function waitForResult() {
   if (screenCapture) {
     await getScreenCapture();
   }
 
   return results;
 }
 
 async function getScreenCapture() {
-  console.log("Capturing screenshot...");
-  var capturing;
-  if (["firefox", "geckoview", "refbrow", "fenix"].includes(browserName)) {
-    capturing = ext.tabs.captureVisibleTab();
-    capturing.then(onCaptured, onError);
-    await capturing;
-  } else {
-    // create capturing promise
-    capturing =  new Promise(function(resolve, reject) {
-    ext.tabs.captureVisibleTab(resolve);
-  });
+  console.log("capturing screenshot");
+
+  try {
+    let screenshotUri;
 
-    // capture and wait for promise to end
-    capturing.then(onCaptured, onError);
-    await capturing;
+    if (["firefox", "geckoview", "refbrow", "fenix"].includes(browserName)) {
+      screenshotUri = await ext.tabs.captureVisibleTab();
+    } else {
+      screenshotUri = await new Promise(resolve =>
+          ext.tabs.captureVisibleTab(resolve));
+    }
+    postToControlServer("screenshot", [screenshotUri, testName, pageCycle]);
+  } catch (e) {
+    console.log(`failed to capture screenshot: ${e}`);
   }
 }
 
-function onCaptured(screenshotUri) {
-  console.log("Screenshot capured!");
-  postToControlServer("screenshot", [screenshotUri, testName, pageCycle]);
-}
-
-function onError(error) {
-  console.log("Screenshot captured failed!");
-  console.log(`Error: ${error}`);
-}
-
 async function startGeckoProfiling() {
   postToControlServer("status", `starting Gecko profiling for threads: ${geckoThreads}`);
   await browser.geckoProfiler.start({
     bufferSize: geckoEntries,
     interval: geckoInterval,
     features: ["js", "leaf", "stackwalk", "threads", "responsiveness"],
     threads: geckoThreads.split(","),
   });