restore-window-name.sub.html (1266B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>popup helper for restore window.name test</title> 5 <script> 6 7 const search = window.location.search.replace("?", ""); 8 const name = search.split("=")[1]; 9 10 if (!search.startsWith("name=")) { 11 throw new Error("Unsupported test!"); 12 } 13 14 function startTest() { 15 if (window.name === "start") { 16 window.name = name; 17 const url = new URL(window.location); 18 url.host = "{{hosts[alt][]}}:{{ports[https][0]}}"; 19 url.pathname = url.pathname.slice(0, url.pathname.lastIndexOf("/") + 1); 20 url.pathname += "restore-window-name-back.sub.html"; 21 window.location = url.href; 22 } 23 } 24 25 function verifyResult() { 26 const result = document.getElementById("result"); 27 if (window.name === "start") { 28 result.textContent = "Please first click the above 'start test' link."; 29 return; 30 } 31 32 result.textContent = window.name === name ? "PASS" : "FAIL"; 33 } 34 35 </script> 36 </head> 37 <body> 38 <p>Please first click the 'start test' link. And then, click the 'Verify Result' button to verify the result. You should get a PASS after clicking the button</p> 39 <a id="navigate" href="javascript:void(0)" onclick="startTest()">start test</a><br> 40 <button onclick="verifyResult()">Verify Result</button> 41 Result: <a id="result"></a> 42 </body> 43 </html>