Home | History | Annotate | Download | only in data
      1 // Disable compositor hit testing
      2 document.addEventListener('touchstart', function() {});
      3 
      4 window.addEventListener('load', function() {
      5   // Create any shadow DOM nodes requested by the test.
      6   var shadowTrees = document.querySelectorAll('[make-shadow-dom]');
      7   if (shadowTrees.length > 0 && !HTMLElement.prototype.createShadowRoot) {
      8     document.body.innerHTML = 'ERROR: Shadow DOM not supported!';
      9     return;
     10   }
     11   for (var i = 0; i < shadowTrees.length; i++) {
     12     var tree = shadowTrees[i];
     13     var host = tree.previousElementSibling;
     14     if (!host.hasAttribute('shadow-host')) {
     15       document.body.innerHTML = 'ERROR: make-shadow-dom node must follow a shadow-host node';
     16       return;
     17     }
     18     tree.parentElement.removeChild(tree);
     19     var shadowRoot = host.createShadowRoot();
     20     shadowRoot.appendChild(tree);
     21   }
     22 });
     23 
     24 /*
     25  * Visualization of hit test locations for manual testing.
     26  * To be invoked manually (so it doesn't intefere with testing).
     27  */
     28 function addMarker(x, y)
     29 {
     30     const kMarkerSize = 6;
     31     var marker = document.createElement('div');
     32     marker.className = 'marker';
     33     marker.style.top = (y - kMarkerSize/2) + 'px';
     34     marker.style.left = (x - kMarkerSize/2) + 'px';
     35     document.body.appendChild(marker);
     36 }
     37 
     38 function addMarkers()
     39 {
     40   var tests = document.querySelectorAll('[expected-action]');
     41   for (var i = 0; i < tests.length; i++) {
     42     var r = tests[i].getClientRects()[0];
     43     addMarker(r.left, r.top);
     44     addMarker(r.right - 1, r.bottom - 1);
     45     addMarker(r.left + r.width / 2, r.top + r.height / 2);
     46   }
     47 }
     48