Bug 1369815 - Add mochitest for additional display modes r=heycam draft
authorJames Willcox <snorp@snorp.net>
Thu, 10 Aug 2017 14:32:34 -0500
changeset 644920 4a2cfc7bd35503e18ecbd0fb337b3f3e94307a58
parent 644919 9d1e1bb9186e844783b408422ebb1f4e37cc537b
child 725750 6c1f937230e4a2eeb12311c01e7f9ca49c37b292
push id73589
push userbmo:snorp@snorp.net
push dateFri, 11 Aug 2017 14:50:20 +0000
reviewersheycam
bugs1369815
milestone57.0a1
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">