Bug 1004395 - Uplift Add-on SDK to Firefox r=me
This commit is contained in:
@@ -50,7 +50,8 @@ function PlainTextConsole(print, innerID) {
|
|||||||
prefix: self.name + ": ",
|
prefix: self.name + ": ",
|
||||||
maxLogLevel: logLevel,
|
maxLogLevel: logLevel,
|
||||||
dump: print,
|
dump: print,
|
||||||
innerID: innerID
|
innerID: innerID,
|
||||||
|
consoleID: "addon/" + self.id
|
||||||
};
|
};
|
||||||
let console = new ConsoleAPI(consoleOptions);
|
let console = new ConsoleAPI(consoleOptions);
|
||||||
|
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ const ContentWorker = Object.freeze({
|
|||||||
"function, which works the same. Replace calls to `on()` " +
|
"function, which works the same. Replace calls to `on()` " +
|
||||||
"with calls to `self.on()`" +
|
"with calls to `self.on()`" +
|
||||||
"For more info on `self.on`, see " +
|
"For more info on `self.on`, see " +
|
||||||
"<https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/addon-development/web-content.html>.");
|
"<https://developer.mozilla.org/en-US/Add-ons/SDK/Guides/Content_Scripts/using_postMessage>.");
|
||||||
return self.on.apply(null, arguments);
|
return self.on.apply(null, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -309,7 +309,7 @@ const ContentWorker = Object.freeze({
|
|||||||
"definitions with calls to `self.on('message', " +
|
"definitions with calls to `self.on('message', " +
|
||||||
"function (data){})`. " +
|
"function (data){})`. " +
|
||||||
"For more info on `self.on`, see " +
|
"For more info on `self.on`, see " +
|
||||||
"<https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/addon-development/web-content.html>.");
|
"<https://developer.mozilla.org/en-US/Add-ons/SDK/Guides/Content_Scripts/using_postMessage>.");
|
||||||
onMessage = v;
|
onMessage = v;
|
||||||
if (typeof onMessage == "function")
|
if (typeof onMessage == "function")
|
||||||
self.on("message", onMessage);
|
self.on("message", onMessage);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const events = require('../system/events');
|
|||||||
const { getInnerId } = require("../window/utils");
|
const { getInnerId } = require("../window/utils");
|
||||||
const { WorkerSandbox } = require('./sandbox');
|
const { WorkerSandbox } = require('./sandbox');
|
||||||
const { getTabForWindow } = require('../tabs/helpers');
|
const { getTabForWindow } = require('../tabs/helpers');
|
||||||
|
const { isPrivate } = require('../private-browsing/utils');
|
||||||
|
|
||||||
// A weak map of workers to hold private attributes that
|
// A weak map of workers to hold private attributes that
|
||||||
// should not be exposed
|
// should not be exposed
|
||||||
@@ -37,7 +38,7 @@ const ERR_FROZEN = "The page is currently hidden and can no longer be used " +
|
|||||||
/**
|
/**
|
||||||
* Message-passing facility for communication between code running
|
* Message-passing facility for communication between code running
|
||||||
* in the content and add-on process.
|
* in the content and add-on process.
|
||||||
* @see https://addons.mozilla.org/en-US/developers/docs/sdk/latest/modules/sdk/content/worker.html
|
* @see https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/content_worker
|
||||||
*/
|
*/
|
||||||
const Worker = Class({
|
const Worker = Class({
|
||||||
implements: [EventTarget],
|
implements: [EventTarget],
|
||||||
@@ -186,6 +187,8 @@ detach.define(Worker, function (worker, reason) {
|
|||||||
model.inited = false;
|
model.inited = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
isPrivate.define(Worker, ({ tab }) => isPrivate(tab));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells content worker to unload itself and
|
* Tells content worker to unload itself and
|
||||||
* removes all the references from itself.
|
* removes all the references from itself.
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const { Trait } = require('../deprecated/traits');
|
|||||||
const { iteratorSymbol } = require('../util/iteration');
|
const { iteratorSymbol } = require('../util/iteration');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see https://jetpack.mozillalabs.com/sdk/latest/docs/#module/api-utils/list
|
* @see https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/util_list
|
||||||
*/
|
*/
|
||||||
const Iterable = Trait.compose({
|
const Iterable = Trait.compose({
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ const WorkerSandbox = EventEmitter.compose({
|
|||||||
/**
|
/**
|
||||||
* Message-passing facility for communication between code running
|
* Message-passing facility for communication between code running
|
||||||
* in the content and add-on process.
|
* in the content and add-on process.
|
||||||
* @see https://addons.mozilla.org/en-US/developers/docs/sdk/latest/modules/sdk/content/worker.html
|
* @see https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/content_worker
|
||||||
*/
|
*/
|
||||||
const Worker = EventEmitter.compose({
|
const Worker = EventEmitter.compose({
|
||||||
on: Trait.required,
|
on: Trait.required,
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ module.metadata = {
|
|||||||
const memory = require('./memory');
|
const memory = require('./memory');
|
||||||
var timer = require("../timers");
|
var timer = require("../timers");
|
||||||
var cfxArgs = require("@test/options");
|
var cfxArgs = require("@test/options");
|
||||||
|
const { getTabs, getURI } = require("../tabs/utils");
|
||||||
|
const { windows, isBrowser } = require("../window/utils");
|
||||||
|
|
||||||
exports.findAndRunTests = function findAndRunTests(options) {
|
exports.findAndRunTests = function findAndRunTests(options) {
|
||||||
var TestFinder = require("./unit-test-finder").TestFinder;
|
var TestFinder = require("./unit-test-finder").TestFinder;
|
||||||
@@ -278,14 +280,39 @@ TestRunner.prototype = {
|
|||||||
this.failed++;
|
this.failed++;
|
||||||
this.test.failed++;
|
this.test.failed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let wins = windows(null, { includePrivate: true });
|
||||||
|
let tabs = [];
|
||||||
|
for (let win of wins.filter(isBrowser)) {
|
||||||
|
for (let tab of getTabs(win)) {
|
||||||
|
tabs.push(tab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wins.length != 1)
|
||||||
|
this.fail("Should not be any unexpected windows open");
|
||||||
|
if (tabs.length != 1)
|
||||||
|
this.fail("Should not be any unexpected tabs open");
|
||||||
|
if (tabs.length != 1 || wins.length != 1) {
|
||||||
|
console.log("Windows open:");
|
||||||
|
for (let win of wins) {
|
||||||
|
if (isBrowser(win)) {
|
||||||
|
tabs = getTabs(win);
|
||||||
|
console.log(win.location + " - " + tabs.map(getURI).join(", "));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log(win.location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.testRunSummary.push({
|
this.testRunSummary.push({
|
||||||
name: this.test.name,
|
name: this.test.name,
|
||||||
passed: this.test.passed,
|
passed: this.test.passed,
|
||||||
failed: this.test.failed,
|
failed: this.test.failed,
|
||||||
errors: [error for (error in this.test.errors)].join(", ")
|
errors: [error for (error in this.test.errors)].join(", ")
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.onDone !== null) {
|
if (this.onDone !== null) {
|
||||||
var onDone = this.onDone;
|
var onDone = this.onDone;
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const { windowIterator } = require('./deprecated/window-utils');
|
|||||||
const { isBrowser, getFrames } = require('./window/utils');
|
const { isBrowser, getFrames } = require('./window/utils');
|
||||||
const { getTabs, getTabContentWindow, getTabForContentWindow,
|
const { getTabs, getTabContentWindow, getTabForContentWindow,
|
||||||
getURI: getTabURI } = require('./tabs/utils');
|
getURI: getTabURI } = require('./tabs/utils');
|
||||||
const { ignoreWindow } = require('sdk/private-browsing/utils');
|
const { ignoreWindow } = require('./private-browsing/utils');
|
||||||
const { Style } = require("./stylesheet/style");
|
const { Style } = require("./stylesheet/style");
|
||||||
const { attach, detach } = require("./content/mod");
|
const { attach, detach } = require("./content/mod");
|
||||||
const { has, hasAny } = require("./util/array");
|
const { has, hasAny } = require("./util/array");
|
||||||
@@ -167,22 +167,8 @@ function onContentWindow({ subject: document }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns all tabs on all currently opened windows
|
|
||||||
function getAllTabs() {
|
|
||||||
let tabs = [];
|
|
||||||
// Iterate over all chrome windows
|
|
||||||
for (let window in windowIterator()) {
|
|
||||||
if (!isBrowser(window))
|
|
||||||
continue;
|
|
||||||
tabs = tabs.concat(getTabs(window));
|
|
||||||
}
|
|
||||||
return tabs;
|
|
||||||
}
|
|
||||||
|
|
||||||
function applyOnExistingDocuments (mod) {
|
function applyOnExistingDocuments (mod) {
|
||||||
let tabs = getAllTabs();
|
getTabs().forEach(tab => {
|
||||||
|
|
||||||
tabs.forEach(function (tab) {
|
|
||||||
// Fake a newly created document
|
// Fake a newly created document
|
||||||
let window = getTabContentWindow(tab);
|
let window = getTabContentWindow(tab);
|
||||||
if (has(mod.attachTo, "top") && mod.include.matchesAny(getTabURI(tab)))
|
if (has(mod.attachTo, "top") && mod.include.matchesAny(getTabURI(tab)))
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ function register(factory) {
|
|||||||
throw new Error("xpcom.register() expect a Factory instance.\n" +
|
throw new Error("xpcom.register() expect a Factory instance.\n" +
|
||||||
"Please refactor your code to new xpcom module if you" +
|
"Please refactor your code to new xpcom module if you" +
|
||||||
" are repacking an addon from SDK <= 1.5:\n" +
|
" are repacking an addon from SDK <= 1.5:\n" +
|
||||||
"https://addons.mozilla.org/en-US/developers/docs/sdk/latest/packages/api-utils/xpcom.html");
|
"https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/platform_xpcom");
|
||||||
}
|
}
|
||||||
|
|
||||||
registerFactory(factory.id, factory.description, factory.contract, factory);
|
registerFactory(factory.id, factory.description, factory.contract, factory);
|
||||||
|
|||||||
@@ -7,13 +7,10 @@ module.metadata = {
|
|||||||
"stability": "stable"
|
"stability": "stable"
|
||||||
};
|
};
|
||||||
|
|
||||||
const { Ci } = require('chrome');
|
const { setMode, getMode, on: onStateChange, isPrivate } = require('./private-browsing/utils');
|
||||||
const { setMode, getMode, on: onStateChange, isPermanentPrivateBrowsing } = require('./private-browsing/utils');
|
|
||||||
const { isWindowPrivate } = require('./window/utils');
|
|
||||||
const { emit, on, once, off } = require('./event/core');
|
const { emit, on, once, off } = require('./event/core');
|
||||||
const { when: unload } = require('./system/unload');
|
const { when: unload } = require('./system/unload');
|
||||||
const { deprecateUsage, deprecateFunction, deprecateEvent } = require('./util/deprecate');
|
const { deprecateFunction, deprecateEvent } = require('./util/deprecate');
|
||||||
const { getOwnerWindow } = require('./private-browsing/window/utils');
|
|
||||||
|
|
||||||
onStateChange('start', function onStart() {
|
onStateChange('start', function onStart() {
|
||||||
emit(exports, 'start');
|
emit(exports, 'start');
|
||||||
@@ -39,48 +36,7 @@ exports.removeListener = deprecateEvents(function removeListener(type, listener)
|
|||||||
off(exports, type, listener);
|
off(exports, type, listener);
|
||||||
});
|
});
|
||||||
|
|
||||||
exports.isPrivate = function(thing) {
|
exports.isPrivate = isPrivate;
|
||||||
// if thing is defined, and we can find a window for it
|
|
||||||
// then check if the window is private
|
|
||||||
if (!!thing) {
|
|
||||||
// if the thing is a window, and the window is private
|
|
||||||
// then return true
|
|
||||||
if (isWindowPrivate(thing)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// does the thing have an associated tab?
|
|
||||||
// page-mod instances do..
|
|
||||||
if (thing.tab) {
|
|
||||||
let tabWindow = getOwnerWindow(thing.tab);
|
|
||||||
if (tabWindow) {
|
|
||||||
let isThingPrivate = isWindowPrivate(tabWindow);
|
|
||||||
if (isThingPrivate)
|
|
||||||
return isThingPrivate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// can we find an associated window?
|
|
||||||
let window = getOwnerWindow(thing);
|
|
||||||
if (window)
|
|
||||||
return isWindowPrivate(window);
|
|
||||||
|
|
||||||
try {
|
|
||||||
let { isChannelPrivate } = thing.QueryInterface(Ci.nsIPrivateBrowsingChannel);
|
|
||||||
if (isChannelPrivate)
|
|
||||||
return true;
|
|
||||||
} catch(e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if the post pwpb, global pb service is enabled.
|
|
||||||
if (isPermanentPrivateBrowsing())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// if we get here, and global private browsing
|
|
||||||
// is available, and it is true, then return
|
|
||||||
// true otherwise false is returned here
|
|
||||||
return getMode();
|
|
||||||
};
|
|
||||||
|
|
||||||
function deprecateEvents(func) deprecateEvent(
|
function deprecateEvents(func) deprecateEvent(
|
||||||
func,
|
func,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const { deprecateFunction } = require('../util/deprecate');
|
|||||||
const { isOneOf, is, satisfiesVersion, version } = require('../system/xul-app');
|
const { isOneOf, is, satisfiesVersion, version } = require('../system/xul-app');
|
||||||
const { isWindowPrivate } = require('../window/utils');
|
const { isWindowPrivate } = require('../window/utils');
|
||||||
const { isPrivateBrowsingSupported } = require('../self');
|
const { isPrivateBrowsingSupported } = require('../self');
|
||||||
|
const { dispatcher } = require("../util/dispatcher");
|
||||||
|
|
||||||
let deferredEmit = defer(emit);
|
let deferredEmit = defer(emit);
|
||||||
let pbService;
|
let pbService;
|
||||||
@@ -53,10 +54,11 @@ let isWindowPBSupported = exports.isWindowPBSupported =
|
|||||||
let isTabPBSupported = exports.isTabPBSupported =
|
let isTabPBSupported = exports.isTabPBSupported =
|
||||||
!pbService && !!PrivateBrowsingUtils && is('Fennec') && satisfiesVersion(version, '>=20.0*');
|
!pbService && !!PrivateBrowsingUtils && is('Fennec') && satisfiesVersion(version, '>=20.0*');
|
||||||
|
|
||||||
exports.isPermanentPrivateBrowsing = function() {
|
function isPermanentPrivateBrowsing() {
|
||||||
return !!(PrivateBrowsingUtils && PrivateBrowsingUtils.permanentPrivateBrowsing);
|
return !!(PrivateBrowsingUtils && PrivateBrowsingUtils.permanentPrivateBrowsing);
|
||||||
}
|
}
|
||||||
|
exports.isPermanentPrivateBrowsing = isPermanentPrivateBrowsing;
|
||||||
|
|
||||||
function ignoreWindow(window) {
|
function ignoreWindow(window) {
|
||||||
return !isPrivateBrowsingSupported && isWindowPrivate(window) && !isGlobalPBSupported;
|
return !isPrivateBrowsingSupported && isWindowPrivate(window) && !isGlobalPBSupported;
|
||||||
}
|
}
|
||||||
@@ -90,14 +92,25 @@ exports.setMode = deprecateFunction(
|
|||||||
);
|
);
|
||||||
|
|
||||||
let getMode = function getMode(chromeWin) {
|
let getMode = function getMode(chromeWin) {
|
||||||
if (isWindowPrivate(chromeWin))
|
if (chromeWin !== undefined && isWindowPrivate(chromeWin))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// default
|
// default
|
||||||
return pbService ? pbService.privateBrowsingEnabled : false;
|
return isGlobalPrivateBrowsing();
|
||||||
};
|
};
|
||||||
exports.getMode = getMode;
|
exports.getMode = getMode;
|
||||||
|
|
||||||
|
function isGlobalPrivateBrowsing() {
|
||||||
|
return pbService ? pbService.privateBrowsingEnabled : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isPrivate = dispatcher("isPrivate");
|
||||||
|
isPrivate.when(isPermanentPrivateBrowsing, _ => true);
|
||||||
|
isPrivate.when(x => x instanceof Ci.nsIDOMWindow, isWindowPrivate);
|
||||||
|
isPrivate.when(x => Ci.nsIPrivateBrowsingChannel && x instanceof Ci.nsIPrivateBrowsingChannel, x => x.isChannelPrivate);
|
||||||
|
isPrivate.define(isGlobalPrivateBrowsing);
|
||||||
|
exports.isPrivate = isPrivate;
|
||||||
|
|
||||||
exports.on = on.bind(null, exports);
|
exports.on = on.bind(null, exports);
|
||||||
|
|
||||||
// Make sure listeners are cleaned up.
|
// Make sure listeners are cleaned up.
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
/* 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/. */
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
module.metadata = {
|
|
||||||
'stability': 'unstable'
|
|
||||||
};
|
|
||||||
|
|
||||||
const privateNS = require('../../core/namespace').ns();
|
|
||||||
|
|
||||||
function getOwnerWindow(thing) {
|
|
||||||
try {
|
|
||||||
// check for and return associated window
|
|
||||||
let fn = (privateNS(thing.prototype) || privateNS(thing) || {}).getOwnerWindow;
|
|
||||||
|
|
||||||
if (fn)
|
|
||||||
return fn.apply(fn, [thing].concat(arguments));
|
|
||||||
}
|
|
||||||
// stuff like numbers and strings throw errors with namespaces
|
|
||||||
catch(e) {}
|
|
||||||
// default
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
getOwnerWindow.define = function(Type, fn) {
|
|
||||||
privateNS(Type.prototype).getOwnerWindow = fn;
|
|
||||||
}
|
|
||||||
|
|
||||||
getOwnerWindow.implement = function(instance, fn) {
|
|
||||||
privateNS(instance).getOwnerWindow = fn;
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.getOwnerWindow = getOwnerWindow;
|
|
||||||
@@ -11,7 +11,8 @@ const { activateTab, getTabTitle, setTabTitle, closeTab, getTabURL, getTabConten
|
|||||||
getTabForBrowser,
|
getTabForBrowser,
|
||||||
setTabURL, getOwnerWindow, getTabContentType, getTabId } = require('./utils');
|
setTabURL, getOwnerWindow, getTabContentType, getTabId } = require('./utils');
|
||||||
const { emit } = require('../event/core');
|
const { emit } = require('../event/core');
|
||||||
const { getOwnerWindow: getPBOwnerWindow } = require('../private-browsing/window/utils');
|
const { isPrivate } = require('../private-browsing/utils');
|
||||||
|
const { isWindowPrivate } = require('../window/utils');
|
||||||
const { when: unload } = require('../system/unload');
|
const { when: unload } = require('../system/unload');
|
||||||
const { viewFor } = require('../view/core');
|
const { viewFor } = require('../view/core');
|
||||||
const { EVENTS } = require('./events');
|
const { EVENTS } = require('./events');
|
||||||
@@ -240,6 +241,6 @@ function onTabClose(event) {
|
|||||||
cleanupTab(this);
|
cleanupTab(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
getPBOwnerWindow.define(Tab, function(tab) {
|
isPrivate.implement(Tab, tab => {
|
||||||
return getTabContentWindow(tabNS(tab).tab);
|
return isWindowPrivate(getTabContentWindow(tabNS(tab).tab));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,11 +12,13 @@ const { getThumbnailURIForWindow } = require("../content/thumbnail");
|
|||||||
const { getFaviconURIForLocation } = require("../io/data");
|
const { getFaviconURIForLocation } = require("../io/data");
|
||||||
const { activateTab, getOwnerWindow, getBrowserForTab, getTabTitle, setTabTitle,
|
const { activateTab, getOwnerWindow, getBrowserForTab, getTabTitle, setTabTitle,
|
||||||
getTabURL, setTabURL, getTabContentType, getTabId } = require('./utils');
|
getTabURL, setTabURL, getTabContentType, getTabId } = require('./utils');
|
||||||
const { getOwnerWindow: getPBOwnerWindow } = require('../private-browsing/window/utils');
|
const { isPrivate } = require('../private-browsing/utils');
|
||||||
|
const { isWindowPrivate } = require('../window/utils');
|
||||||
const viewNS = require('../core/namespace').ns();
|
const viewNS = require('../core/namespace').ns();
|
||||||
const { deprecateUsage } = require('../util/deprecate');
|
const { deprecateUsage } = require('../util/deprecate');
|
||||||
const { getURL } = require('../url/utils');
|
const { getURL } = require('../url/utils');
|
||||||
const { viewFor } = require('../view/core');
|
const { viewFor } = require('../view/core');
|
||||||
|
const { observer } = require('./observer');
|
||||||
|
|
||||||
// Array of the inner instances of all the wrapped tabs.
|
// Array of the inner instances of all the wrapped tabs.
|
||||||
const TABS = [];
|
const TABS = [];
|
||||||
@@ -64,8 +66,8 @@ const TabTrait = Trait.compose(EventEmitter, {
|
|||||||
this.pin();
|
this.pin();
|
||||||
|
|
||||||
viewNS(this._public).tab = this._tab;
|
viewNS(this._public).tab = this._tab;
|
||||||
getPBOwnerWindow.implement(this._public, getChromeTab);
|
|
||||||
viewFor.implement(this._public, getTabView);
|
viewFor.implement(this._public, getTabView);
|
||||||
|
isPrivate.implement(this._public, tab => isWindowPrivate(getChromeTab(tab)));
|
||||||
|
|
||||||
// Add tabs to getURL method
|
// Add tabs to getURL method
|
||||||
getURL.implement(this._public, (function (obj) this._public.url).bind(this));
|
getURL.implement(this._public, (function (obj) this._public.url).bind(this));
|
||||||
@@ -256,8 +258,12 @@ const TabTrait = Trait.compose(EventEmitter, {
|
|||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (callback)
|
if (callback) {
|
||||||
this.once(EVENTS.close.name, callback);
|
if (this.window.tabs.activeTab && (this.window.tabs.activeTab.id == this.id))
|
||||||
|
observer.once('select', callback);
|
||||||
|
else
|
||||||
|
this.once(EVENTS.close.name, callback);
|
||||||
|
}
|
||||||
this._window.gBrowser.removeTab(this._tab);
|
this._window.gBrowser.removeTab(this._tab);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -81,9 +81,9 @@ exports.getTabContainer = getTabContainer;
|
|||||||
*/
|
*/
|
||||||
function getTabs(window) {
|
function getTabs(window) {
|
||||||
if (arguments.length === 0) {
|
if (arguments.length === 0) {
|
||||||
return getWindows().filter(isBrowser).reduce(function(tabs, window) {
|
return getWindows().
|
||||||
return tabs.concat(getTabs(window))
|
filter(isBrowser).
|
||||||
}, []);
|
reduce((tabs, window) => tabs.concat(getTabs(window)), []);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fennec
|
// fennec
|
||||||
@@ -91,7 +91,7 @@ function getTabs(window) {
|
|||||||
return window.BrowserApp.tabs;
|
return window.BrowserApp.tabs;
|
||||||
|
|
||||||
// firefox - default
|
// firefox - default
|
||||||
return Array.slice(getTabContainer(window).children);
|
return Array.filter(getTabContainer(window).children, function(t) !t.closing);
|
||||||
}
|
}
|
||||||
exports.getTabs = getTabs;
|
exports.getTabs = getTabs;
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,10 @@ const { on, off, once } = require('../event/core');
|
|||||||
const { method } = require('../lang/functional');
|
const { method } = require('../lang/functional');
|
||||||
const { getWindowTitle } = require('./utils');
|
const { getWindowTitle } = require('./utils');
|
||||||
const unload = require('../system/unload');
|
const unload = require('../system/unload');
|
||||||
const { isWindowPrivate } = require('../window/utils');
|
|
||||||
const { EventTarget } = require('../event/target');
|
const { EventTarget } = require('../event/target');
|
||||||
const { getOwnerWindow: getPBOwnerWindow } = require('../private-browsing/window/utils');
|
const { isPrivate } = require('../private-browsing/utils');
|
||||||
|
const { isWindowPrivate } = require('../window/utils');
|
||||||
const { viewFor } = require('../view/core');
|
const { viewFor } = require('../view/core');
|
||||||
const { deprecateUsage } = require('../util/deprecate');
|
|
||||||
|
|
||||||
const ERR_FENNEC_MSG = 'This method is not yet supported by Fennec, consider using require("sdk/tabs") instead';
|
const ERR_FENNEC_MSG = 'This method is not yet supported by Fennec, consider using require("sdk/tabs") instead';
|
||||||
|
|
||||||
@@ -38,18 +37,11 @@ const BrowserWindow = Class({
|
|||||||
get activeTab() require('../tabs').activeTab,
|
get activeTab() require('../tabs').activeTab,
|
||||||
on: method(on),
|
on: method(on),
|
||||||
removeListener: method(off),
|
removeListener: method(off),
|
||||||
once: method(once),
|
once: method(once)
|
||||||
get isPrivateBrowsing() {
|
|
||||||
deprecateUsage('`browserWindow.isPrivateBrowsing` is deprecated, please ' +
|
|
||||||
'consider using ' +
|
|
||||||
'`require("sdk/private-browsing").isPrivate(browserWindow)` ' +
|
|
||||||
'instead.');
|
|
||||||
return isWindowPrivate(windowNS(this).window);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
exports.BrowserWindow = BrowserWindow;
|
exports.BrowserWindow = BrowserWindow;
|
||||||
|
|
||||||
const getWindowView = window => windowNS(window).window;
|
const getWindowView = window => windowNS(window).window;
|
||||||
|
|
||||||
getPBOwnerWindow.define(BrowserWindow, getWindowView);
|
isPrivate.define(BrowserWindow, window => isWindowPrivate(windowNS(this).window));
|
||||||
viewFor.define(BrowserWindow, getWindowView);
|
viewFor.define(BrowserWindow, getWindowView);
|
||||||
|
|||||||
@@ -10,18 +10,18 @@ const { Cc, Ci, Cr } = require('chrome'),
|
|||||||
{ WindowTabs, WindowTabTracker } = require('./tabs-firefox'),
|
{ WindowTabs, WindowTabTracker } = require('./tabs-firefox'),
|
||||||
{ WindowDom } = require('./dom'),
|
{ WindowDom } = require('./dom'),
|
||||||
{ WindowLoader } = require('./loader'),
|
{ WindowLoader } = require('./loader'),
|
||||||
{ isBrowser, getWindowDocShell, windows: windowIterator } = require('../window/utils'),
|
{ isBrowser, getWindowDocShell,
|
||||||
|
windows: windowIterator, isWindowPrivate } = require('../window/utils'),
|
||||||
{ Options } = require('../tabs/common'),
|
{ Options } = require('../tabs/common'),
|
||||||
apiUtils = require('../deprecated/api-utils'),
|
apiUtils = require('../deprecated/api-utils'),
|
||||||
unload = require('../system/unload'),
|
unload = require('../system/unload'),
|
||||||
windowUtils = require('../deprecated/window-utils'),
|
windowUtils = require('../deprecated/window-utils'),
|
||||||
{ WindowTrackerTrait } = windowUtils,
|
{ WindowTrackerTrait } = windowUtils,
|
||||||
{ ns } = require('../core/namespace'),
|
{ ns } = require('../core/namespace'),
|
||||||
{ observer: windowObserver } = require('./observer'),
|
{ observer: windowObserver } = require('./observer');
|
||||||
{ getOwnerWindow } = require('../private-browsing/window/utils');
|
|
||||||
const { windowNS } = require('../window/namespace');
|
const { windowNS } = require('../window/namespace');
|
||||||
const { isPrivateBrowsingSupported } = require('../self');
|
const { isPrivateBrowsingSupported } = require('../self');
|
||||||
const { ignoreWindow } = require('sdk/private-browsing/utils');
|
const { ignoreWindow, isPrivate } = require('sdk/private-browsing/utils');
|
||||||
const { viewFor } = require('../view/core');
|
const { viewFor } = require('../view/core');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,7 +76,8 @@ const BrowserWindowTrait = Trait.compose(
|
|||||||
this._load();
|
this._load();
|
||||||
|
|
||||||
windowNS(this._public).window = this._window;
|
windowNS(this._public).window = this._window;
|
||||||
getOwnerWindow.implement(this._public, getChromeWindow);
|
|
||||||
|
isPrivate.implement(this._public, window => isWindowPrivate(getChromeWindow(window)));
|
||||||
viewFor.implement(this._public, getChromeWindow);
|
viewFor.implement(this._public, getChromeWindow);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ const { notifyObservers } = Cc['@mozilla.org/observer-service;1'].
|
|||||||
getService(Ci.nsIObserverService);
|
getService(Ci.nsIObserverService);
|
||||||
const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
|
const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
|
||||||
const { Reflect } = Cu.import("resource://gre/modules/reflect.jsm", {});
|
const { Reflect } = Cu.import("resource://gre/modules/reflect.jsm", {});
|
||||||
const { console } = Cu.import("resource://gre/modules/devtools/Console.jsm");
|
const { ConsoleAPI } = Cu.import("resource://gre/modules/devtools/Console.jsm");
|
||||||
const { join: pathJoin, normalize, dirname } = Cu.import("resource://gre/modules/osfile/ospath_unix.jsm");
|
const { join: pathJoin, normalize, dirname } = Cu.import("resource://gre/modules/osfile/ospath_unix.jsm");
|
||||||
|
|
||||||
// Define some shortcuts.
|
// Define some shortcuts.
|
||||||
@@ -56,7 +56,7 @@ const NODE_MODULES = ["assert", "buffer_ieee754", "buffer", "child_process", "cl
|
|||||||
|
|
||||||
const COMPONENT_ERROR = '`Components` is not available in this context.\n' +
|
const COMPONENT_ERROR = '`Components` is not available in this context.\n' +
|
||||||
'Functionality provided by Components may be available in an SDK\n' +
|
'Functionality provided by Components may be available in an SDK\n' +
|
||||||
'module: https://jetpack.mozillalabs.com/sdk/latest/docs/ \n\n' +
|
'module: https://developer.mozilla.org/en-US/Add-ons/SDK \n\n' +
|
||||||
'However, if you still need to import Components, you may use the\n' +
|
'However, if you still need to import Components, you may use the\n' +
|
||||||
'`chrome` module\'s properties for shortcuts to Component properties:\n\n' +
|
'`chrome` module\'s properties for shortcuts to Component properties:\n\n' +
|
||||||
'Shortcuts: \n' +
|
'Shortcuts: \n' +
|
||||||
@@ -688,6 +688,10 @@ exports.unload = unload;
|
|||||||
// If `resolve` does not returns `uri` string exception will be thrown by
|
// If `resolve` does not returns `uri` string exception will be thrown by
|
||||||
// an associated `require` call.
|
// an associated `require` call.
|
||||||
const Loader = iced(function Loader(options) {
|
const Loader = iced(function Loader(options) {
|
||||||
|
let console = new ConsoleAPI({
|
||||||
|
consoleID: options.id ? "addon/" + options.id : ""
|
||||||
|
});
|
||||||
|
|
||||||
let {
|
let {
|
||||||
modules, globals, resolve, paths, rootURI, manifest, requireMap, isNative
|
modules, globals, resolve, paths, rootURI, manifest, requireMap, isNative
|
||||||
} = override({
|
} = override({
|
||||||
|
|||||||
@@ -264,10 +264,11 @@ parser_groups = (
|
|||||||
cmds=['test', 'run', 'xpi', 'testex',
|
cmds=['test', 'run', 'xpi', 'testex',
|
||||||
'testpkgs', 'testall'])),
|
'testpkgs', 'testall'])),
|
||||||
(("", "--e10s",), dict(dest="enable_e10s",
|
(("", "--e10s",), dict(dest="enable_e10s",
|
||||||
help="enable out-of-process Jetpacks",
|
help="enable remote windows",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
default=False,
|
default=False,
|
||||||
cmds=['test', 'run', 'testex', 'testpkgs'])),
|
cmds=['test', 'run', 'testex', 'testpkgs',
|
||||||
|
'testaddons', 'testcfx', 'testall'])),
|
||||||
(("", "--logfile",), dict(dest="logfile",
|
(("", "--logfile",), dict(dest="logfile",
|
||||||
help="log console output to file",
|
help="log console output to file",
|
||||||
metavar=None,
|
metavar=None,
|
||||||
@@ -902,6 +903,8 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
|
|||||||
if options.addons is not None:
|
if options.addons is not None:
|
||||||
options.addons = options.addons.split(",")
|
options.addons = options.addons.split(",")
|
||||||
|
|
||||||
|
enable_e10s = options.enable_e10s or target_cfg.get('e10s', False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
retval = run_app(harness_root_dir=app_extension_dir,
|
retval = run_app(harness_root_dir=app_extension_dir,
|
||||||
manifest_rdf=manifest_rdf,
|
manifest_rdf=manifest_rdf,
|
||||||
@@ -924,7 +927,8 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
|
|||||||
is_running_tests=(command == "test"),
|
is_running_tests=(command == "test"),
|
||||||
overload_modules=options.overload_modules,
|
overload_modules=options.overload_modules,
|
||||||
bundle_sdk=options.bundle_sdk,
|
bundle_sdk=options.bundle_sdk,
|
||||||
pkgdir=options.pkgdir)
|
pkgdir=options.pkgdir,
|
||||||
|
enable_e10s=enable_e10s)
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
print ""
|
print ""
|
||||||
print "A given cfx option has an inappropriate value:"
|
print "A given cfx option has an inappropriate value:"
|
||||||
|
|||||||
@@ -418,7 +418,8 @@ def run_app(harness_root_dir, manifest_rdf, harness_options,
|
|||||||
is_running_tests=False,
|
is_running_tests=False,
|
||||||
overload_modules=False,
|
overload_modules=False,
|
||||||
bundle_sdk=True,
|
bundle_sdk=True,
|
||||||
pkgdir=""):
|
pkgdir="",
|
||||||
|
enable_e10s=False):
|
||||||
if binary:
|
if binary:
|
||||||
binary = os.path.expanduser(binary)
|
binary = os.path.expanduser(binary)
|
||||||
|
|
||||||
@@ -430,6 +431,9 @@ def run_app(harness_root_dir, manifest_rdf, harness_options,
|
|||||||
cmdargs = []
|
cmdargs = []
|
||||||
preferences = dict(DEFAULT_COMMON_PREFS)
|
preferences = dict(DEFAULT_COMMON_PREFS)
|
||||||
|
|
||||||
|
if enable_e10s:
|
||||||
|
preferences['browser.tabs.remote.autostart'] = True
|
||||||
|
|
||||||
# For now, only allow running on Mobile with --force-mobile argument
|
# For now, only allow running on Mobile with --force-mobile argument
|
||||||
if app_type in ["fennec", "fennec-on-device"] and not enable_mobile:
|
if app_type in ["fennec", "fennec-on-device"] and not enable_mobile:
|
||||||
print """
|
print """
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ def welcome():
|
|||||||
print ("Your SDK may not work properly.")
|
print ("Your SDK may not work properly.")
|
||||||
return
|
return
|
||||||
|
|
||||||
print ("Welcome to the Add-on SDK. For the docs, visit https://addons.mozilla.org/en-US/developers/docs/sdk/latest/")
|
print ("Welcome to the Add-on SDK. For the docs, visit https://developer.mozilla.org/en-US/Add-ons/SDK")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
welcome()
|
welcome()
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<!-- 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/. -->
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
</head>
|
||||||
|
<body></body>
|
||||||
|
</html>
|
||||||
8
addon-sdk/source/test/addons/chrome/data/panel.js
Normal file
8
addon-sdk/source/test/addons/chrome/data/panel.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/* 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/. */
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
self.port.on('echo', _ => {
|
||||||
|
self.port.emit('echo', '');
|
||||||
|
});
|
||||||
@@ -7,6 +7,8 @@ const { Cu, Cc, Ci } = require('chrome');
|
|||||||
const Request = require('sdk/request').Request;
|
const Request = require('sdk/request').Request;
|
||||||
const { WindowTracker } = require('sdk/deprecated/window-utils');
|
const { WindowTracker } = require('sdk/deprecated/window-utils');
|
||||||
const { close, open } = require('sdk/window/helpers');
|
const { close, open } = require('sdk/window/helpers');
|
||||||
|
const { data } = require('sdk/self');
|
||||||
|
const { Panel } = require('sdk/panel');
|
||||||
|
|
||||||
const XUL_URL = 'chrome://test/content/new-window.xul'
|
const XUL_URL = 'chrome://test/content/new-window.xul'
|
||||||
|
|
||||||
@@ -65,4 +67,26 @@ exports.testChromeLocale = function(assert) {
|
|||||||
'locales en-US folder was copied correctly');
|
'locales en-US folder was copied correctly');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.testChromeInPanel = function(assert, done) {
|
||||||
|
let panel = Panel({
|
||||||
|
contentURL: 'chrome://test/content/panel.html',
|
||||||
|
contentScriptWhen: 'start',
|
||||||
|
contentScriptFile: data.url('panel.js')
|
||||||
|
});
|
||||||
|
panel.once('show', _ => {
|
||||||
|
assert.pass('panel shown');
|
||||||
|
panel.port.once('echo', _ => {
|
||||||
|
assert.pass('got echo');
|
||||||
|
panel.once('hide', _ => {
|
||||||
|
panel.destroy();
|
||||||
|
assert.pass('panel is destroyed');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
panel.hide();
|
||||||
|
});
|
||||||
|
panel.port.emit('echo');
|
||||||
|
});
|
||||||
|
panel.show();
|
||||||
|
}
|
||||||
|
|
||||||
require('sdk/test/runner').runTestsFromModule(module);
|
require('sdk/test/runner').runTestsFromModule(module);
|
||||||
|
|||||||
29
addon-sdk/source/test/addons/e10s/lib/main.js
Normal file
29
addon-sdk/source/test/addons/e10s/lib/main.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/* 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/. */
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const { get: getPref } = require('sdk/preferences/service');
|
||||||
|
const { getMostRecentBrowserWindow } = require('sdk/window/utils');
|
||||||
|
const { openTab, closeTab, getBrowserForTab } = require('sdk/tabs/utils');
|
||||||
|
|
||||||
|
exports.testRemotePrefIsSet = function(assert) {
|
||||||
|
assert.ok(getPref('browser.tabs.remote.autostart'),
|
||||||
|
"Electrolysis remote tabs pref should be set");
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.testTabIsRemote = function(assert, done) {
|
||||||
|
const url = 'data:text/html,test-tab-is-remote';
|
||||||
|
let tab = openTab(getMostRecentBrowserWindow(), url);
|
||||||
|
assert.ok(tab.getAttribute('remote'), "The new tab should be remote");
|
||||||
|
|
||||||
|
// can't simply close a remote tab before it is loaded, bug 1006043
|
||||||
|
let mm = getBrowserForTab(tab).messageManager;
|
||||||
|
mm.addMessageListener(7, function() {
|
||||||
|
closeTab(tab);
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
mm.loadFrameScript('data:,sendAsyncMessage(7)', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
require('sdk/test/runner').runTestsFromModule(module);
|
||||||
10
addon-sdk/source/test/addons/e10s/package.json
Normal file
10
addon-sdk/source/test/addons/e10s/package.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"name": "e10s-flag",
|
||||||
|
"title": "e10s-flag",
|
||||||
|
"id": "jid1-DYaXFHAPlHwbgw",
|
||||||
|
"description": "a basic e10s test add-on",
|
||||||
|
"author": "Tomislav Jovanovic",
|
||||||
|
"license": "MPL 2.0",
|
||||||
|
"version": "0.1",
|
||||||
|
"e10s": true
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
const { Cu } = require('chrome');
|
const { Cu } = require('chrome');
|
||||||
const { PageMod } = require('sdk/page-mod');
|
const { PageMod } = require('sdk/page-mod');
|
||||||
const tabs = require('sdk/tabs');
|
const tabs = require('sdk/tabs');
|
||||||
|
const { closeTab } = require('sdk/tabs/utils');
|
||||||
const promise = require('sdk/core/promise')
|
const promise = require('sdk/core/promise')
|
||||||
const { getMostRecentBrowserWindow } = require('sdk/window/utils');
|
const { getMostRecentBrowserWindow } = require('sdk/window/utils');
|
||||||
const { data } = require('sdk/self');
|
const { data } = require('sdk/self');
|
||||||
@@ -47,6 +48,7 @@ exports.testDebugger = function(assert, done) {
|
|||||||
then(_ => { assert.pass('testDebuggerStatement called') }).
|
then(_ => { assert.pass('testDebuggerStatement called') }).
|
||||||
then(closeConnection).
|
then(closeConnection).
|
||||||
then(_ => { assert.pass('closeConnection called') }).
|
then(_ => { assert.pass('closeConnection called') }).
|
||||||
|
then(_ => { tab.close() }).
|
||||||
then(done).
|
then(done).
|
||||||
then(null, aError => {
|
then(null, aError => {
|
||||||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
const { Cu } = require('chrome');
|
const { Cu } = require('chrome');
|
||||||
const { PageMod } = require('sdk/page-mod');
|
const { PageMod } = require('sdk/page-mod');
|
||||||
const tabs = require('sdk/tabs');
|
const tabs = require('sdk/tabs');
|
||||||
|
const { closeTab } = require('sdk/tabs/utils');
|
||||||
const promise = require('sdk/core/promise')
|
const promise = require('sdk/core/promise')
|
||||||
const { getMostRecentBrowserWindow } = require('sdk/window/utils');
|
const { getMostRecentBrowserWindow } = require('sdk/window/utils');
|
||||||
const { data } = require('sdk/self');
|
const { data } = require('sdk/self');
|
||||||
@@ -54,6 +55,7 @@ exports.testDebugger = function(assert, done) {
|
|||||||
then(_ => { assert.pass('testDebuggerStatement called') }).
|
then(_ => { assert.pass('testDebuggerStatement called') }).
|
||||||
then(closeConnection).
|
then(closeConnection).
|
||||||
then(_ => { assert.pass('closeConnection called') }).
|
then(_ => { assert.pass('closeConnection called') }).
|
||||||
|
then(_ => { tab.close() }).
|
||||||
then(done).
|
then(done).
|
||||||
then(null, aError => {
|
then(null, aError => {
|
||||||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ const { isPrivateBrowsingSupported } = require('sdk/self');
|
|||||||
const tabs = require('sdk/tabs');
|
const tabs = require('sdk/tabs');
|
||||||
const { browserWindows: windows } = require('sdk/windows');
|
const { browserWindows: windows } = require('sdk/windows');
|
||||||
const { isPrivate } = require('sdk/private-browsing');
|
const { isPrivate } = require('sdk/private-browsing');
|
||||||
const { getOwnerWindow } = require('sdk/private-browsing/window/utils');
|
|
||||||
const { is } = require('sdk/system/xul-app');
|
const { is } = require('sdk/system/xul-app');
|
||||||
const { isWindowPBSupported, isTabPBSupported } = require('sdk/private-browsing/utils');
|
const { isWindowPBSupported, isTabPBSupported } = require('sdk/private-browsing/utils');
|
||||||
|
|
||||||
@@ -19,47 +18,6 @@ exports.testIsPrivateBrowsingTrue = function(assert) {
|
|||||||
'isPrivateBrowsingSupported property is true');
|
'isPrivateBrowsingSupported property is true');
|
||||||
};
|
};
|
||||||
|
|
||||||
// test tab.open with isPrivate: true
|
|
||||||
// test isPrivate on a tab
|
|
||||||
// test getOwnerWindow on windows and tabs
|
|
||||||
exports.testGetOwnerWindow = function(assert, done) {
|
|
||||||
let window = windows.activeWindow;
|
|
||||||
let chromeWindow = getOwnerWindow(window);
|
|
||||||
assert.ok(chromeWindow instanceof Ci.nsIDOMWindow, 'associated window is found');
|
|
||||||
|
|
||||||
tabs.open({
|
|
||||||
url: 'about:blank',
|
|
||||||
isPrivate: true,
|
|
||||||
onOpen: function(tab) {
|
|
||||||
// test that getOwnerWindow works as expected
|
|
||||||
if (is('Fennec')) {
|
|
||||||
assert.notStrictEqual(chromeWindow, getOwnerWindow(tab));
|
|
||||||
assert.ok(getOwnerWindow(tab) instanceof Ci.nsIDOMWindow);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (isWindowPBSupported) {
|
|
||||||
assert.notStrictEqual(chromeWindow,
|
|
||||||
getOwnerWindow(tab),
|
|
||||||
'associated window is not the same for window and window\'s tab');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
assert.strictEqual(chromeWindow,
|
|
||||||
getOwnerWindow(tab),
|
|
||||||
'associated window is the same for window and window\'s tab');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let pbSupported = isTabPBSupported || isWindowPBSupported;
|
|
||||||
|
|
||||||
// test that the tab is private if it should be
|
|
||||||
assert.equal(isPrivate(tab), pbSupported);
|
|
||||||
assert.equal(isPrivate(getOwnerWindow(tab)), pbSupported);
|
|
||||||
|
|
||||||
tab.close(function() done());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// test that it is possible to open a private tab
|
// test that it is possible to open a private tab
|
||||||
exports.testTabOpenPrivate = function(assert, done) {
|
exports.testTabOpenPrivate = function(assert, done) {
|
||||||
tabs.open({
|
tabs.open({
|
||||||
@@ -68,10 +26,7 @@ exports.testTabOpenPrivate = function(assert, done) {
|
|||||||
onReady: function(tab) {
|
onReady: function(tab) {
|
||||||
assert.equal(tab.url, TAB_URL, 'opened correct tab');
|
assert.equal(tab.url, TAB_URL, 'opened correct tab');
|
||||||
assert.equal(isPrivate(tab), (isWindowPBSupported || isTabPBSupported));
|
assert.equal(isPrivate(tab), (isWindowPBSupported || isTabPBSupported));
|
||||||
|
tab.close(done);
|
||||||
tab.close(function() {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -84,10 +39,7 @@ exports.testTabOpenPrivateDefault = function(assert, done) {
|
|||||||
onReady: function(tab) {
|
onReady: function(tab) {
|
||||||
assert.equal(tab.url, TAB_URL, 'opened correct tab');
|
assert.equal(tab.url, TAB_URL, 'opened correct tab');
|
||||||
assert.equal(isPrivate(tab), false);
|
assert.equal(isPrivate(tab), false);
|
||||||
|
tab.close(done);
|
||||||
tab.close(function() {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -100,10 +52,7 @@ exports.testTabOpenPrivateOffExplicit = function(assert, done) {
|
|||||||
onReady: function(tab) {
|
onReady: function(tab) {
|
||||||
assert.equal(tab.url, TAB_URL, 'opened correct tab');
|
assert.equal(tab.url, TAB_URL, 'opened correct tab');
|
||||||
assert.equal(isPrivate(tab), false);
|
assert.equal(isPrivate(tab), false);
|
||||||
|
tab.close(done);
|
||||||
tab.close(function() {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -121,10 +70,7 @@ if (!is('Fennec')) {
|
|||||||
tab.once('ready', function() {
|
tab.once('ready', function() {
|
||||||
assert.equal(tab.url, TAB_URL, 'opened correct tab');
|
assert.equal(tab.url, TAB_URL, 'opened correct tab');
|
||||||
assert.equal(isPrivate(tab), isWindowPBSupported, 'tab is private');
|
assert.equal(isPrivate(tab), isWindowPBSupported, 'tab is private');
|
||||||
|
window.close(done);
|
||||||
window.close(function() {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -86,25 +86,6 @@ function open(url, options) {
|
|||||||
return promise;
|
return promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Close the Active Tab
|
|
||||||
*/
|
|
||||||
function close(window) {
|
|
||||||
let { promise, resolve } = defer();
|
|
||||||
|
|
||||||
if (window && typeof(window.close) === "function") {
|
|
||||||
closeWindow(window).then(function() resolve());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Here we assuming that the most recent browser window is the one we're
|
|
||||||
// doing the test, and the active tab is the one we just opened.
|
|
||||||
closeTab(getActiveTab(getMostRecentBrowserWindow()));
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
return promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reload the window given and return a promise, that will be resolved with the
|
* Reload the window given and return a promise, that will be resolved with the
|
||||||
* content window after a small delay.
|
* content window after a small delay.
|
||||||
@@ -249,7 +230,7 @@ exports["test PWPB Selection Listener"] = function(assert, done) {
|
|||||||
|
|
||||||
assert.equal(selection.text, "fo");
|
assert.equal(selection.text, "fo");
|
||||||
|
|
||||||
close(window).
|
closeWindow(window).
|
||||||
then(loader.unload).
|
then(loader.unload).
|
||||||
then(done).
|
then(done).
|
||||||
then(null, assert.fail);
|
then(null, assert.fail);
|
||||||
@@ -279,7 +260,7 @@ exports["test PWPB Textarea OnSelect Listener"] = function(assert, done) {
|
|||||||
focus(window).then(function() {
|
focus(window).then(function() {
|
||||||
assert.equal(selection.text, "noodles");
|
assert.equal(selection.text, "noodles");
|
||||||
|
|
||||||
close(window).
|
closeWindow(window).
|
||||||
then(loader.unload).
|
then(loader.unload).
|
||||||
then(done).
|
then(done).
|
||||||
then(null, assert.fail);
|
then(null, assert.fail);
|
||||||
@@ -298,7 +279,7 @@ exports["test PWPB Single DOM Selection"] = function(assert, done) {
|
|||||||
|
|
||||||
open(URL, {private: true, title: "PWPB Single DOM Selection"}).
|
open(URL, {private: true, title: "PWPB Single DOM Selection"}).
|
||||||
then(selectFirstDiv).
|
then(selectFirstDiv).
|
||||||
then(focus).then(function() {
|
then(focus).then(function(window) {
|
||||||
assert.equal(selection.isContiguous, true,
|
assert.equal(selection.isContiguous, true,
|
||||||
"selection.isContiguous with single DOM Selection works.");
|
"selection.isContiguous with single DOM Selection works.");
|
||||||
|
|
||||||
@@ -321,7 +302,9 @@ exports["test PWPB Single DOM Selection"] = function(assert, done) {
|
|||||||
|
|
||||||
assert.equal(selectionCount, 1,
|
assert.equal(selectionCount, 1,
|
||||||
"One iterable selection");
|
"One iterable selection");
|
||||||
}).then(close).then(loader.unload).then(done).then(null, assert.fail);
|
|
||||||
|
return closeWindow(window);
|
||||||
|
}).then(loader.unload).then(done).then(null, assert.fail);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports["test PWPB Textarea Selection"] = function(assert, done) {
|
exports["test PWPB Textarea Selection"] = function(assert, done) {
|
||||||
@@ -331,7 +314,7 @@ exports["test PWPB Textarea Selection"] = function(assert, done) {
|
|||||||
open(URL, {private: true, title: "PWPB Textarea Listener"}).
|
open(URL, {private: true, title: "PWPB Textarea Listener"}).
|
||||||
then(selectTextarea).
|
then(selectTextarea).
|
||||||
then(focus).
|
then(focus).
|
||||||
then(function() {
|
then(function(window) {
|
||||||
|
|
||||||
assert.equal(selection.isContiguous, true,
|
assert.equal(selection.isContiguous, true,
|
||||||
"selection.isContiguous with Textarea Selection works.");
|
"selection.isContiguous with Textarea Selection works.");
|
||||||
@@ -355,7 +338,9 @@ exports["test PWPB Textarea Selection"] = function(assert, done) {
|
|||||||
|
|
||||||
assert.equal(selectionCount, 1,
|
assert.equal(selectionCount, 1,
|
||||||
"One iterable selection");
|
"One iterable selection");
|
||||||
}).then(close).then(loader.unload).then(done).then(null, assert.fail);
|
|
||||||
|
return closeWindow(window);
|
||||||
|
}).then(loader.unload).then(done).then(null, assert.fail);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports["test PWPB Set HTML in Multiple DOM Selection"] = function(assert, done) {
|
exports["test PWPB Set HTML in Multiple DOM Selection"] = function(assert, done) {
|
||||||
@@ -365,7 +350,7 @@ exports["test PWPB Set HTML in Multiple DOM Selection"] = function(assert, done)
|
|||||||
open(URL, {private: true, title: "PWPB Set HTML in Multiple DOM Selection"}).
|
open(URL, {private: true, title: "PWPB Set HTML in Multiple DOM Selection"}).
|
||||||
then(selectAllDivs).
|
then(selectAllDivs).
|
||||||
then(focus).
|
then(focus).
|
||||||
then(function() {
|
then(function(window) {
|
||||||
let html = "<span>b<b>a</b>r</span>";
|
let html = "<span>b<b>a</b>r</span>";
|
||||||
|
|
||||||
let expectedText = ["bar", "and"];
|
let expectedText = ["bar", "and"];
|
||||||
@@ -393,7 +378,9 @@ exports["test PWPB Set HTML in Multiple DOM Selection"] = function(assert, done)
|
|||||||
|
|
||||||
assert.equal(selectionCount, 2,
|
assert.equal(selectionCount, 2,
|
||||||
"Two iterable selections");
|
"Two iterable selections");
|
||||||
}).then(close).then(loader.unload).then(done).then(null, assert.fail);
|
|
||||||
|
return closeWindow(window);
|
||||||
|
}).then(loader.unload).then(done).then(null, assert.fail);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports["test PWPB Set Text in Textarea Selection"] = function(assert, done) {
|
exports["test PWPB Set Text in Textarea Selection"] = function(assert, done) {
|
||||||
@@ -403,7 +390,7 @@ exports["test PWPB Set Text in Textarea Selection"] = function(assert, done) {
|
|||||||
open(URL, {private: true, title: "test PWPB Set Text in Textarea Selection"}).
|
open(URL, {private: true, title: "test PWPB Set Text in Textarea Selection"}).
|
||||||
then(selectTextarea).
|
then(selectTextarea).
|
||||||
then(focus).
|
then(focus).
|
||||||
then(function() {
|
then(function(window) {
|
||||||
|
|
||||||
let text = "bar";
|
let text = "bar";
|
||||||
|
|
||||||
@@ -429,7 +416,8 @@ exports["test PWPB Set Text in Textarea Selection"] = function(assert, done) {
|
|||||||
assert.equal(selectionCount, 1,
|
assert.equal(selectionCount, 1,
|
||||||
"One iterable selection");
|
"One iterable selection");
|
||||||
|
|
||||||
}).then(close).then(loader.unload).then(done).then(null, assert.fail);
|
return closeWindow(window);
|
||||||
|
}).then(loader.unload).then(done).then(null, assert.fail);
|
||||||
};
|
};
|
||||||
|
|
||||||
// If the platform doesn't support the PBPW, we're replacing PBPW tests
|
// If the platform doesn't support the PBPW, we're replacing PBPW tests
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
/* 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/. */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const tabs = require('sdk/tabs');
|
const tabs = require('sdk/tabs');
|
||||||
const { isPrivate } = require('sdk/private-browsing');
|
const { isPrivate } = require('sdk/private-browsing');
|
||||||
const pbUtils = require('sdk/private-browsing/utils');
|
const pbUtils = require('sdk/private-browsing/utils');
|
||||||
const { getOwnerWindow } = require('sdk/private-browsing/window/utils');
|
|
||||||
|
|
||||||
exports.testPrivateTabsAreListed = function (assert, done) {
|
exports.testPrivateTabsAreListed = function (assert, done) {
|
||||||
let originalTabCount = tabs.length;
|
let originalTabCount = tabs.length;
|
||||||
@@ -12,7 +14,6 @@ exports.testPrivateTabsAreListed = function (assert, done) {
|
|||||||
url: 'about:blank',
|
url: 'about:blank',
|
||||||
isPrivate: true,
|
isPrivate: true,
|
||||||
onOpen: function(tab) {
|
onOpen: function(tab) {
|
||||||
let win = getOwnerWindow(tab);
|
|
||||||
// PWPB case
|
// PWPB case
|
||||||
if (pbUtils.isWindowPBSupported || pbUtils.isTabPBSupported) {
|
if (pbUtils.isWindowPBSupported || pbUtils.isTabPBSupported) {
|
||||||
assert.ok(isPrivate(tab), "tab is private");
|
assert.ok(isPrivate(tab), "tab is private");
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
/* 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/. */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const tabs = require('sdk/tabs');
|
const tabs = require('sdk/tabs');
|
||||||
const { isPrivate } = require('sdk/private-browsing');
|
const { isPrivate } = require('sdk/private-browsing');
|
||||||
const { getOwnerWindow } = require('sdk/private-browsing/window/utils');
|
|
||||||
const { promise: windowPromise, close, focus } = require('sdk/window/helpers');
|
const { promise: windowPromise, close, focus } = require('sdk/window/helpers');
|
||||||
const { getMostRecentBrowserWindow } = require('sdk/window/utils');
|
const { getMostRecentBrowserWindow } = require('sdk/window/utils');
|
||||||
|
|
||||||
@@ -16,9 +18,6 @@ exports.testOpenTabWithPrivateActiveWindowNoIsPrivateOption = function(assert, d
|
|||||||
url: 'about:blank',
|
url: 'about:blank',
|
||||||
onOpen: function(tab) {
|
onOpen: function(tab) {
|
||||||
assert.ok(isPrivate(tab), 'new tab is private');
|
assert.ok(isPrivate(tab), 'new tab is private');
|
||||||
assert.ok(isPrivate(getOwnerWindow(tab)), 'new tab window is private');
|
|
||||||
assert.strictEqual(getOwnerWindow(tab), window, 'the tab window and the private window are the same');
|
|
||||||
|
|
||||||
close(window).then(done).then(null, assert.fail);
|
close(window).then(done).then(null, assert.fail);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -35,9 +34,6 @@ exports.testOpenTabWithNonPrivateActiveWindowNoIsPrivateOption = function(assert
|
|||||||
url: 'about:blank',
|
url: 'about:blank',
|
||||||
onOpen: function(tab) {
|
onOpen: function(tab) {
|
||||||
assert.equal(isPrivate(tab), false, 'new tab is not private');
|
assert.equal(isPrivate(tab), false, 'new tab is not private');
|
||||||
assert.equal(isPrivate(getOwnerWindow(tab)), false, 'new tab window is not private');
|
|
||||||
assert.strictEqual(getOwnerWindow(tab), window, 'the tab window and the new window are the same');
|
|
||||||
|
|
||||||
close(window).then(done).then(null, assert.fail);
|
close(window).then(done).then(null, assert.fail);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -55,9 +51,6 @@ exports.testOpenTabWithPrivateActiveWindowWithIsPrivateOptionTrue = function(ass
|
|||||||
isPrivate: true,
|
isPrivate: true,
|
||||||
onOpen: function(tab) {
|
onOpen: function(tab) {
|
||||||
assert.ok(isPrivate(tab), 'new tab is private');
|
assert.ok(isPrivate(tab), 'new tab is private');
|
||||||
assert.ok(isPrivate(getOwnerWindow(tab)), 'new tab window is private');
|
|
||||||
assert.strictEqual(getOwnerWindow(tab), window, 'the tab window and the private window are the same');
|
|
||||||
|
|
||||||
close(window).then(done).then(null, assert.fail);
|
close(window).then(done).then(null, assert.fail);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -75,9 +68,6 @@ exports.testOpenTabWithNonPrivateActiveWindowWithIsPrivateOptionFalse = function
|
|||||||
isPrivate: false,
|
isPrivate: false,
|
||||||
onOpen: function(tab) {
|
onOpen: function(tab) {
|
||||||
assert.equal(isPrivate(tab), false, 'new tab is not private');
|
assert.equal(isPrivate(tab), false, 'new tab is not private');
|
||||||
assert.equal(isPrivate(getOwnerWindow(tab)), false, 'new tab window is not private');
|
|
||||||
assert.strictEqual(getOwnerWindow(tab), window, 'the tab window and the new window are the same');
|
|
||||||
|
|
||||||
close(window).then(done).then(null, assert.fail);
|
close(window).then(done).then(null, assert.fail);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,15 +3,10 @@
|
|||||||
const { Ci } = require('chrome');
|
const { Ci } = require('chrome');
|
||||||
const { openTab, closeTab } = require('sdk/tabs/utils');
|
const { openTab, closeTab } = require('sdk/tabs/utils');
|
||||||
const { browserWindows } = require('sdk/windows');
|
const { browserWindows } = require('sdk/windows');
|
||||||
const { getOwnerWindow } = require('sdk/private-browsing/window/utils');
|
|
||||||
const { isPrivate } = require('sdk/private-browsing');
|
const { isPrivate } = require('sdk/private-browsing');
|
||||||
|
|
||||||
exports.testIsPrivateOnTab = function(assert) {
|
exports.testIsPrivateOnTab = function(assert) {
|
||||||
let window = browserWindows.activeWindow;
|
let window = browserWindows.activeWindow;
|
||||||
|
|
||||||
let chromeWindow = getOwnerWindow(window);
|
|
||||||
|
|
||||||
assert.ok(chromeWindow instanceof Ci.nsIDOMWindow, 'associated window is found');
|
|
||||||
assert.ok(!isPrivate(chromeWindow), 'the top level window is not private');
|
assert.ok(!isPrivate(chromeWindow), 'the top level window is not private');
|
||||||
|
|
||||||
let rawTab = openTab(chromeWindow, 'data:text/html,<h1>Hi!</h1>', {
|
let rawTab = openTab(chromeWindow, 'data:text/html,<h1>Hi!</h1>', {
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
const { Cc, Ci } = require('chrome');
|
const { Cc, Ci } = require('chrome');
|
||||||
const { Loader } = require('sdk/test/loader');
|
const { Loader } = require('sdk/test/loader');
|
||||||
const { setTimeout } = require('sdk/timers');
|
const { setTimeout } = require('sdk/timers');
|
||||||
const { getOwnerWindow } = require('sdk/private-browsing/window/utils');
|
const { viewFor } = require('sdk/view/core');
|
||||||
|
const { getOwnerWindow } = require('sdk/tabs/utils');
|
||||||
const { windows, onFocus, getMostRecentBrowserWindow } = require('sdk/window/utils');
|
const { windows, onFocus, getMostRecentBrowserWindow } = require('sdk/window/utils');
|
||||||
const { open, focus, close } = require('sdk/window/helpers');
|
const { open, focus, close } = require('sdk/window/helpers');
|
||||||
const tabs = require('sdk/tabs');
|
const tabs = require('sdk/tabs');
|
||||||
@@ -165,12 +166,12 @@ exports.testTabPropertiesInNewWindow = function(assert, done) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let tabs = loader.require('sdk/tabs');
|
let tabs = loader.require('sdk/tabs');
|
||||||
let { getOwnerWindow } = loader.require('sdk/private-browsing/window/utils');
|
let { viewFor } = loader.require('sdk/view/core');
|
||||||
|
|
||||||
let count = 0;
|
let count = 0;
|
||||||
function onReadyOrLoad (tab) {
|
function onReadyOrLoad (tab) {
|
||||||
if (count++) {
|
if (count++) {
|
||||||
close(getOwnerWindow(tab)).then(done).then(null, assert.fail);
|
close(getOwnerWindow(viewFor(tab))).then(done).then(null, assert.fail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,6 +369,33 @@ exports.testTabMove = function(assert, done) {
|
|||||||
}).then(null, assert.fail);
|
}).then(null, assert.fail);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.testIgnoreClosing = function(assert, done) {
|
||||||
|
let originalWindow = browserWindows.activeWindow;
|
||||||
|
openBrowserWindow(function(window, browser) {
|
||||||
|
let url = "data:text/html;charset=utf-8,foobar";
|
||||||
|
|
||||||
|
assert.equal(tabs.length, 2, "should be two windows open each with one tab");
|
||||||
|
|
||||||
|
tabs.on('ready', function onReady(tab) {
|
||||||
|
tabs.removeListener('ready', onReady);
|
||||||
|
|
||||||
|
let win = tab.window;
|
||||||
|
assert.equal(win.tabs.length, 2, "should be two tabs in the new window");
|
||||||
|
assert.equal(tabs.length, 3, "should be three tabs in total");
|
||||||
|
|
||||||
|
tab.close(function() {
|
||||||
|
assert.equal(win.tabs.length, 1, "should be one tab in the new window");
|
||||||
|
assert.equal(tabs.length, 2, "should be two tabs in total");
|
||||||
|
|
||||||
|
originalWindow.once("activate", done);
|
||||||
|
close(window);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tabs.open(url);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// TEST: open tab with default options
|
// TEST: open tab with default options
|
||||||
exports.testOpen = function(assert, done) {
|
exports.testOpen = function(assert, done) {
|
||||||
let url = "data:text/html;charset=utf-8,default";
|
let url = "data:text/html;charset=utf-8,default";
|
||||||
@@ -413,6 +441,8 @@ exports.testPinUnpin = function(assert, done) {
|
|||||||
|
|
||||||
// TEST: open tab in background
|
// TEST: open tab in background
|
||||||
exports.testInBackground = function(assert, done) {
|
exports.testInBackground = function(assert, done) {
|
||||||
|
assert.equal(tabs.length, 1, "Should be one tab");
|
||||||
|
|
||||||
let window = getMostRecentBrowserWindow();
|
let window = getMostRecentBrowserWindow();
|
||||||
let activeUrl = tabs.activeTab.url;
|
let activeUrl = tabs.activeTab.url;
|
||||||
let url = "data:text/html;charset=utf-8,background";
|
let url = "data:text/html;charset=utf-8,background";
|
||||||
@@ -441,7 +471,7 @@ exports.testOpenInNewWindow = function(assert, done) {
|
|||||||
url: url,
|
url: url,
|
||||||
inNewWindow: true,
|
inNewWindow: true,
|
||||||
onReady: function(tab) {
|
onReady: function(tab) {
|
||||||
let newWindow = getOwnerWindow(tab);
|
let newWindow = getOwnerWindow(viewFor(tab));
|
||||||
assert.equal(windows().length, startWindowCount + 1, "a new window was opened");
|
assert.equal(windows().length, startWindowCount + 1, "a new window was opened");
|
||||||
|
|
||||||
onFocus(newWindow).then(function() {
|
onFocus(newWindow).then(function() {
|
||||||
@@ -466,7 +496,7 @@ exports.testOpenInNewWindowOnOpen = function(assert, done) {
|
|||||||
url: url,
|
url: url,
|
||||||
inNewWindow: true,
|
inNewWindow: true,
|
||||||
onOpen: function(tab) {
|
onOpen: function(tab) {
|
||||||
let newWindow = getOwnerWindow(tab);
|
let newWindow = getOwnerWindow(viewFor(tab));
|
||||||
|
|
||||||
onFocus(newWindow).then(function() {
|
onFocus(newWindow).then(function() {
|
||||||
assert.equal(windows().length, startWindowCount + 1, "a new window was opened");
|
assert.equal(windows().length, startWindowCount + 1, "a new window was opened");
|
||||||
@@ -942,9 +972,11 @@ exports['test unique tab ids'] = function(assert, done) {
|
|||||||
var one = openWindow(), two = openWindow();
|
var one = openWindow(), two = openWindow();
|
||||||
all([one, two]).then(function(results) {
|
all([one, two]).then(function(results) {
|
||||||
assert.notEqual(results[0].id, results[1].id, "tab Ids should not be equal.");
|
assert.notEqual(results[0].id, results[1].id, "tab Ids should not be equal.");
|
||||||
results[0].win.close();
|
results[0].win.close(function() {
|
||||||
results[1].win.close();
|
results[1].win.close(function () {
|
||||||
done();
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ exports.testExecOptionsEnvironment = function (assert, done) {
|
|||||||
'receives environment option');
|
'receives environment option');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
}).then(null, assert.fail);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.testExecOptionsTimeout = function (assert, done) {
|
exports.testExecOptionsTimeout = function (assert, done) {
|
||||||
@@ -104,7 +104,7 @@ exports.testExecOptionsTimeout = function (assert, done) {
|
|||||||
child.off('close', closeHandler);
|
child.off('close', closeHandler);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
});
|
}).then(null, assert.fail);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.testExecFileCallbackSuccess = function (assert, done) {
|
exports.testExecFileCallbackSuccess = function (assert, done) {
|
||||||
@@ -116,7 +116,7 @@ exports.testExecFileCallbackSuccess = function (assert, done) {
|
|||||||
assert.equal(stdout.trim(), '--myargs -j -s'.trim(), 'passes in correct arguments');
|
assert.equal(stdout.trim(), '--myargs -j -s'.trim(), 'passes in correct arguments');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
}).then(null, assert.fail);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.testExecFileCallbackError = function (assert, done) {
|
exports.testExecFileCallbackError = function (assert, done) {
|
||||||
@@ -143,7 +143,7 @@ exports.testExecFileOptionsEnvironment = function (assert, done) {
|
|||||||
'receives environment option');
|
'receives environment option');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
}).then(null, assert.fail);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.testExecFileOptionsTimeout = function (assert, done) {
|
exports.testExecFileOptionsTimeout = function (assert, done) {
|
||||||
@@ -181,7 +181,7 @@ exports.testExecFileOptionsTimeout = function (assert, done) {
|
|||||||
child.off('close', closeHandler);
|
child.off('close', closeHandler);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
});
|
}).then(null, assert.fail);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -204,7 +204,7 @@ exports.testExecFileOptionsMaxBufferLargeStdOut = function (assert, done) {
|
|||||||
});
|
});
|
||||||
stdoutChild.on('exit', exitHandler);
|
stdoutChild.on('exit', exitHandler);
|
||||||
stdoutChild.on('close', closeHandler);
|
stdoutChild.on('close', closeHandler);
|
||||||
});
|
}).then(null, assert.fail);
|
||||||
|
|
||||||
function exitHandler (code, signal) {
|
function exitHandler (code, signal) {
|
||||||
assert.equal(code, null, 'Exit code is null in exit handler');
|
assert.equal(code, null, 'Exit code is null in exit handler');
|
||||||
@@ -239,7 +239,7 @@ exports.testExecFileOptionsMaxBufferLargeStdOErr = function (assert, done) {
|
|||||||
});
|
});
|
||||||
stderrChild.on('exit', exitHandler);
|
stderrChild.on('exit', exitHandler);
|
||||||
stderrChild.on('close', closeHandler);
|
stderrChild.on('close', closeHandler);
|
||||||
});
|
}).then(null, assert.fail);
|
||||||
|
|
||||||
function exitHandler (code, signal) {
|
function exitHandler (code, signal) {
|
||||||
assert.equal(code, null, 'Exit code is null in exit handler');
|
assert.equal(code, null, 'Exit code is null in exit handler');
|
||||||
@@ -280,7 +280,7 @@ exports.testExecFileOptionsMaxBufferSmallStdOut = function (assert, done) {
|
|||||||
});
|
});
|
||||||
stdoutChild.on('exit', exitHandler);
|
stdoutChild.on('exit', exitHandler);
|
||||||
stdoutChild.on('close', closeHandler);
|
stdoutChild.on('close', closeHandler);
|
||||||
});
|
}).then(null, assert.fail);
|
||||||
|
|
||||||
function exitHandler (code, signal) {
|
function exitHandler (code, signal) {
|
||||||
// Sometimes the buffer limit is hit before the process closes successfully
|
// Sometimes the buffer limit is hit before the process closes successfully
|
||||||
@@ -331,7 +331,7 @@ exports.testExecFileOptionsMaxBufferSmallStdErr = function (assert, done) {
|
|||||||
});
|
});
|
||||||
stderrChild.on('exit', exitHandler);
|
stderrChild.on('exit', exitHandler);
|
||||||
stderrChild.on('close', closeHandler);
|
stderrChild.on('close', closeHandler);
|
||||||
});
|
}).then(null, assert.fail);
|
||||||
|
|
||||||
function exitHandler (code, signal) {
|
function exitHandler (code, signal) {
|
||||||
// Sometimes the buffer limit is hit before the process closes successfully
|
// Sometimes the buffer limit is hit before the process closes successfully
|
||||||
@@ -377,7 +377,7 @@ exports.testChildExecFileKillSignal = function (assert, done) {
|
|||||||
assert.equal(err.signal, 'beepbeep', 'correctly used custom killSignal');
|
assert.equal(err.signal, 'beepbeep', 'correctly used custom killSignal');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
}).then(null, assert.fail);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.testChildProperties = function (assert, done) {
|
exports.testChildProperties = function (assert, done) {
|
||||||
@@ -390,8 +390,7 @@ exports.testChildProperties = function (assert, done) {
|
|||||||
assert.ok(true, 'Windows environment does not have `pid`');
|
assert.ok(true, 'Windows environment does not have `pid`');
|
||||||
else
|
else
|
||||||
assert.ok(child.pid > 0, 'Child has a pid');
|
assert.ok(child.pid > 0, 'Child has a pid');
|
||||||
done();
|
}).then(done, assert.fail);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.testChildStdinStreamLarge = function (assert, done) {
|
exports.testChildStdinStreamLarge = function (assert, done) {
|
||||||
@@ -509,7 +508,7 @@ exports.testSpawnOptions = function (assert, done) {
|
|||||||
|
|
||||||
envChild.on('close', envClose);
|
envChild.on('close', envClose);
|
||||||
cwdChild.on('close', cwdClose);
|
cwdChild.on('close', cwdClose);
|
||||||
});
|
}).then(null, assert.fail);
|
||||||
|
|
||||||
function envClose () {
|
function envClose () {
|
||||||
assert.equal(envStdout.trim(), 'my-value-test', 'spawn correctly passed in ENV');
|
assert.equal(envStdout.trim(), 'my-value-test', 'spawn correctly passed in ENV');
|
||||||
|
|||||||
@@ -90,8 +90,7 @@ function comparePixelImages(imageA, imageB, callback) {
|
|||||||
compared = pixels;
|
compared = pixels;
|
||||||
this.emit("draw-image", imageB);
|
this.emit("draw-image", imageB);
|
||||||
} else {
|
} else {
|
||||||
callback(compared === pixels);
|
tab.close(callback.bind(null, compared === pixels))
|
||||||
tab.close()
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -986,7 +986,7 @@ exports['test panel CSS'] = function(assert, done) {
|
|||||||
getActiveView(panel).querySelector('iframe').contentWindow;
|
getActiveView(panel).querySelector('iframe').contentWindow;
|
||||||
|
|
||||||
let panel = Panel({
|
let panel = Panel({
|
||||||
contentURL: 'data:text/html;charset=utf-8,' +
|
contentURL: 'data:text/html;charset=utf-8,' +
|
||||||
'<div style="background: silver">css test</div>',
|
'<div style="background: silver">css test</div>',
|
||||||
contentStyle: 'div { height: 100px; }',
|
contentStyle: 'div { height: 100px; }',
|
||||||
contentStyleFile: CSS_URL,
|
contentStyleFile: CSS_URL,
|
||||||
@@ -999,7 +999,7 @@ exports['test panel CSS'] = function(assert, done) {
|
|||||||
|
|
||||||
loader.unload();
|
loader.unload();
|
||||||
done();
|
done();
|
||||||
}).then(null, assert.fail);
|
}).then(null, assert.fail);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1016,7 +1016,7 @@ exports['test panel CSS list'] = function(assert, done) {
|
|||||||
getActiveView(panel).querySelector('iframe').contentWindow;
|
getActiveView(panel).querySelector('iframe').contentWindow;
|
||||||
|
|
||||||
let panel = Panel({
|
let panel = Panel({
|
||||||
contentURL: 'data:text/html;charset=utf-8,' +
|
contentURL: 'data:text/html;charset=utf-8,' +
|
||||||
'<div style="width:320px; max-width: 480px!important">css test</div>',
|
'<div style="width:320px; max-width: 480px!important">css test</div>',
|
||||||
contentStyleFile: [
|
contentStyleFile: [
|
||||||
// Highlight evaluation order in this list
|
// Highlight evaluation order in this list
|
||||||
@@ -1049,8 +1049,7 @@ exports['test panel CSS list'] = function(assert, done) {
|
|||||||
'add-on author/page author stylesheet !important precedence works');
|
'add-on author/page author stylesheet !important precedence works');
|
||||||
|
|
||||||
loader.unload();
|
loader.unload();
|
||||||
done();
|
}).then(done, assert.fail);
|
||||||
}).then(null, assert.fail);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1065,12 +1064,12 @@ if (isWindowPBSupported) {
|
|||||||
toolbar: true,
|
toolbar: true,
|
||||||
chrome: true,
|
chrome: true,
|
||||||
private: true
|
private: true
|
||||||
} }).then(function(window) {
|
} }).then(window => {
|
||||||
assert.ok(isPrivate(window), 'window is private');
|
assert.ok(isPrivate(window), 'window is private');
|
||||||
assert.equal(getWindow(window.gBrowser), null, 'private window elements returns null');
|
assert.equal(getWindow(window.gBrowser), null, 'private window elements returns null');
|
||||||
assert.equal(getWindow(activeWindow.gBrowser), activeWindow, 'non-private window elements returns window');
|
assert.equal(getWindow(activeWindow.gBrowser), activeWindow, 'non-private window elements returns window');
|
||||||
close(window).then(done);
|
return window;
|
||||||
})
|
}).then(close).then(done).then(null, assert.fail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isGlobalPBSupported) {
|
else if (isGlobalPBSupported) {
|
||||||
@@ -1084,7 +1083,7 @@ else if (isGlobalPBSupported) {
|
|||||||
open(null, { features: {
|
open(null, { features: {
|
||||||
toolbar: true,
|
toolbar: true,
|
||||||
chrome: true
|
chrome: true
|
||||||
} }).then(function(window) {
|
} }).then(window => {
|
||||||
assert.ok(isPrivate(window), 'window is private');
|
assert.ok(isPrivate(window), 'window is private');
|
||||||
assert.equal(getWindow(window.gBrowser), window, 'private window elements returns window');
|
assert.equal(getWindow(window.gBrowser), window, 'private window elements returns window');
|
||||||
assert.equal(getWindow(activeWindow.gBrowser), activeWindow, 'active window elements returns window');
|
assert.equal(getWindow(activeWindow.gBrowser), activeWindow, 'active window elements returns window');
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ const { isWindowPrivate } = winUtils;
|
|||||||
const { isPrivateBrowsingSupported } = require('sdk/self');
|
const { isPrivateBrowsingSupported } = require('sdk/self');
|
||||||
const { is } = require('sdk/system/xul-app');
|
const { is } = require('sdk/system/xul-app');
|
||||||
const { isPrivate } = require('sdk/private-browsing');
|
const { isPrivate } = require('sdk/private-browsing');
|
||||||
const { getOwnerWindow } = require('sdk/private-browsing/window/utils');
|
|
||||||
const { LoaderWithHookedConsole } = require("sdk/test/loader");
|
const { LoaderWithHookedConsole } = require("sdk/test/loader");
|
||||||
const { getMode, isGlobalPBSupported,
|
const { getMode, isGlobalPBSupported,
|
||||||
isWindowPBSupported, isTabPBSupported } = require('sdk/private-browsing/utils');
|
isWindowPBSupported, isTabPBSupported } = require('sdk/private-browsing/utils');
|
||||||
@@ -84,34 +83,6 @@ exports.testIsPrivateBrowsingFalseDefault = function(assert) {
|
|||||||
'isPrivateBrowsingSupported property is false by default');
|
'isPrivateBrowsingSupported property is false by default');
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.testGetOwnerWindow = function(assert, done) {
|
|
||||||
let window = windows.activeWindow;
|
|
||||||
let chromeWindow = getOwnerWindow(window);
|
|
||||||
assert.ok(chromeWindow instanceof Ci.nsIDOMWindow, 'associated window is found');
|
|
||||||
|
|
||||||
tabs.open({
|
|
||||||
url: 'about:blank',
|
|
||||||
isPrivate: true,
|
|
||||||
onOpen: function(tab) {
|
|
||||||
// test that getOwnerWindow works as expected
|
|
||||||
if (is('Fennec')) {
|
|
||||||
assert.notStrictEqual(chromeWindow, getOwnerWindow(tab));
|
|
||||||
assert.ok(getOwnerWindow(tab) instanceof Ci.nsIDOMWindow);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
assert.strictEqual(chromeWindow, getOwnerWindow(tab), 'associated window is the same for window and window\'s tab');
|
|
||||||
}
|
|
||||||
|
|
||||||
// test that the tab is not private
|
|
||||||
// private flag should be ignored by default
|
|
||||||
assert.ok(!isPrivate(tab));
|
|
||||||
assert.ok(!isPrivate(getOwnerWindow(tab)));
|
|
||||||
|
|
||||||
tab.close(done);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.testNSIPrivateBrowsingChannel = function(assert) {
|
exports.testNSIPrivateBrowsingChannel = function(assert) {
|
||||||
let channel = Services.io.newChannel("about:blank", null, null);
|
let channel = Services.io.newChannel("about:blank", null, null);
|
||||||
channel.QueryInterface(Ci.nsIPrivateBrowsingChannel);
|
channel.QueryInterface(Ci.nsIPrivateBrowsingChannel);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ const tabs = require("sdk/tabs");
|
|||||||
const { setTabURL } = require("sdk/tabs/utils");
|
const { setTabURL } = require("sdk/tabs/utils");
|
||||||
const { getActiveTab, getTabContentWindow, closeTab } = require("sdk/tabs/utils")
|
const { getActiveTab, getTabContentWindow, closeTab } = require("sdk/tabs/utils")
|
||||||
const { getMostRecentBrowserWindow } = require("sdk/window/utils");
|
const { getMostRecentBrowserWindow } = require("sdk/window/utils");
|
||||||
const { open: openNewWindow } = require("sdk/window/helpers");
|
const { open: openNewWindow, close: closeWindow } = require("sdk/window/helpers");
|
||||||
const { Loader } = require("sdk/test/loader");
|
const { Loader } = require("sdk/test/loader");
|
||||||
const { setTimeout } = require("sdk/timers");
|
const { setTimeout } = require("sdk/timers");
|
||||||
const { Cu } = require("chrome");
|
const { Cu } = require("chrome");
|
||||||
@@ -698,13 +698,13 @@ exports["test Selection Listener"] = function(assert, done) {
|
|||||||
|
|
||||||
selection.once("select", function() {
|
selection.once("select", function() {
|
||||||
assert.equal(selection.text, "fo");
|
assert.equal(selection.text, "fo");
|
||||||
|
close();
|
||||||
|
loader.unload();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
open(URL).then(selectContentFirstDiv).
|
open(URL).then(selectContentFirstDiv).
|
||||||
then(dispatchSelectionEvent).
|
then(dispatchSelectionEvent, assert.fail);
|
||||||
then(close).
|
|
||||||
then(loader.unload, assert.fail);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports["test Textarea OnSelect Listener"] = function(assert, done) {
|
exports["test Textarea OnSelect Listener"] = function(assert, done) {
|
||||||
@@ -713,13 +713,13 @@ exports["test Textarea OnSelect Listener"] = function(assert, done) {
|
|||||||
|
|
||||||
selection.once("select", function() {
|
selection.once("select", function() {
|
||||||
assert.equal(selection.text, "noodles");
|
assert.equal(selection.text, "noodles");
|
||||||
|
close();
|
||||||
|
loader.unload();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
open(URL).then(selectTextarea).
|
open(URL).then(selectTextarea).
|
||||||
then(dispatchOnSelectEvent).
|
then(dispatchOnSelectEvent, assert.fail);
|
||||||
then(close).
|
|
||||||
then(loader.unload, assert.fail);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports["test Selection listener removed on unload"] = function(assert, done) {
|
exports["test Selection listener removed on unload"] = function(assert, done) {
|
||||||
@@ -769,14 +769,14 @@ exports["test Selection Listener on existing document"] = function(assert, done)
|
|||||||
|
|
||||||
selection.once("select", function() {
|
selection.once("select", function() {
|
||||||
assert.equal(selection.text, "fo");
|
assert.equal(selection.text, "fo");
|
||||||
|
close();
|
||||||
|
loader.unload();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}).then(selectContentFirstDiv).
|
}).then(selectContentFirstDiv).
|
||||||
then(dispatchSelectionEvent).
|
then(dispatchSelectionEvent, assert.fail);
|
||||||
then(close).
|
|
||||||
then(loader.unload, assert.fail);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -788,14 +788,14 @@ exports["test Textarea OnSelect Listener on existing document"] = function(asser
|
|||||||
|
|
||||||
selection.once("select", function() {
|
selection.once("select", function() {
|
||||||
assert.equal(selection.text, "noodles");
|
assert.equal(selection.text, "noodles");
|
||||||
|
close();
|
||||||
|
loader.unload();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}).then(selectTextarea).
|
}).then(selectTextarea).
|
||||||
then(dispatchOnSelectEvent).
|
then(dispatchOnSelectEvent, assert.fail);
|
||||||
then(close).
|
|
||||||
then(loader.unload, assert.fail);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports["test Selection Listener on document reload"] = function(assert, done) {
|
exports["test Selection Listener on document reload"] = function(assert, done) {
|
||||||
@@ -804,15 +804,15 @@ exports["test Selection Listener on document reload"] = function(assert, done) {
|
|||||||
|
|
||||||
selection.once("select", function() {
|
selection.once("select", function() {
|
||||||
assert.equal(selection.text, "fo");
|
assert.equal(selection.text, "fo");
|
||||||
|
close();
|
||||||
|
loader.unload();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
open(URL).
|
open(URL).
|
||||||
then(reload).
|
then(reload).
|
||||||
then(selectContentFirstDiv).
|
then(selectContentFirstDiv).
|
||||||
then(dispatchSelectionEvent).
|
then(dispatchSelectionEvent, assert.fail);
|
||||||
then(close).
|
|
||||||
then(loader.unload, assert.fail);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports["test Textarea OnSelect Listener on document reload"] = function(assert, done) {
|
exports["test Textarea OnSelect Listener on document reload"] = function(assert, done) {
|
||||||
@@ -821,15 +821,15 @@ exports["test Textarea OnSelect Listener on document reload"] = function(assert,
|
|||||||
|
|
||||||
selection.once("select", function() {
|
selection.once("select", function() {
|
||||||
assert.equal(selection.text, "noodles");
|
assert.equal(selection.text, "noodles");
|
||||||
|
close();
|
||||||
|
loader.unload();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
open(URL).
|
open(URL).
|
||||||
then(reload).
|
then(reload).
|
||||||
then(selectTextarea).
|
then(selectTextarea).
|
||||||
then(dispatchOnSelectEvent).
|
then(dispatchOnSelectEvent, assert.fail);
|
||||||
then(close).
|
|
||||||
then(loader.unload, assert.fail);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports["test Selection Listener on frame"] = function(assert, done) {
|
exports["test Selection Listener on frame"] = function(assert, done) {
|
||||||
@@ -884,7 +884,7 @@ exports["test PBPW Selection Listener"] = function(assert, done) {
|
|||||||
open(URL, {private: true}).
|
open(URL, {private: true}).
|
||||||
then(selectContentFirstDiv).
|
then(selectContentFirstDiv).
|
||||||
then(dispatchSelectionEvent).
|
then(dispatchSelectionEvent).
|
||||||
then(close).
|
then(closeWindow).
|
||||||
then(loader.unload).
|
then(loader.unload).
|
||||||
then(done, assert.fail);
|
then(done, assert.fail);
|
||||||
};
|
};
|
||||||
@@ -902,7 +902,7 @@ exports["test PBPW Textarea OnSelect Listener"] = function(assert, done) {
|
|||||||
open(URL, {private: true}).
|
open(URL, {private: true}).
|
||||||
then(selectTextarea).
|
then(selectTextarea).
|
||||||
then(dispatchOnSelectEvent).
|
then(dispatchOnSelectEvent).
|
||||||
then(close).
|
then(closeWindow).
|
||||||
then(loader.unload).
|
then(loader.unload).
|
||||||
then(done, assert.fail);
|
then(done, assert.fail);
|
||||||
};
|
};
|
||||||
@@ -931,7 +931,7 @@ exports["test PBPW Single DOM Selection"] = function(assert, done) {
|
|||||||
"No iterable selection in PBPW");
|
"No iterable selection in PBPW");
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}).then(close).then(loader.unload).then(done, assert.fail);
|
}).then(closeWindow).then(loader.unload).then(done, assert.fail);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports["test PBPW Textarea Selection"] = function(assert, done) {
|
exports["test PBPW Textarea Selection"] = function(assert, done) {
|
||||||
@@ -964,7 +964,7 @@ exports["test PBPW Textarea Selection"] = function(assert, done) {
|
|||||||
"No iterable selection in PBPW");
|
"No iterable selection in PBPW");
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}).then(close).then(loader.unload).then(done, assert.fail);
|
}).then(closeWindow).then(loader.unload).then(done, assert.fail);
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: test Selection Listener on long-held connection (Bug 661884)
|
// TODO: test Selection Listener on long-held connection (Bug 661884)
|
||||||
|
|||||||
@@ -172,4 +172,4 @@ exports["test modelFor(xulTab)"] = (assert, done) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
require("test").run(exports);
|
require("sdk/test").run(exports);
|
||||||
|
|||||||
@@ -563,33 +563,34 @@ exports.testDestroyEdgeCaseBug = function(assert, done) {
|
|||||||
|
|
||||||
sidebar.show();
|
sidebar.show();
|
||||||
assert.pass('showing the sidebar');
|
assert.pass('showing the sidebar');
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.testClickingACheckedMenuitem = function(assert, done) {
|
exports.testClickingACheckedMenuitem = function(assert, done) {
|
||||||
const { Sidebar } = require('sdk/ui/sidebar');
|
const { Sidebar } = require('sdk/ui/sidebar');
|
||||||
let testName = 'testClickingACheckedMenuitem';
|
const testName = 'testClickingACheckedMenuitem';
|
||||||
let window = getMostRecentBrowserWindow();
|
|
||||||
let sidebar = Sidebar({
|
let sidebar = Sidebar({
|
||||||
id: testName,
|
id: testName,
|
||||||
title: testName,
|
title: testName,
|
||||||
url: 'data:text/html;charset=utf-8,'+testName,
|
url: 'data:text/html;charset=utf-8,'+testName,
|
||||||
});
|
});
|
||||||
|
assert.pass('sidebar was created');
|
||||||
|
|
||||||
sidebar.show().then(function() {
|
open().then(focus).then(window => {
|
||||||
assert.pass('the show callback works');
|
return sidebar.show().then(_ => {
|
||||||
|
assert.pass('the show callback works');
|
||||||
|
|
||||||
sidebar.once('hide', function() {
|
sidebar.once('hide', _ => {
|
||||||
assert.pass('clicking the menuitem after the sidebar has shown hides it.');
|
assert.pass('clicking the menuitem after the sidebar has shown hides it.');
|
||||||
sidebar.destroy();
|
sidebar.destroy();
|
||||||
done();
|
close(window).then(done, assert.fail);
|
||||||
|
});
|
||||||
|
|
||||||
|
let menuitem = window.document.getElementById(makeID(sidebar.id));
|
||||||
|
simulateCommand(menuitem);
|
||||||
});
|
});
|
||||||
|
}).catch(assert.fail);
|
||||||
let menuitem = window.document.getElementById(makeID(sidebar.id));
|
|
||||||
simulateCommand(menuitem);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.testTitleSetter = function(assert, done) {
|
exports.testTitleSetter = function(assert, done) {
|
||||||
|
|||||||
@@ -90,37 +90,30 @@ exports['test close on unload'] = function(assert) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.testWindowTracker = function(assert, done) {
|
exports.testWindowTracker = function(assert, done) {
|
||||||
var myWindow;
|
var myWindow = makeEmptyWindow();
|
||||||
var finished = false;
|
assert.pass('window was created');
|
||||||
|
|
||||||
var delegate = {
|
myWindow.addEventListener("load", function onload() {
|
||||||
onTrack: function(window) {
|
myWindow.removeEventListener("load", onload, false);
|
||||||
if (window == myWindow) {
|
assert.pass("test window has opened");
|
||||||
assert.pass("onTrack() called with our test window");
|
|
||||||
timer.setTimeout(function() myWindow.close());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onUntrack: function(window) {
|
|
||||||
if (window == myWindow) {
|
|
||||||
assert.pass("onUntrack() called with our test window");
|
|
||||||
timer.setTimeout(function() {
|
|
||||||
if (!finished) {
|
|
||||||
finished = true;
|
|
||||||
myWindow = null;
|
|
||||||
wt.unload();
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
assert.fail("finishTest() called multiple times.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// test bug 638007 (new is optional), using new
|
// test bug 638007 (new is optional), using new
|
||||||
var wt = new windowUtils.WindowTracker(delegate);
|
var wt = new windowUtils.WindowTracker({
|
||||||
myWindow = makeEmptyWindow();
|
onTrack: window => {
|
||||||
|
if (window === myWindow) {
|
||||||
|
assert.pass("onTrack() called with our test window");
|
||||||
|
close(window);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onUntrack: window => {
|
||||||
|
if (window === myWindow) {
|
||||||
|
assert.pass("onUntrack() called with our test window");
|
||||||
|
wt.unload();
|
||||||
|
timer.setTimeout(done);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports['test window watcher untracker'] = function(assert, done) {
|
exports['test window watcher untracker'] = function(assert, done) {
|
||||||
|
|||||||
Reference in New Issue
Block a user