subresource.any.js (1960B)
1 promise_test(() => { 2 return fetch("resources/refresh.py").then(response => { 3 assert_equals(response.headers.get("Refresh"), "0;./refreshed.txt?\u0080\u00FF", "bytes got mapped to code points of the same value"); 4 assert_equals(response.url, new URL("resources/refresh.py", location).href, "Fetch API did not navigate to the Refresh URL"); 5 }); 6 }, "Refresh does not affect Fetch API."); 7 8 promise_test(async t => { 9 const { promise: xhrLoaded, resolve: resolveXHRLoaded, reject: rejectXHRLoaded } = Promise.withResolvers(); 10 const xhr = new XMLHttpRequest(); 11 xhr.open("GET", "resources/refresh.py"); 12 xhr.addEventListener("load", t.step_func(() => { 13 assert_equals(xhr.getResponseHeader("Refresh"), "0;./refreshed.txt?\u0080\u00FF", "bytes got mapped to code points of the same value"); 14 assert_equals(xhr.responseURL, new URL("resources/refresh.py", location).href, "XMLHttpRequest did not navigate to the Refresh URL"); 15 resolveXHRLoaded(); 16 })); 17 xhr.addEventListener("error", t.step_func(() => { 18 assert_false(true, "XMLHttpRequest did not navigate to the Refresh URL"); 19 rejectXHRLoaded(); 20 })); 21 xhr.send(); 22 return xhrLoaded; 23 }, "Refresh does not affect XMLHttpRequest."); 24 25 if (self.GLOBAL.isWindow()) { 26 promise_test(async t => { 27 const { promise: imgLoaded, resolve: resolveImgLoaded, reject: rejectImgLoaded } = Promise.withResolvers(); 28 const svgPath = "resources/refresh-with-svg.py"; 29 const img = document.createElement("img"); 30 img.src = svgPath; 31 img.addEventListener("load", () => { 32 assert_equals(img.src, new URL(svgPath, location).href, "Image did not navigate to the Refresh URL"); 33 resolveImgLoaded(); 34 }); 35 img.addEventListener("error", t.step_func(() => { 36 assert_false(true, "Image did not navigate to the Refresh URL"); 37 rejectImgLoaded(); 38 })); 39 document.documentElement.appendChild(img); 40 return imgLoaded; 41 }, "Refresh does not affect Image."); 42 }