55
66// Test that the "orientationchange" event is fired when the "rotate button" is clicked.
77
8- // TODO: This test should also check that the orientation is set properly on the iframe.
9- // This is currently not working and should be worked on in Bug 1704830.
10-
118const TEST_DOCUMENT = `doc_with_remote_iframe_and_isolated_cross_origin_capabilities.sjs` ;
129const TEST_COM_URL = URL_ROOT_COM_SSL + TEST_DOCUMENT ;
1310
@@ -45,11 +42,20 @@ addRDMTask(TEST_COM_URL, async function ({ ui }) {
4542 info (
4643 "Check that rotating the viewport does trigger an orientationchange event"
4744 ) ;
45+ let iframeBrowsingContext =
46+ ui . getViewportBrowser ( ) . browsingContext . children [ 0 ] ;
47+
4848 let waitForOrientationChangeEvent = isOrientationChangeEventEmitted (
4949 ui . getViewportBrowser ( )
5050 ) ;
5151 let waitForScreenOrientationChangeEvent =
5252 isWindowScreenOrientationChangeEventEmitted ( ui . getViewportBrowser ( ) ) ;
53+
54+ let waitForOrientationChangeEventInIframe = isOrientationChangeEventEmitted (
55+ iframeBrowsingContext
56+ ) ;
57+ let waitForScreenOrientationChangeEventInIframe =
58+ isWindowScreenOrientationChangeEventEmitted ( iframeBrowsingContext ) ;
5359 rotateViewport ( ui ) ;
5460 is (
5561 await waitForOrientationChangeEvent ,
@@ -62,6 +68,17 @@ addRDMTask(TEST_COM_URL, async function ({ ui }) {
6268 "'change' event fired on window.screen.orientation"
6369 ) ;
6470
71+ is (
72+ await waitForOrientationChangeEventInIframe ,
73+ true ,
74+ "'orientationchange' event fired in iframe"
75+ ) ;
76+ is (
77+ await waitForScreenOrientationChangeEventInIframe ,
78+ true ,
79+ "'change' event fired on window.screen.orientation in iframe"
80+ ) ;
81+
6582 is (
6683 await getScreenOrientationType ( ui . getViewportBrowser ( ) ) ,
6784 "landscape-primary" ,
@@ -74,8 +91,21 @@ addRDMTask(TEST_COM_URL, async function ({ ui }) {
7491 "Orientation angle was updated to 90 degrees"
7592 ) ;
7693
94+ is (
95+ await getScreenOrientationType ( iframeBrowsingContext ) ,
96+ "landscape-primary" ,
97+ "Orientation state in iframe was updated to landscape-primary"
98+ ) ;
99+
100+ is (
101+ await getScreenOrientationAngle ( iframeBrowsingContext ) ,
102+ 90 ,
103+ "Orientation angle in iframe was updated to 90 degrees"
104+ ) ;
105+
77106 info ( "Check that the viewport orientation values persist after reload" ) ;
78107 await reloadBrowser ( ) ;
108+ iframeBrowsingContext = ui . getViewportBrowser ( ) . browsingContext . children [ 0 ] ;
79109
80110 is (
81111 await getScreenOrientationType ( ui . getViewportBrowser ( ) ) ,
@@ -98,6 +128,17 @@ addRDMTask(TEST_COM_URL, async function ({ ui }) {
98128 "orientation angle was set on the page early in its lifecycle"
99129 ) ;
100130
131+ is (
132+ await getScreenOrientationType ( iframeBrowsingContext ) ,
133+ "landscape-primary" ,
134+ "Orientation is still landscape-primary in iframe"
135+ ) ;
136+ is (
137+ await getScreenOrientationAngle ( iframeBrowsingContext ) ,
138+ 90 ,
139+ "Orientation angle is still 90 in iframe"
140+ ) ;
141+
101142 info (
102143 "Check that the viewport orientation values persist after navigating to a page that forces the creation of a new browsing context"
103144 ) ;
@@ -110,6 +151,7 @@ addRDMTask(TEST_COM_URL, async function ({ ui }) {
110151 URL_ROOT_ORG_SSL + TEST_DOCUMENT + "?crossOriginIsolated=true"
111152 ) ;
112153 await waitForReload ( ) ;
154+ iframeBrowsingContext = ui . getViewportBrowser ( ) . browsingContext . children [ 0 ] ;
113155
114156 isnot (
115157 browser . browsingContext . id ,
@@ -138,6 +180,23 @@ addRDMTask(TEST_COM_URL, async function ({ ui }) {
138180 "orientation angle was set on the page early in its lifecycle"
139181 ) ;
140182
183+ is (
184+ await getScreenOrientationType ( iframeBrowsingContext ) ,
185+ "landscape-primary" ,
186+ "Orientation in iframe is still landscape-primary after navigating to a new browsing context"
187+ ) ;
188+ is (
189+ await getScreenOrientationAngle ( iframeBrowsingContext ) ,
190+ 90 ,
191+ "Orientation angle in iframe is still 90 after navigating to a new browsing context"
192+ ) ;
193+
194+ waitForOrientationChangeEvent = isOrientationChangeEventEmitted (
195+ ui . getViewportBrowser ( )
196+ ) ;
197+ rotateViewport ( ui ) ;
198+ await waitForOrientationChangeEvent ;
199+
141200 info (
142201 "Check the orientationchange event is not dispatched when changing devices."
143202 ) ;
@@ -147,6 +206,12 @@ addRDMTask(TEST_COM_URL, async function ({ ui }) {
147206 waitForScreenOrientationChangeEvent =
148207 isWindowScreenOrientationChangeEventEmitted ( ui . getViewportBrowser ( ) ) ;
149208
209+ waitForOrientationChangeEventInIframe = isOrientationChangeEventEmitted (
210+ iframeBrowsingContext
211+ ) ;
212+ waitForScreenOrientationChangeEventInIframe =
213+ isWindowScreenOrientationChangeEventEmitted ( iframeBrowsingContext ) ;
214+
150215 await selectDevice ( ui , testDevice . name ) ;
151216 is (
152217 await waitForOrientationChangeEvent ,
@@ -159,6 +224,17 @@ addRDMTask(TEST_COM_URL, async function ({ ui }) {
159224 "on window.screen.orientation, change event was not dispatched when changing devices"
160225 ) ;
161226
227+ is (
228+ await waitForOrientationChangeEventInIframe ,
229+ false ,
230+ "orientationchange event was not dispatched in iframe when changing devices"
231+ ) ;
232+ is (
233+ await waitForScreenOrientationChangeEventInIframe ,
234+ false ,
235+ "on window.screen.orientation, change event was not dispatched in iframe when changing devices"
236+ ) ;
237+
162238 info ( "Check the new orientation values after selecting device." ) ;
163239 is (
164240 await getScreenOrientationType ( ui . getViewportBrowser ( ) ) ,
@@ -172,6 +248,18 @@ addRDMTask(TEST_COM_URL, async function ({ ui }) {
172248 "Orientation angle is 0"
173249 ) ;
174250
251+ is (
252+ await getScreenOrientationType ( iframeBrowsingContext ) ,
253+ "portrait-primary" ,
254+ "New orientation type in iframe is portrait-primary"
255+ ) ;
256+
257+ is (
258+ await getScreenOrientationAngle ( iframeBrowsingContext ) ,
259+ 0 ,
260+ "Orientation angle in iframe is 0"
261+ ) ;
262+
175263 info (
176264 "Check the orientationchange event is not dispatched when calling the command with the same orientation."
177265 ) ;
@@ -181,12 +269,17 @@ addRDMTask(TEST_COM_URL, async function ({ ui }) {
181269 waitForScreenOrientationChangeEvent =
182270 isWindowScreenOrientationChangeEventEmitted ( ui . getViewportBrowser ( ) ) ;
183271
272+ waitForOrientationChangeEventInIframe = isOrientationChangeEventEmitted (
273+ iframeBrowsingContext
274+ ) ;
275+ waitForScreenOrientationChangeEventInIframe =
276+ isWindowScreenOrientationChangeEventEmitted ( iframeBrowsingContext ) ;
277+
184278 // We're directly calling the command here as there's no way to do such action from the UI.
185279 await ui . commands . targetConfigurationCommand . updateConfiguration ( {
186280 rdmPaneOrientation : {
187281 type : "portrait-primary" ,
188282 angle : 0 ,
189- isViewportRotated : true ,
190283 } ,
191284 } ) ;
192285 is (
@@ -199,6 +292,17 @@ addRDMTask(TEST_COM_URL, async function ({ ui }) {
199292 false ,
200293 "on window.screen.orientation, change event was not dispatched after trying to set the same orientation again"
201294 ) ;
295+
296+ is (
297+ await waitForOrientationChangeEventInIframe ,
298+ false ,
299+ "orientationchange event was not dispatched in iframe after trying to set the same orientation again"
300+ ) ;
301+ is (
302+ await waitForScreenOrientationChangeEventInIframe ,
303+ false ,
304+ "on window.screen.orientation, change event was not dispatched in iframe after trying to set the same orientation again"
305+ ) ;
202306} ) ;
203307
204308function getScreenOrientationType ( browserOrBrowsingContext ) {
0 commit comments