named-lookup-noopener.html (2076B)
1 <!DOCTYPE html> 2 <title>Named lookup does not work with noopener</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/common/utils.js"></script> 6 <script src="/common/dispatcher/dispatcher.js"></script> 7 <script src="/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js"></script> 8 <link rel="help" href="https://github.com/whatwg/html/issues/11291"> 9 10 <body> 11 <script> 12 13 promise_test(async t => { 14 const windowName = 'named-window'; 15 16 const rcHelper = new RemoteContextHelper(); 17 const rcPopup1 = await rcHelper.addWindow(undefined, { target: windowName, features: 'noopener' }); 18 const rcPopup2 = await rcHelper.addWindow(undefined, { target: windowName, features: 'noopener' }); 19 20 // If both scripts execute, then the windows are separate, and the test passes. 21 // If the window is reused, then rcPopup1 will not be able to execute script, and so the test will timeout. 22 23 assert_equals(await rcPopup1.executeScript(() => window.name), windowName); 24 assert_equals(await rcPopup2.executeScript(() => window.name), windowName); 25 }, 'Two noopener window.open() calls create separate windows'); 26 27 promise_test(async t => { 28 const windowName = 'named-window-2'; 29 30 function executorCreator(url) { 31 const a = document.createElement("a"); 32 a.href = url; 33 a.rel = 'noopener'; 34 a.target = windowName; 35 document.body.append(a); 36 a.click(); 37 } 38 39 const rcHelper = new RemoteContextHelper(); 40 const rcPopup1 = await rcHelper.createContext({ executorCreator }); 41 const rcPopup2 = await rcHelper.createContext({ executorCreator }); 42 43 // If both scripts execute, then the windows are separate, and the test passes. 44 // If the window is reused, then rcPopup1 will not be able to execute script, and so the test will timeout. 45 46 assert_equals(await rcPopup1.executeScript(() => window.name), windowName); 47 assert_equals(await rcPopup2.executeScript(() => window.name), windowName); 48 }, 'Two rel=noopener <a href> clicks create separate windows'); 49 </script>