OLD | NEW |
(Empty) | |
| 1 // Invokes callback from a trusted event. |
| 2 // When testing manually, a button is added to the container. |
| 3 function trusted_event(callback, container) |
| 4 { |
| 5 var document = container.ownerDocument; |
| 6 |
| 7 if (window.testRunner) { |
| 8 // Running under LayoutTests. Use timeout to be async. |
| 9 setTimeout(function() |
| 10 { |
| 11 document.addEventListener("click", callback); |
| 12 eventSender.mouseDown(); |
| 13 eventSender.mouseUp(); |
| 14 document.removeEventListener("click", callback); |
| 15 }, 0); |
| 16 } else { |
| 17 // Running as manual test. Show a button to click. |
| 18 var button = document.createElement("button"); |
| 19 button.textContent = "click to run test"; |
| 20 button.style.fontSize = "20px"; |
| 21 button.style.padding = "10px"; |
| 22 button.onclick = function() |
| 23 { |
| 24 callback(); |
| 25 button.onclick = null; |
| 26 container.removeChild(button); |
| 27 }; |
| 28 container.appendChild(button); |
| 29 } |
| 30 } |
| 31 |
| 32 // Invokes element.requestFullscreen() from a trusted event. |
| 33 function trusted_request(element) |
| 34 { |
| 35 var request = element.requestFullscreen.bind(element); |
| 36 trusted_event(request, element.parentNode); |
| 37 } |
OLD | NEW |