Bug 1369815 - Add mochitest for additional display modes r=heycam
authorJames Willcox <snorp@snorp.net>
Thu, 10 Aug 2017 14:32:34 -0500
changeset 376171 5bb774244a1b337e44695c8a27148a04f6c20978
parent 376170 e8428fa4fe1a69d941e74067104f852fdf049da7
child 376172 270fefa0da6dc725db6abbc0000c647079d29bd2
push id32376
push userkwierso@gmail.com
push dateWed, 23 Aug 2017 00:07:40 +0000
treeherdermozilla-central@64a45ee1731c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1369815
milestone57.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 1369815 - Add mochitest for additional display modes r=heycam MozReview-Commit-ID: 3ADmC1op4Sj
layout/style/test/chrome/test_display_mode.html
--- a/layout/style/test/chrome/test_display_mode.html
+++ b/layout/style/test/chrome/test_display_mode.html
@@ -42,16 +42,22 @@ add_task(async function() {
   function shouldApply(q) {
     ok(queryApplies(q), q + " should apply");
   }
 
   function shouldNotApply(q) {
     ok(!queryApplies(q), q + " should not apply");
   }
 
+  function setDisplayMode(mode) {
+    win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+                 .getInterface(Components.interfaces.nsIDocShell)
+                 .displayMode = mode;
+  }
+
   shouldApply("all and (display-mode: browser)");
   shouldNotApply("all and (display-mode: fullscreen)");
   shouldNotApply("all and (display-mode: standalone)");
   shouldNotApply("all and (display-mode: minimal-ui)");
 
   // Test entering the OS's fullscreen mode.
   var fullScreenEntered = waitOneEvent(win, "sizemodechange");
   synthesizeKey("VK_F11", {});
@@ -72,16 +78,28 @@ add_task(async function() {
   shouldApply("all and (display-mode: fullscreen)");
   shouldNotApply("all and (display-mode: browser)");
   fullScreenExited = waitOneEvent(document, "mozfullscreenchange");
   document.mozCancelFullScreen();
   await fullScreenExited;
   ok(!document.mozFullScreenElement, "window exited fullscreen");
   shouldNotApply("all and (display-mode: fullscreen)");
   shouldApply("all and (display-mode: browser)");
+
+  // Test entering display mode mode through docshell
+  setDisplayMode(Components.interfaces.nsIDocShell.DISPLAY_MODE_STANDALONE);
+  shouldApply("all and (display-mode: standalone)");
+  shouldNotApply("all and (display-mode: fullscreen)");
+  shouldNotApply("all and (display-mode: browser)");
+  shouldNotApply("all and (display-mode: minimal-ui)");
+
+  // Test that changes in the display mode are reflected
+  setDisplayMode(Components.interfaces.nsIDocShell.DISPLAY_MODE_MINIMAL_UI);
+  shouldApply("all and (display-mode: minimal-ui)");
+  shouldNotApply("all and (display-mode: standalone)");
 });
   </script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1104916">Mozilla Bug 1104916</a>
 <iframe id="subdoc" src="http://mochi.test:8888/tests/layout/style/test/media_queries_iframe.html"></iframe>
 <p id="display"></p>
 <div id="content" style="display: none">