Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

  • This WPT test may be referenced by the following Test IDs:
    • /html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html?1-10 - WPT Dashboard Interop Dashboard
    • /html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html?101-110 - WPT Dashboard Interop Dashboard
    • /html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html?11-20 - WPT Dashboard Interop Dashboard
    • /html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html?111-120 - WPT Dashboard Interop Dashboard
    • /html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html?121-130 - WPT Dashboard Interop Dashboard
    • /html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html?131-last - WPT Dashboard Interop Dashboard
    • /html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html?21-30 - WPT Dashboard Interop Dashboard
    • /html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html?31-40 - WPT Dashboard Interop Dashboard
    • /html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html?41-50 - WPT Dashboard Interop Dashboard
    • /html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html?51-60 - WPT Dashboard Interop Dashboard
    • /html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html?61-70 - WPT Dashboard Interop Dashboard
    • /html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html?71-80 - WPT Dashboard Interop Dashboard
    • /html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html?81-90 - WPT Dashboard Interop Dashboard
    • /html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html?91-100 - WPT Dashboard Interop Dashboard
<!doctype html>
<meta charset=utf-8>
<meta name="variant" content="?1-10">
<meta name="variant" content="?11-20">
<meta name="variant" content="?21-30">
<meta name="variant" content="?31-40">
<meta name="variant" content="?41-50">
<meta name="variant" content="?51-60">
<meta name="variant" content="?61-70">
<meta name="variant" content="?71-80">
<meta name="variant" content="?81-90">
<meta name="variant" content="?91-100">
<meta name="variant" content="?101-110">
<meta name="variant" content="?111-120">
<meta name="variant" content="?121-130">
<meta name="variant" content="?131-last">
<title>Parsing of meta refresh</title>
<meta name="timeout" content="long">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/subset-tests.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/web-platform-tests/wpt/issues/8372 for why \f as well
return;
}
const filename = type === "<meta>" ? "refresh.sub.html" : "refresh.py";
subsetTest(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;
var expectedReferrer = location.href;
iframe.onload = t.step_func(function() {
loadCount++;
var content = iframe.contentDocument.body.textContent.trim();
if (test_obj.expected.length === 0) {
assert_equals(content, filename, "page has expected content");
assert_equals(iframe.contentDocument.referrer, expectedReferrer, "referrer is parent frame");
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(content, filename, "page has expected content");
} else {
assert_equals(content, test_obj.expected[1], "page has expected content");
}
assert_equals(iframe.contentDocument.referrer, expectedReferrer, "referrer is previous page");
t.done();
} else if (loadCount === 1) {
expectedReferrer = iframe.src;
}
});
}, type + ": " + format_value(test_obj.input));
});
});
</script>