Skip to content

Commit

Permalink
Add whole load of tests for "Loading Web Pages".
Browse files Browse the repository at this point in the history
There isn't quite a guarantee these all match the spec, as the
spec is places was clearly incompatible with the web when they
were written, and as such test what James Graham recommended
be done instead, both on the mailing list and in bugs.
  • Loading branch information
gsnedders authored and jgraham committed Oct 5, 2015
1 parent 50945de commit dfe897f
Show file tree
Hide file tree
Showing 241 changed files with 3,944 additions and 0 deletions.
11 changes: 11 additions & 0 deletions html/browsers/browsing-the-web/history-traversal/001-1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
001-1
<script>
addEventListener("pageshow",
function(e) {
parent.events.push(e);
if (parent.events.length == 2) {
parent.do_test();
}
}, false);
</script>
5 changes: 5 additions & 0 deletions html/browsers/browsing-the-web/history-traversal/001-2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!doctype html>
001-2
<script>
onload = function() {setTimeout(function() {history.go(-1)}, 500)}
</script>
30 changes: 30 additions & 0 deletions html/browsers/browsing-the-web/history-traversal/001.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!doctype html>
<title>pageshow event from traversal</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<iframe src="001-1.html"></iframe>
<script>
var t = async_test();
var events = [];
var iframe = document.getElementsByTagName("iframe")[0];

onload = t.step_func(function() {
setTimeout(t.step_func(
function() {
assert_equals(iframe.contentDocument.readyState, "complete")
iframe.src = "001-2.html";
}), 500);
onload = null;
})

do_test = t.step_func(function() {
assert_equals(events.length, 2);
events.forEach(function(e, i) {
phase = i ? "after" : "before";
assert_equals(e.type, "pageshow", "type " + phase + " navigation");
assert_equals(e.persisted, i == 0 ? false : true, "persisted " + phase + " navigation");
t.done();
});
});
</script>
16 changes: 16 additions & 0 deletions html/browsers/browsing-the-web/history-traversal/MANIFEST
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
support 001-1.html
support 001-2.html
001.html
support browsing_context_name-1.html
support browsing_context_name-2.html
support browsing_context_name-3.html
support browsing_context_name-4.html
browsing_context_name_cross_origin_2.html
browsing_context_name_cross_origin_3.html
browsing_context_name_cross_origin.html
browsing_context_name.html
events.html
hashchange_event.html
popstate_event.html
support unset_context_name-1.html
unset_context_name.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
document 1
<script>
if (!parent.navigated) {
window.name = "test";
}
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
document 2
<script>
window.name = "test1";
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
document 3
<script>
if (!parent.navigated) {
window.name = "test3";
}
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
document 4
<script>
if (!parent.navigated) {
window.name = "test4";
}
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!doctype html>
<title>Retaining window.name on 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() {
var navigated = true;
assert_equals(f.contentWindow.name, "test", "Initial load");
setTimeout(next, 0);
},
function() {f.src = "browsing_context_name-2.html"; setTimeout(next, 500)},
function() {
assert_equals(f.contentWindow.name, "test1");
setTimeout(next, 0);
},
function() {history.back(); setTimeout(next, 500)},
function() {
assert_equals(f.contentWindow.name, "test1", "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 = setTimeout(next, 0);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!doctype html>
<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() {
var 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 = setTimeout(next, 0);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!doctype html>
<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() {
var navigated = true;
assert_equals(f.contentWindow.name, "test", "Initial load");
setTimeout(next, 0);
},
function() {f.src = "browsing_context_name-3.html"},
function() {
var navigated = true;
assert_equals(f.contentWindow.name, "test3", "Initial load");
setTimeout(next, 0);
},
function() {f.src = f.src.replace("http://", "http://www.").replace("browsing_context_name-3", "browsing_context_name-2");},
function() {
setTimeout(next, 0);
},
function() {history.go(-2); setTimeout(next, 500)},
function() {
assert_equals(f.contentWindow.name, "test3", "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 = setTimeout(next, 0);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!doctype html>
<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() {
var navigated = true;
assert_equals(f.contentWindow.name, "test", "Initial load");
setTimeout(next, 0);
},
function() {f.src = "browsing_context_name-3.html"},
function() {
var navigated = true;
assert_equals(f.contentWindow.name, "test3", "Initial load");
setTimeout(next, 0);
},
function() {f.src = f.src.replace("http://", "http://www.").replace("browsing_context_name-1", "browsing_context_name-2");},
function() {f.src = f.src.replace("http://www.", "http://").replace("browsing_context_name-2", "browsing_context_name-4");},
function() {
assert_equals(f.contentWindow.name, "test3", "After navigation");
history.go(-3); setTimeout(next, 500)
},
function() {
assert_equals(f.contentWindow.name, "test3", "After navigation");
t.done();
}
].map(function(x) {return t.step_func(function() {log("Step " + step + " " + f.contentWindow.location); x()})});

var step = 0;
next = t.step_func(function() {steps[step++]()});

f.onload=next;

onload = setTimeout(next, 0);
</script>
Loading

0 comments on commit dfe897f

Please sign in to comment.