Bug 863246 - Fix test failures r=Gijs
authorChung-Sheng Fu <cfu@mozilla.com>
Wed, 19 Jul 2017 17:30:01 +0800
changeset 426734 27ca9f2f8b611369afe87f96b3e79373b928b72e
parent 426733 b9baf84bb1db7fc5da247707cbe3fbe3357b0ea5
child 426735 bd9c5474a5e4e6391a3ae74574885d1361599184
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs863246
milestone57.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 863246 - Fix test failures r=Gijs MozReview-Commit-ID: 8tUr27zvs8z
browser/base/content/test/static/browser_all_files_referenced.js
browser/base/content/test/static/browser_parsable_css.js
caps/tests/mochitest/test_bug292789.html
devtools/shared/platform/content/test/test_clipboard.html
dom/security/test/mixedcontentblocker/test_bug803225.html
parser/htmlparser/tests/reftest/bug482921-1-ref.html
parser/htmlparser/tests/reftest/bug482921-2-ref.html
parser/htmlparser/tests/reftest/bug535530-2-ref.html
parser/htmlparser/tests/reftest/bug704667-1-ref.html
parser/htmlparser/tests/reftest/bug731234-1-ref.html
parser/htmlparser/tests/reftest/bug910588-1-ref.html
--- a/browser/base/content/test/static/browser_all_files_referenced.js
+++ b/browser/base/content/test/static/browser_all_files_referenced.js
@@ -171,17 +171,16 @@ var whitelist = [
   // Bug 1351079
   {file: "resource://gre/modules/ISO8601DateUtils.jsm"},
   // Bug 1337345
   {file: "resource://gre/modules/Manifest.jsm"},
   // Bug 1351097
   {file: "resource://gre/modules/accessibility/AccessFu.jsm"},
   // Bug 1351637
   {file: "resource://gre/modules/sdk/bootstrap.js"},
-
 ];
 
 whitelist = new Set(whitelist.filter(item =>
   ("isFromDevTools" in item) == isDevtools &&
   (!item.skipNightly || !AppConstants.NIGHTLY_BUILD) &&
   (!item.platforms || item.platforms.includes(AppConstants.platform))
 ).map(item => item.file));
 
@@ -473,17 +472,18 @@ function findChromeUrlsFromArray(array, 
                        array.indexOf("#".charCodeAt(0), index));
     let string = "";
     for ( ; index < end; ++index) {
       string += String.fromCharCode(array[index]);
     }
 
     // Only keep strings that look like real chrome or resource urls.
     if (/chrome:\/\/[a-zA-Z09 -]+\/(content|skin|locale)\//.test(string) ||
-        /resource:\/\/gre.*\.[a-z]+/.test(string))
+        /resource:\/\/gre.*\.[a-z]+/.test(string) ||
+        string.startsWith("resource://content-accessible/"))
       gReferencesFromCode.add(string);
   }
 }
 
 add_task(async function checkAllTheFiles() {
   let libxulPath = OS.Constants.Path.libxul;
   if (AppConstants.platform != "macosx")
     libxulPath = OS.Constants.Path.libDir + "/" + libxulPath;
@@ -535,16 +535,18 @@ add_task(async function checkAllTheFiles
   // Wait for all the files to have actually loaded:
   await Promise.all(allPromises);
 
   // Keep only chrome:// files, and filter out either the devtools paths or
   // the non-devtools paths:
   let devtoolsPrefixes = ["chrome://webide/",
                           "chrome://devtools",
                           "resource://devtools/",
+                          "resource://devtools-client-jsonview/",
+                          "resource://devtools-client-shared/",
                           "resource://app/modules/devtools",
                           "resource://gre/modules/devtools"];
   let chromeFiles = [];
   for (let uri of uris) {
     uri = convertToCodeURI(uri.spec);
     if ((uri.startsWith("chrome://") || uri.startsWith("resource://")) &&
         isDevtools == devtoolsPrefixes.some(prefix => uri.startsWith(prefix)))
       chromeFiles.push(uri);
--- a/browser/base/content/test/static/browser_parsable_css.js
+++ b/browser/base/content/test/static/browser_parsable_css.js
@@ -12,17 +12,17 @@
 let whitelist = [
   // CodeMirror is imported as-is, see bug 1004423.
   {sourceName: /codemirror\.css$/i,
    isFromDevTools: true},
   // The debugger uses cross-browser CSS.
   {sourceName: /devtools\/client\/debugger\/new\/debugger.css/i,
    isFromDevTools: true},
    // Reps uses cross-browser CSS.
-   {sourceName: /devtools\/client\/shared\/components\/reps\/reps.css/i,
+   {sourceName: /devtools-client-shared\/components\/reps\/reps.css/i,
    isFromDevTools: true},
   // PDFjs is futureproofing its pseudoselectors, and those rules are dropped.
   {sourceName: /web\/viewer\.css$/i,
    errorMessage: /Unknown pseudo-class.*(fullscreen|selection)/i,
    isFromDevTools: false},
   // PDFjs rules needed for compat with other UAs.
   {sourceName: /web\/viewer\.css$/i,
    errorMessage: /Unknown property.*appearance/i,
@@ -283,51 +283,59 @@ add_task(async function checkAllTheCSS()
       manifestPromises.push(parseManifest(uri));
       return false;
     }
     return true;
   });
   // Wait for all manifest to be parsed
   await Promise.all(manifestPromises);
 
-  // We build a list of promises that get resolved when their respective
-  // files have loaded and produced no errors.
-  let allPromises = [];
-
   // filter out either the devtools paths or the non-devtools paths:
   let isDevtools = SimpleTest.harnessParameters.subsuite == "devtools";
   let devtoolsPathBits = ["webide", "devtools"];
   uris = uris.filter(uri => isDevtools == devtoolsPathBits.some(path => uri.spec.includes(path)));
 
-  for (let uri of uris) {
-    let linkEl = doc.createElement("link");
+  let loadCSS = chromeUri => new Promise(resolve => {
+    let linkEl, onLoad, onError;
+    onLoad = e => {
+      processCSSRules(linkEl.sheet);
+      resolve();
+      linkEl.removeEventListener("load", onLoad);
+      linkEl.removeEventListener("error", onError);
+    };
+    onError = e => {
+      ok(false, "Loading " + linkEl.getAttribute("href") + " threw an error!");
+      resolve();
+      linkEl.removeEventListener("load", onLoad);
+      linkEl.removeEventListener("error", onError);
+    };
+    linkEl = doc.createElement("link");
     linkEl.setAttribute("rel", "stylesheet");
-    allPromises.push(new Promise(resolve => {
-      let onLoad = (e) => {
-        processCSSRules(linkEl.sheet);
-        resolve();
-        linkEl.removeEventListener("load", onLoad);
-        linkEl.removeEventListener("error", onError);
-      };
-      let onError = (e) => {
-        ok(false, "Loading " + linkEl.getAttribute("href") + " threw an error!");
-        resolve();
-        linkEl.removeEventListener("load", onLoad);
-        linkEl.removeEventListener("error", onError);
-      };
-      linkEl.addEventListener("load", onLoad);
-      linkEl.addEventListener("error", onError);
-      linkEl.setAttribute("type", "text/css");
-      let chromeUri = convertToCodeURI(uri.spec);
-      linkEl.setAttribute("href", chromeUri + kPathSuffix);
-    }));
+    linkEl.setAttribute("type", "text/css");
+    linkEl.addEventListener("load", onLoad);
+    linkEl.addEventListener("error", onError);
+    linkEl.setAttribute("href", chromeUri + kPathSuffix);
     doc.head.appendChild(linkEl);
+  });
+
+  // We build a list of promises that get resolved when their respective
+  // files have loaded and produced no errors.
+  const kInContentCommonCSS = "chrome://global/skin/in-content/common.css";
+  let allPromises = uris.map((uri) => convertToCodeURI(uri.spec))
+                    .filter((uri) => uri !== kInContentCommonCSS);
+
+  // Make sure chrome://global/skin/in-content/common.css is loaded before other
+  // stylesheets in order to guarantee the --in-content variables can be
+  // correctly referenced.
+  if (allPromises.length !== uris.length) {
+    await loadCSS(kInContentCommonCSS);
   }
 
   // Wait for all the files to have actually loaded:
+  allPromises = allPromises.map(loadCSS);
   await Promise.all(allPromises);
 
   // Check if all the files referenced from CSS actually exist.
   for (let [image, references] of imageURIsToReferencesMap) {
     if (!chromeFileExists(image)) {
       for (let ref of references) {
         let ignored = false;
         for (let item of allowedImageReferences) {
--- a/caps/tests/mochitest/test_bug292789.html
+++ b/caps/tests/mochitest/test_bug292789.html
@@ -95,13 +95,18 @@ function loadImage(uri, expect, callback
     img.onload = success;
     img.expected = expect;
     img.callback = callback;
     img.src = uri;
     // document.getElementById("content").appendChild(img);
 }
 
 // Start off the script src test, and have it start the img tests when complete.
-testScriptSrc(runImgTest);
+// Temporarily allow content to access all resource:// URIs.
+SpecialPowers.pushPrefEnv({
+  set: [
+    ["security.all_resource_uri_content_accessible", true]
+  ]
+}, () => testScriptSrc(runImgTest));
 </script>
 </pre>
 </body>
 </html>
--- a/devtools/shared/platform/content/test/test_clipboard.html
+++ b/devtools/shared/platform/content/test/test_clipboard.html
@@ -10,32 +10,47 @@ https://bugzilla.mozilla.org/show_bug.cg
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css">
   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
 
 <script type="application/javascript">
 "use strict";
 var exports = {}
 </script>
-
-  <script type="application/javascript"
-	  src="resource://devtools/shared/platform/content/clipboard.js"></script>
-
 </head>
-<body onload="do_tests()">
+<body onload="pre_do_tests()">
 <script type="application/javascript">
 "use strict";
 
 const RESULT = "lark bunting";
 
 function doCopy(e) {
   console.log(e.isTrusted);
   copyString(RESULT);
 }
 
+async function pre_do_tests() {
+  // Temporarily allow content to access all resource:// URIs.
+  await SpecialPowers.pushPrefEnv({
+    set: [
+      ["security.all_resource_uri_content_accessible", true]
+    ]
+  });
+
+  // Load script.
+  await (() => new Promise((resolve) => {
+    var script = document.createElement("script");
+    script.onload = resolve;
+    script.src = "resource://devtools/shared/platform/content/clipboard.js";
+    document.head.appendChild(script);
+  }))();
+
+  do_tests();
+}
+
 function do_tests() {
   let elt = document.querySelector("#key");
   elt.addEventListener("keydown", doCopy);
 
   // Set the clipboard to something other than what we expect.
   SpecialPowers.clipboardCopyString("snowy owl");
 
   elt.focus();
--- a/dom/security/test/mixedcontentblocker/test_bug803225.html
+++ b/dom/security/test/mixedcontentblocker/test_bug803225.html
@@ -14,18 +14,21 @@ https://bugzilla.mozilla.org/show_bug.cg
   var counter = 0;
   var settings = [ [true, true], [true, false], [false, true], [false, false] ];
 
   var blockActive;
   var blockDisplay;
 
   //Cycle through 4 different preference settings.
   function changePrefs(callback) {
-    let newPrefs = [["security.mixed_content.block_display_content", settings[counter][0]],
-                    ["security.mixed_content.block_active_content", settings[counter][1]]];
+    let newPrefs = [
+      ["security.all_resource_uri_content_accessible", true], // Temporarily allow content to access all resource:// URIs.
+      ["security.mixed_content.block_display_content", settings[counter][0]],
+      ["security.mixed_content.block_active_content", settings[counter][1]]
+    ];
 
     SpecialPowers.pushPrefEnv({"set": newPrefs}, function () {
       blockDisplay = SpecialPowers.getBoolPref("security.mixed_content.block_display_content");
       blockActive = SpecialPowers.getBoolPref("security.mixed_content.block_active_content");
       counter++;
       callback();
     });
   }
--- a/parser/htmlparser/tests/reftest/bug482921-1-ref.html
+++ b/parser/htmlparser/tests/reftest/bug482921-1-ref.html
@@ -1,9 +1,9 @@
-<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype">&lt;!DOCTYPE html&gt;</span>
+<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype">&lt;!DOCTYPE html&gt;</span>
 <span id></span><span>&lt;<span class="start-tag">html</span>&gt;</span>
 <span id></span><span>&lt;<span class="start-tag">head</span>&gt;</span>
 <span id></span><span>&lt;<span class="start-tag">title</span>&gt;</span><span>Title</span><span>&lt;/<span class="end-tag">title</span>&gt;</span>
 <span id></span><span>&lt;<span class="start-tag">script</span>&gt;</span>
 <span id></span>var lt = "&lt;";
 <span id></span>&lt;!--
 <span id></span>var s = "&lt;script&gt;foo&lt;/script&gt;";
 <span id></span>--&gt;
--- a/parser/htmlparser/tests/reftest/bug482921-2-ref.html
+++ b/parser/htmlparser/tests/reftest/bug482921-2-ref.html
@@ -1,9 +1,9 @@
-<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="pi">&lt;?xml version="1.0" encoding="utf-8"?&gt;</span>
+<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="pi">&lt;?xml version="1.0" encoding="utf-8"?&gt;</span>
 <span id></span><span class="pi">&lt;?foo bar?&gt;</span>
 <span id></span><span>&lt;<span class="start-tag">html</span>&gt;</span>
 <span id></span><span>&lt;<span class="start-tag">head</span>&gt;</span>
 <span id></span><span>&lt;<span class="start-tag">title</span>&gt;</span><span>Title</span><span>&lt;/<span class="end-tag">title</span>&gt;</span>
 <span id></span><span>&lt;<span class="start-tag">script</span>&gt;</span>
 <span id></span>var s = "<span>&lt;<span class="start-tag">script</span>&gt;</span><span>foo</span><span>&lt;/<span class="end-tag">script</span>&gt;</span>";
 <span id></span><span class="comment">&lt;!--
 <span id></span>var s = "&lt;script&gt;foo&lt;/script&gt;";
--- a/parser/htmlparser/tests/reftest/bug535530-2-ref.html
+++ b/parser/htmlparser/tests/reftest/bug535530-2-ref.html
@@ -1,9 +1,9 @@
-<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype">&lt;!DOCTYPE html&gt;</span>
+<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype">&lt;!DOCTYPE html&gt;</span>
 <span id></span>XX<span class="error">&amp;</span>XX
 <span id></span>XX<span class="error">&amp;</span>nXX
 <span id></span>XX<span class="error">&amp;</span>noXX
 <span id></span>XX<span class="error entity">&amp;not</span>XX
 <span id></span>XX<span class="error entity">&amp;noti</span>XX
 <span id></span>XX<span class="error entity">&amp;notin</span>XX
 <span id></span>XX<span class="error">&amp;</span>;XX
 <span id></span>XX<span class="error">&amp;</span>n;XX
--- a/parser/htmlparser/tests/reftest/bug704667-1-ref.html
+++ b/parser/htmlparser/tests/reftest/bug704667-1-ref.html
@@ -1,4 +1,4 @@
-<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="error comment">&lt;!--&gt;</span> <span class="error comment">&lt;!X&gt;</span>
+<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="error comment">&lt;!--&gt;</span> <span class="error comment">&lt;!X&gt;</span>
 <span id></span>
 </pre>
 <!-- View source CSS matches the <pre id> and <span id> elements and produces line numbers. -->
--- a/parser/htmlparser/tests/reftest/bug731234-1-ref.html
+++ b/parser/htmlparser/tests/reftest/bug731234-1-ref.html
@@ -1,9 +1,9 @@
-<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype">&lt;!DOCTYPE html&gt;</span><span>
+<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype">&lt;!DOCTYPE html&gt;</span><span>
 <span id></span></span><span>&lt;<span class="start-tag">body</span>&gt;</span><span>
 <span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span>X
 <span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">script</span> &gt;</span><span>X
 <span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">script</span>
 <span id></span>&gt;</span><span>X
 <span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span title="End tag had attributes." class="error">&lt;/<span class="end-tag">script</span> <span class="attribute-name">foo</span>&gt;</span><span>X
 <span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span title="End tag had attributes." class="error">&lt;/<span class="end-tag">script</span> <span class="attribute-name">foo</span>=<a class="attribute-value">bar</a>&gt;</span><span>X
 <span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span title="End tag had attributes." class="error">&lt;/<span class="end-tag">script</span> <span class="attribute-name">foo</span>="<a class="attribute-value">bar</a>"&gt;</span><span>X
--- a/parser/htmlparser/tests/reftest/bug910588-1-ref.html
+++ b/parser/htmlparser/tests/reftest/bug910588-1-ref.html
@@ -1,2 +1,2 @@
-<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="highlight" style="-moz-tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span></span><span>&lt;<span class="start-tag">table</span>&gt;</span><span></span><span title="Start tag “input” seen in “table”." class="error">&lt;<span class="start-tag">input</span> <span class="attribute-name">type</span>=<a class="attribute-value">hidden</a>&gt;</span><span></span><span>&lt;/<span class="end-tag">table</span>&gt;</span><span>
+<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="-moz-tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span></span><span>&lt;<span class="start-tag">table</span>&gt;</span><span></span><span title="Start tag “input” seen in “table”." class="error">&lt;<span class="start-tag">input</span> <span class="attribute-name">type</span>=<a class="attribute-value">hidden</a>&gt;</span><span></span><span>&lt;/<span class="end-tag">table</span>&gt;</span><span>
 <span id="line2"></span></span></pre></body></html>