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