| OLD | NEW | 
|    1 <html> |    1 <html> | 
|    2 <head> |    2 <head> | 
|    3 <script> |    3 <script> | 
|    4  |    4  | 
|    5 var logDiv; |    5 var logDiv; | 
|    6  |    6  | 
|    7 function log(msg, success) |    7 function log(msg, success) | 
|    8 { |    8 { | 
|    9     logDiv.appendChild(document.createElement('div')).textContent = msg + ': ' +
      (success ? 'PASS' : 'FAIL'); |    9     logDiv.appendChild(document.createElement('div')).textContent = msg + ': ' +
      (success ? 'PASS' : 'FAIL'); | 
|   10 } |   10 } | 
|   11  |   11  | 
|   12 function clickOn(element) |   12 function clickOn(element) | 
|   13 { |   13 { | 
|   14     if (!window.eventSender) |   14     if (!window.eventSender) | 
|   15         return; |   15         return; | 
|   16  |   16  | 
|   17     var x = element.offsetLeft + element.offsetWidth / 2; |   17     var x = element.offsetLeft + element.offsetWidth / 2; | 
|   18     var y = element.offsetTop + element.offsetHeight / 2; |   18     var y = element.offsetTop + element.offsetHeight / 2; | 
|   19     eventSender.mouseMoveTo(x, y); |   19     eventSender.mouseMoveTo(x, y); | 
|   20     eventSender.mouseDown(); |   20     eventSender.mouseDown(); | 
|   21     eventSender.mouseUp(); |   21     eventSender.mouseUp(); | 
|   22 } |   22 } | 
|   23  |   23  | 
 |   24 function clickOnLeftQuarterOf(element) | 
 |   25 { | 
 |   26     if (!window.eventSender) | 
 |   27         return; | 
 |   28  | 
 |   29     var x = element.offsetLeft + element.offsetWidth / 4; | 
 |   30     var y = element.offsetTop + element.offsetHeight / 2; | 
 |   31     eventSender.mouseMoveTo(x, y); | 
 |   32     eventSender.mouseDown(); | 
 |   33     eventSender.mouseUp(); | 
 |   34 } | 
|   24  |   35  | 
|   25 function leapForward() |   36 function leapForward() | 
|   26 { |   37 { | 
|   27     if (!window.eventSender) |   38     if (!window.eventSender) | 
|   28         return; |   39         return; | 
|   29  |   40  | 
|   30     eventSender.leapForward(1000); |   41     eventSender.leapForward(1000); | 
|   31 } |   42 } | 
|   32  |   43  | 
|   33 var tests = { |   44 var tests = { | 
|   34     mutationEventPropagation: function() |   45     mutationEventPropagation: function() | 
|   35     { |   46     { | 
|   36         var textarea = document.body.appendChild(document.createElement('textare
     a')); |   47         var textarea = document.body.appendChild(document.createElement('textare
     a')); | 
|   37         var mutationEventFired; |   48         var mutationEventFired; | 
|   38         textarea.addEventListener('DOMSubtreeModified', function(e) |   49         textarea.addEventListener('DOMSubtreeModified', function(e) | 
|   39         { |   50         { | 
|   40             mutationEventFired = true; |   51             mutationEventFired = true; | 
|   41         }, false); |   52         }, false); | 
|   42         textarea.value = 'test'; |   53         textarea.value = 'test'; | 
|   43         // Trigger style recalc and sadly, the actual mutation of the textarea s
     hadow DOM. |   54         // Trigger style recalc and sadly, the actual mutation of the textarea s
     hadow DOM. | 
|   44         textarea.offsetHeight; |   55         textarea.offsetHeight; | 
|   45         log('Mutation events should not propagate out of the shadow DOM', !mutat
     ionEventFired); |   56         log('Mutation events should not propagate out of the shadow DOM', !mutat
     ionEventFired); | 
|   46         textarea.parentNode.removeChild(textarea); |   57         textarea.parentNode.removeChild(textarea); | 
|   47     }, |   58     }, | 
|   48     defaultEventRetargeting: function() |   59     labelSyntheticClick: function() | 
|   49     { |   60     { | 
|   50         var count = 0; |   61         var count = 0; | 
|   51         var label = document.body.appendChild(document.createElement('label')); |   62         var label = document.body.appendChild(document.createElement('label')); | 
|   52         var searchInput = label.appendChild(document.createElement('input')); |   63         var searchInput = label.appendChild(document.createElement('input')); | 
|   53         searchInput.setAttribute('type', 'search'); |   64         searchInput.setAttribute('type', 'search'); | 
|   54         searchInput.setAttribute('id', 'baz'); |   65         searchInput.setAttribute('id', 'baz'); | 
|   55         label.setAttribute('for', 'baz'); |   66         label.setAttribute('for', 'baz'); | 
|   56         searchInput.addEventListener('click', function(e) |   67         searchInput.addEventListener('click', function(e) | 
|   57         { |   68         { | 
|   58             count++; |   69             count++; | 
|   59         }, false); |   70         }, false); | 
|   60         clickOn(searchInput); |   71         clickOn(searchInput); | 
|   61         log("Events for default event handler should also be retargeted", count 
     == 1); |   72         log("Label should look beyond shadow boundary to detect if it encloses i
     ts associated element", count == 1); | 
|   62         label.parentNode.removeChild(label); |   73         label.parentNode.removeChild(label); | 
|   63     }, |   74     }, | 
 |   75     defaultEventRetargeting: function() | 
 |   76     { | 
 |   77         var count = 0; | 
 |   78         var fileInput = document.body.appendChild(document.createElement('input'
     )); | 
 |   79         fileInput.setAttribute('type', 'file'); | 
 |   80         var counter = function() | 
 |   81         { | 
 |   82             count++; | 
 |   83         } | 
 |   84         document.body.addEventListener('DOMActivate', counter, false); | 
 |   85         clickOnLeftQuarterOf(fileInput); | 
 |   86         log("Events for default event handler should not be retargeted", count =
     = 1); | 
 |   87         document.body.removeEventListener('DOMActivate', counter, false); | 
 |   88         fileInput.parentNode.removeChild(fileInput); | 
 |   89     }, | 
|   64     eventInProgress: function() |   90     eventInProgress: function() | 
|   65     { |   91     { | 
|   66         var textInput = document.body.appendChild(document.createElement('input'
     )); |   92         var textInput = document.body.appendChild(document.createElement('input'
     )); | 
|   67         textInput.addEventListener('click', function(e) |   93         textInput.addEventListener('click', function(e) | 
|   68         { |   94         { | 
|   69             log('Other events should be retargeted', e.target == textInput); |   95             log('Other events should be retargeted', e.target == textInput); | 
|   70         }, false); |   96         }, false); | 
|   71         clickOn(textInput); |   97         clickOn(textInput); | 
|   72         textInput.parentNode.removeChild(textInput); |   98         textInput.parentNode.removeChild(textInput); | 
|   73     }, |   99     }, | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  112 } |  138 } | 
|  113  |  139  | 
|  114 </script> |  140 </script> | 
|  115 </head> |  141 </head> | 
|  116 <body onload="runTest()"> |  142 <body onload="runTest()"> | 
|  117     <p>Tests to ensure that shadow DOM boundary is not crossed during event prop
     agation. Can only run within DRT. |  143     <p>Tests to ensure that shadow DOM boundary is not crossed during event prop
     agation. Can only run within DRT. | 
|  118     <p>See <a href="https://bugs.webkit.org/show_bug.cgi?id=46015">bug 46015</a>
      for details. |  144     <p>See <a href="https://bugs.webkit.org/show_bug.cgi?id=46015">bug 46015</a>
      for details. | 
|  119     <div id="log"></div> |  145     <div id="log"></div> | 
|  120 </body> |  146 </body> | 
|  121 </html> |  147 </html> | 
| OLD | NEW |