author Ed Morley <>
Fri, 30 Aug 2013 12:07:58 +0100
changeset 154053 4e359e975ae91094513b5ddc59bf8cfaa4d0f9a3
parent 135456 2251c1d2218e6ceae16695f59cd0b0c193c704cf
child 222980 38e52ef2e13136279b5b210a8a7b2a6a61364e8c
permissions -rw-r--r--
Bug 900453 - Disable test_fullscreen-api.html on OS X since it intermittently breaks the slaves & means they need a reboot. a=test-only DONTBUILD

  <title>Test for Bug 545812</title>
  <script type="application/javascript" src="/MochiKit/packed.js"></script>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  body {
    background-color: black;
<a target="_blank" href="">Mozilla Bug 545812</a>
<p id="display"></p>
<div id="content" style="display: none">

<pre id="test">
<script type="application/javascript">

/** Tests for Bug 545812 **/

// Ensure the full-screen api is enabled, and will be disabled on test exit.
SpecialPowers.setBoolPref("full-screen-api.enabled", true);

// Disable the requirement for trusted contexts only, so the tests are easier
// to write.
SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", false);

// 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 = [

var testWindow = null;
var gTestIndex = 0;

// TODO: if ever we remove these checks for XP and Lion, we should do the same
// in dom/tests/mochitest/pointerlock/test_pointerlock-api.html, which uses the same pattern.
const isWinXP = navigator.userAgent.indexOf("Windows NT 5.1") != -1;
const isOSXLion = navigator.userAgent.indexOf("Mac OS X 10.7") != -1;
const isOSXMtnLion = navigator.userAgent.indexOf("Mac OS X 10.8") != -1;

function nextTest() {
  if (isWinXP) {
    todo(false, "Can't reliably run full-screen tests on Windows XP due to bug 704010");
  if (testWindow) {
    if (isOSXLion || isOSXMtnLion) {
      // On OS X Lion, tests cause problems. Timeouts are a bad way to get around
      // the problem and may lead to future [orange], but they are the only option
      // at this point.
      SimpleTest.waitForFocus(function() { setTimeout(runNextTest, 3000); });

function runNextTest() {
  if (gTestIndex < gTestWindows.length) {
    testWindow =[gTestIndex], "", "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);
    }, false);
  } else {

if (isOSXLion || isOSXMtnLion) {
  todo(false, "Can't reliably run full-screen tests on OS X (bug 900453 comment 18 & bug 802504)");
} else {
  try {
    window.fullScreen = true;
  } catch (e) {
  is(window.fullScreen, false, "Shouldn't be able to set window fullscreen from content");