|
15 | 15 |
|
16 | 16 | var tests_arr = [ |
17 | 17 | {input: '', expected: []}, |
18 | | - {input: '1', expected: [1, 'refresh.sub.html']}, |
19 | | - {input: '1 ', expected: [1, 'refresh.sub.html']}, |
20 | | - {input: '1\t', expected: [1, 'refresh.sub.html']}, |
21 | | - {input: '1\r', expected: [1, 'refresh.sub.html']}, |
22 | | - {input: '1\n', expected: [1, 'refresh.sub.html']}, |
23 | | - {input: '1\f', expected: [1, 'refresh.sub.html']}, |
24 | | - {input: '1;', expected: [1, 'refresh.sub.html']}, |
25 | | - {input: '1,', expected: [1, 'refresh.sub.html']}, |
| 18 | + {input: '1', expected: [1, '__filename__']}, |
| 19 | + {input: '1 ', expected: [1, '__filename__']}, |
| 20 | + {input: '1\t', expected: [1, '__filename__']}, |
| 21 | + {input: '1\r', expected: [1, '__filename__']}, |
| 22 | + {input: '1\n', expected: [1, '__filename__']}, |
| 23 | + {input: '1\f', expected: [1, '__filename__']}, |
| 24 | + {input: '1;', expected: [1, '__filename__']}, |
| 25 | + {input: '1,', expected: [1, '__filename__']}, |
26 | 26 | {input: '1; url=foo', expected: [1, 'foo']}, |
27 | 27 | {input: '1, url=foo', expected: [1, 'foo']}, |
28 | 28 | {input: '1 url=foo', expected: [1, 'foo']}, |
|
76 | 76 | {input: '-1', expected: []}, |
77 | 77 | {input: '+0', expected: []}, |
78 | 78 | {input: '-0', expected: []}, |
79 | | - {input: '0', expected: [0, 'refresh.sub.html']}, |
| 79 | + {input: '0', expected: [0, '__filename__']}, |
80 | 80 | {input: '1.9; url=foo', expected: [1, 'foo']}, |
81 | 81 | {input: '1.9..5.; url=foo', expected: [1, 'foo']}, |
82 | 82 | {input: '.9; url=foo', expected: [0, 'foo']}, |
|
90 | 90 | ]; |
91 | 91 |
|
92 | 92 | tests_arr.forEach(function(test_obj) { |
93 | | - async_test(function(t) { |
94 | | - var iframe = document.createElement('iframe'); |
95 | | - t.add_cleanup(function() { |
96 | | - document.body.removeChild(iframe); |
97 | | - }); |
98 | | - iframe.src = 'support/refresh.sub.html?input=' + encodeURIComponent(test_obj.input); |
99 | | - document.body.appendChild(iframe); |
100 | | - var loadCount = 0; |
101 | | - iframe.onload = t.step_func(function() { |
102 | | - loadCount++; |
103 | | - var got = iframe.contentDocument.body.textContent.trim(); |
104 | | - if (test_obj.expected.length === 0) { |
105 | | - assert_equals(got, 'refresh.sub.html'); |
106 | | - if (loadCount === 1) { |
107 | | - setTimeout(function() { |
108 | | - t.done(); |
109 | | - }, 3000); // want to make sure it doesn't redirect when it shouldn't |
| 93 | + ["<meta>", "Refresh header"].forEach(type => { |
| 94 | + if(type === "Refresh header" && test_obj.input.match("[\n\r\f]")) { // See https://github.com/w3c/wptserve/issues/111 for why \f as well |
| 95 | + return; |
| 96 | + } |
| 97 | + const filename = type === "<meta>" ? "refresh.sub.html" : "refresh.py"; |
| 98 | + async_test(function(t) { |
| 99 | + var iframe = document.createElement('iframe'); |
| 100 | + t.add_cleanup(function() { |
| 101 | + document.body.removeChild(iframe); |
| 102 | + }); |
| 103 | + iframe.src = "support/" + filename + "?input=" + encodeURIComponent(test_obj.input); |
| 104 | + document.body.appendChild(iframe); |
| 105 | + var loadCount = 0; |
| 106 | + iframe.onload = t.step_func(function() { |
| 107 | + loadCount++; |
| 108 | + var got = iframe.contentDocument.body.textContent.trim(); |
| 109 | + if (test_obj.expected.length === 0) { |
| 110 | + assert_equals(got, filename); |
| 111 | + if (loadCount === 1) { |
| 112 | + t.step_timeout(function() { |
| 113 | + t.done(); |
| 114 | + }, 3000); // want to make sure it doesn't redirect when it shouldn't |
| 115 | + } else { |
| 116 | + assert_unreached('Got > 1 load events'); |
| 117 | + } |
110 | 118 | } else { |
111 | | - assert_unreached('Got > 1 load events'); |
112 | | - } |
113 | | - } else { |
114 | | - if (loadCount === 2) { |
115 | | - assert_equals(got, test_obj.expected[1]); |
116 | | - t.done(); |
| 119 | + if (loadCount === 2) { |
| 120 | + if(test_obj.expected[1] === "__filename__") { |
| 121 | + assert_equals(got, filename); |
| 122 | + } else { |
| 123 | + assert_equals(got, test_obj.expected[1]); |
| 124 | + } |
| 125 | + t.done(); |
| 126 | + } |
117 | 127 | } |
118 | | - } |
119 | | - }); |
120 | | - }, format_value(test_obj.input)); |
| 128 | + }); |
| 129 | + }, type + ": " + format_value(test_obj.input)); |
| 130 | + }); |
121 | 131 | }); |
122 | 132 | </script> |
0 commit comments