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

Unified Diff: LayoutTests/screen_orientation/orientationchange-event-subframe.html

Issue 277413002: Make screen.orientation implementation use WebScreenInfo::orientationType (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Improve test Created 6 years, 7 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: LayoutTests/screen_orientation/orientationchange-event-subframe.html
diff --git a/LayoutTests/screen_orientation/orientationchange-event-subframe.html b/LayoutTests/screen_orientation/orientationchange-event-subframe.html
new file mode 100644
index 0000000000000000000000000000000000000000..8a15e04219f52baae3dbcad9d27e2dec45a70878
--- /dev/null
+++ b/LayoutTests/screen_orientation/orientationchange-event-subframe.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+
+<iframe id="testIframe" sandbox="allow-scripts allow-same-origin" style="display:none">
+</iframe>
+
+<script>
+ var test = async_test("Test subframes receive 'orientationchange' events");
+
+ var orientations = [
+ 'portrait-primary',
+ 'portrait-secondary',
+ 'landscape-primary',
+ 'landscape-secondary'
+ ];
+
+ var currentIndex = orientations.indexOf(window.screen.orientation);
+ var eventsReceived = 0;
+
+ function getNextIndex() {
+ return (currentIndex + 1) % orientations.length;
jochen (gone - plz use gerrit) 2014/05/26 10:02:11 4space indent everywhere plz
Inactive 2014/05/27 14:22:15 Done.
+ }
+
+ function changeOrientation() {
+ window.testRunner.setMockScreenOrientation(orientations[getNextIndex()]);
+ currentIndex = getNextIndex();
+ }
+
+ window.onmessage = test.step_func(function (ev) {
+ assert_equals(ev.data, orientations[currentIndex], "subframe receives 'orientationchange' event");
+ ++eventsReceived;
+ if (eventsReceived < 4)
+ changeOrientation()
+ else
+ test.done();
+ });
+
+ var testIframe = document.getElementById("testIframe");
+ testIframe.src = "resources/iframe-listen-orientation-change.html";
+ testIframe.onload = changeOrientation;
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698