Bug 1254448 part 2 - Add new test for checking window dimension.
MozReview-Commit-ID: KjBf5ATdWy4
new file mode 100644
--- /dev/null
+++ b/dom/html/test/file_fullscreen-dimensions.html
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <title>Test for Bug 1240696</title>
+ <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+</head>
+<body>
+<div id="div"></div>
+<script>
+function ok(condition, msg) {
+ opener.ok(condition, "[dimensions] " + msg);
+}
+function is(a, b, msg) {
+ opener.is(a, b, "[dimensions] " + msg);
+}
+
+var windowInnerSize, windowOuterSize, windowPosition;
+
+function begin() {
+ windowInnerSize = {width: window.innerWidth, height: window.innerHeight};
+ windowOuterSize = {width: window.outerWidth, height: window.outerHeight};
+ windowPosition = {x: window.screenX, y: window.screenY};
+ document.addEventListener("fullscreenchange", enteredFullscreen);
+ document.getElementById("div").requestFullscreen();
+}
+
+function enteredFullscreen() {
+ document.removeEventListener("fullscreenchange", enteredFullscreen);
+ is(window.innerWidth, screen.width,
+ "window.innerWidth should match screen.width");
+ is(window.innerHeight, screen.height,
+ "window.innerHeight should match screen.height");
+ is(window.outerWidth, screen.width,
+ "window.outerWidth should match screen.width");
+ is(window.outerHeight, screen.height,
+ "window.outerHeight should match screen.height");
+ is(window.screenX, 0, "window.screenX should be zero");
+ is(window.screenY, 0, "window.screenY should be zero");
+ document.addEventListener("fullscreenchange", exitedFullscreen);
+ SimpleTest.executeSoon(() => document.exitFullscreen());
+}
+
+function exitedFullscreen() {
+ document.removeEventListener("fullscreenchange", exitedFullscreen);
+ is(window.innerWidth, windowInnerSize.width,
+ "window.innerWidth should be restored to the original value");
+ is(window.innerHeight, windowInnerSize.height,
+ "window.innerHeight should be restored to the original value");
+ is(window.outerWidth, windowOuterSize.width,
+ "window.outerWidth should be restored to the original value");
+ is(window.outerHeight, windowOuterSize.height,
+ "window.outerHeight should be restored to the original value");
+ is(window.screenX, windowPosition.x,
+ "window.screenX should be restored to the original value");
+ is(window.screenY, windowPosition.y,
+ "window.screenY should be restored to the original value");
+ opener.nextTest();
+}
+</script>
+</body>
+</html>
--- a/dom/html/test/mochitest.ini
+++ b/dom/html/test/mochitest.ini
@@ -45,16 +45,17 @@ support-files =
file_bug417760.png
file_bug893537.html
file_formSubmission_img.jpg
file_formSubmission_text.txt
file_fullscreen-api.html
file_fullscreen-backdrop.html
file_fullscreen-denied-inner.html
file_fullscreen-denied.html
+ file_fullscreen-dimensions.html
file_fullscreen-esc-exit-inner.html
file_fullscreen-esc-exit.html
file_fullscreen-hidden.html
file_fullscreen-multiple-inner.html
file_fullscreen-multiple.html
file_fullscreen-navigation.html
file_fullscreen-nested.html
file_fullscreen-prefixed.html
--- a/dom/html/test/test_fullscreen-api.html
+++ b/dom/html/test/test_fullscreen-api.html
@@ -24,16 +24,17 @@
/** Tests for Bug 545812 **/
SimpleTest.requestFlakyTimeout("untriaged");
SimpleTest.expectAssertions(0, 1);
// Run the tests which go full-screen in new windows, as mochitests normally
// run in an iframe, which by default will not have the allowfullscreen
// attribute set, so full-screen won't work.
var gTestWindows = [
+ "file_fullscreen-dimensions.html",
"file_fullscreen-multiple.html",
"file_fullscreen-rollback.html",
"file_fullscreen-esc-exit.html",
"file_fullscreen-denied.html",
"file_fullscreen-api.html",
"file_fullscreen-plugins.html",
"file_fullscreen-hidden.html",
"file_fullscreen-svg-element.html",
@@ -58,17 +59,18 @@ function nextTest() {
testWindow.close();
}
SimpleTest.executeSoon(runNextTest);
}
function runNextTest() {
if (gTestIndex < gTestWindows.length) {
info("Run test " + gTestWindows[gTestIndex]);
- testWindow = window.open(gTestWindows[gTestIndex], "", "width=500,height=500");
+ testWindow = window.open(gTestWindows[gTestIndex], "",
+ "left=100,top=100,width=500,height=500");
// We'll wait for the window to load, then make sure our window is refocused
// before starting the test, which will get kicked off on "focus".
// This ensures that we're essentially back on the primary "desktop" on
// OS X Lion before we run the test.
testWindow.addEventListener("load", function onload() {
testWindow.removeEventListener("load", onload, false);
SimpleTest.waitForFocus(function() {
SimpleTest.waitForFocus(testWindow.begin, testWindow);