1 // Invokes callback from a trusted event.
2 // When testing manually, a button is added to the container.
3 function trusted_event(callback, container)
5 var document = container.ownerDocument;
7 if (window.testRunner) {
8 // Running under LayoutTests. Use timeout to be async.
11 document.addEventListener("click", callback);
12 eventSender.mouseDown();
13 eventSender.mouseUp();
14 document.removeEventListener("click", callback);
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.display = "block";
21 button.style.fontSize = "20px";
22 button.style.padding = "10px";
23 button.onclick = function()
26 button.onclick = null;
27 container.removeChild(button);
29 container.appendChild(button);
33 // Invokes element.requestFullscreen() from a trusted event.
34 // When testing manually, a button is added to the container,
35 // or to element's parent if no container is provided.
36 function trusted_request(element, container)
38 var request = element.requestFullscreen.bind(element);
39 trusted_event(request, container || element.parentNode);