tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug1145910.html (1899B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1145910
      5 -->
      6 <head>
      7  <title>Test for Bug 1145910</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 
     14 <script type="application/javascript">
     15 
     16 /** Test for Bug 1145910 */
     17 
     18 function runTests() {
     19 
     20  var iframe = document.createElement('iframe');
     21  document.body.appendChild(iframe);
     22  iframe.contentDocument.body.innerHTML =
     23    '<style> div:active { color: rgb(0, 255, 0); } </style> <div id="host">Foo</div>';
     24 
     25  var host = iframe.contentDocument.getElementById("host");
     26  var shadow = host.attachShadow({mode: 'open'});
     27  shadow.innerHTML = '<style>div:active { color: rgb(0, 255, 0); }</style><div id="inner">Bar</div>';
     28  var inner = shadow.getElementById("inner");
     29  var iframeWin = iframe.contentWindow;
     30 
     31  is(iframeWin.getComputedStyle(host).color, "rgb(0, 0, 0)", "The host should not be active");
     32  is(iframeWin.getComputedStyle(inner).color, "rgb(0, 0, 0)", "The div inside the shadow root should not be active.");
     33 
     34  synthesizeMouseAtCenter(host, { type: "mousedown" }, iframeWin);
     35 
     36  is(iframeWin.getComputedStyle(inner).color, "rgb(0, 255, 0)", "Div inside shadow root should be active.");
     37  is(iframeWin.getComputedStyle(host).color, "rgb(0, 255, 0)", "Host should be active when the inner div is made active.");
     38 
     39  synthesizeMouseAtCenter(host, { type: "mouseup" }, iframeWin);
     40 
     41  is(iframeWin.getComputedStyle(inner).color, "rgb(0, 0, 0)", "Div inside shadow root should no longer be active.");
     42  is(iframeWin.getComputedStyle(host).color, "rgb(0, 0, 0)", "Host should no longer be active.");
     43 
     44  SimpleTest.finish();
     45 };
     46 
     47 SimpleTest.waitForExplicitFinish();
     48 window.onload = () => {
     49  SimpleTest.waitForFocus(runTests);
     50 };
     51 
     52 </script>
     53 </body>
     54 </html>