addon-sdk/source/test/test-hidden-frame.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4 "use strict";
michael@0 5
michael@0 6 const { Loader } = require("sdk/test/loader");
michael@0 7 const hiddenFrames = require("sdk/frame/hidden-frame");
michael@0 8 const { HiddenFrame } = hiddenFrames;
michael@0 9
michael@0 10 exports["test Frame"] = function(assert, done) {
michael@0 11 let url = "data:text/html;charset=utf-8,<!DOCTYPE%20html>";
michael@0 12
michael@0 13 let hiddenFrame = hiddenFrames.add(HiddenFrame({
michael@0 14 onReady: function () {
michael@0 15 assert.equal(this.element.contentWindow.location, "about:blank",
michael@0 16 "HiddenFrame loads about:blank by default.");
michael@0 17
michael@0 18 function onDOMReady() {
michael@0 19 hiddenFrame.element.removeEventListener("DOMContentLoaded", onDOMReady,
michael@0 20 false);
michael@0 21 assert.equal(hiddenFrame.element.contentWindow.location, url,
michael@0 22 "HiddenFrame loads the specified content.");
michael@0 23 done();
michael@0 24 }
michael@0 25
michael@0 26 this.element.addEventListener("DOMContentLoaded", onDOMReady, false);
michael@0 27 this.element.setAttribute("src", url);
michael@0 28 }
michael@0 29 }));
michael@0 30 };
michael@0 31
michael@0 32 exports["test frame removed properly"] = function(assert, done) {
michael@0 33 let url = "data:text/html;charset=utf-8,<!DOCTYPE%20html>";
michael@0 34
michael@0 35 let hiddenFrame = hiddenFrames.add(HiddenFrame({
michael@0 36 onReady: function () {
michael@0 37 let frame = this.element;
michael@0 38 assert.ok(frame.parentNode, "frame has a parent node");
michael@0 39 hiddenFrames.remove(hiddenFrame);
michael@0 40 assert.ok(!frame.parentNode, "frame no longer has a parent node");
michael@0 41 done();
michael@0 42 }
michael@0 43 }));
michael@0 44 };
michael@0 45
michael@0 46 exports["test unload detaches panels"] = function(assert, done) {
michael@0 47 let loader = Loader(module);
michael@0 48 let { add, remove, HiddenFrame } = loader.require("sdk/frame/hidden-frame");
michael@0 49 let frames = []
michael@0 50
michael@0 51 function ready() {
michael@0 52 frames.push(this.element);
michael@0 53 if (frames.length === 2) complete();
michael@0 54 }
michael@0 55
michael@0 56 add(HiddenFrame({ onReady: ready }));
michael@0 57 add(HiddenFrame({ onReady: ready }));
michael@0 58
michael@0 59 function complete() {
michael@0 60 frames.forEach(function(frame) {
michael@0 61 assert.ok(frame.parentNode, "frame is in the document");
michael@0 62 })
michael@0 63 loader.unload();
michael@0 64 frames.forEach(function(frame) {
michael@0 65 assert.ok(!frame.parentNode, "frame isn't in the document'");
michael@0 66 });
michael@0 67 done();
michael@0 68 }
michael@0 69 };
michael@0 70
michael@0 71 require("test").run(exports);

mercurial