invalid-headers-in-early-hints.h2.window.js (1031B)
1 async function testInvalidHeader(t, header_value) { 2 const params = new URLSearchParams(); 3 params.set("header-value", header_value); 4 const test_url = "resources/invalid-headers-in-early-hints.h2.py?" + params.toString(); 5 const opened_window = window.open(test_url, "invalid-header-in-early-hints"); 6 7 // Use step_timeout() because neither "load" event nor postMessage() would 8 // work. Opening the test page should result in a network protocol error and 9 // accessing the document of the opened window should throw a SecurityError. 10 await new Promise(resolve => t.step_timeout(resolve, 1000)); 11 assert_throws_dom("SecurityError", () => { 12 opened_window.document; 13 }, "window.open() should not load the test page successfully."); 14 } 15 16 promise_test(async (t) => { 17 await testInvalidHeader(t, "foo\r\nbar"); 18 }, "Early Hints contains invalid header: newline byte"); 19 20 promise_test(async (t) => { 21 await testInvalidHeader(t, "foo\x00bar"); 22 }, "Early Hints contains invalid header: nul byte");