Bug 1502248 - Add test for GeckoSession.ContentDelegate.onFullScreen() r=snorp
authorRandall Barker <rbarker@mozilla.com>
Thu, 01 Nov 2018 18:29:33 +0000
changeset 444005 d22681de62e7e67e4e61cc112b4f4da30b2f5390
parent 444004 792fd0ab86d1c254369b5003cac95dc19590a9d4
child 444006 7005723d76c7d3215255c75f6eddedf627b153a1
push id34978
push userccoroiu@mozilla.com
push dateFri, 02 Nov 2018 05:09:30 +0000
treeherdermozilla-central@4408e5678aa6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1502248
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1502248 - Add test for GeckoSession.ContentDelegate.onFullScreen() r=snorp Differential Revision: https://phabricator.services.mozilla.com/D9981
mobile/android/geckoview/src/androidTest/assets/www/fullscreen.html
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/BaseSessionTest.kt
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ContentDelegateTest.kt
new file mode 100644
--- /dev/null
+++ b/mobile/android/geckoview/src/androidTest/assets/www/fullscreen.html
@@ -0,0 +1,6 @@
+<html>
+    <head><title>Fullscreen</title></head>
+    <body>
+        <div id="fullscreen">Fullscreen Div</div>
+    </body>
+</html>
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/BaseSessionTest.kt
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/BaseSessionTest.kt
@@ -36,16 +36,17 @@ open class BaseSessionTest(noErrorCollec
         const val LOREM_IPSUM_HTML_PATH = "/assets/www/loremIpsum.html"
         const val NEW_SESSION_CHILD_HTML_PATH = "/assets/www/newSession_child.html"
         const val NEW_SESSION_HTML_PATH = "/assets/www/newSession.html"
         const val POPUP_HTML_PATH = "/assets/www/popup.html"
         const val SAVE_STATE_PATH = "/assets/www/saveState.html"
         const val TITLE_CHANGE_HTML_PATH = "/assets/www/titleChange.html"
         const val TRACKERS_PATH = "/assets/www/trackers.html"
         const val UNKNOWN_HOST_URI = "http://www.test.invalid/"
+        const val FULLSCREEN_PATH = "/assets/www/fullscreen.html"
     }
 
     @get:Rule val sessionRule = GeckoSessionTestRule()
 
     @get:Rule val errors = ErrorCollector()
 
     val mainSession get() = sessionRule.session
 
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ContentDelegateTest.kt
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ContentDelegateTest.kt
@@ -440,9 +440,43 @@ class ContentDelegateTest : BaseSessionT
                            notification,
                            equalTo(GeckoSession.TextInputDelegate.AUTO_FILL_NOTIFY_VIEW_EXITED))
                 assertThat("ID should be valid", virtualId, not(equalTo(View.NO_ID)))
             }
         })
         assertThat("Should not have focused field",
                    countAutoFillNodes({ it.isFocused }), equalTo(0))
     }
+
+    private fun goFullscreen() {
+        sessionRule.setPrefsUntilTestEnd(mapOf("full-screen-api.allow-trusted-requests-only" to false))
+        mainSession.loadTestPath(FULLSCREEN_PATH)
+        mainSession.waitForPageStop()
+        mainSession.evaluateJS("$('#fullscreen').requestFullscreen()")
+        sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
+            override  fun onFullScreen(session: GeckoSession, fullScreen: Boolean) {
+                assertThat("Div went fullscreen", fullScreen, equalTo(true))
+            }
+        })
+    }
+
+    private fun waitForFullscreenExit() {
+        sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
+            override  fun onFullScreen(session: GeckoSession, fullScreen: Boolean) {
+                assertThat("Div went fullscreen", fullScreen, equalTo(false))
+            }
+        })
+    }
+
+    @WithDevToolsAPI
+    @Test fun fullscreen() {
+        goFullscreen()
+        mainSession.evaluateJS("document.exitFullscreen()")
+        waitForFullscreenExit()
+    }
+
+    @WithDevToolsAPI
+    @Test fun sessionExitFullscreen() {
+        goFullscreen()
+        mainSession.exitFullScreen()
+        waitForFullscreenExit()
+    }
 }