зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
e7a3fe847e
Коммит
ce99ef5438
|
@ -52,7 +52,7 @@ addRDMTask(TEST_URL, async function({ ui, manager }) {
|
||||||
await SpecialPowers.pushPrefEnv({
|
await SpecialPowers.pushPrefEnv({
|
||||||
set: [["devtools.responsive.metaViewport.enabled", true],
|
set: [["devtools.responsive.metaViewport.enabled", true],
|
||||||
["layout.testing.overlay-scrollbars.always-visible", true],
|
["layout.testing.overlay-scrollbars.always-visible", true],
|
||||||
["security.data_uri.unique_opaque_origin", false]],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const store = ui.toolWindow.store;
|
const store = ui.toolWindow.store;
|
||||||
|
|
|
@ -75,14 +75,8 @@ function testEnd() {
|
||||||
let load = async function () {
|
let load = async function () {
|
||||||
removeEventListener("load", load);
|
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.
|
// 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");
|
info ("Waiting for content window to load");
|
||||||
gWin.onload = startTest;
|
gWin.onload = startTest;
|
||||||
};
|
};
|
||||||
|
@ -91,3 +85,4 @@ addEventListener("load", load);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -148,14 +148,8 @@ function testEnd() {
|
||||||
let load = async function () {
|
let load = async function () {
|
||||||
removeEventListener("load", load);
|
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.
|
// 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");
|
info ("Waiting for content window to load");
|
||||||
gWin.onload = startTest;
|
gWin.onload = startTest;
|
||||||
};
|
};
|
||||||
|
@ -164,3 +158,4 @@ addEventListener("load", load);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ function f()
|
||||||
function init()
|
function init()
|
||||||
{
|
{
|
||||||
SpecialPowers.pushPrefEnv({"set": [
|
SpecialPowers.pushPrefEnv({"set": [
|
||||||
["security.data_uri.unique_opaque_origin", false],
|
|
||||||
["security.data_uri.block_toplevel_data_uri_navigations", false],
|
["security.data_uri.block_toplevel_data_uri_navigations", false],
|
||||||
]}, start);
|
]}, start);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +32,6 @@ function start()
|
||||||
var html = "<script>" + f + "<\/script><body onload=f()>";
|
var html = "<script>" + f + "<\/script><body onload=f()>";
|
||||||
var win = window.open("data:text/html," + encodeURIComponent(html), null, "width=300,height=300");
|
var win = window.open("data:text/html," + encodeURIComponent(html), null, "width=300,height=300");
|
||||||
win.finish = function() {
|
win.finish = function() {
|
||||||
SpecialPowers.clearUserPref("security.data_uri.unique_opaque_origin");
|
|
||||||
document.documentElement.removeAttribute("class");
|
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() {
|
add_task(async function test_dataURI_unique_opaque_origin() {
|
||||||
let tab = BrowserTestUtils.addTab(gBrowser, "http://example.com");
|
let tab = BrowserTestUtils.addTab(gBrowser, "http://example.com");
|
||||||
let browser = tab.linkedBrowser;
|
let browser = tab.linkedBrowser;
|
||||||
|
|
|
@ -4,13 +4,10 @@
|
||||||
function test() {
|
function test() {
|
||||||
waitForExplicitFinish();
|
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
|
// 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.
|
// 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);
|
Services.prefs.setBoolPref("security.data_uri.block_toplevel_data_uri_navigations", false);
|
||||||
registerCleanupFunction(function() {
|
registerCleanupFunction(function() {
|
||||||
Services.prefs.clearUserPref("security.data_uri.unique_opaque_origin");
|
|
||||||
Services.prefs.clearUserPref("security.data_uri.block_toplevel_data_uri_navigations");
|
Services.prefs.clearUserPref("security.data_uri.block_toplevel_data_uri_navigations");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -40,7 +37,7 @@ function startTest() {
|
||||||
|
|
||||||
// Now load the URL normally
|
// Now load the URL normally
|
||||||
loadURL(url, 0, artificialPrincipal, function() {
|
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
|
// Now load the URL and disallow inheriting the principal
|
||||||
let webNav = Ci.nsIWebNavigation;
|
let webNav = Ci.nsIWebNavigation;
|
||||||
|
|
|
@ -68,10 +68,7 @@ function test() {
|
||||||
win.location = "data:application/vnd.mozilla.xul+xml;charset=utf-8,<window/>";
|
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>
|
</script>
|
||||||
|
|
|
@ -37,15 +37,11 @@ var gFrame;
|
||||||
// fail to load when there's no principal to load them against. This only
|
// fail to load when there's no principal to load them against. This only
|
||||||
// matters when these tests fail (produces better error messages).
|
// matters when these tests fail (produces better error messages).
|
||||||
var tests = [
|
var tests = [
|
||||||
function testInheritFromParent(cb) {
|
function testInitiation(cb) {
|
||||||
gFrame = document.createXULElement("iframe");
|
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("type", "content");
|
||||||
gFrame.setAttribute("src", "data:text/html,<script>parent.inheritedFromParent = true;</script>");
|
|
||||||
document.documentElement.appendChild(gFrame);
|
document.documentElement.appendChild(gFrame);
|
||||||
|
cb();
|
||||||
},
|
},
|
||||||
function testInheritFromCurrent_system(cb) {
|
function testInheritFromCurrent_system(cb) {
|
||||||
loadListener(gFrame, function () {
|
loadListener(gFrame, function () {
|
||||||
|
@ -53,35 +49,12 @@ var tests = [
|
||||||
cb();
|
cb();
|
||||||
}, true);
|
}, true);
|
||||||
gFrame.setAttribute("src", "data:text/html,<script>parent.inheritedSystem = true;</script>");
|
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() {
|
addLoadEvent(function onLoad() {
|
||||||
ok(Components.stack, "this test must be run with the system principal");
|
ok(Components.stack, "this test must be run with the system principal");
|
||||||
SpecialPowers.pushPrefEnv({"set": [
|
nextTest();
|
||||||
["security.data_uri.unique_opaque_origin", false]]}, nextTest);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function loadListener(target, func) {
|
function loadListener(target, func) {
|
||||||
|
|
|
@ -14,10 +14,8 @@
|
||||||
<script>
|
<script>
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
SpecialPowers.setBoolPref("security.data_uri.unique_opaque_origin", true);
|
|
||||||
SpecialPowers.setBoolPref("security.data_uri.block_toplevel_data_uri_navigations", false);
|
SpecialPowers.setBoolPref("security.data_uri.block_toplevel_data_uri_navigations", false);
|
||||||
SimpleTest.registerCleanupFunction(() => {
|
SimpleTest.registerCleanupFunction(() => {
|
||||||
SpecialPowers.clearUserPref("security.data_uri.unique_opaque_origin");
|
|
||||||
SpecialPowers.clearUserPref("security.data_uri.block_toplevel_data_uri_navigations");
|
SpecialPowers.clearUserPref("security.data_uri.block_toplevel_data_uri_navigations");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<script class="testbody" type="text/javascript">
|
<script class="testbody" type="text/javascript">
|
||||||
|
|
||||||
var path = "/tests/dom/base/test/";
|
var path = "/tests/dom/base/test/";
|
||||||
var isUnique = SpecialPowers.getBoolPref("security.data_uri.unique_opaque_origin");
|
var isUnique = true;
|
||||||
|
|
||||||
var testFramesLoaded = function() {
|
var testFramesLoaded = function() {
|
||||||
var harness = SpecialPowers.wrap(document).getElementById("harness");
|
var harness = SpecialPowers.wrap(document).getElementById("harness");
|
||||||
|
|
|
@ -37,7 +37,6 @@ addLoadEvent(function () {
|
||||||
["full-screen-api.unprefix.enabled", true],
|
["full-screen-api.unprefix.enabled", true],
|
||||||
["full-screen-api.allow-trusted-requests-only", false],
|
["full-screen-api.allow-trusted-requests-only", false],
|
||||||
// Use legacy data: URI behavior to run test.
|
// Use legacy data: URI behavior to run test.
|
||||||
["security.data_uri.unique_opaque_origin", false],
|
|
||||||
["security.data_uri.block_toplevel_data_uri_navigations", false],
|
["security.data_uri.block_toplevel_data_uri_navigations", false],
|
||||||
]
|
]
|
||||||
}, next);
|
}, next);
|
||||||
|
|
|
@ -2,9 +2,6 @@ var rootDir = getRootDirectory(gTestPath);
|
||||||
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
|
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
|
||||||
|
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
await SpecialPowers.pushPrefEnv({
|
|
||||||
"set": [["security.data_uri.unique_opaque_origin", true]],
|
|
||||||
});
|
|
||||||
is(navigator.plugins.length, 0,
|
is(navigator.plugins.length, 0,
|
||||||
"plugins should not be available to chrome-privilege pages");
|
"plugins should not be available to chrome-privilege pages");
|
||||||
|
|
||||||
|
|
|
@ -46,10 +46,7 @@ function receiveMessage(event) {
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
SpecialPowers.pushPrefEnv(
|
let DATA_URI = `data:text/html,
|
||||||
{'set':[["security.data_uri.unique_opaque_origin", true]]},
|
|
||||||
function() {
|
|
||||||
let DATA_URI = `data:text/html,
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Security-Policy" content="img-src 'self'">
|
<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==" />
|
<img id="testimg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" />
|
||||||
</body>
|
</body>
|
||||||
</html>`;
|
</html>`;
|
||||||
document.getElementById("testframe").src = DATA_URI;
|
document.getElementById("testframe").src = DATA_URI;
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -314,7 +314,6 @@ function checkChangeIsEnabled(aWindow, aNext)
|
||||||
|
|
||||||
SpecialPowers.pushPrefEnv({
|
SpecialPowers.pushPrefEnv({
|
||||||
"set": [["dom.disable_window_move_resize", false],
|
"set": [["dom.disable_window_move_resize", false],
|
||||||
["security.data_uri.unique_opaque_origin", false],
|
|
||||||
["security.data_uri.block_toplevel_data_uri_navigations", false],]},
|
["security.data_uri.block_toplevel_data_uri_navigations", false],]},
|
||||||
function() {
|
function() {
|
||||||
SimpleTest.waitForFocus(function() {
|
SimpleTest.waitForFocus(function() {
|
||||||
|
|
|
@ -282,9 +282,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=565541
|
||||||
}
|
}
|
||||||
|
|
||||||
addLoadEvent(function onLoad() {
|
addLoadEvent(function onLoad() {
|
||||||
SpecialPowers.pushPrefEnv({"set": [
|
test();
|
||||||
["security.data_uri.unique_opaque_origin", false]]}, test);
|
|
||||||
});
|
|
||||||
]]>
|
]]>
|
||||||
</script>
|
</script>
|
||||||
</window>
|
</window>
|
||||||
|
|
|
@ -19,7 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage
|
||||||
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
var isDataUnique = SpecialPowers.Services.prefs.getBoolPref("security.data_uri.unique_opaque_origin");
|
var isDataUnique = true;
|
||||||
var B64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
var B64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
function init()
|
function init()
|
||||||
{
|
{
|
||||||
SpecialPowers.pushPrefEnv({"set": [
|
SpecialPowers.pushPrefEnv({"set": [
|
||||||
["security.data_uri.unique_opaque_origin", false],
|
|
||||||
["security.data_uri.block_toplevel_data_uri_navigations", false],
|
["security.data_uri.block_toplevel_data_uri_navigations", false],
|
||||||
]}, boom);
|
]}, boom);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +22,6 @@ function boom()
|
||||||
|
|
||||||
frameWin.document.write("2...");
|
frameWin.document.write("2...");
|
||||||
|
|
||||||
SpecialPowers.clearUserPref("security.data_uri.unique_opaque_origin");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</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();
|
SimpleTest.waitForExplicitFinish();
|
||||||
function onLoad()
|
function onLoad()
|
||||||
{
|
{
|
||||||
SpecialPowers.pushPrefEnv({"set": [
|
runTest();
|
||||||
["security.data_uri.unique_opaque_origin", false]]}, runTest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function runTest()
|
function runTest()
|
||||||
|
|
|
@ -22,8 +22,7 @@
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
function onLoad()
|
function onLoad()
|
||||||
{
|
{
|
||||||
SpecialPowers.pushPrefEnv({"set": [
|
runTest();
|
||||||
["security.data_uri.unique_opaque_origin", false]]}, runTest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function runTest()
|
function runTest()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче