mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 18:08:58 +00:00
Bug 1552168 - Fix Tests that rely on data_uri.unique_opaque_origin r=ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D35006 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
e7a3fe847e
commit
ce99ef5438
@ -52,7 +52,7 @@ addRDMTask(TEST_URL, async function({ ui, manager }) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["devtools.responsive.metaViewport.enabled", true],
|
||||
["layout.testing.overlay-scrollbars.always-visible", true],
|
||||
["security.data_uri.unique_opaque_origin", false]],
|
||||
],
|
||||
});
|
||||
|
||||
const store = ui.toolWindow.store;
|
||||
|
@ -75,14 +75,8 @@ function testEnd() {
|
||||
let load = async function () {
|
||||
removeEventListener("load", load);
|
||||
|
||||
await new Promise(resolve => {
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["security.data_uri.unique_opaque_origin", false],
|
||||
]}, resolve);
|
||||
});
|
||||
|
||||
// Open a content window to test XRay functionality on built in functions.
|
||||
gWin = window.open("data:text/html,");
|
||||
gWin = window.open("javascript:1");
|
||||
info ("Waiting for content window to load");
|
||||
gWin.onload = startTest;
|
||||
};
|
||||
@ -91,3 +85,4 @@ addEventListener("load", load);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -148,14 +148,8 @@ function testEnd() {
|
||||
let load = async function () {
|
||||
removeEventListener("load", load);
|
||||
|
||||
await new Promise(resolve => {
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["security.data_uri.unique_opaque_origin", false],
|
||||
]}, resolve);
|
||||
});
|
||||
|
||||
// Open a content window to test XRay functionality on built in functions.
|
||||
gWin = window.open("data:text/html,");
|
||||
gWin = window.open("javascript:1");
|
||||
info ("Waiting for content window to load");
|
||||
gWin.onload = startTest;
|
||||
};
|
||||
@ -164,3 +158,4 @@ addEventListener("load", load);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -23,7 +23,6 @@ function f()
|
||||
function init()
|
||||
{
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["security.data_uri.unique_opaque_origin", false],
|
||||
["security.data_uri.block_toplevel_data_uri_navigations", false],
|
||||
]}, start);
|
||||
}
|
||||
@ -33,7 +32,6 @@ function start()
|
||||
var html = "<script>" + f + "<\/script><body onload=f()>";
|
||||
var win = window.open("data:text/html," + encodeURIComponent(html), null, "width=300,height=300");
|
||||
win.finish = function() {
|
||||
SpecialPowers.clearUserPref("security.data_uri.unique_opaque_origin");
|
||||
document.documentElement.removeAttribute("class");
|
||||
};
|
||||
}
|
||||
|
@ -1,11 +1,3 @@
|
||||
add_task(async function setup() {
|
||||
Services.prefs.setBoolPref("security.data_uri.unique_opaque_origin", true);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref("security.data_uri.unique_opaque_origin");
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_dataURI_unique_opaque_origin() {
|
||||
let tab = BrowserTestUtils.addTab(gBrowser, "http://example.com");
|
||||
let browser = tab.linkedBrowser;
|
||||
|
@ -4,13 +4,10 @@
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
// data: URI will only inherit principal only when the pref is false.
|
||||
Services.prefs.setBoolPref("security.data_uri.unique_opaque_origin", false);
|
||||
// data: URIs will only open at the top level when the pref is false
|
||||
// or the use of system principal but we can't use that to test here.
|
||||
Services.prefs.setBoolPref("security.data_uri.block_toplevel_data_uri_navigations", false);
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref("security.data_uri.unique_opaque_origin");
|
||||
Services.prefs.clearUserPref("security.data_uri.block_toplevel_data_uri_navigations");
|
||||
});
|
||||
|
||||
@ -40,7 +37,7 @@ function startTest() {
|
||||
|
||||
// Now load the URL normally
|
||||
loadURL(url, 0, artificialPrincipal, function() {
|
||||
ok(browser.contentPrincipal.equals(pagePrincipal), url + " should inherit principal");
|
||||
ok(!browser.contentPrincipal.equals(pagePrincipal), url + " should not inherit principal");
|
||||
|
||||
// Now load the URL and disallow inheriting the principal
|
||||
let webNav = Ci.nsIWebNavigation;
|
||||
|
@ -68,10 +68,7 @@ function test() {
|
||||
win.location = "data:application/vnd.mozilla.xul+xml;charset=utf-8,<window/>";
|
||||
}
|
||||
|
||||
addLoadEvent(function onLoad() {
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["security.data_uri.unique_opaque_origin", false]]}, test);
|
||||
});
|
||||
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
@ -37,15 +37,11 @@ var gFrame;
|
||||
// fail to load when there's no principal to load them against. This only
|
||||
// matters when these tests fail (produces better error messages).
|
||||
var tests = [
|
||||
function testInheritFromParent(cb) {
|
||||
function testInitiation(cb) {
|
||||
gFrame = document.createXULElement("iframe");
|
||||
loadListener(gFrame, function () {
|
||||
is(window.inheritedFromParent, true, "load in type=content iframe inherited principal of same type parent");
|
||||
cb();
|
||||
});
|
||||
gFrame.setAttribute("type", "content");
|
||||
gFrame.setAttribute("src", "data:text/html,<script>parent.inheritedFromParent = true;</script>");
|
||||
document.documentElement.appendChild(gFrame);
|
||||
cb();
|
||||
},
|
||||
function testInheritFromCurrent_system(cb) {
|
||||
loadListener(gFrame, function () {
|
||||
@ -53,35 +49,12 @@ var tests = [
|
||||
cb();
|
||||
}, true);
|
||||
gFrame.setAttribute("src", "data:text/html,<script>parent.inheritedSystem = true;</script>");
|
||||
},
|
||||
function testInheritFromCreated(cb) {
|
||||
// Open a new chrome window with a type="content" iframe, so that it has no
|
||||
// same-type parent.
|
||||
// Load a javascript: URI in it to ensure that GetInheritedPrincipal will
|
||||
// force creation of a content viewer.
|
||||
let xulWinURL = 'data:application/vnd.mozilla.xul+xml,<?xml version="1.0"?>' +
|
||||
'<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/>';
|
||||
let newWin = window.openDialog(xulWinURL, "chrome_window", "chrome");
|
||||
loadListener(newWin, function () {
|
||||
let frame = newWin.document.createXULElement("iframe");
|
||||
frame.setAttribute("type", "content");
|
||||
frame.setAttribute("src", "javascript:'1';");
|
||||
loadListener(frame, function () {
|
||||
is(frame.contentWindow.document.body.textContent, "1", "content viewer was created");
|
||||
SimpleTest.executeSoon(function () {
|
||||
newWin.close();
|
||||
cb();
|
||||
})
|
||||
});
|
||||
newWin.document.documentElement.appendChild(frame);
|
||||
});
|
||||
}
|
||||
];
|
||||
|
||||
addLoadEvent(function onLoad() {
|
||||
ok(Components.stack, "this test must be run with the system principal");
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["security.data_uri.unique_opaque_origin", false]]}, nextTest);
|
||||
nextTest();
|
||||
});
|
||||
|
||||
function loadListener(target, func) {
|
||||
|
@ -14,10 +14,8 @@
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
SpecialPowers.setBoolPref("security.data_uri.unique_opaque_origin", true);
|
||||
SpecialPowers.setBoolPref("security.data_uri.block_toplevel_data_uri_navigations", false);
|
||||
SimpleTest.registerCleanupFunction(() => {
|
||||
SpecialPowers.clearUserPref("security.data_uri.unique_opaque_origin");
|
||||
SpecialPowers.clearUserPref("security.data_uri.block_toplevel_data_uri_navigations");
|
||||
});
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var path = "/tests/dom/base/test/";
|
||||
var isUnique = SpecialPowers.getBoolPref("security.data_uri.unique_opaque_origin");
|
||||
var isUnique = true;
|
||||
|
||||
var testFramesLoaded = function() {
|
||||
var harness = SpecialPowers.wrap(document).getElementById("harness");
|
||||
|
@ -37,7 +37,6 @@ addLoadEvent(function () {
|
||||
["full-screen-api.unprefix.enabled", true],
|
||||
["full-screen-api.allow-trusted-requests-only", false],
|
||||
// Use legacy data: URI behavior to run test.
|
||||
["security.data_uri.unique_opaque_origin", false],
|
||||
["security.data_uri.block_toplevel_data_uri_navigations", false],
|
||||
]
|
||||
}, next);
|
||||
|
@ -2,9 +2,6 @@ var rootDir = getRootDirectory(gTestPath);
|
||||
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
|
||||
|
||||
add_task(async function() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
"set": [["security.data_uri.unique_opaque_origin", true]],
|
||||
});
|
||||
is(navigator.plugins.length, 0,
|
||||
"plugins should not be available to chrome-privilege pages");
|
||||
|
||||
|
@ -46,10 +46,7 @@ function receiveMessage(event) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{'set':[["security.data_uri.unique_opaque_origin", true]]},
|
||||
function() {
|
||||
let DATA_URI = `data:text/html,
|
||||
let DATA_URI = `data:text/html,
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Security-Policy" content="img-src 'self'">
|
||||
@ -59,8 +56,8 @@ SpecialPowers.pushPrefEnv(
|
||||
<img id="testimg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" />
|
||||
</body>
|
||||
</html>`;
|
||||
document.getElementById("testframe").src = DATA_URI;
|
||||
});
|
||||
document.getElementById("testframe").src = DATA_URI;
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
@ -314,7 +314,6 @@ function checkChangeIsEnabled(aWindow, aNext)
|
||||
|
||||
SpecialPowers.pushPrefEnv({
|
||||
"set": [["dom.disable_window_move_resize", false],
|
||||
["security.data_uri.unique_opaque_origin", false],
|
||||
["security.data_uri.block_toplevel_data_uri_navigations", false],]},
|
||||
function() {
|
||||
SimpleTest.waitForFocus(function() {
|
||||
|
@ -282,9 +282,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=565541
|
||||
}
|
||||
|
||||
addLoadEvent(function onLoad() {
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["security.data_uri.unique_opaque_origin", false]]}, test);
|
||||
});
|
||||
test();
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
||||
|
@ -19,7 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var isDataUnique = SpecialPowers.Services.prefs.getBoolPref("security.data_uri.unique_opaque_origin");
|
||||
var isDataUnique = true;
|
||||
var B64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,6 @@
|
||||
function init()
|
||||
{
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["security.data_uri.unique_opaque_origin", false],
|
||||
["security.data_uri.block_toplevel_data_uri_navigations", false],
|
||||
]}, boom);
|
||||
}
|
||||
@ -23,7 +22,6 @@ function boom()
|
||||
|
||||
frameWin.document.write("2...");
|
||||
|
||||
SpecialPowers.clearUserPref("security.data_uri.unique_opaque_origin");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
@ -1,2 +0,0 @@
|
||||
[016.html]
|
||||
prefs: [security.data_uri.unique_opaque_origin:true]
|
@ -1,2 +0,0 @@
|
||||
[016.html]
|
||||
prefs: [security.data_uri.unique_opaque_origin:true]
|
@ -14,8 +14,7 @@
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function onLoad()
|
||||
{
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["security.data_uri.unique_opaque_origin", false]]}, runTest);
|
||||
runTest();
|
||||
}
|
||||
|
||||
function runTest()
|
||||
|
@ -22,8 +22,7 @@
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function onLoad()
|
||||
{
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["security.data_uri.unique_opaque_origin", false]]}, runTest);
|
||||
runTest();
|
||||
}
|
||||
|
||||
function runTest()
|
||||
|
Loading…
Reference in New Issue
Block a user