Bug 907509 - Uplift Addon SDK to fx-team

This commit is contained in:
Wes Kocher 2013-08-20 18:24:12 -07:00
Родитель 25d85daf30
Коммит 0563e70cbf
124 изменённых файлов: 950 добавлений и 1335 удалений

3
addon-sdk/source/app-extension/bootstrap.js поставляемый
Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 expandtab */
/* 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/. */
@ -222,8 +221,6 @@ function startup(data, reasonCode) {
resultFile: options.resultFile,
// Arguments passed as --static-args
staticArgs: options.staticArgs,
// Add-on preferences branch name
preferencesBranch: options.preferencesBranch,
// Arguments related to test runner.
modules: {

Просмотреть файл

@ -99,7 +99,7 @@ function Method(hint) {
// in the host object's prototype chain. This avoids memory
// leaks that otherwise could happen when saving JS objects
// on host object.
host[value["!" + name]] ||
host[value["!" + name] || void(0)] ||
// Otherwise attempt to lookup implementation for builtins by
// a type of the value. This basically makes sure that all
// non primitive values will delegate to an `Object`.

Просмотреть файл

@ -3,11 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
module.metadata = {
"stability": "experimental",
"engines": {
// TODO Fennec Support in bug 894515
"Firefox": "*"
}
"stability": "experimental"
};
const { Cc, Ci, Cu } = require("chrome");

Просмотреть файл

@ -1,8 +1,6 @@
/* vim:set ts=2 sw=2 sts=2 expandtab */
/* 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/.
*/
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
module.metadata = {
"stability": "experimental"
@ -15,6 +13,7 @@ const { exit, env, staticArgs } = require('../system');
const { when: unload } = require('../system/unload');
const { loadReason } = require('../self');
const { rootURI } = require("@loader/options");
const cfxArgs = require("@test/options");
const globals = require('../system/globals');
const xulApp = require('../system/xul-app');
const appShellService = Cc['@mozilla.org/appshell/appShellService;1'].
@ -103,7 +102,11 @@ function startup(reason, options) {
// Run the addon even in case of error (best effort approach)
require('../l10n/loader').
load(rootURI).
then(null, function failure(error) {
then(function l10nSuccess() {
if (cfxArgs.parseable) {
console.info("localization information has loaded successfully.");
}
}, function l10nFailure(error) {
console.info("Error while loading localization: " + error.message);
}).
then(function onLocalizationReady(data) {
@ -112,6 +115,10 @@ function startup(reason, options) {
definePseudo(options.loader, '@l10n/data', data ? data : null);
return ready;
}).then(function() {
if (cfxArgs.parseable) {
console.info("addon window has loaded successfully.");
}
run(options);
}).then(null, console.exception);
}
@ -130,6 +137,7 @@ function run(options) {
catch(error) {
console.exception(error);
}
// Initialize inline options localization, without preventing addon to be
// run in case of error
try {
@ -159,7 +167,8 @@ function run(options) {
quit: exit
});
}
} catch (error) {
}
catch (error) {
console.exception(error);
throw error;
}

Просмотреть файл

@ -1,8 +1,6 @@
/* 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/.
*/
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
module.metadata = {

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -20,7 +20,7 @@ const SDK_LOG_LEVEL_PREF = "extensions.sdk.console.logLevel";
let logLevel = DEFAULT_LOG_LEVEL;
function setLogLevel() {
logLevel = prefs.get(ADDON_LOG_LEVEL_PREF,
logLevel = prefs.get(ADDON_LOG_LEVEL_PREF,
prefs.get(SDK_LOG_LEVEL_PREF,
DEFAULT_LOG_LEVEL));
}

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,9 +1,6 @@
/* vim:set ts=2 sw=2 sts=2 expandtab */
/* 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/.
*/
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict';
module.metadata = {

Просмотреть файл

@ -1,7 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 expandtab */
/*jshint undef: true es5: true node: true browser: true devel: true
forin: true latedef: false */
/*global define: true, Cu: true, __URI__: true */
;(function(id, factory) { // Module boilerplate :(
if (typeof(define) === 'function') { // RequireJS
define(factory);

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,4 @@
/* vim:set ts=2 sw=2 sts=2
* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,4 @@
/* vim:ts=2:sts=2:sw=2:
* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */

Просмотреть файл

@ -1,5 +1,4 @@
/* vim:st=2:sts=2:sw=2:
* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,7 +1,6 @@
/* 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/.
*/
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
module.metadata = {

Просмотреть файл

@ -1,6 +1,4 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:set ts=2 sw=2 sts=2 et filetype=javascript
* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */

Просмотреть файл

@ -1,7 +1,6 @@
/* 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/.
*/
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
module.metadata = {
@ -927,4 +926,4 @@ exports.unwatchFile = unwatchFile;
function watch(path, options, listener) {
throw Error("Not implemented");
}
exports.watch = watch;
exports.watch = watch;

Просмотреть файл

@ -1,7 +1,6 @@
/* 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/.
*/
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
module.metadata = {

Просмотреть файл

@ -1,6 +1,4 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:set ts=2 sw=2 sts=2 et filetype=javascript
* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,4 @@
/* vim:ts=2:sts=2:sw=2:
* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */

Просмотреть файл

@ -1,9 +1,6 @@
/* vim:set ts=2 sw=2 sts=2 expandtab */
/* 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/.
*/
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict';
module.metadata = {

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,6 +1,4 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:set ts=2 sw=2 sts=2 et filetype=javascript
* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,4 @@
/* vim:st=2:sts=2:sw=2:
* This Source Code Form is subject to the terms of the Mozilla Public
/* 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";

Просмотреть файл

@ -11,11 +11,9 @@ const { emit, off } = require("./event/core");
const { when: unload } = require("./system/unload");
const { PrefsTarget } = require("./preferences/event-target");
const { id } = require("./self");
const { preferencesBranch } = require('@loader/options');
const observers = require("./deprecated/observer-service");
const ADDON_BRANCH = "extensions." + preferencesBranch + ".";
const ADDON_BRANCH = "extensions." + id + ".";
const BUTTON_PRESSED = id + "-cmdPressed";
const target = PrefsTarget({ branchName: ADDON_BRANCH });

Просмотреть файл

@ -1,6 +1,4 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:set ts=2 sw=2 sts=2 et filetype=javascript
* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 expandtab */
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 expandtab */
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 expandtab */
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,4 @@
/* vim:ts=2:sts=2:sw=2:
* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */

Просмотреть файл

@ -1,5 +1,4 @@
/* vim:ts=2:sts=2:sw=2:
* This Source Code Form is subject to the terms of the Mozilla Public
/* 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";

Просмотреть файл

@ -426,7 +426,7 @@ var POINTLESS_ERRORS = [
'Invalid chrome URI:',
'OpenGL LayerManager Initialized Succesfully.',
'[JavaScript Error: "TelemetryStopwatch:',
'[JavaScript Warning: "ReferenceError: reference to undefined property',
'reference to undefined property',
'[JavaScript Error: "The character encoding of the HTML document was ' +
'not declared.',
'[Javascript Warning: "Error: Failed to preserve wrapper of wrapped ' +

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,4 @@
/* vim:ts=2:sts=2:sw=2:
* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,4 +1,3 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,5 +1,4 @@
/* vim:ts=2:sts=2:sw=2:
* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */

Просмотреть файл

@ -1,8 +1,7 @@
/* vim:set ts=2 sw=2 sts=2 expandtab */
/* 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/.
*/
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
;(function(id, factory) { // Module boilerplate :(
if (typeof(define) === 'function') { // RequireJS
define(factory);

Просмотреть файл

@ -2,7 +2,7 @@
# 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/.
def parse_options_defaults(options, preferencesBranch):
def parse_options_defaults(options, jetpack_id):
# this returns a unicode string
pref_list = []
@ -21,6 +21,6 @@ def parse_options_defaults(options, preferencesBranch):
else:
value = str(pref["value"])
pref_list.append("pref(\"extensions." + preferencesBranch + "." + pref["name"] + "\", " + value + ");")
pref_list.append("pref(\"extensions." + jetpack_id + "." + pref["name"] + "\", " + value + ");")
return "\n".join(pref_list) + "\n"

Просмотреть файл

@ -45,7 +45,7 @@ def validate_prefs(options):
# TODO: Check that pref["type"] matches default value type
def parse_options(options, jetpack_id, preferencesBranch):
def parse_options(options, jetpack_id):
doc = Document()
root = doc.createElement("vbox")
root.setAttribute("xmlns", "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul")
@ -58,7 +58,7 @@ def parse_options(options, jetpack_id, preferencesBranch):
setting = doc.createElement("setting")
setting.setAttribute("pref-name", pref["name"])
setting.setAttribute("data-jetpack-id", jetpack_id)
setting.setAttribute("pref", "extensions." + preferencesBranch + "." + pref["name"])
setting.setAttribute("pref", "extensions." + jetpack_id + "." + pref["name"])
setting.setAttribute("type", pref["type"])
setting.setAttribute("title", pref["title"])

Просмотреть файл

@ -396,21 +396,6 @@ def generate_build_for_target(pkg_cfg, target, deps,
if ('preferences' in target_cfg):
build['preferences'] = target_cfg.preferences
if 'id' in target_cfg:
# NOTE: logic duplicated from buildJID()
jid = target_cfg['id']
if not ('@' in jid or jid.startswith('{')):
jid += '@jetpack'
build['preferencesBranch'] = jid
if 'preferences-branch' in target_cfg:
# check it's a non-empty, valid branch name
preferencesBranch = target_cfg['preferences-branch']
if re.match('^[\w{@}-]+$', preferencesBranch):
build['preferencesBranch'] = preferencesBranch
elif not is_running_tests:
print >>sys.stderr, "IGNORING preferences-branch (not a valid branch name)"
return build
def _get_files_in_dir(path):

Просмотреть файл

@ -1,14 +0,0 @@
{
"id": "{34a1eae1-c20a-464f-9b0e-000000000000}",
"fullName": "curly ID test",
"author": "Tomislav Jovanovic",
"preferences": [{
"name": "test13",
"type": "integer",
"title": "test13",
"value": 26
}],
"preferences-branch": "invalid^branch*name"
}

Просмотреть файл

@ -1,4 +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/. */

Просмотреть файл

@ -1,14 +0,0 @@
{
"id": "test-preferences-branch",
"fullName": "preferences-branch test",
"author": "Tomislav Jovanovic",
"preferences": [{
"name": "test42",
"type": "bool",
"title": "test42",
"value": true
}],
"preferences-branch": "human-readable"
}

Просмотреть файл

@ -22,8 +22,7 @@ def get_configs(pkg_name, dirname='static-files'):
build = packaging.generate_build_for_target(
pkg_cfg=pkg_cfg,
target=pkg_name,
deps=deps,
is_running_tests=True,
deps=deps
)
return Bunch(target_cfg=target_cfg, pkg_cfg=pkg_cfg, build=build)

Просмотреть файл

@ -40,11 +40,10 @@ class PrefsTests(unittest.TestCase):
def testPackageWithSimplePrefs(self):
self.makexpi('simple-prefs')
packageName = 'jid1-fZHqN9JfrDBa8A@jetpack'
self.failUnless('options.xul' in self.xpi.namelist())
optsxul = self.xpi.read('options.xul').decode("utf-8")
self.failUnlessEqual(self.xpi_harness_options["jetpackID"], packageName)
self.failUnlessEqual(self.xpi_harness_options["preferencesBranch"], packageName)
self.failUnlessEqual(self.xpi_harness_options["jetpackID"],
"jid1-fZHqN9JfrDBa8A@jetpack")
root = ElementTree.XML(optsxul.encode('utf-8'))
@ -54,6 +53,7 @@ class PrefsTests(unittest.TestCase):
settings = root.findall(xulNamespacePrefix + 'setting')
def assertPref(setting, name, prefType, title):
packageName = 'jid1-fZHqN9JfrDBa8A@jetpack'
self.failUnlessEqual(setting.get('data-jetpack-id'), packageName)
self.failUnlessEqual(setting.get('pref'),
'extensions.' + packageName + '.' + name)
@ -88,25 +88,6 @@ class PrefsTests(unittest.TestCase):
]
self.failUnlessEqual(prefsjs, "\n".join(exp)+"\n")
def testPackageWithPreferencesBranch(self):
self.makexpi('preferences-branch')
self.failUnless('options.xul' in self.xpi.namelist())
optsxul = self.xpi.read('options.xul').decode("utf-8")
self.failUnlessEqual(self.xpi_harness_options["preferencesBranch"],
"human-readable")
root = ElementTree.XML(optsxul.encode('utf-8'))
xulNamespacePrefix = \
"{http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul}"
setting = root.find(xulNamespacePrefix + 'setting')
self.failUnlessEqual(setting.get('pref'),
'extensions.human-readable.test42')
prefsjs = self.xpi.read('defaults/preferences/prefs.js').decode("utf-8")
self.failUnlessEqual(prefsjs,
'pref("extensions.human-readable.test42", true);\n')
def testPackageWithNoPrefs(self):
self.makexpi('no-prefs')
self.failIf('options.xul' in self.xpi.namelist())
@ -115,33 +96,6 @@ class PrefsTests(unittest.TestCase):
prefsjs = self.xpi.read('defaults/preferences/prefs.js').decode("utf-8")
self.failUnlessEqual(prefsjs, "")
def testPackageWithInvalidPreferencesBranch(self):
self.makexpi('curly-id')
self.failIfEqual(self.xpi_harness_options["preferencesBranch"],
"invalid^branch*name")
self.failUnlessEqual(self.xpi_harness_options["preferencesBranch"],
"{34a1eae1-c20a-464f-9b0e-000000000000}")
def testPackageWithCurlyID(self):
self.makexpi('curly-id')
self.failUnlessEqual(self.xpi_harness_options["jetpackID"],
"{34a1eae1-c20a-464f-9b0e-000000000000}")
self.failUnless('options.xul' in self.xpi.namelist())
optsxul = self.xpi.read('options.xul').decode("utf-8")
root = ElementTree.XML(optsxul.encode('utf-8'))
xulNamespacePrefix = \
"{http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul}"
setting = root.find(xulNamespacePrefix + 'setting')
self.failUnlessEqual(setting.get('pref'),
'extensions.{34a1eae1-c20a-464f-9b0e-000000000000}.test13')
prefsjs = self.xpi.read('defaults/preferences/prefs.js').decode("utf-8")
self.failUnlessEqual(prefsjs,
'pref("extensions.{34a1eae1-c20a-464f-9b0e-000000000000}.test13", 26);\n')
class Bug588119Tests(unittest.TestCase):
def makexpi(self, pkg_name):

Просмотреть файл

@ -77,15 +77,14 @@ def build_xpi(template_root_dir, manifest, xpi_path,
validate_prefs(harness_options["preferences"])
opts_xul = parse_options(harness_options["preferences"],
harness_options["jetpackID"],
harness_options["preferencesBranch"])
harness_options["jetpackID"])
open('.options.xul', 'wb').write(opts_xul.encode("utf-8"))
zf.write('.options.xul', 'options.xul')
os.remove('.options.xul')
from options_defaults import parse_options_defaults
prefs_js = parse_options_defaults(harness_options["preferences"],
harness_options["preferencesBranch"])
harness_options["jetpackID"])
open('.prefs.js', 'wb').write(prefs_js.encode("utf-8"))
else:

Просмотреть файл

@ -1,45 +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';
const { id } = require('sdk/self');
const simple = require('sdk/simple-prefs');
const service = require('sdk/preferences/service');
const { preferencesBranch } = require('@loader/options');
const { AddonManager } = require('chrome').Cu.import('resource://gre/modules/AddonManager.jsm');
exports.testCurlyID = function(assert) {
assert.equal(id, '{34a1eae1-c20a-464f-9b0e-000000000000}', 'curly ID is curly');
assert.equal(simple.prefs.test13, 26, 'test13 is 26');
simple.prefs.test14 = '15';
assert.equal(service.get('extensions.{34a1eae1-c20a-464f-9b0e-000000000000}.test14'), '15', 'test14 is 15');
assert.equal(service.get('extensions.{34a1eae1-c20a-464f-9b0e-000000000000}.test14'), simple.prefs.test14, 'simple test14 also 15');
}
exports.testInvalidPreferencesBranch = function(assert) {
assert.notEqual(preferencesBranch, 'invalid^branch*name', 'invalid preferences-branch value ignored');
assert.equal(preferencesBranch, '{34a1eae1-c20a-464f-9b0e-000000000000}', 'preferences-branch is {34a1eae1-c20a-464f-9b0e-000000000000}');
}
// from `/test/test-self.js`, adapted to `sdk/test/assert` API
exports.testSelfID = function(assert, done) {
assert.equal(typeof(id), 'string', 'self.id is a string');
assert.ok(id.length > 0, 'self.id not empty');
AddonManager.getAddonByID(id, function(addon) {
assert.ok(addon, 'found addon with self.id');
done();
});
}
require('sdk/test/runner').runTestsFromModule(module);

Просмотреть файл

@ -1,14 +0,0 @@
{
"id": "{34a1eae1-c20a-464f-9b0e-000000000000}",
"fullName": "curly ID test",
"author": "Tomislav Jovanovic",
"preferences": [{
"name": "test13",
"type": "integer",
"title": "test13",
"value": 26
}],
"preferences-branch": "invalid^branch*name"
}

Просмотреть файл

@ -1,35 +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';
const { id } = require('sdk/self');
const simple = require('sdk/simple-prefs');
const service = require('sdk/preferences/service');
const { preferencesBranch } = require('@loader/options');
const { AddonManager } = require('chrome').Cu.import('resource://gre/modules/AddonManager.jsm', {});
const expected_id = 'predefined-id@test';
exports.testExpectedID = function(assert) {
assert.equal(id, expected_id, 'ID is as expected');
assert.equal(preferencesBranch, expected_id, 'preferences-branch is ' + expected_id);
assert.equal(simple.prefs.test, 5, 'test pref is 5');
simple.prefs.test2 = '25';
assert.equal(service.get('extensions.'+expected_id+'.test2'), '25', 'test pref is 25');
assert.equal(service.get('extensions.'+expected_id+'.test2'), simple.prefs.test2, 'test pref is 25');
}
exports.testSelfID = function(assert, done) {
assert.equal(typeof(id), 'string', 'self.id is a string');
assert.ok(id.length > 0, 'self.id not empty');
AddonManager.getAddonByID(id, function(addon) {
assert.equal(addon.id, id, 'found addon with self.id');
done();
});
}
require('sdk/test/runner').runTestsFromModule(module);

Просмотреть файл

@ -1,11 +0,0 @@
{
"id": "predefined-id@test",
"fullName": "predefined ID test",
"author": "Erik Vold",
"preferences": [{
"name": "test",
"type": "integer",
"title": "test",
"value": 5
}]
}

Просмотреть файл

@ -1,36 +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';
const { id } = require('sdk/self');
const simple = require('sdk/simple-prefs');
const service = require('sdk/preferences/service');
const { preferencesBranch } = require('@loader/options');
const { AddonManager } = require('chrome').Cu.import('resource://gre/modules/AddonManager.jsm');
exports.testPreferencesBranch = function(assert) {
assert.equal(preferencesBranch, 'human-readable', 'preferencesBranch is human-readable');
assert.equal(simple.prefs.test42, true, 'test42 is true');
simple.prefs.test43 = 'movie';
assert.equal(service.get('extensions.human-readable.test43'), 'movie', 'test43 is a movie');
}
// from `/test/test-self.js`, adapted to `sdk/test/assert` API
exports.testSelfID = function(assert, done) {
assert.equal(typeof(id), 'string', 'self.id is a string');
assert.ok(id.length > 0, 'self.id not empty');
AddonManager.getAddonByID(id, function(addon) {
assert.ok(addon, 'found addon with self.id');
done();
});
}
require('sdk/test/runner').runTestsFromModule(module);

Просмотреть файл

@ -1,14 +0,0 @@
{
"id": "test-preferences-branch",
"fullName": "preferences-branch test",
"author": "Tomislav Jovanovic",
"preferences": [{
"name": "test42",
"type": "bool",
"title": "test42",
"value": true
}],
"preferences-branch": "human-readable"
}

Просмотреть файл

@ -8,7 +8,6 @@ const sp = require('sdk/simple-prefs');
const app = require('sdk/system/xul-app');
const self = require('sdk/self');
const tabs = require('sdk/tabs');
const { preferencesBranch } = require('@loader/options');
const { AddonManager } = Cu.import('resource://gre/modules/AddonManager.jsm', {});
@ -90,8 +89,4 @@ if (app.is('Firefox')) {
}
}
exports.testDefaultPreferencesBranch = function(assert) {
assert.equal(preferencesBranch, self.id, 'preferencesBranch default the same as self.id');
}
require('sdk/test/runner').runTestsFromModule(module);

Просмотреть файл

@ -1,45 +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';
const { id } = require('sdk/self');
const simple = require('sdk/simple-prefs');
const service = require('sdk/preferences/service');
const { preferencesBranch } = require('@loader/options');
const { AddonManager } = require('chrome').Cu.import('resource://gre/modules/AddonManager.jsm');
exports.testStandardID = function(assert) {
assert.equal(id, 'standard-id@jetpack', 'standard ID is standard');
assert.equal(simple.prefs.test13, 26, 'test13 is 26');
simple.prefs.test14 = '15';
assert.equal(service.get('extensions.standard-id@jetpack.test14'), '15', 'test14 is 15');
assert.equal(service.get('extensions.standard-id@jetpack.test14'), simple.prefs.test14, 'simple test14 also 15');
}
exports.testInvalidPreferencesBranch = function(assert) {
assert.notEqual(preferencesBranch, 'invalid^branch*name', 'invalid preferences-branch value ignored');
assert.equal(preferencesBranch, 'standard-id@jetpack', 'preferences-branch is standard-id@jetpack');
}
// from `/test/test-self.js`, adapted to `sdk/test/assert` API
exports.testSelfID = function(assert, done) {
assert.equal(typeof(id), 'string', 'self.id is a string');
assert.ok(id.length > 0, 'self.id not empty');
AddonManager.getAddonByID(id, function(addon) {
assert.ok(addon, 'found addon with self.id');
done();
});
}
require('sdk/test/runner').runTestsFromModule(module);

Просмотреть файл

@ -1,14 +0,0 @@
{
"id": "standard-id",
"fullName": "standard ID test",
"author": "Tomislav Jovanovic",
"preferences": [{
"name": "test13",
"type": "integer",
"title": "test13",
"value": 26
}],
"preferences-branch": "invalid^branch*name"
}

Двоичные данные
addon-sdk/source/test/fixtures/addon-install-unit-test@mozilla.com.xpi поставляемый

Двоичный файл не отображается.

Просмотреть файл

@ -1,8 +1,6 @@
/* 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/.
*/
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict';
postMessage('Hello');

Просмотреть файл

@ -1,8 +1,6 @@
/* 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/.
*/
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict';
postMessage(typeof ctypes.open);

Просмотреть файл

@ -1,8 +1,6 @@
/* 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/.
*/
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict';
throw new Error('ok');

Просмотреть файл

@ -1,8 +1,6 @@
/* 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/.
*/
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict';
onmessage = function (event) {

Просмотреть файл

@ -1,8 +1,6 @@
/* 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/.
*/
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict';
setTimeout(function () {

Просмотреть файл

@ -1,8 +1,6 @@
/* 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/.
*/
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict';
let xhr = XMLHttpRequest();

Просмотреть файл

@ -13,10 +13,7 @@ const { StringBundle } = require('sdk/deprecated/app-strings');
const tabs = require('sdk/tabs');
const { browserWindows } = require('sdk/windows');
const base64png = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYA" +
"AABzenr0AAAASUlEQVRYhe3O0QkAIAwD0eyqe3Q993AQ3cBSUKpygfsNTy" +
"N5ugbQpK0BAADgP0BRDWXWlwEAAAAAgPsA3rzDaAAAAHgPcGrpgAnzQ2FG" +
"bWRR9AAAAABJRU5ErkJggg%3D%3D";
const base64png = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAA";
// Bug 682681 - tab.title should never be empty
exports.testBug682681_aboutURI = function(assert, done) {
@ -864,50 +861,45 @@ exports['test unique tab ids'] = function(assert, done) {
// related to Bug 671305
exports.testOnLoadEventWithDOM = function(assert, done) {
openBrowserWindow(function(window, browser) {
let count = 0;
tabs.on('load', function onLoad(tab) {
assert.equal(tab.title, 'tab', 'tab passed in as arg, load called');
if (!count++) {
tab.reload();
let count = 0;
let title = 'testOnLoadEventWithDOM';
// open a about: url
tabs.open({
url: 'data:text/html;charset=utf-8,<title>' + title + '</title>',
inBackground: true,
onLoad: function(tab) {
assert.equal(tab.title, title, 'tab passed in as arg, load called');
if (++count > 1) {
assert.pass('onLoad event called on reload');
tab.close(done);
}
else {
// end of test
tabs.removeListener('load', onLoad);
assert.pass('onLoad event called on reload');
close(window).then(done);
assert.pass('first onLoad event occured');
tab.reload();
}
});
// open a about: url
tabs.open({
url: 'data:text/html;charset=utf-8,<title>tab</title>',
inBackground: true
});
}
});
};
// related to Bug 671305
exports.testOnLoadEventWithImage = function(assert, done) {
openBrowserWindow(function(window, browser) {
let count = 0;
tabs.on('load', function onLoad(tab) {
if (!count++) {
tab.reload();
let count = 0;
tabs.open({
url: base64png,
inBackground: true,
onLoad: function(tab) {
if (++count > 1) {
assert.pass('onLoad event called on reload with image');
tab.close(done);
}
else {
// end of test
tabs.removeListener('load', onLoad);
assert.pass('onLoad event called on reload with image');
close(window).then(done);
assert.pass('first onLoad event occured');
tab.reload();
}
});
// open a image url
tabs.open({
url: base64png,
inBackground: true
});
}
});
};

Просмотреть файл

@ -0,0 +1,22 @@
/* 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';
let { Loader } = require('sdk/test/loader');
exports.testReady = function(assert, done) {
let loader = Loader(module);
let { ready, window } = loader.require('sdk/addon/window');
let windowIsReady = false;
ready.then(function() {
assert.equal(windowIsReady, false, 'ready promise was resolved only once');
windowIsReady = true;
loader.unload();
done();
}).then(null, assert.fail);
}
require('sdk/test').run(exports);

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */

Просмотреть файл

@ -1,6 +1,4 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:set ts=2 sw=2 sts=2 et filetype=javascript
* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */

Просмотреть файл

@ -1,8 +1,6 @@
/* 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/.
*/
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict';
let chrome = require('chrome');
@ -72,7 +70,7 @@ exports['test onerror'] = function(assert, done) {
let worker = new chrome.ChromeWorker(uri);
worker.onerror = function(event) {
assert.equal(event.filename, uri, 'event reports the correct uri');
assert.equal(event.lineno, 8, 'event reports the correct line number');
assert.equal(event.lineno, 6, 'event reports the correct line number');
assert.equal(event.target, worker, 'event reports the correct worker');
assert.ok(event.message.match(/ok/),
'event contains the exception message');
@ -83,4 +81,4 @@ exports['test onerror'] = function(assert, done) {
};
};
require('test').run(exports);
require('sdk/test').run(exports);

Просмотреть файл

@ -1,7 +1,6 @@
/* 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";
require("sdk/clipboard");

Просмотреть файл

@ -1,81 +1,80 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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 collection = require("sdk/util/collection");
exports.testAddRemove = function (test) {
exports.testAddRemove = function (assert) {
let coll = new collection.Collection();
compare(test, coll, []);
addRemove(test, coll, [], false);
compare(assert, coll, []);
addRemove(assert, coll, [], false);
};
exports.testAddRemoveBackingArray = function (test) {
exports.testAddRemoveBackingArray = function (assert) {
let items = ["foo"];
let coll = new collection.Collection(items);
compare(test, coll, items);
addRemove(test, coll, items, true);
compare(assert, coll, items);
addRemove(assert, coll, items, true);
items = ["foo", "bar"];
coll = new collection.Collection(items);
compare(test, coll, items);
addRemove(test, coll, items, true);
compare(assert, coll, items);
addRemove(assert, coll, items, true);
};
exports.testProperty = function (test) {
exports.testProperty = function (assert) {
let obj = makeObjWithCollProp();
compare(test, obj.coll, []);
addRemove(test, obj.coll, [], false);
compare(assert, obj.coll, []);
addRemove(assert, obj.coll, [], false);
// Test single-value set.
let items = ["foo"];
obj.coll = items[0];
compare(test, obj.coll, items);
addRemove(test, obj.coll, items, false);
compare(assert, obj.coll, items);
addRemove(assert, obj.coll, items, false);
// Test array set.
items = ["foo", "bar"];
obj.coll = items;
compare(test, obj.coll, items);
addRemove(test, obj.coll, items, false);
compare(assert, obj.coll, items);
addRemove(assert, obj.coll, items, false);
};
exports.testPropertyBackingArray = function (test) {
exports.testPropertyBackingArray = function (assert) {
let items = ["foo"];
let obj = makeObjWithCollProp(items);
compare(test, obj.coll, items);
addRemove(test, obj.coll, items, true);
compare(assert, obj.coll, items);
addRemove(assert, obj.coll, items, true);
items = ["foo", "bar"];
obj = makeObjWithCollProp(items);
compare(test, obj.coll, items);
addRemove(test, obj.coll, items, true);
compare(assert, obj.coll, items);
addRemove(assert, obj.coll, items, true);
};
// Adds some values to coll and then removes them. initialItems is an array
// containing coll's initial items. isBacking is true if initialItems is coll's
// backing array; the point is that updates to coll should affect initialItems
// if that's the case.
function addRemove(test, coll, initialItems, isBacking) {
function addRemove(assert, coll, initialItems, isBacking) {
let items = isBacking ? initialItems : initialItems.slice(0);
let numInitialItems = items.length;
// Test add(val).
let numInsertions = 5;
for (let i = 0; i < numInsertions; i++) {
compare(test, coll, items);
compare(assert, coll, items);
coll.add(i);
if (!isBacking)
items.push(i);
}
compare(test, coll, items);
compare(assert, coll, items);
// Add the items we just added to make sure duplicates aren't added.
for (let i = 0; i < numInsertions; i++)
coll.add(i);
compare(test, coll, items);
compare(assert, coll, items);
// Test remove(val). Do a kind of shuffled remove. Remove item 1, then
// item 0, 3, 2, 5, 4, ...
@ -85,37 +84,37 @@ function addRemove(test, coll, initialItems, isBacking) {
coll.remove(val);
if (!isBacking)
items.splice(items.indexOf(val), 1);
compare(test, coll, items);
compare(assert, coll, items);
}
test.assertEqual(coll.length, numInitialItems,
"All inserted items should be removed");
assert.equal(coll.length, numInitialItems,
"All inserted items should be removed");
// Remove the items we just removed. coll should be unchanged.
for (let i = 0; i < numInsertions; i++)
coll.remove(i);
compare(test, coll, items);
compare(assert, coll, items);
// Test add and remove([val1, val2]).
let newItems = [0, 1];
coll.add(newItems);
compare(test, coll, isBacking ? items : items.concat(newItems));
compare(assert, coll, isBacking ? items : items.concat(newItems));
coll.remove(newItems);
compare(test, coll, items);
test.assertEqual(coll.length, numInitialItems,
"All inserted items should be removed");
compare(assert, coll, items);
assert.equal(coll.length, numInitialItems,
"All inserted items should be removed");
}
// Asserts that the items in coll are the items of array.
function compare(test, coll, array) {
test.assertEqual(coll.length, array.length,
"Collection length should be correct");
function compare(assert, coll, array) {
assert.equal(coll.length, array.length,
"Collection length should be correct");
let numItems = 0;
for (let item in coll) {
test.assertEqual(item, array[numItems], "Items should be equal");
assert.equal(item, array[numItems], "Items should be equal");
numItems++;
}
test.assertEqual(numItems, array.length,
"Number of items in iteration should be correct");
assert.equal(numItems, array.length,
"Number of items in iteration should be correct");
}
// Returns a new object with a collection property named "coll". backingArray,
@ -125,3 +124,5 @@ function makeObjWithCollProp(backingArray) {
collection.addCollectionProperty(obj, "coll", backingArray);
return obj;
}
require("sdk/test").run(exports);

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше