diff options
Diffstat (limited to 'tools/addon-sdk-1.12/test/test-hidden-frame.js')
-rw-r--r-- | tools/addon-sdk-1.12/test/test-hidden-frame.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tools/addon-sdk-1.12/test/test-hidden-frame.js b/tools/addon-sdk-1.12/test/test-hidden-frame.js new file mode 100644 index 0000000..cf99df5 --- /dev/null +++ b/tools/addon-sdk-1.12/test/test-hidden-frame.js @@ -0,0 +1,51 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +let tests = {}, hiddenFrames, HiddenFrame; + +tests.testFrame = function(test) { + let url = "data:text/html;charset=utf-8,<!DOCTYPE%20html>"; + test.waitUntilDone(); + let hiddenFrame = hiddenFrames.add(HiddenFrame({ + onReady: function () { + test.assertEqual(this.element.contentWindow.location, "about:blank", + "HiddenFrame loads about:blank by default."); + + function onDOMReady() { + hiddenFrame.element.removeEventListener("DOMContentLoaded", onDOMReady, + false); + test.assertEqual(hiddenFrame.element.contentWindow.location, url, + "HiddenFrame loads the specified content."); + test.done(); + } + this.element.addEventListener("DOMContentLoaded", onDOMReady, false); + this.element.setAttribute("src", url); + } + })); +}; + +let hiddenFrameSupported = true; + +try { + hiddenFrames = require("sdk/frame/hidden-frame"); + HiddenFrame = hiddenFrames.HiddenFrame; +} +catch(ex if ex.message == [ + "The hidden-frame module currently supports only Firefox and Thunderbird. ", + "In the future, we would like it to support other applications, however. ", + "Please see https://bugzilla.mozilla.org/show_bug.cgi?id=546740 for more ", + "information." + ].join("")) { + hiddenFrameSupported = false; +} + +if (hiddenFrameSupported) { + for (let test in tests) + exports[test] = tests[test]; +} +else { + exports.testHiddenFrameNotSupported = function(test) { + test.pass("The hidden-frame module is not supported on this app."); + } +} |