tor-browser

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

test-002.html (1906B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>Shadow DOM Test: A_05_03_02</title>
      5 <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
      6 <link rel="help" href="http://www.w3.org/TR/2013/WD-shadow-dom-20130514/#retargeting-focus-events">
      7 <meta name="assert" content="Retargeting focus events:The blur event must be treated in the same way as events with a relatedTarget, where the node that is gaining focus causing the blurring of target acts as the related target">
      8 <script src="/resources/testharness.js"></script>
      9 <script src="/resources/testharnessreport.js"></script>
     10 <script src="../../../../html/resources/common.js"></script>
     11 <script src="../../../resources/shadow-dom-utils.js"></script>
     12 </head>
     13 <body>
     14 <div id="log"></div>
     15 <script>
     16 //test blur event
     17 var A_05_03_02_T01 = async_test('A_05_03_02_T01');
     18 
     19 
     20 A_05_03_02_T01.step(unit(function (ctx) {
     21 
     22    var d = newRenderedHTMLDocument(ctx);
     23 
     24    var invoked = false;
     25 
     26    var roots = createTestMediaPlayer(d);
     27 
     28    roots.playerShadowRoot.querySelector('.volume-slider').focus();
     29 
     30    //expected result of what relative target should be see
     31    //see at http://www.w3.org/TR/shadow-dom/#event-retargeting-example
     32 
     33    //For #volume-slider relative target is #volume-slider
     34    roots.playerShadowRoot.querySelector('.volume-slider').addEventListener('blur',
     35            A_05_03_02_T01.step_func(function(event) {
     36                invoked = true;
     37                assert_equals(event.target.getAttribute('id'), 'volume-slider',
     38                        'Wrong target');
     39        }), false);
     40 
     41    // move focus out of shadow tree. blur should be fired
     42    d.querySelector('#outside-control').focus();
     43 
     44    assert_true(invoked, 'Event listener was not invoked');
     45 
     46    A_05_03_02_T01.done();
     47 }));
     48 
     49 
     50 //TODO (sgrekhov) add test for the case when related target differs from the
     51 //node on which event listener is invoked
     52 </script>
     53 </body>
     54 </html>