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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/misc/scroll-cross-origin-iframes.html

Issue 2642723009: Improve cross-origin-subframe-for-scrolling layout test (Closed)
Patch Set: Simplifying Created 3 years, 11 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="/js-test-resources/js-test.js"></script> 2 <script src="/resources/testharness.js"></script>
3 <script src='/resources/testharnessreport.js'></script>
3 <iframe id="target-iframe1" src="http://localhost:8080/misc/resources/cross-orig in-subframe-for-scrolling.html" style="height: 100px; width: 100px; overflow-y: scroll; position: absolute; left: 50px; top: 50px"></iframe> 4 <iframe id="target-iframe1" src="http://localhost:8080/misc/resources/cross-orig in-subframe-for-scrolling.html" style="height: 100px; width: 100px; overflow-y: scroll; position: absolute; left: 50px; top: 50px"></iframe>
4 <iframe id="target-iframe2" src="http://localhost:8080/misc/resources/cross-orig in-subframe-for-scrolling.html" style="height: 100px; width: 100px; overflow-y: scroll; position: absolute; left: 50px; top: 200px"></iframe> 5 <iframe id="target-iframe2" src="http://localhost:8080/misc/resources/cross-orig in-subframe-for-scrolling.html" style="height: 100px; width: 100px; overflow-y: scroll; position: absolute; left: 50px; top: 200px"></iframe>
5 6
6 <script> 7 <script>
7 description("Verify that two sibling cross-origin iframes both correctly scroll on MouseWheel events, as per https://crbug.com/675695."); 8 var scroll_test = async_test("Verify that two sibling cross-origin iframes both correctly scroll on MouseWheel events, as per https://crbug.com/675695.");
8 9
9 // States: 10 var last_frame_scrolled;
10 // 0 => Scroll sent to iframe1
11 // 1 => Fetching scroll offset from iframe1
12 // 2 => Scroll sent to iframe2
13 // 3 => Fetching scroll offset from iframe2
14 var state = 0;
15 var iframe1 = document.getElementById("target-iframe1"); 11 var iframe1 = document.getElementById("target-iframe1");
16 var iframe2 = document.getElementById("target-iframe2"); 12 var iframe2 = document.getElementById("target-iframe2");
17 setPrintTestResultsLazily();
18 self.jsTestIsAsync = true;
19 13
20 function handleMessage(event) { 14 function handleMessage(event) {
21 if (state == 0) { 15 if (event.data.scrolled == 1 && last_frame_scrolled == 1) {
22 » iframe1.contentWindow.postMessage("", "*"); 16 scroll_test.step(() => { assert_greater_than(event.data.scrollTop, 0, "ifram e1 scroll offset greater than 0")} );
23 » state = 1; 17 last_frame_scrolled = 2;
24 } else if (state == 1) { 18 iframe2.contentWindow.postMessage({scrollBy: -1, frame_id: 2, left: iframe2. offsetLeft, top: iframe2.offsetTop}, "*");
25 shouldBeEqualToNumber("event.data.scrollTop", 40); 19 } else if (event.data.scrolled == 2) {
26 state = 2; 20 scroll_test.step(() => { assert_greater_than(event.data.scrollTop, 0, "ifram e2 scroll offset greater than 0")} );
27 iframe2.contentWindow.postMessage({scrollBy: -1, left: iframe2.offsetLeft, t op: iframe2.offsetTop}, "*"); 21 scroll_test.done();
28 iframe2.contentWindow.postMessage("", "*");
29 } else if (state == 2) {
30 » iframe1.contentWindow.postMessage("", "*");
31 » state = 3;
32 } else if (state == 3) {
33 shouldBeEqualToNumber("event.data.scrollTop", 40);
34 finishJSTest();
35 } 22 }
bokan 2017/01/20 19:24:54 Nit: Add an else clause that fails the test.
kenrb 2017/01/23 16:15:44 Done, although it still had to be an 'else if' bec
bokan 2017/01/23 16:17:41 Ah, yah - didn't think of that. else if looks fine
36 } 23 }
37 24
38 window.addEventListener("message", handleMessage); 25 window.addEventListener("message", handleMessage);
39 26
40 iframe1.onload = (() => { 27 iframe1.onload = (() => {
41 iframe1.contentWindow.postMessage({scrollBy: -1, left: iframe1.offsetLeft, top : iframe1.offsetTop}, "*"); 28 last_frame_scrolled = 1;
29 iframe1.contentWindow.postMessage({scrollBy: -1, frame_id: 1, left: iframe1.of fsetLeft, top: iframe1.offsetTop}, "*");
42 }); 30 });
43 31
44 </script> 32 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698