test_bug1150308.html (1667B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1150308 5 --> 6 <head> 7 <title>Test for Bug 1150308</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script src="/tests/SimpleTest/EventUtils.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 </head> 12 <body> 13 <script type="application/javascript"> 14 15 /** Test for Bug 1150308 */ 16 17 function runTests() { 18 var iframe = document.createElement('iframe'); 19 document.body.appendChild(iframe); 20 iframe.contentDocument.body.innerHTML = 21 '<div id="host"><span id="distributeme">Foo</span></div>'; 22 23 var host = iframe.contentDocument.getElementById("host"); 24 var shadow = host.attachShadow({mode: 'open'}); 25 shadow.innerHTML = '<style>.bar:active { color: rgb(0, 255, 0); }</style><div class="bar" id="inner"><slot></slot></div>'; 26 var inner = shadow.getElementById("inner"); 27 var distributed = iframe.contentDocument.getElementById("distributeme"); 28 var iframeWin = iframe.contentWindow; 29 30 is(iframeWin.getComputedStyle(inner).color, "rgb(0, 0, 0)", "The div inside the shadow root should not be active."); 31 32 synthesizeMouseAtCenter(distributed, { type: "mousedown" }, iframeWin); 33 34 is(iframeWin.getComputedStyle(inner).color, "rgb(0, 255, 0)", "Div inside shadow root should be active."); 35 36 synthesizeMouseAtCenter(distributed, { type: "mouseup" }, iframeWin); 37 38 is(iframeWin.getComputedStyle(inner).color, "rgb(0, 0, 0)", "Div inside shadow root should no longer be active."); 39 40 SimpleTest.finish(); 41 }; 42 43 SimpleTest.waitForExplicitFinish(); 44 window.onload = () => { 45 SimpleTest.waitForFocus(runTests); 46 }; 47 </script> 48 </body> 49 </html>