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