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
--- 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?