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

Unified 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: Added an assert_unreached clause for invalid messages 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/misc/scroll-cross-origin-iframes.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/misc/scroll-cross-origin-iframes.html b/third_party/WebKit/LayoutTests/http/tests/misc/scroll-cross-origin-iframes.html
index acd83091601202aaba7a62707ae3370a475546b6..4d86e2ef3b1182e553b12bdaebd8d258357fe417 100644
--- a/third_party/WebKit/LayoutTests/http/tests/misc/scroll-cross-origin-iframes.html
+++ b/third_party/WebKit/LayoutTests/http/tests/misc/scroll-cross-origin-iframes.html
@@ -1,44 +1,34 @@
<!DOCTYPE html>
-<script src="/js-test-resources/js-test.js"></script>
+<script src="/resources/testharness.js"></script>
+<script src='/resources/testharnessreport.js'></script>
<iframe id="target-iframe1" src="http://localhost:8080/misc/resources/cross-origin-subframe-for-scrolling.html" style="height: 100px; width: 100px; overflow-y: scroll; position: absolute; left: 50px; top: 50px"></iframe>
<iframe id="target-iframe2" src="http://localhost:8080/misc/resources/cross-origin-subframe-for-scrolling.html" style="height: 100px; width: 100px; overflow-y: scroll; position: absolute; left: 50px; top: 200px"></iframe>
<script>
-description("Verify that two sibling cross-origin iframes both correctly scroll on MouseWheel events, as per https://crbug.com/675695.");
+var scroll_test = async_test("Verify that two sibling cross-origin iframes both correctly scroll on MouseWheel events, as per https://crbug.com/675695.");
-// States:
-// 0 => Scroll sent to iframe1
-// 1 => Fetching scroll offset from iframe1
-// 2 => Scroll sent to iframe2
-// 3 => Fetching scroll offset from iframe2
-var state = 0;
+var last_frame_scrolled;
var iframe1 = document.getElementById("target-iframe1");
var iframe2 = document.getElementById("target-iframe2");
-setPrintTestResultsLazily();
-self.jsTestIsAsync = true;
function handleMessage(event) {
- if (state == 0) {
- iframe1.contentWindow.postMessage("", "*");
- state = 1;
- } else if (state == 1) {
- shouldBeEqualToNumber("event.data.scrollTop", 40);
- state = 2;
- iframe2.contentWindow.postMessage({scrollBy: -1, left: iframe2.offsetLeft, top: iframe2.offsetTop}, "*");
- iframe2.contentWindow.postMessage("", "*");
- } else if (state == 2) {
- iframe1.contentWindow.postMessage("", "*");
- state = 3;
- } else if (state == 3) {
- shouldBeEqualToNumber("event.data.scrollTop", 40);
- finishJSTest();
+ if (event.data.scrolled == 1 && last_frame_scrolled == 1) {
+ scroll_test.step(() => { assert_greater_than(event.data.scrollTop, 0, "iframe1 scroll offset greater than 0.")} );
+ last_frame_scrolled = 2;
+ iframe2.contentWindow.postMessage({scrollBy: -1, frame_id: 2, left: iframe2.offsetLeft, top: iframe2.offsetTop}, "*");
+ } else if (event.data.scrolled == 2) {
+ scroll_test.step(() => { assert_greater_than(event.data.scrollTop, 0, "iframe2 scroll offset greater than 0.")} );
+ scroll_test.done();
+ } else if (event.data.scrolled != 1){
+ assert_unreached("Received invalid postMessage from subframe.");
}
}
window.addEventListener("message", handleMessage);
iframe1.onload = (() => {
- iframe1.contentWindow.postMessage({scrollBy: -1, left: iframe1.offsetLeft, top: iframe1.offsetTop}, "*");
+ last_frame_scrolled = 1;
+ iframe1.contentWindow.postMessage({scrollBy: -1, frame_id: 1, left: iframe1.offsetLeft, top: iframe1.offsetTop}, "*");
});
</script>

Powered by Google App Engine
This is Rietveld 408576698