mirror of
https://github.com/servo/servo.git
synced 2025-08-16 10:55:34 +01:00
Update web-platform-tests to revision 58eb04cecbbec2e18531ab440225e38944a9c444
This commit is contained in:
parent
25e8bf69e6
commit
665817d2a6
35333 changed files with 1818077 additions and 16036 deletions
|
@ -1,5 +1,3 @@
|
|||
@ayg
|
||||
@Ms2ger
|
||||
@jdm
|
||||
@jgraham
|
||||
@zcorpan
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<iframe id="test"></iframe>
|
||||
<script>
|
||||
var t = opener.t;
|
||||
var f = document.getElementById("test");
|
||||
var l = opener.document.getElementById("step_log");
|
||||
|
||||
var log = function(t) {l.textContent += ("\n" + t)}
|
||||
var navigated = false;
|
||||
var steps = [
|
||||
() => f.src = "browsing_context_name-1.html",
|
||||
() => {
|
||||
navigated = true;
|
||||
opener.assert_equals(f.contentWindow.name, "test", "Initial load");
|
||||
f.src = f.src.replace("http://", "http://www.").replace("browsing_context_name-1", "browsing_context_name-2");
|
||||
},
|
||||
() => {
|
||||
// Can't test .name easily here because it's cross-origin
|
||||
opener.assert_equals(history.length, 2);
|
||||
history.back()
|
||||
},
|
||||
() => {
|
||||
opener.assert_equals(f.contentWindow.name, "test", "After navigation");
|
||||
t.done();
|
||||
}
|
||||
].map((x, i) => t.step_func(() => {log("Step " + (i+1)); x()}));
|
||||
|
||||
next = () => steps.shift()();
|
||||
|
||||
onload = () => {
|
||||
log("page load");
|
||||
f.onload = () => {log("iframe onload"); next()};
|
||||
setTimeout(next, 0);
|
||||
};
|
||||
</script>
|
|
@ -2,40 +2,12 @@
|
|||
<title>Restoring window.name on cross-origin history traversal</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<pre id="step_log"></pre>
|
||||
<iframe id="test"></iframe>
|
||||
|
||||
<script>
|
||||
|
||||
var t = async_test(undefined, {timeout:10000});
|
||||
var f = document.getElementById("test");
|
||||
var l = document.getElementById("step_log");
|
||||
var navigated = false;
|
||||
|
||||
log = function(t) {l.textContent += ("\n" + t)}
|
||||
|
||||
var steps = [
|
||||
function() {f.src = "browsing_context_name-1.html"},
|
||||
function() {
|
||||
navigated = true;
|
||||
assert_equals(f.contentWindow.name, "test", "Initial load");
|
||||
setTimeout(next, 0);
|
||||
},
|
||||
function() {f.src = f.src.replace("http://", "http://www.").replace("browsing_context_name-1", "browsing_context_name-2");},
|
||||
function() {
|
||||
setTimeout(next, 0);
|
||||
},
|
||||
function() {history.back(); setTimeout(next, 500)},
|
||||
function() {
|
||||
assert_equals(f.contentWindow.name, "test", "After navigation");
|
||||
t.done();
|
||||
}
|
||||
].map(function(x) {return t.step_func(function() {log("Step " + step); x()})});
|
||||
|
||||
var step = 0;
|
||||
next = t.step_func(function() {steps[step++]()});
|
||||
|
||||
f.onload=next;
|
||||
|
||||
onload = function() { setTimeout(next, 0); };
|
||||
var t = async_test();
|
||||
t.step(() => {
|
||||
var win = window.open("browsing_context_name_cross_origin-0.html");
|
||||
t.add_cleanup(() => win.close());
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -11,43 +11,82 @@
|
|||
<script>
|
||||
"use strict";
|
||||
|
||||
async_test(t => {
|
||||
promise_test(t => {
|
||||
let onbeforeunloadHappened = false;
|
||||
window.onbeforeunload = t.step_func(() => {
|
||||
onbeforeunloadHappened = true;
|
||||
return "cancel me";
|
||||
});
|
||||
|
||||
const listener = t.step_func(e => {
|
||||
const eventWatcher = new EventWatcher(t, window, "beforeunload");
|
||||
const promise = eventWatcher.wait_for("beforeunload").then(e => {
|
||||
assert_true(onbeforeunloadHappened, "CustomEvent must be able to trigger the event handler");
|
||||
assert_false(e.defaultPrevented, "The event must not have been canceled");
|
||||
window.onbeforeunload = null;
|
||||
t.done();
|
||||
});
|
||||
|
||||
window.addEventListener("beforeunload", listener);
|
||||
|
||||
window.dispatchEvent(new CustomEvent("beforeunload"));
|
||||
|
||||
return promise;
|
||||
}, "Returning a string must not cancel the event: CustomEvent, non-cancelable");
|
||||
|
||||
async_test(t => {
|
||||
promise_test(t => {
|
||||
let onbeforeunloadHappened = false;
|
||||
window.onbeforeunload = t.step_func(() => {
|
||||
onbeforeunloadHappened = true;
|
||||
return "cancel me";
|
||||
});
|
||||
|
||||
const listener = t.step_func(e => {
|
||||
const eventWatcher = new EventWatcher(t, window, "beforeunload");
|
||||
const promise = eventWatcher.wait_for("beforeunload").then(e => {
|
||||
assert_true(onbeforeunloadHappened, "CustomEvent must be able to trigger the event handler");
|
||||
assert_false(e.defaultPrevented, "The event must not have been canceled");
|
||||
window.onbeforeunload = null;
|
||||
t.done();
|
||||
});
|
||||
|
||||
window.addEventListener("beforeunload", listener);
|
||||
window.dispatchEvent(new CustomEvent("beforeunload", { cancelable: true }));
|
||||
|
||||
return promise;
|
||||
}, "Returning a string must not cancel the event: CustomEvent, cancelable");
|
||||
|
||||
promise_test(t => {
|
||||
let onbeforeunloadHappened = false;
|
||||
window.onbeforeunload = t.step_func(() => {
|
||||
onbeforeunloadHappened = true;
|
||||
return false;
|
||||
});
|
||||
|
||||
const eventWatcher = new EventWatcher(t, window, "beforeunload");
|
||||
const promise = eventWatcher.wait_for("beforeunload").then(e => {
|
||||
assert_true(onbeforeunloadHappened, "CustomEvent must be able to trigger the event handler");
|
||||
assert_false(e.defaultPrevented, "The event must not have been canceled");
|
||||
window.onbeforeunload = null;
|
||||
t.done();
|
||||
});
|
||||
|
||||
window.dispatchEvent(new CustomEvent("beforeunload", { cancelable: true }));
|
||||
}, "Returning a string must not cancel the event: CustomEvent, cancelable");
|
||||
|
||||
return promise;
|
||||
}, "Returning false must not cancel the event, because it's coerced to the DOMString \"false\" which does not cancel " +
|
||||
"CustomEvents: CustomEvent, cancelable");
|
||||
|
||||
// This test can be removed if we update the DOM Standard to disallow createEvent("BeforeUnloadEvent"). Browser support
|
||||
// is inconsistent. https://github.com/whatwg/dom/issues/362
|
||||
promise_test(t => {
|
||||
const eventWatcher = new EventWatcher(t, window, "click");
|
||||
const promise = eventWatcher.wait_for("click").then(e => {
|
||||
assert_false(e.defaultPrevented, "The event must not have been canceled");
|
||||
window.onbeforeunload = null;
|
||||
t.done();
|
||||
});
|
||||
|
||||
const ev = document.createEvent("BeforeUnloadEvent");
|
||||
ev.initEvent("click", false, true);
|
||||
window.dispatchEvent(ev);
|
||||
|
||||
return promise;
|
||||
}, "Returning a string must not cancel the event: BeforeUnloadEvent with type \"click\", cancelable");
|
||||
|
||||
const testCases = [
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<div id=log></div>
|
||||
<iframe id="existing" src="resources/post-your-protocol.html?existing"></iframe>
|
||||
<iframe id="http-and-gunk" src="resources/post-your-protocol.html?http-and-gunk"></iframe>
|
||||
<iframe id="https-and-gunk" src="resources/post-your-protocol.html?https-and-gunk"></iframe>
|
||||
<!-- iframe id="https-and-gunk" src="resources/post-your-protocol.html?https-and-gunk"></iframe -->
|
||||
<script>
|
||||
// NOTE: we do not listen to message events until our load event fires, so we
|
||||
// only get them for the things we actually care about.
|
||||
|
@ -21,15 +21,13 @@ var tests = {
|
|||
};
|
||||
|
||||
function messageListener(e) {
|
||||
test(function() {
|
||||
var data = e.data;
|
||||
var id = data.id;
|
||||
var t = tests[id].test;
|
||||
t.step(function() {
|
||||
assert_equals(data.protocol, tests[id].result, "Protocol should match");
|
||||
})
|
||||
t.done();
|
||||
}, "Message listener");
|
||||
var data = e.data;
|
||||
var id = data.id;
|
||||
var t = tests[id].test;
|
||||
t.step(function() {
|
||||
assert_equals(data.protocol, tests[id].result, "Protocol should match");
|
||||
})
|
||||
t.done();
|
||||
}
|
||||
|
||||
addEventListener("load", wrapper_test.step_func_done(function() {
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>[[SetPrototypeOf]] on a Location object should not allow changing its value: cross-origin via document.domain</title>
|
||||
<link rel="help" href="http://html.spec.whatwg.org/multipage/#location-setprototypeof">
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/test-setting-immutable-prototype.js"></script>
|
||||
|
||||
<iframe src="/common/domain-setter.sub.html"></iframe>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
// This page does *not* set document.domain, so it's cross-origin with the iframe
|
||||
setup({ explicit_done: true });
|
||||
|
||||
window.onload = () => {
|
||||
const targetLocation = frames[0].location;
|
||||
const origProto = Object.getPrototypeOf(targetLocation);
|
||||
|
||||
test(() => {
|
||||
assert_equals(Object.getPrototypeOf(targetLocation), null);
|
||||
}, "Cross-origin via document.domain: the prototype is null");
|
||||
|
||||
testSettingImmutablePrototype("Cross-origin via document.domain", targetLocation, origProto,
|
||||
{ isSameOriginDomain: false });
|
||||
|
||||
done();
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>[[SetPrototypeOf]] on a Location object should not allow changing its value: cross-origin</title>
|
||||
<link rel="help" href="http://html.spec.whatwg.org/multipage/#location-setprototypeof">
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/test-setting-immutable-prototype.js"></script>
|
||||
|
||||
<iframe src="//{{domains[www]}}:{{ports[http][1]}}/common/blank.html"></iframe>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
setup({ explicit_done: true });
|
||||
|
||||
window.onload = () => {
|
||||
const targetLocation = frames[0].location;
|
||||
|
||||
test(() => {
|
||||
assert_equals(Object.getPrototypeOf(targetLocation), null);
|
||||
}, "Cross-origin: the prototype is null");
|
||||
|
||||
testSettingImmutablePrototype("Cross-origin", targetLocation, null, { isSameOriginDomain: false });
|
||||
|
||||
done();
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>[[SetPrototypeOf]] on a Location object should not allow changing its value: cross-origin via document.domain after initially getting the object</title>
|
||||
<link rel="help" href="http://html.spec.whatwg.org/multipage/#location-setprototypeof">
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/test-setting-immutable-prototype.js"></script>
|
||||
|
||||
<iframe src="/common/blank.html"></iframe>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
setup({ explicit_done: true });
|
||||
|
||||
window.onload = () => {
|
||||
const targetLocation = frames[0].location;
|
||||
const origProto = Object.getPrototypeOf(targetLocation);
|
||||
|
||||
test(() => {
|
||||
assert_not_equals(origProto, null);
|
||||
}, "Same-origin (for now): the prototype is accessible");
|
||||
|
||||
document.domain = "{{host}}";
|
||||
|
||||
test(() => {
|
||||
assert_equals(Object.getPrototypeOf(targetLocation), null);
|
||||
}, "Became cross-origin via document.domain: the prototype is now null");
|
||||
|
||||
testSettingImmutablePrototype("Became cross-origin via document.domain", targetLocation, null, { isSameOriginDomain: false });
|
||||
|
||||
testSettingImmutablePrototypeToNewValueOnly(
|
||||
"Became cross-origin via document.domain", targetLocation, origProto,
|
||||
"the original value from before going cross-origin", { isSameOriginDomain: false });
|
||||
|
||||
done();
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>[[SetPrototypeOf]] on a Location object should not allow changing its value: cross-origin, but same-origin-domain</title>
|
||||
<link rel="help" href="http://html.spec.whatwg.org/multipage/#location-setprototypeof">
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/test-setting-immutable-prototype.js"></script>
|
||||
|
||||
<iframe src="//{{domains[www]}}:{{ports[http][1]}}/common/domain-setter.sub.html"></iframe>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
document.domain = "{{host}}";
|
||||
setup({ explicit_done: true });
|
||||
|
||||
window.onload = () => {
|
||||
const targetLocation = frames[0].location;
|
||||
const origProto = Object.getPrototypeOf(targetLocation);
|
||||
|
||||
test(() => {
|
||||
assert_not_equals(origProto, null);
|
||||
}, "Same-origin-domain prerequisite check: the original prototype is accessible");
|
||||
|
||||
testSettingImmutablePrototype("Same-origin-domain", targetLocation, origProto, { isSameOriginDomain: true });
|
||||
|
||||
done();
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>[[SetPrototypeOf]] on a location object should not allow changing its value: same-origin</title>
|
||||
<link rel="help" href="http://html.spec.whatwg.org/multipage/#location-setprototypeof">
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src="/common/test-setting-immutable-prototype.js"></script>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
const origProto = Object.getPrototypeOf(location);
|
||||
|
||||
test(() => {
|
||||
assert_not_equals(origProto, null);
|
||||
}, "Same-origin prerequisite check: the original prototype is accessible");
|
||||
|
||||
testSettingImmutablePrototype("Same-origin", location, origProto, { isSameOriginDomain: true });
|
||||
</script>
|
|
@ -1,18 +0,0 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>[[SetPrototypeOf]] on a location object should return false</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script>
|
||||
test(function() {
|
||||
var origProto = Object.getPrototypeOf(location);
|
||||
assert_throws(new TypeError, function() {
|
||||
Object.setPrototypeOf(location, {});
|
||||
});
|
||||
assert_throws(new TypeError, function() {
|
||||
location.__proto__ = {};
|
||||
});
|
||||
assert_false(Reflect.setPrototypeOf(location, {}));
|
||||
assert_equals(Object.getPrototypeOf(location), origProto);
|
||||
});
|
||||
</script>
|
|
@ -11,12 +11,19 @@
|
|||
<script>
|
||||
var cache = window.applicationCache;
|
||||
|
||||
test(function() {
|
||||
try {
|
||||
async_test(function(t) {
|
||||
var next = t.step_func(function() {
|
||||
cache.onnoupdate = cache.oncached = null;
|
||||
|
||||
cache.update()
|
||||
assert_true(true, "update method test")
|
||||
} catch (e) {
|
||||
assert_unreached("update method failed.");
|
||||
|
||||
t.done();
|
||||
});
|
||||
|
||||
if (cache.status === cache.IDLE) {
|
||||
next();
|
||||
} else {
|
||||
cache.onnoupdate = cache.oncached = next;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html manifest="../resources/manifest/clock.manifest">
|
||||
<html manifest="./non-existent-file.manifest">
|
||||
<head>
|
||||
<title>Offline Application Cache - API_update_error</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<ol>
|
||||
<li>Remove the manifest file (manifest/clock.manifest) from the server.</li>
|
||||
<li>Refresh the page, then calling update() will throw InvalidStateError exception.</li>
|
||||
</ol>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<script>
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>AppCache should not exist in shared workers, even though it was specced at some point</title>
|
||||
<link rel="help" href="https://github.com/whatwg/html/pull/2384">
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
if (typeof SharedWorker === "undefined") {
|
||||
test(() => {
|
||||
}, "This browser doesn't implement SharedWorker, and so passes this test automatically");
|
||||
} else {
|
||||
fetch_tests_from_worker(new SharedWorker("no-appcache-in-shared-workers-historical.js"));
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,14 @@
|
|||
"use strict";
|
||||
self.importScripts('/resources/testharness.js');
|
||||
|
||||
test(() => {
|
||||
assert_equals(self.applicationCache, undefined, "self.applicationCache must be undefined");
|
||||
assert_false("applicationCache" in self, "applicationCache must not even be a property of self");
|
||||
}, "self.applicationCache must not exist");
|
||||
|
||||
test(() => {
|
||||
assert_equals(self.ApplicationCache, undefined, "self.ApplicationCache must be undefined");
|
||||
assert_false("ApplicationCache" in self, "ApplicationCache must not even be a property of self");
|
||||
}, "ApplicationCache must not be exposed");
|
||||
|
||||
done();
|
|
@ -52,14 +52,14 @@ function addTest(fun, desc) { testList.push([fun, desc]); }
|
|||
* Basic sanity testing.
|
||||
*/
|
||||
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
// Note: we do not check location.host as its default port semantics are hard to reflect statically
|
||||
assert_equals(location.hostname, host_info.ORIGINAL_HOST, 'Need to run the top-level test from domain ' + host_info.ORIGINAL_HOST);
|
||||
assert_equals(get_port(location), host_info.HTTP_PORT, 'Need to run the top-level test from port ' + host_info.HTTP_PORT);
|
||||
assert_equals(B.parent, window, "window.parent works same-origin");
|
||||
assert_equals(C.parent, window, "window.parent works cross-origin");
|
||||
assert_equals(B.location.pathname, path, "location.href works same-origin");
|
||||
test_throws(exception_t, "SecurityError", function() { C.location.pathname; }, "location.pathname throws cross-origin");
|
||||
assert_throws("SecurityError", function() { C.location.pathname; }, "location.pathname throws cross-origin");
|
||||
assert_equals(B.frames, 'override', "Overrides visible in the same-origin case");
|
||||
assert_equals(C.frames, C, "Overrides invisible in the cross-origin case");
|
||||
}, "Basic sanity-checking");
|
||||
|
@ -81,21 +81,21 @@ var whitelistedSymbols = [Symbol.toStringTag, Symbol.hasInstance,
|
|||
Symbol.isConcatSpreadable];
|
||||
var whitelistedWindowProps = whitelistedWindowPropNames.concat(whitelistedSymbols);
|
||||
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
for (var prop in window) {
|
||||
if (whitelistedWindowProps.indexOf(prop) != -1) {
|
||||
C[prop]; // Shouldn't throw.
|
||||
Object.getOwnPropertyDescriptor(C, prop); // Shouldn't throw.
|
||||
assert_true(Object.prototype.hasOwnProperty.call(C, prop), "hasOwnProperty for " + String(prop));
|
||||
} else {
|
||||
test_throws(exception_t, "SecurityError", function() { C[prop]; }, "Should throw when accessing " + String(prop) + " on Window");
|
||||
test_throws(exception_t, "SecurityError", function() { Object.getOwnPropertyDescriptor(C, prop); },
|
||||
assert_throws("SecurityError", function() { C[prop]; }, "Should throw when accessing " + String(prop) + " on Window");
|
||||
assert_throws("SecurityError", function() { Object.getOwnPropertyDescriptor(C, prop); },
|
||||
"Should throw when accessing property descriptor for " + prop + " on Window");
|
||||
test_throws(exception_t, "SecurityError", function() { Object.prototype.hasOwnProperty.call(C, prop); },
|
||||
assert_throws("SecurityError", function() { Object.prototype.hasOwnProperty.call(C, prop); },
|
||||
"Should throw when invoking hasOwnProperty for " + prop + " on Window");
|
||||
}
|
||||
if (prop != 'location')
|
||||
test_throws(exception_t, "SecurityError", function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Window");
|
||||
assert_throws("SecurityError", function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Window");
|
||||
}
|
||||
for (var prop in location) {
|
||||
if (prop == 'replace') {
|
||||
|
@ -104,14 +104,14 @@ addTest(function(exception_t) {
|
|||
assert_true(Object.prototype.hasOwnProperty.call(C.location, prop), "hasOwnProperty for " + prop);
|
||||
}
|
||||
else {
|
||||
test_throws(exception_t, "SecurityError", function() { C[prop]; }, "Should throw when accessing " + prop + " on Location");
|
||||
test_throws(exception_t, "SecurityError", function() { Object.getOwnPropertyDescriptor(C, prop); },
|
||||
assert_throws("SecurityError", function() { C[prop]; }, "Should throw when accessing " + prop + " on Location");
|
||||
assert_throws("SecurityError", function() { Object.getOwnPropertyDescriptor(C, prop); },
|
||||
"Should throw when accessing property descriptor for " + prop + " on Location");
|
||||
test_throws(exception_t, "SecurityError", function() { Object.prototype.hasOwnProperty.call(C, prop); },
|
||||
assert_throws("SecurityError", function() { Object.prototype.hasOwnProperty.call(C, prop); },
|
||||
"Should throw when invoking hasOwnProperty for " + prop + " on Location");
|
||||
}
|
||||
if (prop != 'href')
|
||||
test_throws(exception_t, "SecurityError", function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Location");
|
||||
assert_throws("SecurityError", function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Location");
|
||||
}
|
||||
}, "Only whitelisted properties are accessible cross-origin");
|
||||
|
||||
|
@ -122,36 +122,42 @@ addTest(function(exception_t) {
|
|||
/*
|
||||
* [[GetPrototypeOf]]
|
||||
*/
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
assert_true(Object.getPrototypeOf(C) === null, "cross-origin Window proto is null");
|
||||
assert_true(Object.getPrototypeOf(C.location) === null, "cross-origin Location proto is null (__proto__)");
|
||||
var protoGetter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').get;
|
||||
assert_true(protoGetter.call(C) === null, "cross-origin Window proto is null");
|
||||
assert_true(protoGetter.call(C.location) === null, "cross-origin Location proto is null (__proto__)");
|
||||
test_throws(exception_t, "SecurityError", function() { C.__proto__; }, "__proto__ property not available cross-origin");
|
||||
test_throws(exception_t, "SecurityError", function() { C.location.__proto__; }, "__proto__ property not available cross-origin");
|
||||
assert_throws("SecurityError", function() { C.__proto__; }, "__proto__ property not available cross-origin");
|
||||
assert_throws("SecurityError", function() { C.location.__proto__; }, "__proto__ property not available cross-origin");
|
||||
|
||||
}, "[[GetPrototypeOf]] should return null");
|
||||
|
||||
/*
|
||||
* [[SetPrototypeOf]]
|
||||
*/
|
||||
addTest(function(exception_t) {
|
||||
test_throws(exception_t, "SecurityError", function() { C.__proto__ = new Object(); }, "proto set on cross-origin Window");
|
||||
test_throws(exception_t, "SecurityError", function() { C.location.__proto__ = new Object(); }, "proto set on cross-origin Location");
|
||||
addTest(function() {
|
||||
assert_throws("SecurityError", function() { C.__proto__ = new Object(); }, "proto set on cross-origin Window");
|
||||
assert_throws("SecurityError", function() { C.location.__proto__ = new Object(); }, "proto set on cross-origin Location");
|
||||
var setters = [Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set];
|
||||
if (Object.setPrototypeOf)
|
||||
setters.push(function(p) { Object.setPrototypeOf(this, p); });
|
||||
setters.forEach(function(protoSetter) {
|
||||
test_throws(exception_t, new TypeError, function() { protoSetter.call(C, new Object()); }, "proto setter |call| on cross-origin Window");
|
||||
test_throws(exception_t, new TypeError, function() { protoSetter.call(C.location, new Object()); }, "proto setter |call| on cross-origin Location");
|
||||
assert_throws(new TypeError, function() { protoSetter.call(C, new Object()); }, "proto setter |call| on cross-origin Window");
|
||||
assert_throws(new TypeError, function() { protoSetter.call(C.location, new Object()); }, "proto setter |call| on cross-origin Location");
|
||||
});
|
||||
}, "[[SetPrototypeOf]] should throw");
|
||||
if (Reflect.setPrototypeOf) {
|
||||
assert_false(Reflect.setPrototypeOf(C, new Object()),
|
||||
"Reflect.setPrototypeOf on cross-origin Window");
|
||||
assert_false(Reflect.setPrototypeOf(C.location, new Object()),
|
||||
"Reflect.setPrototypeOf on cross-origin Location");
|
||||
}
|
||||
}, "[[SetPrototypeOf]] should return false");
|
||||
|
||||
/*
|
||||
* [[IsExtensible]]
|
||||
*/
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
assert_true(Object.isExtensible(C), "cross-origin Window should be extensible");
|
||||
assert_true(Object.isExtensible(C.location), "cross-origin Location should be extensible");
|
||||
}, "[[IsExtensible]] should return true for cross-origin objects");
|
||||
|
@ -159,10 +165,10 @@ addTest(function(exception_t) {
|
|||
/*
|
||||
* [[PreventExtensions]]
|
||||
*/
|
||||
addTest(function(exception_t) {
|
||||
test_throws(exception_t, new TypeError, function() { Object.preventExtensions(C) },
|
||||
addTest(function() {
|
||||
assert_throws(new TypeError, function() { Object.preventExtensions(C) },
|
||||
"preventExtensions on cross-origin Window should throw");
|
||||
test_throws(exception_t, new TypeError, function() { Object.preventExtensions(C.location) },
|
||||
assert_throws(new TypeError, function() { Object.preventExtensions(C.location) },
|
||||
"preventExtensions on cross-origin Location should throw");
|
||||
}, "[[PreventExtensions]] should throw for cross-origin objects");
|
||||
|
||||
|
@ -170,7 +176,7 @@ addTest(function(exception_t) {
|
|||
* [[GetOwnProperty]]
|
||||
*/
|
||||
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'close')), "C.close is |own|");
|
||||
assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'top')), "C.top is |own|");
|
||||
assert_true(isObject(Object.getOwnPropertyDescriptor(C.location, 'href')), "C.location.href is |own|");
|
||||
|
@ -197,7 +203,7 @@ function checkPropertyDescriptor(desc, propName, expectWritable) {
|
|||
"property descriptor for " + propName + " should " + (expectWritable ? "" : "not ") + "have setter");
|
||||
}
|
||||
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
whitelistedWindowProps.forEach(function(prop) {
|
||||
var desc = Object.getOwnPropertyDescriptor(C, prop);
|
||||
checkPropertyDescriptor(desc, prop, prop == 'location');
|
||||
|
@ -214,46 +220,46 @@ addTest(function(exception_t) {
|
|||
/*
|
||||
* [[Delete]]
|
||||
*/
|
||||
addTest(function(exception_t) {
|
||||
test_throws(exception_t, "SecurityError", function() { delete C[0]; }, "Can't delete cross-origin indexed property");
|
||||
test_throws(exception_t, "SecurityError", function() { delete C[100]; }, "Can't delete cross-origin indexed property");
|
||||
test_throws(exception_t, "SecurityError", function() { delete C.location; }, "Can't delete cross-origin property");
|
||||
test_throws(exception_t, "SecurityError", function() { delete C.parent; }, "Can't delete cross-origin property");
|
||||
test_throws(exception_t, "SecurityError", function() { delete C.length; }, "Can't delete cross-origin property");
|
||||
test_throws(exception_t, "SecurityError", function() { delete C.document; }, "Can't delete cross-origin property");
|
||||
test_throws(exception_t, "SecurityError", function() { delete C.foopy; }, "Can't delete cross-origin property");
|
||||
test_throws(exception_t, "SecurityError", function() { delete C.location.href; }, "Can't delete cross-origin property");
|
||||
test_throws(exception_t, "SecurityError", function() { delete C.location.replace; }, "Can't delete cross-origin property");
|
||||
test_throws(exception_t, "SecurityError", function() { delete C.location.port; }, "Can't delete cross-origin property");
|
||||
test_throws(exception_t, "SecurityError", function() { delete C.location.foopy; }, "Can't delete cross-origin property");
|
||||
addTest(function() {
|
||||
assert_throws("SecurityError", function() { delete C[0]; }, "Can't delete cross-origin indexed property");
|
||||
assert_throws("SecurityError", function() { delete C[100]; }, "Can't delete cross-origin indexed property");
|
||||
assert_throws("SecurityError", function() { delete C.location; }, "Can't delete cross-origin property");
|
||||
assert_throws("SecurityError", function() { delete C.parent; }, "Can't delete cross-origin property");
|
||||
assert_throws("SecurityError", function() { delete C.length; }, "Can't delete cross-origin property");
|
||||
assert_throws("SecurityError", function() { delete C.document; }, "Can't delete cross-origin property");
|
||||
assert_throws("SecurityError", function() { delete C.foopy; }, "Can't delete cross-origin property");
|
||||
assert_throws("SecurityError", function() { delete C.location.href; }, "Can't delete cross-origin property");
|
||||
assert_throws("SecurityError", function() { delete C.location.replace; }, "Can't delete cross-origin property");
|
||||
assert_throws("SecurityError", function() { delete C.location.port; }, "Can't delete cross-origin property");
|
||||
assert_throws("SecurityError", function() { delete C.location.foopy; }, "Can't delete cross-origin property");
|
||||
}, "[[Delete]] Should throw on cross-origin objects");
|
||||
|
||||
/*
|
||||
* [[DefineOwnProperty]]
|
||||
*/
|
||||
function checkDefine(exception_t, obj, prop) {
|
||||
function checkDefine(obj, prop) {
|
||||
var valueDesc = { configurable: true, enumerable: false, writable: false, value: 2 };
|
||||
var accessorDesc = { configurable: true, enumerable: false, get: function() {} };
|
||||
test_throws(exception_t, "SecurityError", function() { Object.defineProperty(obj, prop, valueDesc); }, "Can't define cross-origin value property " + prop);
|
||||
test_throws(exception_t, "SecurityError", function() { Object.defineProperty(obj, prop, accessorDesc); }, "Can't define cross-origin accessor property " + prop);
|
||||
assert_throws("SecurityError", function() { Object.defineProperty(obj, prop, valueDesc); }, "Can't define cross-origin value property " + prop);
|
||||
assert_throws("SecurityError", function() { Object.defineProperty(obj, prop, accessorDesc); }, "Can't define cross-origin accessor property " + prop);
|
||||
}
|
||||
addTest(function(exception_t) {
|
||||
checkDefine(exception_t, C, 'length');
|
||||
checkDefine(exception_t, C, 'parent');
|
||||
checkDefine(exception_t, C, 'location');
|
||||
checkDefine(exception_t, C, 'document');
|
||||
checkDefine(exception_t, C, 'foopy');
|
||||
checkDefine(exception_t, C.location, 'href');
|
||||
checkDefine(exception_t, C.location, 'replace');
|
||||
checkDefine(exception_t, C.location, 'port');
|
||||
checkDefine(exception_t, C.location, 'foopy');
|
||||
addTest(function() {
|
||||
checkDefine(C, 'length');
|
||||
checkDefine(C, 'parent');
|
||||
checkDefine(C, 'location');
|
||||
checkDefine(C, 'document');
|
||||
checkDefine(C, 'foopy');
|
||||
checkDefine(C.location, 'href');
|
||||
checkDefine(C.location, 'replace');
|
||||
checkDefine(C.location, 'port');
|
||||
checkDefine(C.location, 'foopy');
|
||||
}, "[[DefineOwnProperty]] Should throw for cross-origin objects");
|
||||
|
||||
/*
|
||||
* [[Enumerate]]
|
||||
*/
|
||||
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
for (var prop in C)
|
||||
assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Window");
|
||||
for (var prop in C.location)
|
||||
|
@ -264,7 +270,7 @@ addTest(function(exception_t) {
|
|||
* [[OwnPropertyKeys]]
|
||||
*/
|
||||
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
assert_array_equals(Object.getOwnPropertyNames(C).sort(),
|
||||
whitelistedWindowPropNames,
|
||||
"Object.getOwnPropertyNames() gives the right answer for cross-origin Window");
|
||||
|
@ -273,7 +279,7 @@ addTest(function(exception_t) {
|
|||
"Object.getOwnPropertyNames() gives the right answer for cross-origin Location");
|
||||
}, "[[OwnPropertyKeys]] should return all properties from cross-origin objects");
|
||||
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
assert_array_equals(Object.getOwnPropertySymbols(C), whitelistedSymbols,
|
||||
"Object.getOwnPropertySymbols() should return the three symbol-named properties that are exposed on a cross-origin Window");
|
||||
assert_array_equals(Object.getOwnPropertySymbols(C.location),
|
||||
|
@ -281,7 +287,7 @@ addTest(function(exception_t) {
|
|||
"Object.getOwnPropertySymbols() should return the three symbol-named properties that are exposed on a cross-origin Location");
|
||||
}, "[[OwnPropertyKeys]] should return the right symbol-named properties for cross-origin objects");
|
||||
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
var allWindowProps = Reflect.ownKeys(C);
|
||||
indexedWindowProps = allWindowProps.slice(0, whitelistedWindowIndices.length);
|
||||
stringWindowProps = allWindowProps.slice(0, -1 * whitelistedSymbols.length);
|
||||
|
@ -302,7 +308,7 @@ addTest(function(exception_t) {
|
|||
"Reflect.ownKeys should end with the cross-origin symbols for a cross-origin Location.")
|
||||
}, "[[OwnPropertyKeys]] should place the symbols after the property names after the subframe indices");
|
||||
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
assert_true(B.eval('parent.C') === C, "A and B observe the same identity for C's Window");
|
||||
assert_true(B.eval('parent.C.location') === C.location, "A and B observe the same identity for C's Location");
|
||||
}, "A and B jointly observe the same identity for cross-origin Window and Location");
|
||||
|
@ -313,19 +319,19 @@ function checkFunction(f, proto) {
|
|||
assert_equals(Object.getPrototypeOf(f), proto, f.name + " has the right prototype");
|
||||
}
|
||||
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
checkFunction(C.close, Function.prototype);
|
||||
checkFunction(C.location.replace, Function.prototype);
|
||||
}, "Cross-origin functions get local Function.prototype");
|
||||
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'parent')),
|
||||
"Need to be able to use Object.getOwnPropertyDescriptor do this test");
|
||||
checkFunction(Object.getOwnPropertyDescriptor(C, 'parent').get, Function.prototype);
|
||||
checkFunction(Object.getOwnPropertyDescriptor(C.location, 'href').set, Function.prototype);
|
||||
}, "Cross-origin Window accessors get local Function.prototype");
|
||||
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
checkFunction(close, Function.prototype);
|
||||
assert_true(close != B.close, 'same-origin Window functions get their own object');
|
||||
assert_true(close != C.close, 'cross-origin Window functions get their own object');
|
||||
|
@ -341,7 +347,7 @@ addTest(function(exception_t) {
|
|||
checkFunction(replace_B, B.Function.prototype);
|
||||
}, "Same-origin observers get different functions for cross-origin objects");
|
||||
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'parent')),
|
||||
"Need to be able to use Object.getOwnPropertyDescriptor do this test");
|
||||
var get_self_parent = Object.getOwnPropertyDescriptor(window, 'parent').get;
|
||||
|
@ -354,7 +360,7 @@ addTest(function(exception_t) {
|
|||
checkFunction(get_parent_B, B.Function.prototype);
|
||||
}, "Same-origin observers get different accessors for cross-origin Window");
|
||||
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
var set_self_href = Object.getOwnPropertyDescriptor(window.location, 'href').set;
|
||||
var set_href_A = Object.getOwnPropertyDescriptor(C.location, 'href').set;
|
||||
var set_href_B = B.eval('Object.getOwnPropertyDescriptor(parent.C.location, "href").set');
|
||||
|
@ -365,39 +371,17 @@ addTest(function(exception_t) {
|
|||
checkFunction(set_href_B, B.Function.prototype);
|
||||
}, "Same-origin observers get different accessors for cross-origin Location");
|
||||
|
||||
addTest(function(exception_t) {
|
||||
addTest(function() {
|
||||
assert_equals({}.toString.call(C), "[object Object]");
|
||||
assert_equals({}.toString.call(C.location), "[object Object]");
|
||||
}, "{}.toString.call() does the right thing on cross-origin objects");
|
||||
|
||||
// Separate test for throwing at all and throwing the right exception type
|
||||
// so that we can test that all implementations could pass while implementing
|
||||
// the observables that are actually important for security and interop, so
|
||||
// they would notice if they ever regressed them.
|
||||
function test_throws(exception_t, code, func, description) {
|
||||
assert_throws(null, func, description);
|
||||
exception_t.step(function() {
|
||||
assert_throws(code, func, description);
|
||||
});
|
||||
}
|
||||
|
||||
// We do a fresh load of the subframes for each test to minimize side-effects.
|
||||
// It would be nice to reload ourselves as well, but we can't do that without
|
||||
// disrupting the test harness.
|
||||
function runNextTest() {
|
||||
var entry = testList.shift();
|
||||
var fun = entry[0];
|
||||
var desc = entry[1];
|
||||
var main_t = async_test(desc);
|
||||
var exception_t = async_test(desc + ' (exception type)');
|
||||
main_t.add_cleanup(function() {
|
||||
exception_t.unreached_func('Main test failed')();
|
||||
});
|
||||
main_t.step(function() {
|
||||
fun(exception_t);
|
||||
});
|
||||
exception_t.done();
|
||||
main_t.done();
|
||||
test(() => entry[0](), entry[1])
|
||||
if (testList.length != 0)
|
||||
reloadSubframes(runNextTest);
|
||||
else
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: negative values for legacy `innerwidth`, `innerheight`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
|
||||
<!-- user agents are not required to support open features other than `noopener`
|
||||
and on some platforms position and size features don't make sense -->
|
||||
<meta name="flags" content="may" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
var windowURL = 'resources/message-opener.html';
|
||||
var featuresPrefix = `top=0,left=0,`;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-integers
|
||||
|
||||
setup (() => {
|
||||
// Before running tests, open a window using features that mimic
|
||||
// what would happen if the features tested here were set to invalid
|
||||
// values in later tests.
|
||||
// In cases where the value for `innerwidth` or `innerheight` is
|
||||
// is less than the browser's minimum allowed value for that dimension,
|
||||
// but NOT 0, the value affected will become the browser's minimum allowed value.
|
||||
|
||||
// This should result in a minimally-sized window for later comparison
|
||||
var featureString = `${featuresPrefix}innerwidth=1,innerheight=1`;
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage((data, e) => {
|
||||
e.source.close();
|
||||
runWindowTests(data);
|
||||
});
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
});
|
||||
|
||||
function runWindowTests (baselineDimensions) {
|
||||
|
||||
// Negative values for `innerwidth` should result in a window with minimum
|
||||
// valid allowed width
|
||||
[ 'innerwidth=-404',
|
||||
'innerwidth=-404.5',
|
||||
'innerwidth=-404e1'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}height=405,${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.width, baselineDimensions.width, `"${feature} is negative and should result in a minimally-wide window"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should NOT set "width=404"`);
|
||||
});
|
||||
|
||||
// Negative values for `innerheight` should result in a window with minimum
|
||||
// valid allowed height
|
||||
[ 'innerheight=-404',
|
||||
'innerheight=-404.5',
|
||||
'innerheight=-404e1'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}width=404,${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.height, baselineDimensions.height, `"${feature} is negative and should result in a minimal-height window"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should NOT set "height=404"`);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
|
@ -0,0 +1,67 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: negative values for legacy `screenx`, `screeny`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
|
||||
<!-- user agents are not required to support open features other than `noopener`
|
||||
and on some platforms position and size features don't make sense -->
|
||||
<meta name="flags" content="may" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
var featuresPrefix = `width=401,height=404,`;
|
||||
var windowURL = 'resources/message-opener.html';
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-integers
|
||||
|
||||
setup (() => {
|
||||
// Before running tests, open a window using features that mimic
|
||||
// what would happen if the feature tested here were set to 0
|
||||
// for comparison later.
|
||||
var featureString = `${featuresPrefix}top=0,left=0`;
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage((data, e) => {
|
||||
e.source.close();
|
||||
runWindowTests(data);
|
||||
});
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
});
|
||||
|
||||
function runWindowTests (baselineDimensions) {
|
||||
// Negative values should be interpreted as 0
|
||||
[ 'screeny=-204',
|
||||
'screeny=-204.5',
|
||||
'screeny=-0'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}left=0,${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.top, baselineDimensions.top, `"${feature} is negative and should be set to 0"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should NOT set "top=204"`);
|
||||
});
|
||||
|
||||
// Negative values should be interpreted as 0
|
||||
[ 'screenx=-204',
|
||||
'screenx=-204.5',
|
||||
'screenx=-0'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}top=0,${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.left, baselineDimensions.left, `"${feature} is negative and should be set to 0"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should NOT set "left=204"`);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
|
@ -0,0 +1,68 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: negative values for `top`, `left`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
|
||||
<!-- user agents are not required to support open features other than `noopener`
|
||||
and on some platforms position and size features don't make sense -->
|
||||
<meta name="flags" content="may" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
var featuresPrefix = `width=401,height=404,`;
|
||||
var windowURL = 'resources/message-opener.html';
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-integers
|
||||
|
||||
setup (() => {
|
||||
// Before running tests, open a window using features that mimic
|
||||
// what would happen if the feature tested here were set to 0
|
||||
// for comparison later.
|
||||
var featureString = `${featuresPrefix}top=0,left=0`;
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage((data, e) => {
|
||||
e.source.close();
|
||||
runWindowTests(data);
|
||||
});
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
});
|
||||
|
||||
function runWindowTests (baselineDimensions) {
|
||||
|
||||
// Negative values for `top`, `left` should be interpreted as 0
|
||||
[ 'top=-204',
|
||||
'top=-204.5',
|
||||
'top=-0'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}left=0,${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.top, baselineDimensions.top, `"${feature} is negative and should be set to 0"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should NOT set "top=204"`);
|
||||
});
|
||||
|
||||
// Negative values for `top`, `left` should be interpreted as 0
|
||||
[ 'left=-204',
|
||||
'left=-204.5',
|
||||
'left=-0'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}top=0,${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.left, baselineDimensions.left, `"${feature} is negative and should be set to 0"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should NOT set "left=204"`);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
|
@ -0,0 +1,75 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: negative values for `width`, `height`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
|
||||
<!-- user agents are not required to support open features other than `noopener`
|
||||
and on some platforms position and size features don't make sense -->
|
||||
<meta name="flags" content="may" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
var featuresPrefix = `top=0,left=0,`;
|
||||
var windowURL = 'resources/message-opener.html';
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-integers
|
||||
|
||||
setup (() => {
|
||||
// Before running tests, open a window using features that mimic
|
||||
// what would happen if the features tested here were set to invalid
|
||||
// values in later tests.
|
||||
// In cases where the value for `width` or `height` is
|
||||
// is less than the browser's minimum allowed value for that dimension,
|
||||
// but NOT 0, the value affected will become the browser's minimum allowed value.
|
||||
|
||||
// This should result in a minimally-sized window for later comparison
|
||||
var featureString = `${featuresPrefix}width=1,height=1`;
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage((data, e) => {
|
||||
e.source.close();
|
||||
runWindowTests(data);
|
||||
});
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
});
|
||||
|
||||
function runWindowTests (baselineDimensions) {
|
||||
|
||||
// Negative values for `width` should result in a window with minimum
|
||||
// valid allowed width
|
||||
[ 'width=-404',
|
||||
'width=-404.5',
|
||||
'width=-404e1'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}height=405,${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.width, baselineDimensions.width, `"${feature} is negative and should result in a minimally-wide window"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should NOT set "width=404"`);
|
||||
});
|
||||
|
||||
// Negative values for `height` should result in a window with minimum
|
||||
// valid allowed height
|
||||
[ 'height=-404',
|
||||
'height=-404.5',
|
||||
'height=-404e1'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}width=404,${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.height, baselineDimensions.height, `"${feature} is negative and should result in a minimal-height window"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should NOT set "height=404"`);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
|
@ -0,0 +1,91 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: non-integer values for feature `height`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
|
||||
<!-- user agents are not required to support open features other than `noopener`
|
||||
and on some platforms position and size features don't make sense -->
|
||||
<meta name="flags" content="may" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
var featuresPrefix = `top=0,left=0,width=401,`;
|
||||
var windowURL = 'resources/message-opener.html';
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-integers
|
||||
|
||||
setup (() => {
|
||||
// Before running tests, open a window using features that mimic
|
||||
// what would happen if the feature tested here were set to 0
|
||||
// for comparison later.
|
||||
var featureString = `${featuresPrefix}height=0`;
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage((data, e) => {
|
||||
e.source.close();
|
||||
runWindowTests(data);
|
||||
});
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
});
|
||||
|
||||
function runWindowTests (baselineDimensions) {
|
||||
// The absence of the sizing feature should have the same behavior
|
||||
// as that feature set to 0
|
||||
[ featuresPrefix,
|
||||
'top=0,left=0',
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.width, baselineDimensions.width);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', feature);
|
||||
}, `${feature}: absence of feature "height" should be treated same as "height=0"`);
|
||||
});
|
||||
|
||||
// When code point in first position is not an ASCII digit, "+" or "-",
|
||||
// that's an error and the value becomes 0
|
||||
[ 'height=/404',
|
||||
'height=_404',
|
||||
'height=L404'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.height, baselineDimensions.height, `"${feature} begins with an invalid character and should be ignored"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should NOT set "height=404"`);
|
||||
});
|
||||
|
||||
// Codepoints that are valid ASCII digits should be collected
|
||||
// Non-ASCII digits and subsequent code points are ignored
|
||||
[ 'height=405.5',
|
||||
'height=405.32',
|
||||
'height=405LLl',
|
||||
'height=405^4',
|
||||
'height=405*3',
|
||||
'height=405/5',
|
||||
'height=405 ',
|
||||
'height=405e1',
|
||||
'height=405e-1'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.height, 405, `"${featureString} value after first non-digit will be ignored"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should set "height=405"`);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
</script>
|
|
@ -0,0 +1,76 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: non-integer values for legacy feature `innerheight`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
|
||||
<!-- user agents are not required to support open features other than `noopener`
|
||||
and on some platforms position and size features don't make sense -->
|
||||
<meta name="flags" content="may" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
var featuresPrefix = `top=0,left=0,width=401,`;
|
||||
var windowURL = 'resources/message-opener.html';
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-integers
|
||||
|
||||
setup (() => {
|
||||
// Before running tests, open a window using features that mimic
|
||||
// what would happen if the feature tested here were set to 0
|
||||
// for comparison later.
|
||||
var featureString = `${featuresPrefix}height=0`;
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage((data, e) => {
|
||||
e.source.close();
|
||||
runWindowTests(data);
|
||||
});
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
});
|
||||
|
||||
function runWindowTests (baselineDimensions) {
|
||||
// When code point in first position is not an ASCII digit, "+" or "-",
|
||||
// that's an error and the value becomes 0
|
||||
[ 'innerheight=/404',
|
||||
'innerheight=_404',
|
||||
'innerheight=L404'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.height, baselineDimensions.height, `"${feature} begins with an invalid character and should be ignored"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should NOT set "height=404"`);
|
||||
});
|
||||
|
||||
// Codepoints that are valid ASCII digits should be collected
|
||||
// Non-ASCII digits and subsequent code points are ignored
|
||||
[ 'innerheight=405.5',
|
||||
'innerheight=405.32',
|
||||
'innerheight=405LLl',
|
||||
'innerheight=405^4',
|
||||
'innerheight=405*3',
|
||||
'innerheight=405/5',
|
||||
'innerheight=405 ',
|
||||
'innerheight=405e1',
|
||||
'innerheight=405e-1'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.height, 405, `"${featureString} value after first non-digit will be ignored"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should set "height=405"`);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
</script>
|
|
@ -0,0 +1,75 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: non-integer values for legacy feature `innerwidth`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
|
||||
<!-- user agents are not required to support open features other than `noopener`
|
||||
and on some platforms position and size features don't make sense -->
|
||||
<meta name="flags" content="may" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
var featuresPrefix = `top=0,left=0,height=401,`;
|
||||
var windowURL = 'resources/message-opener.html';
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-integers
|
||||
|
||||
setup (() => {
|
||||
// Before running tests, open a window using features that mimic
|
||||
// what would happen if the feature tested here were set to 0
|
||||
// for comparison later.
|
||||
var featureString = `${featuresPrefix}width=0`;
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage((data, e) => {
|
||||
e.source.close();
|
||||
runWindowTests(data);
|
||||
});
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
});
|
||||
|
||||
function runWindowTests (baselineDimensions) {
|
||||
// When code point in first position is not an ASCII digit, "+" or "-",
|
||||
// that's an error and the value becomes 0
|
||||
[ 'innerwidth=/404',
|
||||
'innerwidth=_404',
|
||||
'innerwidth=L404'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.width, baselineDimensions.width, `"${feature} begins with an invalid character and should be ignored"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should NOT set "width=404"`);
|
||||
});
|
||||
|
||||
// Codepoints that are valid ASCII digits should be collected
|
||||
// Non-ASCII digits and subsequent code points are ignored
|
||||
[ 'innerwidth=405.5',
|
||||
'innerwidth=405.32',
|
||||
'innerwidth=405LLl',
|
||||
'innerwidth=405^4',
|
||||
'innerwidth=405*3',
|
||||
'innerwidth=405/5',
|
||||
'innerwidth=405 ',
|
||||
'innerwidth=405e1',
|
||||
'innerwidth=405e-1'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.width, 405, `"${featureString} value after first non-digit will be ignored"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should set "width=405"`);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
|
@ -0,0 +1,76 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: non-integer values for feature `left`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
|
||||
<!-- user agents are not required to support open features other than `noopener`
|
||||
and on some platforms position and size features don't make sense -->
|
||||
<meta name="flags" content="may" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
|
||||
var featuresPrefix = `width=401,height=204,top=0,`;
|
||||
var windowURL = 'resources/message-opener.html';
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-integers
|
||||
|
||||
setup (() => {
|
||||
// Before running tests, open a window using features that mimic
|
||||
// what would happen if the feature tested here were set to 0
|
||||
// for comparison later.
|
||||
var featureString = `${featuresPrefix}left=0`;
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage((data, e) => {
|
||||
e.source.close();
|
||||
runWindowTests(data);
|
||||
});
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
});
|
||||
|
||||
function runWindowTests (baselineDimensions) {
|
||||
// When code point in first position is not an ASCII digit, "+" or "-",
|
||||
// that's an error and the value becomes 0
|
||||
[ 'left=/104',
|
||||
'left=_104',
|
||||
'left=L104'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var featureString = `${featuresPrefix}${feature}`;
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.left, baselineDimensions.left, `"${feature} begins with an invalid character and should be ignored"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should NOT set "left=104"`);
|
||||
});
|
||||
|
||||
// Codepoints that are valid ASCII digits should be collected
|
||||
// Non-ASCII digits and subsequent code points are ignored
|
||||
[ 'left=105.5',
|
||||
'left=105.32',
|
||||
'left=105LLl',
|
||||
'left=105^4',
|
||||
'left=105*3',
|
||||
'left=105/5',
|
||||
'left=105 ',
|
||||
'left=105e1',
|
||||
'left=105e-1'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var featureString = `${featuresPrefix}${feature}`;
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.left, 105, `"${featureString} value after first non-digit will be ignored"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should set "left=105"`);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
|
@ -0,0 +1,75 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: non-integer values for legacy feature `screenx`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
|
||||
<!-- user agents are not required to support open features other than `noopener`
|
||||
and on some platforms position and size features don't make sense -->
|
||||
<meta name="flags" content="may" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
var featuresPrefix = `width=401,height=204,top=0,`;
|
||||
var windowURL = 'resources/message-opener.html';
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-integers
|
||||
|
||||
setup (() => {
|
||||
// Before running tests, open a window using features that mimic
|
||||
// what would happen if the feature tested here were set to 0
|
||||
// for comparison later.
|
||||
var featureString = `${featuresPrefix}left=0`;
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage((data, e) => {
|
||||
e.source.close();
|
||||
runWindowTests(data);
|
||||
});
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
});
|
||||
|
||||
function runWindowTests (baselineDimensions) {
|
||||
// When code point in first position is not an ASCII digit, "+" or "-",
|
||||
// that's an error and the value becomes 0
|
||||
[ 'screenx=/104',
|
||||
'screenx=_104',
|
||||
'screenx=L104'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.left, baselineDimensions.left, `"${feature} begins with an invalid character and should be ignored"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should NOT set "left=104"`);
|
||||
});
|
||||
|
||||
// Codepoints that are valid ASCII digits should be collected
|
||||
// Non-ASCII digits and subsequent code points are ignored
|
||||
[ 'screenx=105.5',
|
||||
'screenx=105.32',
|
||||
'screenx=105LLl',
|
||||
'screenx=105^4',
|
||||
'screenx=105*3',
|
||||
'screenx=105/5',
|
||||
'screenx=105 ',
|
||||
'screenx=105e1',
|
||||
'screenx=105e-1'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.left, 105, `"${featureString} value after first non-digit will be ignored"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should set "left=105"`);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
|
@ -0,0 +1,76 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: non-integer values for legacy feature `screeny`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
|
||||
<!-- user agents are not required to support open features other than `noopener`
|
||||
and on some platforms position and size features don't make sense -->
|
||||
<meta name="flags" content="may" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
var featuresPrefix = `height=401,width=402,left=0,`;
|
||||
var windowURL = 'resources/message-opener.html';
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-integers
|
||||
|
||||
setup (() => {
|
||||
// Before running tests, open a window using features that mimic
|
||||
// what would happen if the feature tested here were set to 0
|
||||
// for comparison later.
|
||||
var featureString = `${featuresPrefix}top=0`;
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage((data, e) => {
|
||||
e.source.close();
|
||||
runWindowTests(data);
|
||||
});
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
});
|
||||
|
||||
function runWindowTests (baselineDimensions) {
|
||||
// When code point in first position is not an ASCII digit, "+" or "-",
|
||||
// that's an error and the value becomes 0
|
||||
[ 'screeny=/404',
|
||||
'screeny=_404',
|
||||
'screeny=L404'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.top, baselineDimensions.top, `"${feature} begins with an invalid character and should be ignored"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should NOT set "height=404"`);
|
||||
});
|
||||
|
||||
// Codepoints that are valid ASCII digits should be collected
|
||||
// Non-ASCII digits and subsequent code points are ignored
|
||||
[ 'screeny=405.5',
|
||||
'screeny=405.32',
|
||||
'screeny=405LLl',
|
||||
'screeny=405^4',
|
||||
'screeny=405*3',
|
||||
'screeny=405/5',
|
||||
'screeny=405 ',
|
||||
'screeny=405e1',
|
||||
'screeny=405e-1'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.top, 405, `"${featureString} value after first non-digit will be ignored"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should set "height=405"`);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
</script>
|
|
@ -0,0 +1,73 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: non-integer values for feature `top`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
|
||||
<!-- user agents are not required to support open features other than `noopener`
|
||||
and on some platforms position and size features don't make sense -->
|
||||
<meta name="flags" content="may" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
var windowURL = 'resources/message-opener.html';
|
||||
var featuresPrefix = `width=401,height=204,left=0,`;
|
||||
|
||||
setup (() => {
|
||||
// Before running tests, open a window using features that mimic
|
||||
// what would happen if the feature tested here were set to 0
|
||||
// for comparison later.
|
||||
var featureString = `${featuresPrefix}top=0`;
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage((data, e) => {
|
||||
e.source.close();
|
||||
runWindowTests(data);
|
||||
});
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
});
|
||||
|
||||
function runWindowTests (baselineDimensions) {
|
||||
// When code point in first position is not an ASCII digit, "+" or "-",
|
||||
// that's an error and the value becomes 0
|
||||
[ 'top=/104',
|
||||
'top=_104',
|
||||
'top=L104'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.top, baselineDimensions.top, `"${feature} begins with an invalid character and should be ignored"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should NOT set "top=104"`);
|
||||
});
|
||||
|
||||
// Codepoints that are valid ASCII digits should be collected
|
||||
// Non-ASCII digits and subsequent code points are ignored
|
||||
[ 'top=105.5',
|
||||
'top=105.32',
|
||||
'top=105LLl',
|
||||
'top=105^4',
|
||||
'top=105*3',
|
||||
'top=105/5',
|
||||
'top=105 ',
|
||||
'top=105e1',
|
||||
'top=105e-1'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var featureString = `${featuresPrefix}${feature}`;
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.top, 105, `"${feature} value after first non-digit will be ignored"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should set "top=105"`);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
|
@ -0,0 +1,91 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: non-integer values for feature `width`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
|
||||
<!-- user agents are not required to support open features other than `noopener`
|
||||
and on some platforms position and size features don't make sense -->
|
||||
<meta name="flags" content="may" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
var featuresPrefix = `top=0,left=0,height=401,`;
|
||||
var windowURL = 'resources/message-opener.html';
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-integers
|
||||
|
||||
setup (() => {
|
||||
// Before running tests, open a window using features that mimic
|
||||
// what would happen if the feature tested here were set to 0
|
||||
// for comparison later.
|
||||
var featureString = `${featuresPrefix}width=0`;
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage((data, e) => {
|
||||
e.source.close();
|
||||
runWindowTests(data);
|
||||
});
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
});
|
||||
|
||||
function runWindowTests (baselineDimensions) {
|
||||
|
||||
// The absence of the sizing feature should have the same behavior
|
||||
// as that feature set to 0
|
||||
[ featuresPrefix,
|
||||
'top=0,left=0',
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.width, baselineDimensions.width);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', feature);
|
||||
}, `${feature}: absence of feature "width" should be treated same as "width=0"`);
|
||||
});
|
||||
|
||||
// When code point in first position is not an ASCII digit, "+" or "-",
|
||||
// that's an error and the value becomes 0
|
||||
[ 'width=/404',
|
||||
'width=_404',
|
||||
'width=L404'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.width, baselineDimensions.width, `"${feature} begins with an invalid character and should be ignored"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should NOT set "width=404"`);
|
||||
});
|
||||
|
||||
// Codepoints that are valid ASCII digits should be collected
|
||||
// Non-ASCII digits and subsequent code points are ignored
|
||||
[ 'width=405.5',
|
||||
'width=405.32',
|
||||
'width=405LLl',
|
||||
'width=405^4',
|
||||
'width=405*3',
|
||||
'width=405/5',
|
||||
'width=405 ',
|
||||
'width=405e1',
|
||||
'width=405e-1'
|
||||
].forEach(feature => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
var featureString = `${featuresPrefix}${feature}`;
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.width, 405, `"${featureString} value after first non-digit will be ignored"`);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
|
||||
}, `features "${feature}" should set "width=405"`);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
|
@ -0,0 +1,55 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: tokenization -- legacy size features `innerheight`, `innerwidth`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
|
||||
<!-- user agents are not required to support open features other than `noopener`
|
||||
and on some platforms position and size features don't make sense -->
|
||||
<meta name="flags" content="may" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
var windowURL = 'resources/message-opener.html';
|
||||
var width = 'width=401,';
|
||||
var height = 'height=402,';
|
||||
|
||||
[ 'innerwidth=401',
|
||||
' innerwidth = 401',
|
||||
'innerwidth==401',
|
||||
'\ninnerwidth= 401',
|
||||
',innerwidth=401,,',
|
||||
'INNERWIDTH=401',
|
||||
'innerWidth=401'
|
||||
].forEach((features, idx, arr) => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.width, 401);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', height + features);
|
||||
}, `${format_value(features)} should set width of opened window`);
|
||||
});
|
||||
|
||||
[ 'innerheight=402',
|
||||
' innerheight = 402',
|
||||
'innerheight==402',
|
||||
'\ninnerheight= 402',
|
||||
',innerheight=402,,',
|
||||
'INNERHEIGHT=402',
|
||||
'innerHeight=402'
|
||||
].forEach((features, idx, arr) => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.height, 402);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', width + features);
|
||||
}, `${format_value(features)} should set height of opened window`);
|
||||
});
|
||||
|
||||
</script>
|
|
@ -0,0 +1,149 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: tokenization -- `noopener`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
var windowURL = 'resources/close-self.html';
|
||||
|
||||
// Tests for how windows features are tokenized into 'name', 'value'
|
||||
// window features separators are ASCII whitespace, '=' and ','
|
||||
|
||||
test (t => {
|
||||
// Tokenizing `name`: initial window features separators are ignored
|
||||
// Each of these variants should tokenize to ('noopener', '')
|
||||
var featureVariants = [
|
||||
' noopener',
|
||||
'=noopener',
|
||||
',,noopener',
|
||||
',=, noopener',
|
||||
'\n=noopener=',
|
||||
'\tnoopener',
|
||||
'\r,,,=noopener',
|
||||
'\u000Cnoopener'
|
||||
];
|
||||
featureVariants.forEach(feature => {
|
||||
var win = window.open(windowURL, '', feature);
|
||||
assert_equals(win, null, `"${feature}" should activate feature "noopener"`);
|
||||
});
|
||||
}, 'tokenization should skip window features separators before `name`');
|
||||
|
||||
test (t => {
|
||||
// Tokenizing `name`: lowercase conversion
|
||||
// Each of these variants should tokenize as feature ('noopener', '')
|
||||
// except where indicated
|
||||
// Note also that `value` is lowercased during tokenization
|
||||
var featureVariants = [
|
||||
'NOOPENER',
|
||||
'noOpenER',
|
||||
' NOopener',
|
||||
'=NOOPENER',
|
||||
'noopener=NOOPENER', // => ('noopener', 'noopener')
|
||||
'NOOPENER=noopener' // => ('noopener', 'noopener')
|
||||
];
|
||||
featureVariants.forEach(feature => {
|
||||
var win = window.open(windowURL, '', feature);
|
||||
assert_equals(win, null, `"${feature}" should activate feature "noopener"`);
|
||||
});
|
||||
}, 'feature `name` should be converted to ASCII lowercase');
|
||||
|
||||
test (t => {
|
||||
// After `name` has been collected, ignore any window features separators until '='
|
||||
// except ',' OR a non-window-features-separator — break in those cases
|
||||
// i.e. ignore whitespace until '=' unless a ',' is encountered first
|
||||
// Each of these variants should tokenize as feature ('noopener', '')
|
||||
var featureVariants = [
|
||||
'noopener',
|
||||
' noopener\r',
|
||||
'noopener\n =',
|
||||
'noopener,',
|
||||
'noopener =,',
|
||||
', noopener =',
|
||||
'noopener,=',
|
||||
'noopener foo', // => ('noopener', ''), ('foo', '')
|
||||
'foo noopener=1', // => ('foo', ''), ('noopener', '1')
|
||||
'foo=\u000Cnoopener' // => ('foo', ''), ('noopener', '')
|
||||
];
|
||||
featureVariants.forEach(feature => {
|
||||
var win = window.open(windowURL, '', feature);
|
||||
assert_equals(win, null, `"${feature}" should activate feature "noopener"`);
|
||||
});
|
||||
}, 'after `name`, tokenization should skip window features separators that are not "=" or ","');
|
||||
|
||||
test (t => {
|
||||
// After initial '=', tokenizing should ignore all separators except ','
|
||||
// before collecting `value`
|
||||
// Each of these variants should tokenize as feature ('noopener', '')
|
||||
// Except where indicated
|
||||
var featureVariants = [
|
||||
'noopener= yes', // => ('noopener', 'yes')
|
||||
'noopener==,',
|
||||
'noopener=\n ,',
|
||||
'noopener = \t ,',
|
||||
'noopener\n=\r noopener,', // => ('noopener', 'noopener')
|
||||
'noopener=,yes', // => ('noopener'), ('yes')
|
||||
'noopener= foo=,', // => ('noopener', 'foo')
|
||||
'noopener = \u000Cyes' // => ('noopener', 'yes')
|
||||
];
|
||||
featureVariants.forEach(feature => {
|
||||
var win = window.open(windowURL, '', feature);
|
||||
assert_equals(win, null, `"${feature}" should activate feature "noopener"`);
|
||||
});
|
||||
}, 'Tokenizing should ignore window feature separators except "," after initial "=" and before value');
|
||||
|
||||
test (t => {
|
||||
// Tokenizing `value` should collect any non-separator code points until first separator
|
||||
var featureVariants = [
|
||||
'noopener=noopener', // => ('noopener', 'noopener')
|
||||
'noopener=yes', // => ('noopener', 'yes')
|
||||
'noopener = yes ,', // => ('noopener', 'yes')
|
||||
'noopener=\nyes ,', // => ('noopener', 'yes')
|
||||
'noopener=yes yes', // => ('noopener', 'yes'), ('yes', '')
|
||||
'noopener=yes\ts', // => ('noopener', 'yes'), ('s', '')
|
||||
'noopener==', // => ('noopener', '')
|
||||
'noopener=0\n,', // => ('noopener', '0')
|
||||
'==noopener===', // => ('noopener', '')
|
||||
'noopener==\u000C' // => ('noopener', '')
|
||||
];
|
||||
featureVariants.forEach(feature => {
|
||||
var win = window.open(windowURL, '', feature);
|
||||
assert_equals(win, null, `"${feature}" should set "noopener"`);
|
||||
});
|
||||
}, 'Tokenizing should read characters until first window feature separator as `value`');
|
||||
|
||||
test (t => {
|
||||
// If tokenizedFeatures contains an entry with the key "noopener"...disown opener
|
||||
// i.e. `value` should be irrelevant
|
||||
var featureVariants = [
|
||||
'noopener=false',
|
||||
',noopener=0, ',
|
||||
'foo=bar,noopener=noopener,',
|
||||
'noopener=true',
|
||||
'noopener=foo\nbar\t'
|
||||
];
|
||||
featureVariants.forEach(feature => {
|
||||
var win = window.open(windowURL, '', feature);
|
||||
assert_equals(win, null, `"${feature}" should activate feature "noopener"`);
|
||||
});
|
||||
}, '"noopener" should be based on name (key), not value');
|
||||
|
||||
test (t => {
|
||||
var invalidFeatureVariants = [
|
||||
'-noopener', // => ('-noopener', '')
|
||||
'NOOPENERRRR', // => ('noopenerrr', '')
|
||||
'noOpenErR', // => ('noopenerr', '')
|
||||
'no_opener', // => ('no_opener', '')
|
||||
' no opener', // => ('no', ''), ('opener', '')
|
||||
'no\nopener', // => ('no', ''), ('opener', '')
|
||||
'no,opener', // => ('no', ''), ('opener', '')
|
||||
'\0noopener', // => ('\0noopener', '')
|
||||
'noopener\u0000=yes' // => ('noopener\0', 'yes')
|
||||
];
|
||||
invalidFeatureVariants.forEach(feature => {
|
||||
var win = window.open(windowURL, '', feature);
|
||||
assert_not_equals(win, null, `"${feature}" should NOT activate feature "noopener"`);
|
||||
});
|
||||
}, 'invalid feature names should not tokenize as "noopener"');
|
||||
</script>
|
|
@ -0,0 +1,55 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: tokenization -- legacy position features `screenx`, `screeny`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
|
||||
<!-- user agents are not required to support open features other than `noopener`
|
||||
and on some platforms position and size features don't make sense -->
|
||||
<meta name="flags" content="may" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
var windowURL = 'resources/message-opener.html';
|
||||
var width = 'width=401,';
|
||||
var height = 'height=402,';
|
||||
|
||||
[ 'screenx=141',
|
||||
' screenx = 141',
|
||||
'screenx==141',
|
||||
'\nscreenx= 141',
|
||||
',screenx=141,,',
|
||||
'SCREENX=141',
|
||||
'screenX=141'
|
||||
].forEach((features, idx, arr) => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.left, 141);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', width + height + features);
|
||||
}, `${format_value(features)} should set left position of opened window`);
|
||||
});
|
||||
|
||||
[ 'screeny=142',
|
||||
' screeny = 142',
|
||||
'screeny==142',
|
||||
'\nscreeny= 142',
|
||||
',screeny=142,,',
|
||||
'SCREENY=142',
|
||||
'screenY=142'
|
||||
].forEach((features, idx, arr) => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.top, 142);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', width + height + features);
|
||||
}, `${format_value(features)} should set top position of opened window`);
|
||||
});
|
||||
|
||||
</script>
|
|
@ -0,0 +1,69 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: tokenization -- position features `top` and `left`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
|
||||
<!-- user agents are not required to support open features other than `noopener`
|
||||
and on some platforms position and size features don't make sense -->
|
||||
<meta name="flags" content="may" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
var windowURL = 'resources/message-opener.html';
|
||||
var width = 'width=401,';
|
||||
var height = 'height=402,';
|
||||
|
||||
[ 'left=141',
|
||||
' left = 141',
|
||||
'left==141',
|
||||
'\nleft= 141',
|
||||
',left=141,,',
|
||||
'LEFT=141'
|
||||
].forEach((features, idx, arr) => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.left, 141);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', width + height + features);
|
||||
}, `"${features}" should set left position of opened window`);
|
||||
});
|
||||
|
||||
[ 'top=142',
|
||||
' top = 142',
|
||||
'top==142',
|
||||
'\ttop= 142',
|
||||
',top=142,,',
|
||||
'TOP=142'
|
||||
].forEach((features, idx, arr) => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.top, 142);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', width + height + features);
|
||||
}, `${format_value(features)} should set top position of opened window`);
|
||||
});
|
||||
|
||||
[ 'top=152,left=152',
|
||||
'top=152,,left=152,',
|
||||
'top=152==left=152',
|
||||
',,top= 152, left=152'
|
||||
].forEach((features, idx, arr) => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.top, 152);
|
||||
assert_equals(data.left, 152);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', width + height + features);
|
||||
}, `${format_value(features)} should set top and left position of opened window`);
|
||||
});
|
||||
|
||||
</script>
|
|
@ -0,0 +1,71 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML: window.open `features`: tokenization -- size features `width` and `height`</title>
|
||||
<meta name=timeout content=long>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
|
||||
|
||||
<!-- user agents are not required to support open features other than `noopener`
|
||||
and on some platforms position and size features don't make sense -->
|
||||
<meta name="flags" content="may" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
var windowURL = 'resources/message-opener.html';
|
||||
var width = 'width=401,';
|
||||
var height = 'height=402,';
|
||||
|
||||
[ 'width=401',
|
||||
' width = 401',
|
||||
'width==401',
|
||||
'\nwidth= 401',
|
||||
',width=401,,',
|
||||
'WIDTH=401'
|
||||
].forEach((features, idx, arr) => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.width, 401);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', height + features);
|
||||
}, `${format_value(features)} should set width of opened window`);
|
||||
});
|
||||
|
||||
[ 'height=402',
|
||||
' height = 402',
|
||||
'height==402',
|
||||
'\nheight= 402',
|
||||
',height=402,,',
|
||||
'HEIGHT=402'
|
||||
].forEach((features, idx, arr) => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.height, 402);
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', width + features);
|
||||
}, `${format_value(features)} should set height of opened window`);
|
||||
});
|
||||
|
||||
[ 'height=402,width=401',
|
||||
' height = 402 , width = 401 ,',
|
||||
'height==402 width = 401',
|
||||
'\nheight= 402,,width=\n401',
|
||||
',height=402,,width==401',
|
||||
'HEIGHT=402, WIDTH=401'
|
||||
].forEach((features, idx, arr) => {
|
||||
async_test(t => {
|
||||
var prefixedMessage = new PrefixedMessageTest();
|
||||
prefixedMessage.onMessage(t.step_func_done((data, e) => {
|
||||
e.source.close();
|
||||
assert_equals(data.height, 402);
|
||||
assert_equals(data.width, 401)
|
||||
}));
|
||||
var win = window.open(prefixedMessage.url(windowURL), '', features);
|
||||
}, `${format_value(features)} should set height and width of opened window`);
|
||||
});
|
||||
|
||||
</script>
|
|
@ -0,0 +1,3 @@
|
|||
<script>
|
||||
window.close();
|
||||
</script>
|
|
@ -0,0 +1,12 @@
|
|||
<script src="/common/PrefixedPostMessage.js"></script>
|
||||
<script>
|
||||
var prefixedMessage = new PrefixedMessageResource();
|
||||
window.addEventListener('load', () => {
|
||||
prefixedMessage.postToOpener({
|
||||
left: window.screenX,
|
||||
top: window.screenY,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -4,5 +4,12 @@
|
|||
var channel = new BroadcastChannel(channelName);
|
||||
channel.postMessage({ name: window.name,
|
||||
haveOpener: window.opener !== null });
|
||||
window.close();
|
||||
|
||||
// Because messages are not delivered synchronously and because closing a
|
||||
// browsing context prompts the eventual clearing of all task sources, this
|
||||
// document should not be closed until the opener document has confirmed
|
||||
// receipt.
|
||||
channel.onmessage = function() {
|
||||
window.close();
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -64,7 +64,10 @@ for (var i = 0; i < testData.length; ++i) {
|
|||
} else {
|
||||
t.step(function() {
|
||||
var w1;
|
||||
this.add_cleanup(function() { w1.close(); });
|
||||
this.add_cleanup(function() {
|
||||
w1.close();
|
||||
channel.postMessage(null);
|
||||
});
|
||||
|
||||
var windowName = this.windowName;
|
||||
var channel = new BroadcastChannel(windowName);
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>[[SetPrototypeOf]] on a WindowProxy object should not allow changing its value: cross-origin via document.domain</title>
|
||||
<link rel="help" href="http://html.spec.whatwg.org/multipage/#windowproxy-setprototypeof">
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/test-setting-immutable-prototype.js"></script>
|
||||
|
||||
<iframe src="/common/domain-setter.sub.html"></iframe>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
// This page does *not* set document.domain, so it's cross-origin with the iframe
|
||||
setup({ explicit_done: true });
|
||||
|
||||
window.onload = () => {
|
||||
const target = frames[0];
|
||||
|
||||
test(() => {
|
||||
assert_equals(Object.getPrototypeOf(target), null);
|
||||
}, "Cross-origin via document.domain: the prototype is null");
|
||||
|
||||
testSettingImmutablePrototype("Cross-origin via document.domain", target, null, { isSameOriginDomain: false });
|
||||
|
||||
done();
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>[[SetPrototypeOf]] on a WindowProxy object should not allow changing its value: cross-origin</title>
|
||||
<link rel="help" href="http://html.spec.whatwg.org/multipage/#windowproxy-setprototypeof">
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/test-setting-immutable-prototype.js"></script>
|
||||
|
||||
<iframe src="//{{domains[www]}}:{{ports[http][1]}}/common/blank.html"></iframe>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
setup({ explicit_done: true });
|
||||
|
||||
window.onload = () => {
|
||||
const target = frames[0];
|
||||
|
||||
test(() => {
|
||||
assert_equals(Object.getPrototypeOf(target), null);
|
||||
}, "Cross-origin: the prototype is null");
|
||||
|
||||
testSettingImmutablePrototype("Cross-origin", target, null, { isSameOriginDomain: false });
|
||||
|
||||
done();
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>[[SetPrototypeOf]] on a WindowProxy object should not allow changing its value: cross-origin via document.domain after initially getting the object</title>
|
||||
<link rel="help" href="http://html.spec.whatwg.org/multipage/#windowproxy-setprototypeof">
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/test-setting-immutable-prototype.js"></script>
|
||||
|
||||
<iframe src="/common/blank.html"></iframe>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
setup({ explicit_done: true });
|
||||
|
||||
window.onload = () => {
|
||||
const target = frames[0];
|
||||
const origProto = Object.getPrototypeOf(target);
|
||||
|
||||
test(() => {
|
||||
assert_not_equals(origProto, null);
|
||||
}, "Same-origin (for now): the prototype is accessible");
|
||||
|
||||
document.domain = "{{host}}";
|
||||
|
||||
test(() => {
|
||||
assert_equals(Object.getPrototypeOf(target), null);
|
||||
}, "Became cross-origin via document.domain: the prototype is now null");
|
||||
|
||||
testSettingImmutablePrototype("Became cross-origin via document.domain", target, null, { isSameOriginDomain: false });
|
||||
|
||||
testSettingImmutablePrototypeToNewValueOnly(
|
||||
"Became cross-origin via document.domain", target, origProto,
|
||||
"the original value from before going cross-origin", { isSameOriginDomain: false });
|
||||
|
||||
done();
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>[[SetPrototypeOf]] on a WindowProxy object should not allow changing its value: cross-origin, but same-origin-domain</title>
|
||||
<link rel="help" href="http://html.spec.whatwg.org/multipage/#windowproxy-setprototypeof">
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/test-setting-immutable-prototype.js"></script>
|
||||
|
||||
<iframe src="//{{domains[www]}}:{{ports[http][1]}}/common/domain-setter.sub.html"></iframe>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
document.domain = "{{host}}";
|
||||
setup({ explicit_done: true });
|
||||
|
||||
window.onload = () => {
|
||||
const target = frames[0];
|
||||
const origProto = Object.getPrototypeOf(target);
|
||||
|
||||
test(() => {
|
||||
assert_not_equals(origProto, null);
|
||||
}, "Same-origin-domain prerequisite check: the original prototype is accessible");
|
||||
|
||||
testSettingImmutablePrototype("Same-origin-domain", target, origProto, { isSameOriginDomain: true });
|
||||
|
||||
done();
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>[[SetPrototypeOf]] on a WindowProxy object should not allow changing its value: same-origin</title>
|
||||
<link rel="help" href="http://html.spec.whatwg.org/multipage/#windowproxy-setprototypeof">
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/test-setting-immutable-prototype.js"></script>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
const origProto = Object.getPrototypeOf(window);
|
||||
|
||||
test(() => {
|
||||
assert_not_equals(origProto, null);
|
||||
}, "Same-origin prerequisite check: the original prototype is accessible");
|
||||
|
||||
testSettingImmutablePrototype("Same-origin", window, origProto, { isSameOriginDomain: true });
|
||||
</script>
|
|
@ -0,0 +1,31 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<html>
|
||||
<head>
|
||||
<title>Auxiliary Browing Contexts: window.opener when Opener Removed/Closed</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var prefixedLocalStorage;
|
||||
setup (() => prefixedLocalStorage = new PrefixedLocalStorageTest());
|
||||
async_test(t => {
|
||||
t.add_cleanup (() => prefixedLocalStorage.cleanup());
|
||||
var a = document.createElement('a');
|
||||
a.href = prefixedLocalStorage.url('resources/open-closer.html');
|
||||
a.target = '_blank';
|
||||
prefixedLocalStorage.onSet('openerIsNull', t.step_func_done(e => {
|
||||
// The window for this auxiliary browsing context's opener
|
||||
// has been closed and discarded, so the aux browsing context
|
||||
// should now report `null` for `window.opener`
|
||||
assert_equals(e.newValue, 'true');
|
||||
}));
|
||||
document.body.append(a);
|
||||
a.click();
|
||||
}, 'An auxiliary browsing context should report `null` for `window.opener` when that browsing context is discarded');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,35 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Auxiliary Browing Contexts: window.opener, multiple</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var prefixedLocalStorage;
|
||||
setup (() => prefixedLocalStorage = new PrefixedLocalStorageTest());
|
||||
async_test(t => {
|
||||
t.add_cleanup (() => prefixedLocalStorage.cleanup());
|
||||
var a = document.createElement('a');
|
||||
a.href = prefixedLocalStorage.url('resources/multiple-opener.html');
|
||||
a.target = 'multipleOpener';
|
||||
window.name = 'topOpener';
|
||||
document.body.appendChild(a);
|
||||
window.addEventListener('message', t.step_func_done(e => {
|
||||
var aux1 = e.data.aux1; // First opened context
|
||||
var aux2 = e.data.aux2; // Context opened by first-opened context
|
||||
assert_equals(aux1.name, 'multipleOpener');
|
||||
assert_equals(aux1.openerName, window.name);
|
||||
assert_equals(aux1.isTop, true);
|
||||
assert_equals(aux2.name, 'multipleOpenee');
|
||||
assert_equals(aux2.openerName, aux1.name);
|
||||
assert_equals(aux2.isTop, true);
|
||||
}));
|
||||
a.click();
|
||||
}, 'An auxiliary browsing context should be able to open another auxiliary browsing context');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,25 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Auxiliary Browing Contexts: window.opener noopener</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var prefixedLocalStorage;
|
||||
setup(() => prefixedLocalStorage = new PrefixedLocalStorageTest());
|
||||
async_test(t => {
|
||||
t.add_cleanup(() => prefixedLocalStorage.cleanup());
|
||||
prefixedLocalStorage.onSet('openerIsNull', t.step_func_done(e => {
|
||||
assert_equals(e.newValue, 'true');
|
||||
}));
|
||||
window.open(prefixedLocalStorage.url('resources/no-opener.html'),
|
||||
'iShouldNotHaveAnOpener',
|
||||
'noopener');
|
||||
}, 'Auxiliary browsing context created via `window.open` setting `noopener` should report `window.opener` `null`');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,29 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Auxiliary Browing Contexts: window.opener noreferrer</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var prefixedLocalStorage;
|
||||
setup(() => prefixedLocalStorage = new PrefixedLocalStorageTest());
|
||||
async_test(t => {
|
||||
t.add_cleanup(() => prefixedLocalStorage.cleanup());
|
||||
var a = document.createElement('a');
|
||||
a.href = prefixedLocalStorage.url('resources/no-opener.html');
|
||||
a.target = '_blank';
|
||||
a.rel = 'noreferrer';
|
||||
window.name = 'topWindow';
|
||||
document.body.appendChild(a);
|
||||
prefixedLocalStorage.onSet('openerIsNull', t.step_func_done(e => {
|
||||
assert_equals(e.newValue, 'true');
|
||||
}));
|
||||
a.click();
|
||||
}, 'Auxiliary browsing context created with `rel="noreferrer"` should report `window.opener` `null`');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,55 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Auxiliary Browing Contexts: window.opener</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var prefixedLocalStorage;
|
||||
setup (() => {
|
||||
window.name = 'topWindow';
|
||||
prefixedLocalStorage = new PrefixedLocalStorageTest();
|
||||
});
|
||||
|
||||
function cleanup () {
|
||||
prefixedLocalStorage.setItem('closeAll', 'true');
|
||||
prefixedLocalStorage.clear();
|
||||
}
|
||||
|
||||
function testOpener (t, target) {
|
||||
t.add_cleanup(cleanup);
|
||||
window.addEventListener('message', t.step_func(e => {
|
||||
if (e.data.name === target) {
|
||||
// The opener IDL attribute...must return the WindowProxy object of the
|
||||
// browsing context from which the current browsing context was created
|
||||
assert_equals(e.data.openerName, 'topWindow');
|
||||
// Auxiliary browsing contexts are always top-level browsing contexts
|
||||
assert_equals(e.data.isTop, true);
|
||||
t.done();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
async_test(t => {
|
||||
var target = 'windowOpenerA';
|
||||
var a = document.createElement('a');
|
||||
a.href = prefixedLocalStorage.url('resources/message-window-opener.html');
|
||||
a.target = target;
|
||||
document.body.appendChild(a);
|
||||
testOpener(t, target);
|
||||
a.click();
|
||||
}, 'Newly-created auxiliary browsing context should report `window.opener`');
|
||||
|
||||
async_test(t => {
|
||||
var target = 'windowOpenerB';
|
||||
testOpener(t, target);
|
||||
window.open(prefixedLocalStorage.url('resources/message-window-opener.html'),
|
||||
target);
|
||||
}, 'Browsing context created with `window.open` should report `window.opener`');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,30 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<html>
|
||||
<body onload="closeOpener()">
|
||||
<p>This window should close its opener.</p>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<script>
|
||||
var prefixedLocalStorage = new PrefixedLocalStorageResource({
|
||||
close_on_cleanup: true
|
||||
});
|
||||
var prefixedLocalStorage = new PrefixedLocalStorageResource({
|
||||
close_on_cleanup: true
|
||||
});
|
||||
function closeOpener () {
|
||||
if (window.opener) {
|
||||
window.opener.close();
|
||||
|
||||
// Give the browsing context a chance to dispose of itself
|
||||
function waitForContextDiscard () {
|
||||
if (window.opener === null) {
|
||||
return prefixedLocalStorage.setItem('openerIsNull', 'true');
|
||||
}
|
||||
return setTimeout(waitForContextDiscard, 0);
|
||||
}
|
||||
waitForContextDiscard();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,14 @@
|
|||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<script>
|
||||
var prefixedLocalStorage = new PrefixedLocalStorageResource({
|
||||
close_on_cleanup: true
|
||||
});
|
||||
|
||||
if (window.opener) {
|
||||
window.opener.postMessage ({
|
||||
name : window.name,
|
||||
openerName: window.opener.name,
|
||||
isTop : window.top === window
|
||||
}, '*');
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,32 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<body onload="openNested()">
|
||||
<script>
|
||||
var prefixedLocalStorage = new PrefixedLocalStorageResource({
|
||||
close_on_cleanup: true
|
||||
});
|
||||
function openNested () {
|
||||
// Listen for message from opened context and pass through to this
|
||||
// context's opener
|
||||
window.addEventListener('message', (e) => {
|
||||
if (window.opener) {
|
||||
window.opener.postMessage({
|
||||
aux2: e.data, // From multipleOpenee
|
||||
aux1: { // This context
|
||||
name : window.name,
|
||||
openerName : window.opener.name,
|
||||
isTop : window.top === window
|
||||
}
|
||||
}, '*');
|
||||
}
|
||||
});
|
||||
var a = document.createElement('a');
|
||||
a.target = 'multipleOpenee';
|
||||
a.href = prefixedLocalStorage.url('message-window-opener.html');
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,16 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<html>
|
||||
<p>This window should have no opener.</p>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<script>
|
||||
var prefixedLocalStorage = new PrefixedLocalStorageResource({
|
||||
close_on_cleanup: true
|
||||
});
|
||||
function checkOpener () {
|
||||
return prefixedLocalStorage.setItem('openerIsNull', window.opener === null);
|
||||
}
|
||||
</script>
|
||||
<body onload="checkOpener()">
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,17 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<html>
|
||||
<body onload="openAuxiliary()">
|
||||
<a target="_blank">Open auxiliary context that will close this window (its opener)</a>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<script>
|
||||
function openAuxiliary () {
|
||||
var prefixedLocalStorage = new PrefixedLocalStorageResource();
|
||||
var a = document.body.querySelector('a');
|
||||
a.href = prefixedLocalStorage.url('close-opener.html');
|
||||
document.body.append(a);
|
||||
a.click();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,8 +0,0 @@
|
|||
<!doctype html>
|
||||
001-1
|
||||
<script>
|
||||
if (window.opener !== null) {
|
||||
window.opener.postMessage("FAIL", "*");
|
||||
}
|
||||
window.close();
|
||||
</script>
|
|
@ -1,22 +0,0 @@
|
|||
<!doctype html>
|
||||
<title>Link with target=_blank, rel=noreferrer</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<a href="001-1.html" rel="noreferrer" target="_blank">Link</a>
|
||||
<script>
|
||||
var t = async_test();
|
||||
var a;
|
||||
t.step(function() {
|
||||
a = document.getElementsByTagName("a")[0];
|
||||
a.click();
|
||||
//This is a bit hacky; if the test passes there isn't a link back to the parent
|
||||
//window so we have to pass on a timeout. But opening the link could be slow in
|
||||
//some cases, so there is some possibility of false passes
|
||||
setTimeout(t.step_func(function() {
|
||||
t.done();
|
||||
}), 1000);
|
||||
});
|
||||
|
||||
onmessage = t.step_func(function() {assert_unreached("Opened window had a reference to opener")});
|
||||
</script>
|
|
@ -1,8 +0,0 @@
|
|||
<!doctype html>
|
||||
002-1
|
||||
<script>
|
||||
if (window.opener !== null) {
|
||||
window.opener.postMessage("PASS", "*");
|
||||
}
|
||||
window.close();
|
||||
</script>
|
|
@ -1,25 +0,0 @@
|
|||
<!doctype html>
|
||||
<title>Link with target=_blank, no rel</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<a href="002-1.html" target="_blank">Link</a>
|
||||
<script>
|
||||
var a;
|
||||
async_test(function(t) {
|
||||
a = document.getElementsByTagName("a")[0];
|
||||
a.click();
|
||||
|
||||
// This is a bit hacky; if the test fails there isn't a link back to the parent
|
||||
// window so we have to pass on a timeout. But opening the link could be slow in
|
||||
// some cases, so there is some possibility of false fails
|
||||
step_timeout(t.step_func(function() {
|
||||
assert_unreached("Failed to get callback from opened window");
|
||||
}), 5000);
|
||||
|
||||
onmessage = t.step_func(function(e) {
|
||||
assert_equals(e.data, "PASS");
|
||||
t.done()
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -1,25 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: Choose browsing context - the given name is same as an existing browsing context's name</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="existing.html" style="display:none"></iframe>
|
||||
<iframe name="existWin" style="display:none"></iframe>
|
||||
<script>
|
||||
|
||||
var t = async_test("The browsing context must be chosen if the given name is same as its name");
|
||||
|
||||
window.addEventListener("message", function (e) {
|
||||
t.step(function() {
|
||||
assert_equals(e.data.name, "existWin", "The browsing context name should be 'existWin'.");
|
||||
});
|
||||
t.done();
|
||||
}, false);
|
||||
|
||||
frames[0].onload = t.step_func(function(e) {
|
||||
frames[0].do_test();
|
||||
});
|
||||
|
||||
</script>
|
|
@ -1,20 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: Choose browsing context - the given name is '_parent'</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="parent1.html" name="parentWin" style="display:none"></iframe>
|
||||
<script>
|
||||
|
||||
var t = async_test("The parent browsing context must be chosen if the given name is '_parent'");
|
||||
|
||||
window.addEventListener("message", function (e) {
|
||||
t.step(function() {
|
||||
assert_equals(e.data.name, "parentWin", "The browsing context name should be 'parentWin'.");
|
||||
});
|
||||
t.done();
|
||||
}, false);
|
||||
|
||||
</script>
|
|
@ -1,20 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: Choose browsing context - the given name is '_self'</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="self1.html" style="display:none"></iframe>
|
||||
<script>
|
||||
|
||||
var t = async_test("The current browsing context must be chosen if the given name is '_self'");
|
||||
|
||||
window.addEventListener("message", function (e) {
|
||||
t.step(function () {
|
||||
assert_equals(e.data.name, "selfWin1", "The browsing context name should be 'selfWin1'.");
|
||||
});
|
||||
t.done();
|
||||
}, false);
|
||||
|
||||
</script>
|
|
@ -1,20 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: Choose browsing context - the given name is empty string</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="self2.html" style="display:none"></iframe>
|
||||
<script>
|
||||
|
||||
var t = async_test("The current browsing context must be chosen if the given name is empty string");
|
||||
|
||||
window.addEventListener("message", function (e) {
|
||||
t.step(function () {
|
||||
assert_equals(e.data.name, "selfWin2", "The browsing context name should be 'selfWin2'.");
|
||||
});
|
||||
t.done();
|
||||
}, false);
|
||||
|
||||
</script>
|
|
@ -1,26 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: Browsing context - Default name</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="message.html" style="display:none"></iframe>
|
||||
<script>
|
||||
|
||||
test(function () {
|
||||
assert_equals(window.frames[0].name, "", "The browsing context should not have a default name.");
|
||||
}, "A embedded browsing context has no default name");
|
||||
|
||||
test(function () {
|
||||
var win = window.open("about:blank", "_blank");
|
||||
assert_equals(win.name, "", "The browsing context should not have a name.");
|
||||
win.close();
|
||||
}, "A browsing context which is opened by window.open() method with '_blank' parameter has no default name");
|
||||
|
||||
//This test must be run when the current browsing context's name is not set
|
||||
test(function () {
|
||||
assert_equals(window.name, "", "The browsing context should not have a name.");
|
||||
}, "A browsing context has no default name");
|
||||
|
||||
</script>
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: Browsing context - `_blank` name keyword</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(t => {
|
||||
var window1 = window.open('about:blank', '_blank');
|
||||
var window2 = window.open('about:blank', '_blank');
|
||||
var window3 = window.open('about:blank', '_blank');
|
||||
t.add_cleanup(() => {
|
||||
window1.close();
|
||||
window2.close();
|
||||
window3.close();
|
||||
});
|
||||
assert_not_equals(window1, window2);
|
||||
assert_not_equals(window2, window3);
|
||||
assert_not_equals(window1, window3);
|
||||
}, 'window.open into `_blank` should create a new browsing context each time');
|
||||
|
||||
test(t => {
|
||||
var window1 = window.open('about:blank', '_bLAnk');
|
||||
var window2 = window.open('about:blank', '_bLAnk');
|
||||
var window3 = window.open('about:blank', '_bLAnk');
|
||||
t.add_cleanup(() => {
|
||||
window1.close();
|
||||
window2.close();
|
||||
window3.close();
|
||||
});
|
||||
assert_not_equals(window1, window2);
|
||||
assert_not_equals(window2, window3);
|
||||
assert_not_equals(window1, window3);
|
||||
}, '`_blank` should be ASCII case-insensitive');
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
<!doctype html>
|
||||
<title>Link with target=_blank, rel=noreferrer</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<div id="log"></div>
|
||||
<a href="resources/report-has-opener.html" rel="noreferrer" target="_blank">Link</a>
|
||||
<script>
|
||||
var prefixedStorage;
|
||||
setup (() => prefixedStorage = new PrefixedLocalStorageTest());
|
||||
|
||||
async_test(t => {
|
||||
t.add_cleanup(() => prefixedStorage.cleanup());
|
||||
var a = document.getElementsByTagName('a')[0];
|
||||
a.href = prefixedStorage.url(a.href);
|
||||
prefixedStorage.onSet('hasOpener', t.step_func_done(e => {
|
||||
assert_equals(e.newValue, 'false');
|
||||
}));
|
||||
a.click();
|
||||
}, 'Context for opened noreferrer link targeted to "_blank" should not have opener reference');
|
||||
</script>
|
|
@ -0,0 +1,20 @@
|
|||
<!doctype html>
|
||||
<title>Link with target=_blank, no rel</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<div id="log"></div>
|
||||
<a href="resources/report-has-opener.html" target="_blank">Link</a>
|
||||
<script>
|
||||
var prefixedStorage;
|
||||
setup(() => prefixedStorage = new PrefixedLocalStorageTest());
|
||||
async_test(t => {
|
||||
t.add_cleanup(() => prefixedStorage.cleanup());
|
||||
prefixedStorage.onSet('hasOpener', t.step_func_done(e => {
|
||||
assert_equals(e.newValue, 'true');
|
||||
}));
|
||||
var a = document.getElementsByTagName('a')[0];
|
||||
a.href = prefixedStorage.url(a.href);
|
||||
a.click();
|
||||
}, 'Context created by link targeting "_blank" should retain opener reference');
|
||||
</script>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: Choose browsing context - '_parent'</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(t => {
|
||||
window.addEventListener('message', t.step_func_done(e => {
|
||||
assert_equals(e.data.name, 'parentWin');
|
||||
}));
|
||||
}, 'The parent browsing context must be chosen if the given name is `_parent`');
|
||||
</script>
|
||||
<iframe id="embedded" src="resources/choose-_parent-001-iframe-1.html" name="parentWin" style="display:none"></iframe>
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: Choose browsing context - '_parent' (nested contexts)</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(t => {
|
||||
var topWindow;
|
||||
t.add_cleanup(() => topWindow.close());
|
||||
window.addEventListener('message', t.step_func_done(e => {
|
||||
assert_equals(e.data.name, 'iframeParent');
|
||||
assert_false(e.data.isTop, 'window.parent is not top');
|
||||
}));
|
||||
topWindow = window.open('resources/choose-_parent-002-window.html', '_blank');
|
||||
}, 'choosing _parent context: multiple nested contexts');
|
||||
</script>
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: Choose browsing context - '_parent' (via window.open)</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(t => {
|
||||
var topWindow;
|
||||
t.add_cleanup(() => topWindow.close());
|
||||
window.addEventListener('message', t.step_func_done(e => {
|
||||
assert_equals(e.data.name, 'parentTopReplace');
|
||||
assert_equals(e.data.isTop, true);
|
||||
}));
|
||||
topWindow = window.open('resources/choose-_parent-003-window.html', 'parentTopReplace');
|
||||
}, '_parent should reuse window.parent context');
|
||||
</script>
|
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: Choose browsing context - '_parent' (case-sensitivity)</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
|
||||
<script>
|
||||
var prefixedStorage;
|
||||
var iframe;
|
||||
setup(() => prefixedStorage = new PrefixedLocalStorageTest());
|
||||
|
||||
async_test(t => {
|
||||
t.add_cleanup(() => prefixedStorage.cleanup());
|
||||
var testFunc = (function (t) {
|
||||
var completed = 0;
|
||||
var testCount = 2;
|
||||
return function (actual, expected) {
|
||||
assert_equals(actual, expected);
|
||||
if (++completed >= testCount) {
|
||||
t.done();
|
||||
}
|
||||
}
|
||||
}(t));
|
||||
|
||||
prefixedStorage.onSet('isTop', t.step_func(e => {
|
||||
testFunc(e.newValue, 'false');
|
||||
}));
|
||||
prefixedStorage.onSet('name', t.step_func(e => {
|
||||
testFunc(e.newValue, 'parentWin');
|
||||
}));
|
||||
iframe = document.createElement('iframe');
|
||||
iframe.src = prefixedStorage.url('resources/choose-_parent-004-iframe-1.html');
|
||||
iframe.name = 'parentWin';
|
||||
document.body.appendChild(iframe);
|
||||
}, 'choosing _parent context should be case-insensitive');
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: Choose browsing context - the given name is '_self'</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="resources/choose-_self-001-iframe.html" style="display:none"></iframe>
|
||||
<script>
|
||||
async_test(t => {
|
||||
window.addEventListener('message', t.step_func_done(e => {
|
||||
assert_equals(e.data.name, 'myownself');
|
||||
}), false);
|
||||
}, 'The current browsing context must be chosen if the given name is "_self"');
|
||||
</script>
|
|
@ -0,0 +1,46 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: Choose browsing context - '_self' (case-sensitivity)</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
|
||||
<script>
|
||||
var prefixedStorage;
|
||||
setup(() => prefixedStorage = new PrefixedLocalStorageTest());
|
||||
|
||||
async_test(t => {
|
||||
var iframe;
|
||||
|
||||
var testFunc = (function (t) {
|
||||
var completed = 0;
|
||||
var testCount = 2;
|
||||
return function (actual, expected) {
|
||||
assert_equals(actual, expected);
|
||||
if (++completed >= testCount) {
|
||||
t.done();
|
||||
}
|
||||
}
|
||||
}(t));
|
||||
|
||||
t.add_cleanup(() => prefixedStorage.cleanup());
|
||||
|
||||
prefixedStorage.onSet('isTop', t.step_func(e => {
|
||||
testFunc(e.newValue, 'false');
|
||||
}));
|
||||
prefixedStorage.onSet('name', t.step_func(e => {
|
||||
testFunc(e.newValue, 'testWin');
|
||||
}));
|
||||
|
||||
iframe = document.createElement('iframe');
|
||||
iframe.name = 'testWin';
|
||||
iframe.src = prefixedStorage.url('resources/choose-_self-002-iframe.html');
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
}, 'choosing _self context should be case-insensitive');
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
|
@ -0,0 +1,34 @@
|
|||
<!doctype html>
|
||||
<title>HTML Test: Browsing context name - _top (current is top)</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var prefixedStorage;
|
||||
setup (() => prefixedStorage = new PrefixedLocalStorageTest());
|
||||
|
||||
async_test(t => {
|
||||
t.add_cleanup(() => prefixedStorage.cleanup());
|
||||
|
||||
var testFunc = (function (t) {
|
||||
var completed = 0;
|
||||
var testCount = 2;
|
||||
return function (actual, expected) {
|
||||
assert_equals(actual, expected);
|
||||
if (++completed >= testCount) {
|
||||
t.done();
|
||||
}
|
||||
}
|
||||
}(t));
|
||||
|
||||
prefixedStorage.onSet('isTop', t.step_func(e => {
|
||||
testFunc(e.newValue, 'true');
|
||||
}));
|
||||
prefixedStorage.onSet('name', t.step_func(e => {
|
||||
testFunc(e.newValue, 'topWin1');
|
||||
}));
|
||||
|
||||
window.open(prefixedStorage.url('resources/open-in-_top.html'), '_blank');
|
||||
}, 'Should choose current browsing context for "_top" if current is top');
|
||||
</script>
|
|
@ -0,0 +1,33 @@
|
|||
<!doctype html>
|
||||
<title>HTML Test: Browsing context name - _top</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var prefixedStorage;
|
||||
setup (() => prefixedStorage = new PrefixedLocalStorageTest());
|
||||
|
||||
async_test(t => {
|
||||
t.add_cleanup(() => prefixedStorage.cleanup());
|
||||
|
||||
var testFunc = (function (t) {
|
||||
var completed = 0;
|
||||
var testCount = 2;
|
||||
return function (actual, expected) {
|
||||
assert_equals(actual, expected);
|
||||
if (++completed >= testCount) {
|
||||
t.done();
|
||||
}
|
||||
}
|
||||
}(t));
|
||||
|
||||
prefixedStorage.onSet('isTop', t.step_func(e => {
|
||||
testFunc(e.newValue, 'true');
|
||||
}));
|
||||
prefixedStorage.onSet('name', t.step_func(e => {
|
||||
testFunc(e.newValue, 'topWin2');
|
||||
}));
|
||||
window.open(prefixedStorage.url('resources/choose-_top-002-window.html'), '_blank');
|
||||
}, 'Should choose top browsing context for "_top" if current is not top');
|
||||
</script>
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: Choose browsing context - '_top' (case-sensitivity)</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
|
||||
<script>
|
||||
var prefixedStorage;
|
||||
setup(() => prefixedStorage = new PrefixedLocalStorageTest());
|
||||
|
||||
async_test(t => {
|
||||
var testFunc = (function (t) {
|
||||
var completed = 0;
|
||||
var testCount = 2;
|
||||
return function (actual, expected) {
|
||||
assert_equals(actual, expected);
|
||||
if (++completed >= testCount) {
|
||||
t.done();
|
||||
}
|
||||
}
|
||||
}(t));
|
||||
|
||||
t.add_cleanup(() => prefixedStorage.cleanup());
|
||||
|
||||
prefixedStorage.onSet('isTop', t.step_func(e => {
|
||||
testFunc(e.newValue, 'true');
|
||||
}));
|
||||
prefixedStorage.onSet('name', t.step_func(e => {
|
||||
testFunc(e.newValue, 'topWin');
|
||||
}));
|
||||
|
||||
window.open(prefixedStorage.url('resources/choose-_top-003-iframe-1.html'), '_blank');
|
||||
}, 'choosing _top context should be case-insensitive');
|
||||
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: Browsing context - Default name</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="/common/blank.html" style="display:none"></iframe>
|
||||
<object id="obj" type="text/html" data="about:blank"></object>
|
||||
<embed id="embedded" type="image/svg+xml" src="/images/green.svg" width="0" height="0" />
|
||||
<script>
|
||||
test(t => {
|
||||
assert_equals(window.frames[0].name, "");
|
||||
assert_equals(document.getElementById("embedded").name, "");
|
||||
assert_equals(window["obj"].name, "");
|
||||
}, "A embedded browsing context has empty-string default name");
|
||||
|
||||
test(t => {
|
||||
var win = window.open("about:blank", "_blank");
|
||||
assert_equals(win.name, "");
|
||||
win.close();
|
||||
}, "A browsing context which is opened by window.open() method with '_blank' parameter has empty-string default name");
|
||||
</script>
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: Browsing context names - empty string</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(t => {
|
||||
window.addEventListener('message', t.step_func_done(e => {
|
||||
assert_equals(e.data.isTop, false);
|
||||
assert_equals(e.data.name, 'hellothere', 'Empty-string browsing context should choose current context');
|
||||
}), false);
|
||||
}, 'The current browsing context must be chosen if the given name is empty string');
|
||||
</script>
|
||||
<iframe name="hellothere" src="resources/choose-default-002-iframe.html"></iframe>
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: Choose browsing context - the given name is same as an existing browsing context's name</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="resources/choose-existing-001-iframe.html" style="display:none"></iframe>
|
||||
<iframe name="iExist" style="display:none"></iframe>
|
||||
<script>
|
||||
async_test(t => {
|
||||
window.addEventListener('message', t.step_func_done(e => {
|
||||
assert_equals(e.data.name, 'iExist');
|
||||
}), false);
|
||||
|
||||
}, 'An existing browsing context must be chosen if the given name is the same as its name');
|
||||
</script>
|
|
@ -2,4 +2,4 @@
|
|||
<meta charset="utf-8">
|
||||
<title>HTML Test: browsing context name - parent</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<iframe src="parent2.html"></iframe>
|
||||
<iframe src="open-in-_parent.html"></iframe>
|
|
@ -0,0 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: browsing context name - parent: nested context</title>
|
||||
<iframe name="iframeChild" src="open-in-_parent.html"></iframe>
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: browsing context name - parent: top-level context</title>
|
||||
<iframe name="iframeParent" src="choose-_parent-002-iframe.html"></iframe>
|
||||
<script>
|
||||
// Relay a message from child context to opener context
|
||||
window.addEventListener('message', e => {
|
||||
if (window.opener) {
|
||||
window.opener.postMessage(e.data, '*');
|
||||
}
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: browsing context name - parent</title>
|
||||
<script>
|
||||
window.open("post-to-opener.html", "_parent");
|
||||
</script>
|
|
@ -0,0 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: browsing context name - parent: top-level context (gets replaced)</title>
|
||||
<iframe name="iframeOpener" src="choose-_parent-003-iframe.html"></iframe>
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: browsing context name - parent</title>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<body>
|
||||
<script>
|
||||
var prefixedStorage = new PrefixedLocalStorageResource({
|
||||
close_on_cleanup: true
|
||||
});
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.src = prefixedStorage.url('choose-_parent-004-iframe-2.html');
|
||||
document.body.appendChild(iframe);
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: browsing context name - parent (case-insensitive)</title>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<script>
|
||||
var prefixedStorage = new PrefixedLocalStorageResource();
|
||||
window.open(prefixedStorage.url('report-is-top.html'), '_pARent');
|
||||
|
||||
</script>
|
|
@ -3,9 +3,7 @@
|
|||
<title>HTML Test: browsing context name - self</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script>
|
||||
|
||||
window.name = "selfWin2";
|
||||
var win = window.open("message.html", "");
|
||||
window.name = 'myownself';
|
||||
var win = window.open('post-to-top.html', '_self');
|
||||
win.close();
|
||||
|
||||
</script>
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: browsing context name - self (case-insensitive)</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<script>
|
||||
var prefixedStorage = new PrefixedLocalStorageResource({
|
||||
close_on_cleanup: true
|
||||
});
|
||||
var win = window.open(prefixedStorage.url('report-is-top.html'), '_sElF');
|
||||
</script>
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<title>HTML Test: browsing context name - _top</title>
|
||||
<body>
|
||||
<script>
|
||||
var prefixedStorage = new PrefixedLocalStorageResource({
|
||||
close_on_cleanup:true
|
||||
});
|
||||
window.name = 'topWin2';
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.src = prefixedStorage.url('open-in-_top.html');
|
||||
// Append iframe that will open another document into `_top` (this context)
|
||||
document.body.appendChild(iframe);
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: browsing context name - top (case-insensitive)</title>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<body>
|
||||
</body>
|
||||
<script>
|
||||
var prefixedStorage = new PrefixedLocalStorageResource({
|
||||
close_on_cleanup: true
|
||||
});
|
||||
window.name = 'topWin';
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.src = prefixedStorage.url('choose-_top-003-iframe-2.html');
|
||||
document.body.appendChild(iframe);
|
||||
</script>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: browsing context name - top (case-insensitive)</title>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<script>
|
||||
var prefixedStorage = new PrefixedLocalStorageResource({
|
||||
close_on_cleanup: true
|
||||
});
|
||||
window.open(prefixedStorage.url("report-is-top.html"), "_ToP");
|
||||
</script>
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: browsing context name - Empty string</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<body onload="followLink()">
|
||||
</body>
|
||||
<script>
|
||||
function followLink() {
|
||||
var a = document.createElement('a');
|
||||
a.href = 'post-to-top.html';
|
||||
a.target = ''; // Target is empty string
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
}
|
||||
</script>
|
||||
</html>
|
|
@ -3,9 +3,5 @@
|
|||
<title>This is a test page</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script>
|
||||
|
||||
function do_test() {
|
||||
window.open("message.html", "existWin");
|
||||
}
|
||||
|
||||
window.open("post-to-top.html", "iExist");
|
||||
</script>
|
|
@ -4,6 +4,6 @@
|
|||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script>
|
||||
|
||||
window.open("message.html", "_parent");
|
||||
window.open("post-to-top.html", "_parent");
|
||||
|
||||
</script>
|
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<title>HTML Test: browsing context name - _top</title>
|
||||
<script>
|
||||
var prefixedStorage = new PrefixedLocalStorageResource();
|
||||
window.name = 'topWin1';
|
||||
window.open(prefixedStorage.url('report-is-top.html'), '_top');
|
||||
</script>
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: post window's name to top browsing context</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script>
|
||||
if (window.opener) {
|
||||
window.opener.postMessage({
|
||||
name: window.name,
|
||||
isTop: (window.top === window)
|
||||
}, "*");
|
||||
}
|
||||
</script>
|
|
@ -3,7 +3,8 @@
|
|||
<title>HTML Test: post window's name to top browsing context</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script>
|
||||
|
||||
top.postMessage({name: window.name}, "*");
|
||||
|
||||
top.postMessage({
|
||||
name: window.name,
|
||||
isTop: (window.top === window)
|
||||
}, "*");
|
||||
</script>
|
|
@ -0,0 +1,8 @@
|
|||
<!doctype html>
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<script>
|
||||
var prefixedStorage = new PrefixedLocalStorageResource({
|
||||
close_on_cleanup: true
|
||||
});
|
||||
prefixedStorage.setItem('hasOpener', window.opener !== null);
|
||||
</script>
|
|
@ -0,0 +1,10 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<script src="/common/PrefixedLocalStorage.js"></script>
|
||||
<script>
|
||||
var prefixedStorage = new PrefixedLocalStorageResource({
|
||||
close_on_cleanup: true
|
||||
});
|
||||
prefixedStorage.setItem('isTop', window === window.top);
|
||||
prefixedStorage.setItem('name', window.name);
|
||||
</script>
|
|
@ -1,11 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: browsing context name - self</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script>
|
||||
|
||||
window.name = "selfWin1";
|
||||
var win = window.open("message.html", "_self");
|
||||
win.close();
|
||||
|
||||
</script>
|
|
@ -0,0 +1,37 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Test: Newly-Created browsing context Window and `this`</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/" />
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
|
||||
/**
|
||||
* Test for creating a new browsing context, [Browsing Contexts](#windows).
|
||||
* This test is separate from the rest of the browsing-content-creation tests
|
||||
* because the `iframe` has a src and thus its document won't be `about:blank`.
|
||||
*/
|
||||
var doc, iframe;
|
||||
|
||||
setup(function () {
|
||||
iframe = document.createElement("iframe");
|
||||
iframe.src = get_host_info().HTTP_REMOTE_ORIGIN + "/html/browsers/windows/resources/browsing-context-window.html";
|
||||
document.body.appendChild(iframe);
|
||||
doc = iframe.contentDocument;
|
||||
});
|
||||
|
||||
async_test(function (t) {
|
||||
window.onmessage = t.step_func(function (e) {
|
||||
assert_equals(e.data.thisWindowEquivalency, true, "The global `this` for the created browsing context should be a reference to Window through WindowProxy");
|
||||
t.done();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Test: Browsing context is first created</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/" />
|
||||
|
@ -9,34 +9,25 @@
|
|||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
<![CDATA[
|
||||
|
||||
var doc, iframe;
|
||||
|
||||
setup(function () {
|
||||
// Create new browsing context via iframe
|
||||
iframe = document.createElement("iframe");
|
||||
document.body.appendChild(iframe);
|
||||
doc = iframe.contentDocument;
|
||||
});
|
||||
|
||||
test(function () {
|
||||
assert_equals(iframe.contentWindow.history.length, 1, "The history.length should be 1.");
|
||||
}, "Check the history.length of the first created browsing context");
|
||||
|
||||
test(function () {
|
||||
assert_equals(doc.compatMode, "BackCompat", "The compatMode of a document without a document type declaration should be 'BackCompat'."); // Quirksmode
|
||||
assert_equals(doc.contentType, "text/html", "The document should be an HTML document.");
|
||||
assert_equals(doc.readyState, "complete", "The readyState attribute should be 'complete'.");
|
||||
// Document metadata...
|
||||
assert_equals(doc.documentURI, "about:blank", "The document's address should be 'about:blank'.");
|
||||
assert_equals(doc.URL, "about:blank", "The document's address should be 'about:blank'.");
|
||||
assert_equals(doc.contentType, "text/html", "The document should be an HTML document.");
|
||||
assert_equals(doc.doctype, null, "The docType of a document without a document type declaration should be null.");
|
||||
assert_equals(doc.compatMode, "BackCompat", "The compatMode of a document without a document type declaration should be 'BackCompat'.");
|
||||
assert_equals(doc.characterSet, "UTF-8", "The document's encoding should be 'UTF-8'.");
|
||||
assert_equals(iframe.contentWindow.parent.document, document);
|
||||
assert_equals(doc.referrer, document.URL, "The document's referrer should be its creator document's address.");
|
||||
}, "Check the document's meta data");
|
||||
|
||||
test(function () {
|
||||
assert_equals(doc.readyState, "complete", "The readyState attribute should be 'complete'.");
|
||||
}, "Check the document's status");
|
||||
}, "Check that browsing context has new, ready HTML document");
|
||||
|
||||
test(function () {
|
||||
assert_equals(doc.childNodes.length, 1, "The document must have only one child.");
|
||||
|
@ -46,9 +37,18 @@
|
|||
assert_false(doc.documentElement.childNodes[0].hasChildNodes(), "The HEAD element should not have children.");
|
||||
assert_equals(doc.documentElement.childNodes[1].tagName, "BODY", "The second child of HTML element should be a BODY element.");
|
||||
assert_false(doc.documentElement.childNodes[1].hasChildNodes(), "The BODY element should not have children.");
|
||||
}, "Check the document's content");
|
||||
}, "Check that new document nodes extant, empty");
|
||||
|
||||
test(function () {
|
||||
assert_equals(doc.origin, document.origin, "The document's origin should be its creator document's origin");
|
||||
assert_equals(doc.referrer, document.URL, "The document's referrer should be its creator document's address.");
|
||||
assert_equals(iframe.contentWindow.parent.document, document);
|
||||
}, "Check the document properties corresponding to the creator browsing context");
|
||||
|
||||
test(function () {
|
||||
assert_equals(iframe.contentWindow.history.length, 1, "The history.length should be 1.");
|
||||
}, "Check the history.length of the created browsing context");
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -21,7 +21,7 @@ function on_load() {
|
|||
"The frameElement attribute should be the embed element.");
|
||||
assert_equals(document.getElementById("fr4").contentWindow[0].frameElement,
|
||||
document.getElementById("fr4").contentDocument.getElementById("f1"),
|
||||
"The frameElement attribute should be the frame element in 'test.html'.");
|
||||
"The frameElement attribute should be the frame element in 'resources/frameElement-nested-frame.html'.");
|
||||
});
|
||||
t1.done();
|
||||
|
||||
|
@ -50,19 +50,19 @@ function on_load() {
|
|||
<body onload="on_load()">
|
||||
<div id="log"></div>
|
||||
<iframe id="fr1"></iframe>
|
||||
<iframe id="fr2" src="test.html"></iframe> <!-- cross origin -->
|
||||
<iframe id="fr2" src="resources/frameElement-nested-frame.html"></iframe> <!-- cross origin -->
|
||||
<iframe id="fr3" src="" style="display:none"></iframe>
|
||||
<object id="obj" name="win2" type="text/html" data="about:blank"></object>
|
||||
<embed id="emb" name="win3" type="image/svg+xml" src="/images/green.svg" />
|
||||
<iframe id="fr4" src="test.html"></iframe> <!-- same origin -->
|
||||
<iframe id="fr5" src="testcase3.html"></iframe> <!-- cross origin -->
|
||||
<iframe id="fr4" src="resources/frameElement-nested-frame.html"></iframe> <!-- same origin -->
|
||||
<iframe id="fr5" src="resources/frameElement-window-post.html"></iframe> <!-- cross origin -->
|
||||
<script>
|
||||
|
||||
setup(function () {
|
||||
var src_base = get_host_info().HTTP_REMOTE_ORIGIN;
|
||||
src_base += document.location.pathname.substring(0, document.location.pathname.lastIndexOf("/") + 1);
|
||||
document.getElementById("fr2").src = src_base + "test.html";
|
||||
document.getElementById("fr5").src = src_base + "testcase3.html";
|
||||
document.getElementById("fr2").src = src_base + "/resources/frameElement-nested-frame.html";
|
||||
document.getElementById("fr5").src = src_base + "/resources/frameElement-window-post.html";
|
||||
});
|
||||
|
||||
test(function () {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue