Bug 1015466 - Part 6, wait "http-on-opening-request" after tracker iframe is inserted. r=MattN
authorShih-Chiang Chien <schien@mozilla.com>
Tue, 23 May 2017 13:29:52 +0800
changeset 409887 12783b5a0fca4162a36a61b45f7b2a5bc2b452d1
parent 409886 c4116710d7f4a0404ecf59101792352650992a98
child 409888 6975992de12186bee51d03dc8a0fea965dbf8ed7
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1015466
milestone55.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 1015466 - Part 6, wait "http-on-opening-request" after tracker iframe is inserted. r=MattN The tracking protection status will be updated after nsHttpChannel.asyncOpen on chrome process and it is asynchronously triggered by inserting the tracker iframe. This is not guaranteed to be happened before the |showMenuPromise|. Waiting for "http-on-opening-request" on chrome process before "showMenuPromise" is invoked can ensure the tracking protection status is updated when the menu is shown. MozReview-Commit-ID: INjaJUMLvZU
browser/components/uitour/test/browser_trackingProtection_tour.js
--- a/browser/components/uitour/test/browser_trackingProtection_tour.js
+++ b/browser/components/uitour/test/browser_trackingProtection_tour.js
@@ -36,24 +36,36 @@ add_UITour_task(async function test_bloc
   await checkToggleTarget("controlCenter-trackingBlock");
   TrackingProtection.enableForCurrentPage();
 });
 
 
 async function checkToggleTarget(targetID) {
   let popup = document.getElementById("UITourTooltip");
 
+  let trackerOpened = new Promise(function(resolve, reject) {
+    Services.obs.addObserver(function onopen(subject) {
+      let asciiSpec = subject.QueryInterface(Ci.nsIHttpChannel).URI.asciiSpec;
+      if (asciiSpec === "https://tracking.example.com/") {
+        Services.obs.removeObserver(onopen, "http-on-opening-request");
+        resolve();
+      }
+    }, "http-on-opening-request");
+  });
+
   await ContentTask.spawn(gBrowser.selectedBrowser, {}, function() {
     let doc = content.document;
     let iframe = doc.createElement("iframe");
     iframe.setAttribute("id", "tracking-element");
     iframe.setAttribute("src", "https://tracking.example.com/");
     doc.body.insertBefore(iframe, doc.body.firstChild);
   });
 
+  await trackerOpened;
+
   let testTargetAvailability = async function(expectedAvailable) {
     let data = await getConfigurationPromise("availableTargets");
     let available = (data.targets.indexOf(targetID) != -1);
     is(available, expectedAvailable, "Target has expected availability.");
   };
   await testTargetAvailability(false);
   await showMenuPromise("controlCenter");
   await testTargetAvailability(true);