Bug 1369815 - Add mochitest for additional display modes r=heycam
MozReview-Commit-ID: 3ADmC1op4Sj
--- 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">