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

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

Issue 2706293013: Add tests for exiting from nested fullscreen (Closed)
Patch Set: tweak auto-click.js style Created 3 years, 10 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
« no previous file with comments | « third_party/WebKit/LayoutTests/external/wpt/fullscreen/api/document-exit-fullscreen-nested-manual.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/external/wpt_automation/fullscreen/auto-click.js
diff --git a/third_party/WebKit/LayoutTests/external/wpt_automation/fullscreen/auto-click.js b/third_party/WebKit/LayoutTests/external/wpt_automation/fullscreen/auto-click.js
index 2c4723bc2569b9aed72d792792690133a1e27b14..81f66f552c1d12bb47b71a67a884dd40f2dbd7d8 100644
--- a/third_party/WebKit/LayoutTests/external/wpt_automation/fullscreen/auto-click.js
+++ b/third_party/WebKit/LayoutTests/external/wpt_automation/fullscreen/auto-click.js
@@ -1,15 +1,31 @@
(function() {
+// Gets the offset of an element in coordinates relative to the top-level frame.
+function offset(element) {
+ const rect = element.getBoundingClientRect();
+ const iframe = element.ownerDocument.defaultView.frameElement;
+ if (!iframe) {
+ return { left: rect.left, top: rect.top };
+ }
+ const outerOffset = offset(iframe);
+ const style = getComputedStyle(iframe);
+ const get = prop => +/[\d.]*/.exec(style[prop])[0];
+ return {
+ left: outerOffset.left + get('borderLeftWidth') + get('paddingLeft') + rect.left,
+ top: outerOffset.top + get('borderTopWidth') + get('paddingTop') + rect.top
+ };
+}
+
function click(button) {
- var rect = button.getBoundingClientRect();
- eventSender.mouseMoveTo(rect.left, rect.top);
+ const pos = offset(button);
+ eventSender.mouseMoveTo(Math.ceil(pos.left), Math.ceil(pos.top));
eventSender.mouseDown();
eventSender.mouseUp();
}
-var observer = new MutationObserver(mutations => {
- for (var mutation of mutations) {
- for (var node of mutation.addedNodes) {
+const observer = new MutationObserver(mutations => {
+ for (const mutation of mutations) {
+ for (const node of mutation.addedNodes) {
if (node.localName == 'button')
click(node);
else if (node.localName == 'iframe')
@@ -23,11 +39,14 @@ function observe(target) {
}
// Handle what's already in the document.
-for (var button of document.getElementsByTagName('button')) {
+for (const button of document.getElementsByTagName('button')) {
click(button);
}
-for (var iframe of document.getElementsByTagName('iframe')) {
+for (const iframe of document.getElementsByTagName('iframe')) {
observe(iframe.contentDocument);
+ iframe.addEventListener('load', () => {
+ observe(iframe.contentDocument);
+ });
}
// Observe future changes.
« no previous file with comments | « third_party/WebKit/LayoutTests/external/wpt/fullscreen/api/document-exit-fullscreen-nested-manual.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698