Bug 1358070 - register dedicated privileged image for browser_docshell_type_editor.js;r=Gijs
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 20 Apr 2017 11:46:51 +0200
changeset 354345 622dd3df21ca10b4b5b343b550c3ca5a4699e25c
parent 354344 3cb3b2425a447a3a47edc713cfdaf2f708046da4
child 354347 a4746985e0ba9060bc7b64fd7d7355c24d88dd1e
push id41251
push userjdescottes@mozilla.com
push dateFri, 21 Apr 2017 18:08:25 +0000
treeherderautoland@622dd3df21ca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1358070
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 1358070 - register dedicated privileged image for browser_docshell_type_editor.js;r=Gijs The test image/test/browser/browser_docshell_type_editor.js used to rely on a devtools image. Devtools are moving away from mozilla central, so here we register a new image dedicated for this test. MozReview-Commit-ID: Log4J0eLudV
image/test/browser/browser.ini
image/test/browser/browser_docshell_type_editor.js
image/test/browser/browser_docshell_type_editor/chrome.manifest
image/test/browser/browser_docshell_type_editor/img/privileged.png
--- a/image/test/browser/browser.ini
+++ b/image/test/browser/browser.ini
@@ -1,14 +1,15 @@
 [DEFAULT]
 support-files =
   animated.gif
   animated2.gif
   big.png
   head.js
   image.html
   imageX2.html
+  browser_docshell_type_editor/**
 
 [browser_bug666317.js]
 skip-if = true || e10s # Bug 1207012 - Permaorange from an uncaught exception that isn't actually turning the suite orange until it hits beta, Bug 948194 - Decoded Images seem to not be discarded on memory-pressure notification with e10s enabled
 [browser_image.js]
 skip-if = true # Bug 987616
 [browser_docshell_type_editor.js]
--- a/image/test/browser/browser_docshell_type_editor.js
+++ b/image/test/browser/browser_docshell_type_editor.js
@@ -1,63 +1,87 @@
 
 "use strict";
 
 const Ci = Components.interfaces;
 const SIMPLE_HTML = "data:text/html,<html><head></head><body></body></html>";
 
+/**
+ * Returns the directory where the chrome.manifest file for the test can be found.
+ *
+ * @return nsILocalFile of the manifest directory
+ */
+function getManifestDir() {
+  let path = getTestFilePath("browser_docshell_type_editor");
+  let file = Components.classes["@mozilla.org/file/local;1"]
+                       .createInstance(Components.interfaces.nsILocalFile);
+  file.initWithPath(path);
+  return file;
+}
+
 // The following URI is *not* accessible to content, hence loading that URI
 // from an unprivileged site should be blocked. If docshell is of appType
 // APP_TYPE_EDITOR however the load should be allowed.
-// >> chrome://devtools/content/framework/dev-edition-promo/dev-edition-logo.png
+// >> chrome://test1/skin/privileged.png
 
 add_task(function* () {
   info("docshell of appType APP_TYPE_EDITOR can access privileged images.");
 
+  // Load a temporary manifest adding a route to a privileged image
+  let manifestDir = getManifestDir();
+  Components.manager.addBootstrappedManifestLocation(manifestDir);
+
   yield BrowserTestUtils.withNewTab({
     gBrowser,
     url: SIMPLE_HTML
   }, function* (browser) {
     yield ContentTask.spawn(browser, null, function* () {
       let rootDocShell = docShell.QueryInterface(Ci.nsIDocShellTreeItem)
                                  .rootTreeItem
                                  .QueryInterface(Ci.nsIInterfaceRequestor)
                                  .getInterface(Ci.nsIDocShell);
       let defaultAppType = rootDocShell.appType;
 
       rootDocShell.appType = Ci.nsIDocShell.APP_TYPE_EDITOR;
 
       is(rootDocShell.appType, Ci.nsIDocShell.APP_TYPE_EDITOR,
         "sanity check: appType after update should be type editor");
 
+
       return new Promise(resolve => {
         let doc = content.document;
         let image = doc.createElement("img");
         image.onload = function() {
           ok(true, "APP_TYPE_EDITOR is allowed to load privileged image");
           // restore appType of rootDocShell before moving on to the next test
           rootDocShell.appType = defaultAppType;
           resolve();
         }
         image.onerror = function() {
           ok(false, "APP_TYPE_EDITOR is allowed to load privileged image");
           // restore appType of rootDocShell before moving on to the next test
           rootDocShell.appType = defaultAppType;
           resolve();
         }
         doc.body.appendChild(image);
-        image.src = "chrome://devtools/content/framework/dev-edition-promo/dev-edition-logo.png";
+        image.src = "chrome://test1/skin/privileged.png";
       });
     });
   });
+
+  Components.manager.removeBootstrappedManifestLocation(manifestDir);
 });
 
 add_task(function* () {
   info("docshell of appType APP_TYPE_UNKNOWN can *not* access privileged images.");
 
+  // Load a temporary manifest adding a route to a privileged image
+  let manifestDir = getManifestDir();
+  Components.manager.addBootstrappedManifestLocation(manifestDir);
+
   yield BrowserTestUtils.withNewTab({
     gBrowser,
     url: SIMPLE_HTML
   }, function* (browser) {
     yield ContentTask.spawn(browser, null, function* () {
       let rootDocShell = docShell.QueryInterface(Ci.nsIDocShellTreeItem)
                                  .rootTreeItem
                                  .QueryInterface(Ci.nsIInterfaceRequestor)
@@ -80,13 +104,15 @@ add_task(function* () {
         }
         image.onerror = function() {
           ok(true, "APP_TYPE_UNKNOWN is *not* allowed to acces privileged image");
           // restore appType of rootDocShell before moving on to the next test
           rootDocShell.appType = defaultAppType;
           resolve();
         }
         doc.body.appendChild(image);
-        image.src = "chrome://devtools/content/framework/dev-edition-promo/dev-edition-logo.png";
+        image.src = "chrome://test1/skin/privileged.png";
       });
     });
   });
+
+  Components.manager.removeBootstrappedManifestLocation(manifestDir);
 });
new file mode 100644
--- /dev/null
+++ b/image/test/browser/browser_docshell_type_editor/chrome.manifest
@@ -0,0 +1,1 @@
+skin test1 test img/
\ No newline at end of file
new file mode 100644
index 0000000000000000000000000000000000000000..2bf7b7e828b39c161a4e3218c281b78b242e7f9d
GIT binary patch
literal 90
zc%17D@N?(olHy`uVBq!ia0vp^EFjFm1|(O0oL2{=<UL&+LnOkJ|J2WYXwNK^z`|*e
n<>c}&K0V=pUc(wz2D>W$$mL64`T~_Qc)I$ztaD0eVqgFOl-w6?