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

--HG--
extra : rebase_source : 63890e9b4bbcf4de46190d42808ed92430f3c072
This commit is contained in:
Julian Descottes 2017-04-20 11:46:51 +02:00
parent 1b936ebd82
commit 3466153b93
4 changed files with 31 additions and 3 deletions

View File

@ -6,6 +6,7 @@ support-files =
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

View File

@ -4,14 +4,31 @@
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
@ -28,6 +45,7 @@ add_task(function* () {
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");
@ -44,15 +62,21 @@ add_task(function* () {
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
@ -85,8 +109,10 @@ add_task(function* () {
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);
});

View File

@ -0,0 +1 @@
skin test1 test img/

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 B