Bug 1304531 - Remove CPOW usage from browser_timelineMarkers-01.js. r=Felipe, a=test-only
authorBlake Kaplan <mrbkap@gmail.com>
Tue, 20 Sep 2016 17:07:39 -0700
changeset 355925 cc34bcf6b29d57392c073e8078c7fce42acb3976
parent 355924 7d179054600599ace1a29ced1c2c3b7d6451cb82
child 355926 4ec7f48bd14fc2cfa456d552917a25563c21b0db
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFelipe, test-only
bugs1304531
milestone51.0a2
Bug 1304531 - Remove CPOW usage from browser_timelineMarkers-01.js. r=Felipe, a=test-only MozReview-Commit-ID: Ec3py9hntta
docshell/test/browser/browser_timelineMarkers-01.js
--- a/docshell/test/browser/browser_timelineMarkers-01.js
+++ b/docshell/test/browser/browser_timelineMarkers-01.js
@@ -1,50 +1,32 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 // Test that the docShell has the right profile timeline API
 
-var test = Task.async(function*() {
-  waitForExplicitFinish();
-
-  yield openUrl("data:text/html;charset=utf-8,Test page");
-
-  let docShell = content.QueryInterface(Ci.nsIInterfaceRequestor)
-                        .getInterface(Ci.nsIWebNavigation)
-                        .QueryInterface(Ci.nsIDocShell);
-
-  ok("recordProfileTimelineMarkers" in docShell,
-    "The recordProfileTimelineMarkers attribute exists");
-  ok("popProfileTimelineMarkers" in docShell,
-    "The popProfileTimelineMarkers function exists");
-  ok(docShell.recordProfileTimelineMarkers === false,
-    "recordProfileTimelineMarkers is false by default");
-  ok(docShell.popProfileTimelineMarkers().length === 0,
-    "There are no markers by default");
-
-  docShell.recordProfileTimelineMarkers = true;
-  ok(docShell.recordProfileTimelineMarkers === true,
-    "recordProfileTimelineMarkers can be set to true");
+const URL = "data:text/html;charset=utf-8,Test page";
 
-  docShell.recordProfileTimelineMarkers = false;
-  ok(docShell.recordProfileTimelineMarkers === false,
-    "recordProfileTimelineMarkers can be set to false");
-
-  gBrowser.removeCurrentTab();
-  finish();
-});
+add_task(function* () {
+  yield BrowserTestUtils.withNewTab({ gBrowser, url: URL },
+    function* (browser) {
+      yield ContentTask.spawn(browser, null, function() {
+        ok("recordProfileTimelineMarkers" in docShell,
+           "The recordProfileTimelineMarkers attribute exists");
+        ok("popProfileTimelineMarkers" in docShell,
+           "The popProfileTimelineMarkers function exists");
+        ok(docShell.recordProfileTimelineMarkers === false,
+           "recordProfileTimelineMarkers is false by default");
+        ok(docShell.popProfileTimelineMarkers().length === 0,
+           "There are no markers by default");
 
-function openUrl(url) {
-  return new Promise(function(resolve, reject) {
-    window.focus();
-
-    let tab = window.gBrowser.selectedTab = window.gBrowser.addTab(url);
-    let linkedBrowser = tab.linkedBrowser;
+        docShell.recordProfileTimelineMarkers = true;
+        ok(docShell.recordProfileTimelineMarkers === true,
+           "recordProfileTimelineMarkers can be set to true");
 
-    linkedBrowser.addEventListener("load", function onload() {
-      linkedBrowser.removeEventListener("load", onload, true);
-      resolve(tab);
-    }, true);
-  });
-}
+        docShell.recordProfileTimelineMarkers = false;
+        ok(docShell.recordProfileTimelineMarkers === false,
+           "recordProfileTimelineMarkers can be set to false");
+      });
+    });
+});