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: third_party/WebKit/LayoutTests/external/wpt_automation/fullscreen/auto-click.js

Issue 2706293013: Add tests for exiting from nested fullscreen (Closed)
Patch Set: 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..552a5cb3a67d3370617db43539d57751bc32c66d 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,8 +1,25 @@
(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 };
Mike West 2017/02/24 11:37:16 I must be getting old, but the `{}` for the object
foolip 2017/02/24 15:12:58 Ah, this does look a bit, more {} it is.
+ const style = getComputedStyle(iframe);
Mike West 2017/02/24 11:37:16 I don't think you actually use this. Is it just to
foolip 2017/02/24 15:12:58 It's used as style[prop] inside the get function.
+ function get(prop) {
Mike West 2017/02/24 11:37:16 Hrm. I don't know if we have a style-guide about n
foolip 2017/02/24 15:12:58 Didn't think of that, done. (I also threw in some
+ return +/[\d.]*/.exec(style[prop])[0];
+ }
+ const outerOffset = offset(iframe);
+ 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);
+ var pos = offset(button);
+ eventSender.mouseMoveTo(Math.ceil(pos.left), Math.ceil(pos.top));
eventSender.mouseDown();
eventSender.mouseUp();
}
@@ -28,6 +45,9 @@ for (var button of document.getElementsByTagName('button')) {
}
for (var 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