Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: LayoutTests/fullscreen/trusted-event.js

Issue 395633011: Implement the unprefixed the Fullscreen API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fullscreen/trusted-event.js
diff --git a/LayoutTests/fullscreen/trusted-event.js b/LayoutTests/fullscreen/trusted-event.js
new file mode 100644
index 0000000000000000000000000000000000000000..5bcc767090892d8ce5820ecb844be0cf4ed9dd66
--- /dev/null
+++ b/LayoutTests/fullscreen/trusted-event.js
@@ -0,0 +1,37 @@
+// 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
+// When testing manually, a button is added to the container.
+function trusted_event(callback, container)
+{
+ var document = container.ownerDocument;
+
+ if (window.testRunner) {
+ // Running under LayoutTests. Use timeout to be async.
+ setTimeout(function()
+ {
+ document.addEventListener("click", callback);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ document.removeEventListener("click", callback);
+ }, 0);
+ } else {
+ // Running as manual test. Show a button to click.
+ var button = document.createElement("button");
+ button.textContent = "click to run test";
+ button.style.fontSize = "20px";
+ button.style.padding = "10px";
+ button.onclick = function()
+ {
+ callback();
+ button.onclick = null;
+ container.removeChild(button);
+ };
+ container.appendChild(button);
+ }
+}
+
+// Invoke element.requestFullscreen() from a trusted event.
falken 2014/08/12 03:26:08 "Invokes"
+function trusted_request(element)
+{
+ var request = element.requestFullscreen.bind(element);
+ trusted_event(request, element.parentNode);
+}

Powered by Google App Engine
This is Rietveld 408576698