browser/base/content/test/general/content_aboutAccounts.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/base/content/test/general/content_aboutAccounts.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,48 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +// This file is loaded as a "content script" for browser_aboutAccounts tests
     1.9 +"use strict";
    1.10 +
    1.11 +addEventListener("load", function load(event) {
    1.12 +  if (event.target != content.document) {
    1.13 +    return;
    1.14 +  }
    1.15 +//  content.document.removeEventListener("load", load, true);
    1.16 +  sendAsyncMessage("test:document:load");
    1.17 +}, true);
    1.18 +
    1.19 +addEventListener("DOMContentLoaded", function domContentLoaded(event) {
    1.20 +  removeEventListener("DOMContentLoaded", domContentLoaded, true);
    1.21 +  let iframe = content.document.getElementById("remote");
    1.22 +  iframe.addEventListener("load", function iframeLoaded(event) {
    1.23 +    if (iframe.contentWindow.location.href == "about:blank" ||
    1.24 +        event.target != iframe) {
    1.25 +      return;
    1.26 +    }
    1.27 +    iframe.removeEventListener("load", iframeLoaded, true);
    1.28 +    sendAsyncMessage("test:iframe:load", {url: iframe.getAttribute("src")});
    1.29 +  }, true);
    1.30 +}, true);
    1.31 +
    1.32 +// Return the visibility state of a list of ids.
    1.33 +addMessageListener("test:check-visibilities", function (message) {
    1.34 +  let result = {};
    1.35 +  for (let id of message.data.ids) {
    1.36 +    let elt = content.document.getElementById(id);
    1.37 +    if (elt) {
    1.38 +      let displayStyle = content.window.getComputedStyle(elt).display;
    1.39 +      if (displayStyle == 'none') {
    1.40 +        result[id] = false;
    1.41 +      } else if (displayStyle == 'block') {
    1.42 +        result[id] = true;
    1.43 +      } else {
    1.44 +        result[id] = "strange: " + displayStyle; // tests should fail!
    1.45 +      }
    1.46 +    } else {
    1.47 +      result[id] = "doesn't exist: " + id;
    1.48 +    }
    1.49 +  }
    1.50 +  sendAsyncMessage("test:check-visibilities-response", result);
    1.51 +});

mercurial