Update web-platform-tests to revision e8bfc205e36ad699601212cd50083870bad9a75d

This commit is contained in:
Ms2ger 2016-11-14 11:07:09 +01:00
parent 65dd6d4340
commit ccdb0a3458
1428 changed files with 118036 additions and 9786 deletions

View file

@ -4,7 +4,7 @@
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<iframe id="test" name="test"></iframe>
<form action="javascript:parent.events.push('submit')"></form>
<form target="test" action="javascript:parent.events.push('submit');"></form>
<a target="test" onclick="document.forms[0].submit()">Test</a>
<script>
var t = async_test(undefined, {timeout:4000});

View file

@ -16,6 +16,9 @@
onload = t.step_func_done(function() {
assert_equals(frames[0].document.documentElement.textContent,
"1", "string return should cause navigation");
// The rest of the test is disabled for now, until
// https://github.com/whatwg/html/issues/1895 gets sorted out
/*
assert_equals(frames[1].document.documentElement.textContent,
"", "number return should not cause navigation");
assert_equals(frames[2].document.documentElement.textContent,
@ -28,5 +31,6 @@
"", "null return should not cause navigation");
assert_equals(frames[6].document.documentElement.textContent,
"", "String object return should not cause navigation");
*/
});
</script>

View file

@ -0,0 +1,23 @@
<!doctype html>
<script src="history.js"></script>
<script>
onunload = function() {}
onload = function() {
if (!opener.started) {
queue_next();
} else {
opener.pages.push(id);
opener.start_test_wait();
if (!opener.gone) {
// This is meant to test that passing a string is not supported.
// According to the spec, the value passed to 'go' must be an int.
// Internet Explorer supports passing a string and will navigate
// to that Url. This test will protect against regressing in
// this area and reverting back to IE's incorrect behavior.
history.go("history_entry.html");
opener.gone = true;
}
}
};
</script>

View file

@ -0,0 +1,32 @@
<!doctype html>
<title>history.go() negative tests</title>
<link rel="author" title="John Jansen" href="mailto:johnjan@microsoft.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsers.html#dom-history-go">
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var t = async_test(undefined, {timeout:5000});
started = false;
gone = false;
pages = []
timer = null;
start_test_wait = t.step_func(
function() {
clearTimeout(timer);
timer = setTimeout(t.step_func(
function() {
try {
assert_array_equals(pages, [3, 2, 2], "Pages opened during history navigation");
t.done();
} finally {
win.close();
}
}
), 500);
}
);
t.step(function() {win = window.open("history_entry.html?urls=history_go_to_uri-1.html,history_forward-2.html");
});
</script>

View file

@ -0,0 +1,18 @@
<!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>

View file

@ -7,6 +7,8 @@
</head>
<body>
<div id="log"></div>
<iframe id="srcdoc-iframe"
srcdoc="<div style='height: 200vh'></div><div id='test'></div>"></iframe>
<script>
test(function () {
window.history.pushState(1, document.title, '#x=1');
@ -15,6 +17,17 @@
assert_equals(hash, "#x=1", "hash");
}, "location hash");
var t = async_test("Setting location.hash on srcdoc iframe");
addEventListener("load", t.step_func_done(function() {
var frameWin = document.getElementById("srcdoc-iframe").contentWindow;
assert_equals(frameWin.location.href, "about:srcdoc");
assert_equals(frameWin.scrollY, 0, "Should not have scrolled yet");
frameWin.location.hash = "test";
assert_equals(frameWin.location.href, "about:srcdoc#test");
assert_true(frameWin.scrollY > frameWin.innerHeight,
"Should have scrolled by more than one viewport height");
}));
</script>
</body>
</html>

View file

@ -55,7 +55,7 @@ function addTest(fun, desc) { testList.push([fun, desc]); }
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(location.port, host_info.HTTP_PORT, 'Need to run the top-level test from port ' + host_info.HTTP_PORT);
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");

View file

@ -10,9 +10,9 @@
var path = location.pathname.substring(0, location.pathname.lastIndexOf('/')) + '/frame.html';
A.location = 'frame.html';
B.location = '//{{domains[www2]}}:' + location.port + path;
C.location = '//{{domains[www2]}}:' + location.port + path;
D.location = '//{{domains[www1]}}:' + location.port + path;
B.location = '//{{domains[www2]}}:' + get_port(location) + path;
C.location = '//{{domains[www2]}}:' + get_port(location) + path;
D.location = '//{{domains[www1]}}:' + get_port(location) + path;
var loadCount = 0;
function frameLoaded() {

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<script>
window.onload = function() {
top.calledFromIframe();
}
</script>
</head>
<body>
<div id="inner">foo</div>
</body>
</html>

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<title>DOM access in sandbox="allow-same-origin" iframe</title>
<link rel="author" title="Kinuko Yasuda" href="mailto:kinuko@chromium.org">
<link rel="help" href="http://www.w3.org/html/wg/drafts/html/master/browsers.html#sandboxing">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>DOM access in sandbox="allow-same-origin" iframe</h1>
<script type="text/javascript">
var t = async_test("DOM access in sandbox='allow-same-origin' iframe is allowed")
var called = 0;
function calledFromIframe() {
called++;
}
function loaded() {
assert_equals(document.getElementById('sandboxedframe').contentWindow.document.getElementById('inner').innerHTML, 'foo');
assert_equals(called, 0);
t.done();
}
</script>
<iframe src="/html/browsers/sandboxing/inner-iframe.html" style="visibility:hidden;display:none" sandbox="allow-same-origin" id="sandboxedframe" onload="loaded();"></iframe>
<div id="log"></div>
</body>
</html>

View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<title>Script execution in sandbox="allow-scripts" iframe</title>
<link rel="author" title="Kinuko Yasuda" href="mailto:kinuko@chromium.org">
<link rel="help" href="http://www.w3.org/html/wg/drafts/html/master/browsers.html#sandboxing">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Script execution in sandbox="allow-scripts" iframe</h1>
<script type="text/javascript">
var t = async_test("Running script from sandbox='allow-scripts' iframe is allowed")
var called = 0;
function calledFromIframe() {
called++;
}
function loaded() {
assert_equals(called, 1);
t.done();
}
</script>
<iframe src="/html/browsers/sandboxing/inner-iframe.html" style="visibility:hidden;display:none" sandbox="allow-scripts allow-same-origin" id="sandboxedframe" onload="loaded();"></iframe>
<div id="log"></div>
</body>
</html>

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<title>Access to sandbox iframe</title>
<link rel="author" title="Kinuko Yasuda" href="mailto:kinuko@chromium.org">
<link rel="help" href="http://www.w3.org/html/wg/drafts/html/master/browsers.html#sandboxing">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Access to sandbox iframe</h1>
<script type="text/javascript">
var t = async_test("Access to sandbox iframe is disallowed")
var called = 0;
function calledFromIframe() {
called++;
}
function loaded() {
assert_equals(document.getElementById('sandboxedframe').contentWindow.document, undefined);
assert_equals(called, 0);
t.done();
}
</script>
<iframe src="/html/browsers/sandboxing/inner-iframe.html" style="visibility:hidden;display:none" sandbox id="sandboxedframe" onload="loaded();"></iframe>
</body>
<div id="log"></div>
</html>

View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<title>Script execution in sandbox iframe</title>
<link rel="author" title="Kinuko Yasuda" href="mailto:kinuko@chromium.org">
<link rel="help" href="http://www.w3.org/html/wg/drafts/html/master/browsers.html#sandboxing">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Script execution in sandbox iframe</h1>
<script type="text/javascript">
var t = async_test("Running script from sandbox iframe is disallowed")
var called = 0;
function calledFromIframe() {
called++;
}
function loaded() {
assert_equals(called, 0);
t.done();
}
</script>
<iframe src="/html/browsers/sandboxing/inner-iframe.html" style="visibility:hidden;display:none" sandbox id="sandboxedframe" onload="loaded();"></iframe>
<div id="log"></div>
</body>
</html>

View file

@ -33,30 +33,28 @@ test(function() {
}, "Check if the first nested browsing context is returned by window['c']");
test(function() {
assert_equals(window['a'].length, 7, "The length should be 7.");
assert_equals(window['a'].length, 5, "The length should be 5.");
assert_true(window['a'] instanceof HTMLCollection);
assert_array_equals(window['a'],
[ document.getElementById('a1'), document.getElementById('app1'),
document.getElementById('area1'), document.getElementById('embed1'),
document.getElementById('form1'), document.getElementById('img1'),
document.getElementById('obj1') ],
"The elements are not in tree order.");
document.getElementById('a1').setAttribute("name", "");
document.getElementById('area1').setAttribute("name", "");
assert_array_equals(window['a'],
[ document.getElementById('app1'), document.getElementById('embed1'),
document.getElementById('form1'), document.getElementById('img1'),
document.getElementById('obj1') ],
"Window['a'] should not contain the elements with empty name attribute.");
}, "Check if window['a'] contains all a, applet, area, embed, form, img, and object elements, and their order");
"The elements are not in tree order.");
var t = async_test("Check if window['fs'] return the frameset element with name='fs'");
document.getElementById('form1').setAttribute("name", "");
document.getElementById('embed1').setAttribute("name", "");
assert_array_equals(window['a'],
[ document.getElementById('app1'), document.getElementById('img1'),
document.getElementById('obj1') ],
"Window['a'] should not contain the elements with empty name attribute.");
}, "Check if window['a'] contains all applet, embed, form, img, and object elements, and their order");
var t = async_test("Check that window['fs'] does not return the frameset element with name='fs' (historical)");
function on_load () {
t.step(function () {
assert_equals(document.getElementById('fm2').contentWindow['fs'],
document.getElementById('fm2').contentDocument.getElementById('fs1'),
"The frameset element should be returned.");
undefined,
"The frameset element should not be returned.");
});
t.done();
}

View file

@ -0,0 +1,8 @@
<!DOCTYPE html>
<script>
var channelName = location.search.substr(1);
var channel = new BroadcastChannel(channelName);
channel.postMessage({ name: window.name,
haveOpener: window.opener !== null });
window.close();
</script>

View file

@ -0,0 +1,105 @@
<!doctype html>
<meta charset=utf-8>
<title>window.open() with "noopener" tests</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
var testData = [
{ testDescription: "window.open() with 'noopener' should not reuse existing target",
secondWindowFeatureString: "noopener",
shouldReuse: false },
{ testDescription: "noopener needs to be present as a token on its own",
secondWindowFeatureString: "noopener=1",
shouldReuse: true },
{ testDescription: "noopener needs to be present as a token on its own again",
secondWindowFeatureString: "noopener=0",
shouldReuse: true },
{ testDescription: "noopener needs to be present as a token on its own yet again",
secondWindowFeatureString: "make me noopener",
shouldReuse: true },
{ testDescription: "Trailing noopener should work",
secondWindowFeatureString: "abc def, \n\r noopener",
shouldReuse: false },
{ testDescription: "Leading noopener should work",
secondWindowFeatureString: "noopener \f\t , hey, there",
shouldReuse: false },
{ testDescription: "Interior noopener should work",
secondWindowFeatureString: "and now, noopener , hey, there",
shouldReuse: false },
];
var tests = [];
/**
* Loop over our testData array and kick off an async test for each entry. Each
* async test opens a window using window.open() with some per-test unique name,
* then tries to do a second window.open() call with the same name and the
* test-specific feature string. It then checks whether that second
* window.open() call reuses the existing window, whether the return value of
* the second window.open() call is correct (it should be null in the noopener
* cases and non-null in the cases when the existing window gets reused) and so
* forth.
*/
for (var i = 0; i < testData.length; ++i) {
var test = testData[i];
var t = async_test(test.testDescription);
tests.push(t);
t.secondWindowFeatureString = test.secondWindowFeatureString;
t.windowName = "someuniquename" + i;
if (test.shouldReuse) {
t.step(function() {
var windowName = this.windowName;
var w1 = window.open("", windowName);
this.add_cleanup(function() { w1.close(); });
assert_equals(w1.opener, window);
var w2 = window.open("", windowName, this.secondWindowFeatureString);
assert_equals(w2, w1);
assert_equals(w2.opener, w1.opener);
assert_equals(w2.opener, window);
this.done();
});
} else {
t.step(function() {
var w1;
this.add_cleanup(function() { w1.close(); });
var windowName = this.windowName;
var channel = new BroadcastChannel(windowName);
channel.onmessage = this.step_func_done(function(e) {
var data = e.data;
assert_equals(data.name, windowName, "Should have the right name");
assert_equals(data.haveOpener, false, "Should not have opener");
assert_equals(w1.opener, window);
assert_equals(w1.location.href, "about:blank");
});
w1 = window.open("", windowName);
assert_equals(w1.opener, window);
var w2 = window.open("support/noopener-target.html?" + windowName,
windowName, this.secondWindowFeatureString);
assert_equals(w2, null);
assert_equals(w1.opener, window);
});
}
}
/**
* Loop over the special targets that ignore noopener and check that doing a
* window.open() with those targets correctly reuses the existing window.
*/
for (var target of ["_self", "_parent", "_top"]) {
var t = async_test("noopener window.open targeting " + target);
tests.push(t);
t.openedWindow = window.open(`javascript:var w2 = window.open("", "${target}", "noopener"); this.checkValues(w2); this.close(); void(0);`);
assert_equals(t.openedWindow.opener, window);
t.openedWindow.checkValues = t.step_func_done(function(win) {
assert_equals(win, this.openedWindow);
});
}
</script>

View file

@ -0,0 +1,3 @@
<meta charset=utf-8>
<p>Follow this link to open a new browsing context in a separate origin.
<a target=second href="{{location[scheme]}}://{{domains[www2]}}:{{location[port]}}/html/browsers/windows/support-open-cross-origin.sub.html">link</a>.

View file

@ -0,0 +1,9 @@
<meta charset=utf-8>
<p>Follow this link to open a new browsing context in a separate origin. Follow the instructions
in that new window, and then come back to this window.
<a target=first href="{{location[scheme]}}://{{domains[天気の良い日]}}:{{location[port]}}/html/browsers/windows/support-open-cross-origin.sub.html">link</a>.
<p>Once you come back to this page, follow this link.
<a target=second href="support-window-name-echo.html">link</a>.
<p>After clicking that link, you should have three additional windows open.