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

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt_automation/fullscreen/auto-click.js

Issue 2466333002: Automate Fullscreen web-platform-tests using wpt_automation (Closed)
Patch Set: update line numbers Created 4 years, 1 month 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: third_party/WebKit/LayoutTests/imported/wpt_automation/fullscreen/auto-click.js
diff --git a/third_party/WebKit/LayoutTests/imported/wpt_automation/fullscreen/auto-click.js b/third_party/WebKit/LayoutTests/imported/wpt_automation/fullscreen/auto-click.js
new file mode 100644
index 0000000000000000000000000000000000000000..2c4723bc2569b9aed72d792792690133a1e27b14
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/wpt_automation/fullscreen/auto-click.js
@@ -0,0 +1,36 @@
+(function() {
+
+function click(button) {
+ var rect = button.getBoundingClientRect();
+ eventSender.mouseMoveTo(rect.left, rect.top);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+}
+
+var observer = new MutationObserver(mutations => {
+ for (var mutation of mutations) {
+ for (var node of mutation.addedNodes) {
+ if (node.localName == 'button')
+ click(node);
+ else if (node.localName == 'iframe')
+ observe(node.contentDocument);
+ }
+ }
+});
+
+function observe(target) {
+ observer.observe(target, { childList: true, subtree: true });
+}
+
+// Handle what's already in the document.
+for (var button of document.getElementsByTagName('button')) {
+ click(button);
+}
+for (var iframe of document.getElementsByTagName('iframe')) {
+ observe(iframe.contentDocument);
+}
+
+// Observe future changes.
+observe(document);
+
+})();

Powered by Google App Engine
This is Rietveld 408576698