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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 (function() { 1 (function() {
2 2
3 // Gets the offset of an element in coordinates relative to the top-level frame.
4 function offset(element) {
5 const rect = element.getBoundingClientRect();
6 const iframe = element.ownerDocument.defaultView.frameElement;
7 if (!iframe) {
8 return { left: rect.left, top: rect.top };
9 }
10 const outerOffset = offset(iframe);
11 const style = getComputedStyle(iframe);
12 const get = prop => +/[\d.]*/.exec(style[prop])[0];
13 return {
14 left: outerOffset.left + get('borderLeftWidth') + get('paddingLeft') + rect. left,
15 top: outerOffset.top + get('borderTopWidth') + get('paddingTop') + rect.top
16 };
17 }
18
3 function click(button) { 19 function click(button) {
4 var rect = button.getBoundingClientRect(); 20 const pos = offset(button);
5 eventSender.mouseMoveTo(rect.left, rect.top); 21 eventSender.mouseMoveTo(Math.ceil(pos.left), Math.ceil(pos.top));
6 eventSender.mouseDown(); 22 eventSender.mouseDown();
7 eventSender.mouseUp(); 23 eventSender.mouseUp();
8 } 24 }
9 25
10 var observer = new MutationObserver(mutations => { 26 const observer = new MutationObserver(mutations => {
11 for (var mutation of mutations) { 27 for (const mutation of mutations) {
12 for (var node of mutation.addedNodes) { 28 for (const node of mutation.addedNodes) {
13 if (node.localName == 'button') 29 if (node.localName == 'button')
14 click(node); 30 click(node);
15 else if (node.localName == 'iframe') 31 else if (node.localName == 'iframe')
16 observe(node.contentDocument); 32 observe(node.contentDocument);
17 } 33 }
18 } 34 }
19 }); 35 });
20 36
21 function observe(target) { 37 function observe(target) {
22 observer.observe(target, { childList: true, subtree: true }); 38 observer.observe(target, { childList: true, subtree: true });
23 } 39 }
24 40
25 // Handle what's already in the document. 41 // Handle what's already in the document.
26 for (var button of document.getElementsByTagName('button')) { 42 for (const button of document.getElementsByTagName('button')) {
27 click(button); 43 click(button);
28 } 44 }
29 for (var iframe of document.getElementsByTagName('iframe')) { 45 for (const iframe of document.getElementsByTagName('iframe')) {
30 observe(iframe.contentDocument); 46 observe(iframe.contentDocument);
47 iframe.addEventListener('load', () => {
48 observe(iframe.contentDocument);
49 });
31 } 50 }
32 51
33 // Observe future changes. 52 // Observe future changes.
34 observe(document); 53 observe(document);
35 54
36 })(); 55 })();
OLDNEW
« 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