1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
<!doctype html>
<meta charset=utf-8>
<meta name=timeout content=long>
<title>Parsing of meta refresh</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<style>
iframe { display:none }
</style>
<body>
<script>
// failure to parse is []
// success to parse is [time, url] where url is unresolved
var tests_arr = [
{input: '', expected: []},
{input: '1', expected: [1, '__filename__']},
{input: '1 ', expected: [1, '__filename__']},
{input: '1\t', expected: [1, '__filename__']},
{input: '1\r', expected: [1, '__filename__']},
{input: '1\n', expected: [1, '__filename__']},
{input: '1\f', expected: [1, '__filename__']},
{input: '1;', expected: [1, '__filename__']},
{input: '1,', expected: [1, '__filename__']},
{input: '1; url=foo', expected: [1, 'foo']},
{input: '1, url=foo', expected: [1, 'foo']},
{input: '1 url=foo', expected: [1, 'foo']},
{input: '1;\turl=foo', expected: [1, 'foo']},
{input: '1,\turl=foo', expected: [1, 'foo']},
{input: '1\turl=foo', expected: [1, 'foo']},
{input: '1;\rurl=foo', expected: [1, 'foo']},
{input: '1,\rurl=foo', expected: [1, 'foo']},
{input: '1\rurl=foo', expected: [1, 'foo']},
{input: '1;\nurl=foo', expected: [1, 'foo']},
{input: '1,\nurl=foo', expected: [1, 'foo']},
{input: '1\nurl=foo', expected: [1, 'foo']},
{input: '1;\furl=foo', expected: [1, 'foo']},
{input: '1,\furl=foo', expected: [1, 'foo']},
{input: '1\furl=foo', expected: [1, 'foo']},
{input: '1url=foo', expected: []},
{input: '1x;url=foo', expected: []},
{input: '1 x;url=foo', expected: [1, 'x;url=foo']},
{input: '1;;url=foo', expected: [1, ';url=foo']},
{input: ' 1 ; url = foo', expected: [1, 'foo']},
{input: ' 1 , url = foo', expected: [1, 'foo']},
{input: ' 1 ; foo', expected: [1, 'foo']},
{input: ' 1 , foo', expected: [1, 'foo']},
{input: ' 1 url = foo', expected: [1, 'foo']},
{input: '1; url=foo ', expected: [1, 'foo']},
{input: '1; url=f\to\no', expected: [1, 'foo']},
{input: '1; url="foo"bar', expected: [1, 'foo']},
{input: '1; url=\'foo\'bar', expected: [1, 'foo']},
{input: '1; url="foo\'bar', expected: [1, 'foo\'bar']},
{input: '1; url foo', expected: [1, 'url foo']},
{input: '1; urlfoo', expected: [1, 'urlfoo']},
{input: '1; urfoo', expected: [1, 'urfoo']},
{input: '1; ufoo', expected: [1, 'ufoo']},
{input: '1; "foo"bar', expected: [1, 'foo']},
{input: '; foo', expected: []},
{input: ';foo', expected: []},
{input: ', foo', expected: []},
{input: ',foo', expected: []},
{input: 'foo', expected: []},
{input: '+1; url=foo', expected: []},
{input: '-1; url=foo', expected: []},
{input: '+0; url=foo', expected: []},
{input: '-0; url=foo', expected: []},
{input: '0; url=foo', expected: [0, 'foo']},
{input: '+1; foo', expected: []},
{input: '-1; foo', expected: []},
{input: '+0; foo', expected: []},
{input: '-0; foo', expected: []},
{input: '0; foo', expected: [0, 'foo']},
{input: '+1', expected: []},
{input: '-1', expected: []},
{input: '+0', expected: []},
{input: '-0', expected: []},
{input: '0', expected: [0, '__filename__']},
{input: '1.9; url=foo', expected: [1, 'foo']},
{input: '1.9..5.; url=foo', expected: [1, 'foo']},
{input: '.9; url=foo', expected: [0, 'foo']},
{input: '0.9; url=foo', expected: [0, 'foo']},
{input: '0...9; url=foo', expected: [0, 'foo']},
{input: '0...; url=foo', expected: [0, 'foo']},
{input: '1e0; url=foo', expected: []},
{input: '1e1; url=foo', expected: []},
{input: '10e-1; url=foo', expected: []},
{input: '-0.1; url=foo', expected: []},
];
tests_arr.forEach(function(test_obj) {
["<meta>", "Refresh header"].forEach(type => {
if(type === "Refresh header" && test_obj.input.match("[\n\r\f]")) { // See https://github.com/w3c/wptserve/issues/111 for why \f as well
return;
}
const filename = type === "<meta>" ? "refresh.sub.html" : "refresh.py";
async_test(function(t) {
var iframe = document.createElement('iframe');
t.add_cleanup(function() {
document.body.removeChild(iframe);
});
iframe.src = "support/" + filename + "?input=" + encodeURIComponent(test_obj.input);
document.body.appendChild(iframe);
var loadCount = 0;
iframe.onload = t.step_func(function() {
loadCount++;
var got = iframe.contentDocument.body.textContent.trim();
if (test_obj.expected.length === 0) {
assert_equals(got, filename);
if (loadCount === 1) {
t.step_timeout(function() {
t.done();
}, 3000); // want to make sure it doesn't redirect when it shouldn't
} else {
assert_unreached('Got > 1 load events');
}
} else {
if (loadCount === 2) {
if(test_obj.expected[1] === "__filename__") {
assert_equals(got, filename);
} else {
assert_equals(got, test_obj.expected[1]);
}
t.done();
}
}
});
}, type + ": " + format_value(test_obj.input));
});
});
</script>
|