Update web-platform-tests to revision 8a2ceb5f18911302b7a5c1cd2791f4ab50ad4326

This commit is contained in:
Josh Matthews 2017-10-12 09:25:50 -04:00
parent 462c272380
commit 1f531f66ea
5377 changed files with 174916 additions and 84369 deletions

View file

@ -0,0 +1,44 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Navigating forward after replace() should still trigger hashchange</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#history-traversal">
<link rel="author" href="mailto:d@domenic.me" title="Domenic Denicola">
<!-- While writing ./replacement-enabled.html, a bug was discovered in Firefox where it does not
fire hashchange when using history.forward(), at least under certain conditions. So, this test
exercises that specifically. -->
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="navigate-helpers.js"></script>
<body>
<script>
"use strict";
let resolve, iframe;
promise_test(() => {
iframe = document.createElement("iframe");
iframe.src = "/common/blank.html";
iframe.addEventListener("load", runTest);
document.body.appendChild(iframe);
return new Promise(r => resolve = r);
});
function runTest() {
iframe.removeEventListener("load", runTest);
const frameWindow = iframe.contentWindow;
resolve((async () => {
await navigateAndWaitForChange(frameWindow, w => w.location.href = "/common/blank.html#apple");
await navigateAndWaitForChange(frameWindow, w => w.location.href = "/common/blank.html#banana");
await navigateAndWaitForChange(frameWindow, w => w.location.href = "/common/blank.html#cat");
await navigateAndWaitForChange(frameWindow, w => w.history.back());
await navigateAndWaitForChange(frameWindow,
w => w.location.replace("/common/blank.html#zebra"));
await navigateAndWaitForChange(frameWindow, w => w.history.forward());
})());
}
</script>

View file

@ -0,0 +1,23 @@
"use strict";
// Usage examples:
// navigateAndWaitForChange(frameWindow, w => w.location.href = "...");
// navigateAndWaitForChange(frameWindow, w => w.history.back());
// navigateAndWaitForChange(frameWindow, w => w.history.back(), { assumeSuccessAfter: 100 });
window.navigateAndWaitForChange = (w, navigationAction, { assumeSuccessAfter } = {}) => {
return new Promise(resolve => {
w.addEventListener("hashchange", listener);
function listener() {
w.removeEventListener("hashchange", listener);
resolve();
}
if (assumeSuccessAfter !== undefined) {
step_timeout(resolve, assumeSuccessAfter);
}
navigationAction(w);
});
};

View file

@ -0,0 +1,69 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Navigating to a fragment should not clear forward history</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#scroll-to-fragid">
<link rel="help" href="https://github.com/whatwg/html/issues/2796">
<link rel="help" href="https://github.com/whatwg/html/pull/2869">
<link rel="author" href="mailto:d@domenic.me" title="Domenic Denicola">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="navigate-helpers.js"></script>
<body>
<script>
"use strict";
let resolve, iframe;
promise_test(() => {
iframe = document.createElement("iframe");
iframe.src = "/common/blank.html";
iframe.addEventListener("load", runTest);
document.body.appendChild(iframe);
return new Promise(r => resolve = r);
});
function runTest() {
iframe.removeEventListener("load", runTest);
const frameWindow = iframe.contentWindow;
resolve((async () => {
await navigateAndWaitForChange(frameWindow, w => w.location.href = "/common/blank.html#apple");
await navigateAndWaitForChange(frameWindow, w => w.location.href = "/common/blank.html#banana");
await navigateAndWaitForChange(frameWindow, w => w.location.href = "/common/blank.html#cat");
assert_equals(frameWindow.location.hash, "#cat");
// Might not be 4 (= 3 for iframe + 1 initial) due to cross-browser differences or if people are
// running this test in a window that has previously been places. The important thing for this
// test is the delta from this value.
const afterThreeNavigations = frameWindow.history.length;
await navigateAndWaitForChange(frameWindow, w => w.history.back());
assert_equals(frameWindow.location.hash, "#banana");
assert_equals(frameWindow.history.length, afterThreeNavigations,
"back() must not change the history length");
await navigateAndWaitForChange(frameWindow,
w => w.location.replace("/common/blank.html#zebra"));
assert_equals(frameWindow.location.hash, "#zebra");
assert_equals(frameWindow.history.length, afterThreeNavigations,
"replace() must not change the history length");
// As of the time of this writing (2017-08-14), Firefox is not firing hashchange on forward, so
// we automatically assume navigation succeeded after 100 ms. A sibling test will test this
// particular Firefox bug.
await navigateAndWaitForChange(frameWindow, w => w.history.forward(),
{ assumeSuccessAfter: 100 });
assert_equals(frameWindow.location.hash, "#cat");
assert_equals(frameWindow.history.length, afterThreeNavigations,
"forward() must not change the history length");
})());
}
</script>

View file

@ -5,8 +5,9 @@
<script src="/resources/testharnessreport.js"></script>
<body>
<div></div>
<div id="has two spaces" style="position:absolute; top:200px;"></div>
<div id="escape%20collision" style="position:absolute; top:300px;"></div>
<div id="has two spaces" style="position:absolute; top:100px;"></div>
<div id="escape%20collision" style="position:absolute; top:200px;"></div>
<div id="%20has%20two%20spaces" style="position:absolute; top:300px;"></div>
<div id="escape collision" style="position:absolute; top:400px;"></div>
<div id="do%20not%20go%20here" style="position:absolute; top:400px;"></div>
<div style="height:200em;"></div>
@ -14,12 +15,18 @@
var steps = [{
fragid:'has%20two%20spaces',
handler: function(){
assert_equals( scrollPosition(), 200 );
assert_equals( scrollPosition(), 100 );
}
},{
fragid:'escape%20collision',
handler: function(){
assert_equals( scrollPosition(), 400 );
assert_equals( scrollPosition(), 200 );
document.getElementById("%20has%20two%20spaces").setAttribute("id", "has%20two%20spaces");
}
},{
fragid:'has%20two%20spaces',
handler: function(){
assert_equals( scrollPosition(), 300 );
}
},{
fragid:'do%20not%20go%20here',