OLD | NEW |
---|---|
(Empty) | |
1 // Invoke callback from a trusted event. | |
falken
2014/08/12 03:26:08
nit: Typically function documentation is written i
philipj_slow
2014/08/12 08:09:53
Done. I much appreciate the attention to detail, a
| |
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 // Invoke element.requestFullscreen() from a trusted event. | |
falken
2014/08/12 03:26:08
"Invokes"
| |
33 function trusted_request(element) | |
34 { | |
35 var request = element.requestFullscreen.bind(element); | |
36 trusted_event(request, element.parentNode); | |
37 } | |
OLD | NEW |