Bug 1495110 - make slow-iframe as a separated file r=mayhemer
authorLiang-Heng Chen <xeonchen@gmail.com>
Fri, 12 Oct 2018 13:39:09 +0000
changeset 499329 defaf4df79d35b6377589bfa8be43420880eafd1
parent 499328 2fe9ae64504697968b89d5ec4ef0d027a0dc46fa
child 499330 7de161eb2e1189967306da2a4f3f0b483b77a507
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1495110, 1488974
milestone64.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 1495110 - make slow-iframe as a separated file r=mayhemer The slowIframe added in bug 1488974 shares the same target HTML page with fastIframe, and the resource will be canceled by ChannelUnifier and only loaded once. Sometimes, when slowIframe is loaded faster than fastIframe, the resource in fastIframe will be canceled, that's the root cause of the intermittent. Differential Revision: https://phabricator.services.mozilla.com/D8423
toolkit/components/url-classifier/tests/mochitest/chrome.ini
toolkit/components/url-classifier/tests/mochitest/fastblock.html
toolkit/components/url-classifier/tests/mochitest/fastblock_slow_iframe.html
toolkit/components/url-classifier/tests/mochitest/test_fastblock_bug1477046.html
--- a/toolkit/components/url-classifier/tests/mochitest/chrome.ini
+++ b/toolkit/components/url-classifier/tests/mochitest/chrome.ini
@@ -10,16 +10,17 @@ support-files =
   gethash.sjs
   classifierCommon.js
   classifierHelper.js
   head.js
   threathit.sjs
   fastblock.html
   redirect_tracker.sjs
   fastblock_iframe.html
+  fastblock_slow_iframe.html
   !/toolkit/components/url-classifier/tests/mochitest/classifierFrame.html
   !/toolkit/components/url-classifier/tests/mochitest/cleanWorker.js
   !/toolkit/components/url-classifier/tests/mochitest/good.js
   !/toolkit/components/url-classifier/tests/mochitest/evil.css
   !/toolkit/components/url-classifier/tests/mochitest/evil.css^headers^
   !/toolkit/components/url-classifier/tests/mochitest/evil.js
   !/toolkit/components/url-classifier/tests/mochitest/evil.js^headers^
   !/toolkit/components/url-classifier/tests/mochitest/evilWorker.js
@@ -64,9 +65,8 @@ skip-if = verify
 [test_classifier_changetablepref_bug1395411.html]
 [test_reporturl.html]
 skip-if = verify
 [test_trackingprotection_bug1312515.html]
 [test_advisory_link.html]
 [test_threathit_report.html]
 skip-if = verify
 [test_fastblock_bug1477046.html]
-skip-if = (os == 'win' && os_version == "6.1") || (os == 'mac') # Bug 1495110
--- a/toolkit/components/url-classifier/tests/mochitest/fastblock.html
+++ b/toolkit/components/url-classifier/tests/mochitest/fastblock.html
@@ -3,17 +3,17 @@
 <head>
   <title></title>
 </head>
 <body>
   <!-- Tracking iframe contains some trackers -->
   <iframe id="fastIFrame" data-touched="not sure" src="http://tracking.example.org/chrome/toolkit/components/url-classifier/tests/mochitest/fastblock_iframe.html" onload="this.dataset.touched='yes';" onerror="this.dataset.touched='no';"></iframe>
 
   <!-- A slow tracking iframe containing some trackers -->
-  <iframe id="slowIFrame" data-touched="not sure" src="http://tracking.example.org/chrome/toolkit/components/url-classifier/tests/mochitest/fastblock_iframe.html?slow" onload="this.dataset.touched='yes';"></iframe>
+  <iframe id="slowIFrame" data-touched="not sure" src="http://tracking.example.org/chrome/toolkit/components/url-classifier/tests/mochitest/fastblock_slow_iframe.html" onload="this.dataset.touched='yes';"></iframe>
 
   <!-- A fast tracker that redirects to become a slow tracker -->
   <script id="redirectScript"src="http://example.com/chrome/toolkit/components/url-classifier/tests/mochitest/redirect_tracker.sjs" onload="this.dataset.touched='yes';" onerror="this.dataset.touched='no';"></script>
 
   <!-- Tracking URL -->
   <script id="goodScript" data-touched="not sure" src="http://tracking.example.com/tests/toolkit/components/url-classifier/tests/mochitest/good.js" onload="this.dataset.touched='yes';" onerror="this.dataset.touched='no';"></script>
 
   <!-- Tracking Annotation -->
new file mode 100644
--- /dev/null
+++ b/toolkit/components/url-classifier/tests/mochitest/fastblock_slow_iframe.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title></title>
+</head>
+<body>
+
+  <!-- Tracking URL -->
+  <script id="goodSlowIFrameScript" data-touched="not sure" src="http://example.com/tests/toolkit/components/url-classifier/tests/mochitest/good.js?slowiframe" onload="this.dataset.touched='yes';" onerror="this.dataset.touched='no';"></script>
+
+  <!-- Tracking Annotation -->
+  <script id="fastSlowIFrameScript" data-touched="not sure" src="http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/evil.js?slowiframe" onload="this.dataset.touched='yes';" onerror="this.dataset.touched='no';"></script>
+
+  <!-- Tracking Annotation -->
+  <script id="slowSlowIFrameScript" data-touched="not sure" src="http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackingRequest.js?slowiframe" onload="this.dataset.touched='yes';" onerror="this.dataset.touched='no';"></script>
+
+</body>
+</html>
--- a/toolkit/components/url-classifier/tests/mochitest/test_fastblock_bug1477046.html
+++ b/toolkit/components/url-classifier/tests/mochitest/test_fastblock_bug1477046.html
@@ -1,49 +1,49 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=1477046
 
-------------------------------------------
-| ID               | Tracker | FastBlock |
--------------------+---------+------------
-| fastblock.html   | No      | N/A       |
--------------------+---------+------------
-| goodScript       | No      | N/A       |
-| fastScript       | Yes     | No        |
-| slowScript       | Yes     | Yes       |
-| redirectScript   | Yes     | Yes       |
--------------------+---------+------------
-| fastIFrame       | Yes     | No        |
--------------------+---------+------------
-| goodIFrameScript | No      | N/A       |
-| fastIFrameScript | Yes     | No        |
-| slowIFrameScript | Yes     | Yes       |
--------------------+---------+------------
-| slowIFrame       | Yes     | Yes       |
--------------------+---------+------------
-| goodIFrameScript | No      | N/A       |
-| fastIFrameScript | Yes     | N/A       |
-| slowIFrameScript | Yes     | N/A       |
--------------------+---------+------------
-|          (load event fires)            |
--------------------+---------+------------
-| badIFrame        | Yes     | No        |
--------------------+---------+------------
-| goodIFrameScript | No      | N/A       |
-| fastIFrameScript | Yes     | No        |
-| slowIFrameScript | Yes     | No        |
--------------------+---------+------------
-| goodIFrame       | No      | N/A       |
--------------------+---------+------------
-| goodIFrameScript | No      | N/A       |
-| fastIFrameScript | Yes     | No        |
-| slowIFrameScript | Yes     | No        |
-------------------------------------------
+----------------------------------------------
+| ID                   | Tracker | FastBlock |
+-----------------------+---------+------------
+| fastblock.html       | No      | N/A       |
+-----------------------+---------+------------
+| goodScript           | No      | N/A       |
+| fastScript           | Yes     | No        |
+| slowScript           | Yes     | Yes       |
+| redirectScript       | Yes     | Yes       |
+-----------------------+---------+------------
+| fastIFrame           | Yes     | No        |
+-----------------------+---------+------------
+| goodIFrameScript     | No      | N/A       |
+| fastIFrameScript     | Yes     | No        |
+| slowIFrameScript     | Yes     | Yes       |
+-----------------------+---------+------------
+| slowIFrame           | Yes     | Yes       |
+-----------------------+---------+------------
+| goodSlowIFrameScript | No      | N/A       |
+| fastSlowIFrameScript | Yes     | N/A       |
+| slowSlowIFrameScript | Yes     | N/A       |
+-----------------------+---------+------------
+|            (load event fires)              |
+-----------------------+---------+------------
+| badIFrame            | Yes     | No        |
+-----------------------+---------+------------
+| goodIFrameScript     | No      | N/A       |
+| fastIFrameScript     | Yes     | No        |
+| slowIFrameScript     | Yes     | No        |
+-----------------------+---------+------------
+| goodIFrame           | No      | N/A       |
+-----------------------+---------+------------
+| goodIFrameScript     | No      | N/A       |
+| fastIFrameScript     | Yes     | No        |
+| slowIFrameScript     | Yes     | No        |
+----------------------------------------------
 
 -->
 <head>
   <meta charset="utf-8">
   <title>Test for Bug 1477046</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
 </head>
@@ -76,19 +76,21 @@ const gValidHosts = [
   "itisatracker.org",
   "trackertest.org",
   "tracking.example.com",
   "tracking.example.org",
 ];
 const gSlowTrackers = [
   "http://tracking.example.org/tests/toolkit/components/url-classifier/tests/mochitest/trackingRequest.js",
   "http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackingRequest.js",
+  "http://tracking.example.org/chrome/toolkit/components/url-classifier/tests/mochitest/fastblock_slow_iframe.html",
   "http://tracking.example.org/tests/toolkit/components/url-classifier/tests/mochitest/trackingRequest.js?iframe",
   "http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackingRequest.js?iframe",
-  "http://tracking.example.org/chrome/toolkit/components/url-classifier/tests/mochitest/fastblock_iframe.html?slow",
+  "http://tracking.example.org/tests/toolkit/components/url-classifier/tests/mochitest/trackingRequest.js?slowiframe",
+  "http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackingRequest.js?slowiframe",
 ];
 const gRedirectTracker =
   "http://example.com/chrome/toolkit/components/url-classifier/tests/mochitest/redirect_tracker.sjs";
 
 const gInfiniteTimeout = 300000;
 const gDebug = false;
 
 function log(aMsg) {
@@ -371,20 +373,20 @@ async function testFastBlock(aWindow) {
   let browser = aWindow.gBrowser.selectedBrowser;
   let results = await ContentTask.spawn(browser, {}, () => {
     let iframe = content.document.getElementById("fastIFrame").contentDocument;
     return {
       goodScript: content.document.getElementById("goodScript").dataset.touched,
       fastScript: content.document.getElementById("fastScript").dataset.touched,
       slowScript: content.document.getElementById("slowScript").dataset.touched,
       fastIFrame: content.document.getElementById("fastIFrame").dataset.touched,
-      slowIFrame: content.document.getElementById("slowIFrame").dataset.touched,
       goodIFrameScript: iframe.getElementById("goodIFrameScript").dataset.touched,
       fastIFrameScript: iframe.getElementById("fastIFrameScript").dataset.touched,
       slowIFrameScript: iframe.getElementById("slowIFrameScript").dataset.touched,
+      slowIFrame: content.document.getElementById("slowIFrame").dataset.touched,
       redirectScript: content.document.getElementById("redirectScript").dataset.touched,
       numTrackersFound: content.document.numTrackersFound,
       numTrackersBlocked: content.document.numTrackersBlocked,
     };
   });
 
   let { goodScript,
         fastScript,
@@ -457,52 +459,62 @@ async function testFastBlock(aWindow) {
   is(results.numTrackersFound, 12, "12 trackers found");
   is(results.numTrackersBlocked, 4, "4 tracker blocked");
 }
 
 async function testNoFastBlock(aWindow) {
   log("testNoFastBlock");
   let browser = aWindow.gBrowser.selectedBrowser;
   let results = await ContentTask.spawn(browser, {}, () => {
-    let iframe = content.document.getElementById("fastIFrame").contentDocument;
+    let fastIframe = content.document.getElementById("fastIFrame").contentDocument;
+    let slowIframe = content.document.getElementById("slowIFrame").contentDocument;
     return {
       goodScript: content.document.getElementById("goodScript").dataset.touched,
       fastScript: content.document.getElementById("fastScript").dataset.touched,
       slowScript: content.document.getElementById("slowScript").dataset.touched,
       fastIFrame: content.document.getElementById("fastIFrame").dataset.touched,
+      goodIFrameScript: fastIframe.getElementById("goodIFrameScript").dataset.touched,
+      fastIFrameScript: fastIframe.getElementById("fastIFrameScript").dataset.touched,
+      slowIFrameScript: fastIframe.getElementById("slowIFrameScript").dataset.touched,
       slowIFrame: content.document.getElementById("slowIFrame").dataset.touched,
-      goodIFrameScript: iframe.getElementById("goodIFrameScript").dataset.touched,
-      fastIFrameScript: iframe.getElementById("fastIFrameScript").dataset.touched,
-      slowIFrameScript: iframe.getElementById("slowIFrameScript").dataset.touched,
+      goodSlowIFrameScript: slowIframe.getElementById("goodSlowIFrameScript").dataset.touched,
+      fastSlowIFrameScript: slowIframe.getElementById("fastSlowIFrameScript").dataset.touched,
+      slowSlowIFrameScript: slowIframe.getElementById("slowSlowIFrameScript").dataset.touched,
       numTrackersFound: content.document.numTrackersFound,
       numTrackersBlocked: content.document.numTrackersBlocked,
     };
   });
 
   let { goodScript,
         fastScript,
         slowScript,
         fastIFrame,
-        slowIFrame,
         goodIFrameScript,
         fastIFrameScript,
         slowIFrameScript,
+        slowIFrame,
+        goodSlowIFrameScript,
+        fastSlowIFrameScript,
+        slowSlowIFrameScript,
         numTrackersFound,
         numTrackersBlocked,
   } = results;
 
   is(goodScript, "yes", "is not a tracker");
   is(fastScript, "yes", "FastBlock is disabled");
   is(slowScript, "yes", "FastBlock is disabled");
   is(fastIFrame, "yes", "fast iframe loaded");
-  is(slowIFrame, "yes", "FastBlock is disabled");
   is(goodIFrameScript, "yes", "is not a tracker");
   is(fastIFrameScript, "yes", "FastBlock is disabled");
   is(slowIFrameScript, "yes", "FastBlock is disabled");
-  is(numTrackersFound, 7, "7 trackers found");
+  is(slowIFrame, "yes", "FastBlock is disabled");
+  is(goodSlowIFrameScript, "yes", "is not a tracker");
+  is(fastSlowIFrameScript, "yes", "FastBlock is disabled");
+  is(slowSlowIFrameScript, "yes", "FastBlock is disabled");
+  is(numTrackersFound, 9, "9 trackers found");
   is(numTrackersBlocked, 0, "no tracker blocked");
 
   let iframeLoaded = await addIFrame(aWindow, gBadIFramePage, "badIFrame");
   ok(iframeLoaded, "tracking iframe is loaded");
 
   results = await ContentTask.spawn(browser, log, (LOG) => {
     let iframe = content.document.getElementById("badIFrame").contentDocument;
     return {
@@ -515,17 +527,17 @@ async function testNoFastBlock(aWindow) 
     };
   });
 
   is(results.badIFrame, "yes", "FastBlock is disabled");
   is(results.goodIFrameScript, "yes", "is not a tracker");
   is(results.fastIFrameScript, "yes", "FastBlock is disabled");
   is(results.slowIFrameScript, "yes", "FastBlock is disabled");
 
-  is(results.numTrackersFound, 10, "10 trackers found");
+  is(results.numTrackersFound, 12, "12 trackers found");
   is(results.numTrackersBlocked, 0, "0 tracker blocked");
 
   let goodIFrameLoaded = await addIFrame(aWindow, gGoodIFramePage, "goodIFrame");
   ok(goodIFrameLoaded, "non tracking iframe is loaded");
 
   results = await ContentTask.spawn(browser, {}, () => {
     let iframe = content.document.getElementById("goodIFrame").contentDocument;
     return {
@@ -538,17 +550,17 @@ async function testNoFastBlock(aWindow) 
     };
   });
 
   is(results.goodIFrame, "yes", "non tracking iframe is loaded");
   is(results.goodIFrameScript, "yes", "is not a tracker");
   is(results.fastIFrameScript, "yes", "FastBlock is disabled");
   is(results.slowIFrameScript, "yes", "FastBlock is disabled");
 
-  is(results.numTrackersFound, 12, "12 trackers found");
+  is(results.numTrackersFound, 14, "14 trackers found");
   is(results.numTrackersBlocked, 0, "0 tracker blocked");
 }
 
 async function testPrefsSwitch() {
   // FastBlock ON
   await runTest({
     "set": [
       ["browser.contentblocking.enabled", true],