test_isRemoteProxy.html (1743B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Tests for Cu.isRemoteProxy</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 8 </head> 9 <body> 10 <script> 11 12 async function addFrame(url) { 13 let frame = document.createElement("iframe"); 14 frame.src = url; 15 document.body.appendChild(frame); 16 17 await new Promise(resolve => { 18 frame.addEventListener("load", resolve, { once: true }); 19 }); 20 21 return frame; 22 } 23 24 add_task(async function() { 25 const { Cu } = SpecialPowers; 26 27 let localFrame = await addFrame("file_empty.html"); 28 let remoteFrame = await addFrame( 29 SimpleTest.getTestFileURL("file_empty.html") 30 .replace("mochi.test:8888", "example.com")); 31 32 ok(frames[0] === localFrame.contentWindow, "frames[0] is localFrame"); 33 ok(frames[1] === remoteFrame.contentWindow, "frames[1] is remoteFrame"); 34 35 ok(!Cu.isRemoteProxy(window), "window is not a remote proxy"); 36 ok(!Cu.isRemoteProxy(location), "location is not a remote proxy"); 37 38 ok(!Cu.isRemoteProxy(frames[0]), "frames[0] is not a remote proxy"); 39 ok( 40 !Cu.isRemoteProxy(frames[0].location), 41 "frames[0].location is not a remote proxy" 42 ); 43 44 // The processes will be remote only with isolateEverything strategy 45 const expected = SpecialPowers.effectiveIsolationStrategy() == SpecialPowers.ISOLATION_STRATEGY.IsolateEverything; 46 47 is(Cu.isRemoteProxy(frames[1]), expected, 48 "frames[1] is a remote proxy if Fission is enabled and strategy is isolateEverything"); 49 is(Cu.isRemoteProxy(frames[1].location), expected, 50 "frames[1].location is a remote proxy if Fission is enabled and strategy is isolateEverything"); 51 }); 52 53 </script> 54 </body> 55 </html>