Bug 863246 - Fix test failures draft
authorChung-Sheng Fu <cfu@mozilla.com>
Fri, 14 Jul 2017 13:39:48 +0800
changeset 609662 8fef2e6e11836bee0a5a51936b7904af381fcb9a
parent 609606 caefbe532e2457d980873995bd80ed1190a4ba11
child 637616 dafa42aba0d0c89d11502d3d8c143f44fda6ab04
push id68626
push userbmo:cfu@mozilla.com
push dateMon, 17 Jul 2017 06:50:51 +0000
bugs863246
milestone56.0a1
Bug 863246 - Fix test failures MozReview-Commit-ID: 2fdpZhHpgmM
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/client/debugger/test/mochitest/browser_dbg_worker-source-map.js
devtools/client/debugger/test/mochitest/head.js
devtools/client/shared/shim/test/test_service_appinfo.html
devtools/client/shared/shim/test/test_service_focus.html
devtools/client/shared/shim/test/test_service_prefs.html
devtools/client/shared/shim/test/test_service_prefs_defaults.html
devtools/client/shared/shim/test/test_service_wm.html
devtools/shared/platform/content/test/test_clipboard.html
dom/security/test/mixedcontentblocker/test_bug803225.html
--- a/browser/base/content/test/static/browser_all_files_referenced.js
+++ b/browser/base/content/test/static/browser_all_files_referenced.js
@@ -488,16 +488,23 @@ function findChromeUrlsFromArray(array, 
     // 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))
       gReferencesFromCode.add(string);
   }
 }
 
 add_task(async function checkAllTheFiles() {
+  // Temporarily allow content to access all resource:// URIs.
+  await SpecialPowers.pushPrefEnv({
+    set: [
+      ["security.all_resource_uri_content_accessible", true]
+    ]
+  });
+
   let libxulPath = OS.Constants.Path.libxul;
   if (AppConstants.platform != "macosx")
     libxulPath = OS.Constants.Path.libDir + "/" + libxulPath;
   let libxul = await OS.File.read(libxulPath);
   findChromeUrlsFromArray(libxul, "chrome://");
   findChromeUrlsFromArray(libxul, "resource://");
   // Handle NS_LITERAL_STRING.
   let uint16 = new Uint16Array(libxul.buffer);
@@ -544,16 +551,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,
--- 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/client/debugger/test/mochitest/browser_dbg_worker-source-map.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_worker-source-map.js
@@ -15,16 +15,19 @@ function selectWorker(aPanel, aURL) {
     return workerForm.url === aURL;
   });
   Workers.selectedItem = item;
   return promise;
 }
 
 function test() {
   return Task.spawn(function* () {
+    // Temporarily allow content to access all resource:// URIs.
+    yield pushPrefs(["security.all_resource_uri_content_accessible", true]);
+
     yield pushPrefs(["devtools.debugger.workers", true]);
 
     let options = {
       source: TAB_URL,
       line: 1
     };
     let [tab,, panel] = yield initDebugger(TAB_URL, options);
     let toolbox = yield selectWorker(panel, WORKER_URL);
--- a/devtools/client/debugger/test/mochitest/head.js
+++ b/devtools/client/debugger/test/mochitest/head.js
@@ -1052,17 +1052,22 @@ function evalInTab(tab, string) {
   info("Evalling string in tab.");
 
   return jsonrpc(tab, "_eval", [string]);
 }
 
 function createWorkerInTab(tab, url) {
   info("Creating worker with url '" + url + "' in tab.");
 
-  return jsonrpc(tab, "createWorker", [url]);
+  // Temporarily allow content to access all resource:// URIs.
+  return SpecialPowers.pushPrefEnv({
+    set: [
+      ["security.all_resource_uri_content_accessible", true]
+    ]
+  }).then(() => jsonrpc(tab, "createWorker", [url]));
 }
 
 function terminateWorkerInTab(tab, url) {
   info("Terminating worker with url '" + url + "' in tab.");
 
   return jsonrpc(tab, "terminateWorker", [url]);
 }
 
--- a/devtools/client/shared/shim/test/test_service_appinfo.html
+++ b/devtools/client/shared/shim/test/test_service_appinfo.html
@@ -12,17 +12,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   <script type="application/javascript">
   "use strict";
   var exports = {}
   var module = {exports};
   </script>
 
   <script type="application/javascript"
-	  src="resource://devtools/client/shared/shim/Services.js"></script>
+	  src="resource://devtools-client-shared/shim/Services.js"></script>
 </head>
 <body>
 <script type="application/javascript">
 "use strict";
 
 is(Services.appinfo.OS, SpecialPowers.Services.appinfo.OS,
    "check that Services.appinfo.OS shim matches platform");
 </script>
--- a/devtools/client/shared/shim/test/test_service_focus.html
+++ b/devtools/client/shared/shim/test/test_service_focus.html
@@ -12,17 +12,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   <script type="application/javascript">
   "use strict";
   var exports = {}
   var module = {exports};
   </script>
 
   <script type="application/javascript"
-	  src="resource://devtools/client/shared/shim/Services.js"></script>
+	  src="resource://devtools-client-shared/shim/Services.js"></script>
 </head>
 <body>
   <span>
     <span id="start" testvalue="0" tabindex="0"> </span>
     <label>
       <input testvalue="1" type="radio">Hi</input>
     </label>
     <label>
--- a/devtools/client/shared/shim/test/test_service_prefs.html
+++ b/devtools/client/shared/shim/test/test_service_prefs.html
@@ -40,17 +40,17 @@ localStorage.setItem("Services.prefs:dev
   userValue: null
 }));
 
 </script>
 
   <script type="application/javascript"
 	  src="prefs-wrapper.js"></script>
   <script type="application/javascript"
-	  src="resource://devtools/client/shared/shim/Services.js"></script>
+	  src="resource://devtools-client-shared/shim/Services.js"></script>
 </head>
 <body>
 <script type="application/javascript">
 "use strict";
 
 function do_tests() {
   // We can't load the defaults in this context.
   Services._defaultPrefsEnabled = false;
--- a/devtools/client/shared/shim/test/test_service_prefs_defaults.html
+++ b/devtools/client/shared/shim/test/test_service_prefs_defaults.html
@@ -39,17 +39,17 @@ localStorage.setItem("Services.prefs:pre
   defaultValue: "pref3default",
   hasUserValue: true,
   userValue: "glass winged butterfly"
 }));
 
 </script>
 
   <script type="application/javascript"
-	  src="resource://devtools/client/shared/shim/Services.js"></script>
+	  src="resource://devtools-client-shared/shim/Services.js"></script>
 </head>
 <body>
 <script type="application/javascript">
 "use strict";
 
 is(Services.prefs.getCharPref("pref1"), "pref1default", "pref1 value");
 is(Services.prefs.getCharPref("pref2"), "pref2default", "pref2 value");
 is(Services.prefs.getCharPref("pref2.sub1"), "pref2sub1default", "pref2 sub1 value");
--- a/devtools/client/shared/shim/test/test_service_wm.html
+++ b/devtools/client/shared/shim/test/test_service_wm.html
@@ -12,17 +12,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   <script type="application/javascript">
   "use strict";
   var exports = {}
   var module = {exports};
   </script>
 
   <script type="application/javascript"
-	  src="resource://devtools/client/shared/shim/Services.js"></script>
+	  src="resource://devtools-client-shared/shim/Services.js"></script>
 </head>
 <body>
 
 <script type="application/javascript">
   "use strict";
 
   function hurray(window) {
     ok(true, "window loaded");
--- 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((aResolve) => {
+    var script = document.createElement("script");
+    script.onload = aResolve;
+    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();
     });
   }