Bug 1248855 - [webext] Add "object-curly-spacing" ESLint rule and auto-fix errors. r=billm

MozReview-Commit-ID: BAZ2rRl7eSM
This commit is contained in:
Kris Maglione 2016-02-16 20:10:00 -08:00
parent 575bd7a423
commit 1ca36cb9c8
54 changed files with 423 additions and 420 deletions

View File

@ -2,7 +2,7 @@
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/PlacesUtils.jsm");
var Bookmarks = PlacesUtils.bookmarks;
@ -141,7 +141,7 @@ extensions.registerSchemaAPI("bookmarks", "bookmarks", (extension, context) => {
try {
return Bookmarks.insert(info).then(convert);
} catch (e) {
return Promise.reject({ message: `Invalid bookmark: ${JSON.stringify(info)}` });
return Promise.reject({message: `Invalid bookmark: ${JSON.stringify(info)}`});
}
},
@ -160,7 +160,7 @@ extensions.registerSchemaAPI("bookmarks", "bookmarks", (extension, context) => {
try {
return Bookmarks.update(info).then(convert);
} catch (e) {
return Promise.reject({ message: `Invalid bookmark: ${JSON.stringify(info)}` });
return Promise.reject({message: `Invalid bookmark: ${JSON.stringify(info)}`});
}
},
@ -179,7 +179,7 @@ extensions.registerSchemaAPI("bookmarks", "bookmarks", (extension, context) => {
try {
return Bookmarks.update(info).then(convert);
} catch (e) {
return Promise.reject({ message: `Invalid bookmark: ${JSON.stringify(info)}` });
return Promise.reject({message: `Invalid bookmark: ${JSON.stringify(info)}`});
}
},
@ -192,7 +192,7 @@ extensions.registerSchemaAPI("bookmarks", "bookmarks", (extension, context) => {
try {
return Bookmarks.remove(info).then(result => {});
} catch (e) {
return Promise.reject({ message: `Invalid bookmark: ${JSON.stringify(info)}` });
return Promise.reject({message: `Invalid bookmark: ${JSON.stringify(info)}`});
}
},
},

View File

@ -44,7 +44,7 @@ function BrowserAction(options, extension) {
title: title || extension.name,
badgeText: "",
badgeBackgroundColor: null,
icon: IconDetails.normalize({ path: options.default_icon }, extension,
icon: IconDetails.normalize({path: options.default_icon}, extension,
null, true),
popup: popup,
};

View File

@ -310,7 +310,7 @@ MenuItem.prototype = {
let extension = this.extension;
if (!rootItems.has(extension)) {
let root = new MenuItem(extension, this.context,
{ title: extension.name },
{title: extension.name},
/* isRoot = */ true);
rootItems.set(extension, root);
}

View File

@ -4,7 +4,7 @@
extensions.on("uninstall", (msg, extension) => {
if (extension.uninstallURL) {
let browser = Services.wm.getMostRecentWindow("navigator:browser").gBrowser;
browser.addTab(extension.uninstallURL, { relatedToCurrent: true });
browser.addTab(extension.uninstallURL, {relatedToCurrent: true});
}
});

View File

@ -28,7 +28,7 @@ function PageAction(options, extension) {
this.defaults = {
show: false,
title: title || extension.name,
icon: IconDetails.normalize({ path: options.default_icon }, extension,
icon: IconDetails.normalize({path: options.default_icon}, extension,
null, true),
popup: popup && extension.baseURI.resolve(popup),
};

View File

@ -465,7 +465,7 @@ extensions.registerSchemaAPI("tabs", null, (extension, context) => {
captureVisibleTab: function(windowId, options) {
if (!extension.hasPermission("<all_urls>")) {
return Promise.reject({ message: "The <all_urls> permission is required to use the captureVisibleTab API" });
return Promise.reject({message: "The <all_urls> permission is required to use the captureVisibleTab API"});
}
let window = windowId == null ?
@ -524,7 +524,7 @@ extensions.registerSchemaAPI("tabs", null, (extension, context) => {
if (details.file !== null) {
let url = context.uri.resolve(details.file);
if (!extension.isExtensionURL(url)) {
return Promise.reject({ message: "Files to be injected must be within the extension" });
return Promise.reject({message: "Files to be injected must be within the extension"});
}
options[kind].push(url);
}
@ -538,7 +538,7 @@ extensions.registerSchemaAPI("tabs", null, (extension, context) => {
options.run_at = details.runAt;
}
return context.sendMessage(mm, "Extension:Execute", { options }, recipient);
return context.sendMessage(mm, "Extension:Execute", {options}, recipient);
},
executeScript: function(tabId, details) {

View File

@ -235,7 +235,7 @@ class BasePopup {
};
this.browser.addEventListener("load", loadListener, true);
}).then(() => {
let { contentWindow } = this.browser;
let {contentWindow} = this.browser;
contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
@ -423,7 +423,7 @@ ExtensionTabManager.prototype = {
convert(tab) {
let window = tab.ownerDocument.defaultView;
let mutedInfo = { muted: tab.muted };
let mutedInfo = {muted: tab.muted};
if (tab.muteReason === null) {
mutedInfo.reason = "user";
} else if (tab.muteReason) {

View File

@ -13,10 +13,10 @@ function* runTests(options) {
browser.browserAction.getBadgeText({tabId}),
browser.browserAction.getBadgeBackgroundColor({tabId})]
).then(details => {
return Promise.resolve({ title: details[0],
popup: details[1],
badge: details[2],
badgeBackgroundColor: details[3] });
return Promise.resolve({title: details[0],
popup: details[1],
badge: details[2],
badgeBackgroundColor: details[3]});
});
}
@ -53,7 +53,7 @@ function* runTests(options) {
// Check that the API returns the expected values, and then
// run the next test.
new Promise(resolve => {
return browser.tabs.query({ active: true, currentWindow: true }, resolve);
return browser.tabs.query({active: true, currentWindow: true}, resolve);
}).then(tabs => {
return checkDetails(expecting, tabs[0].id);
}).then(() => {
@ -72,7 +72,7 @@ function* runTests(options) {
nextTest();
});
browser.tabs.query({ active: true, currentWindow: true }, resultTabs => {
browser.tabs.query({active: true, currentWindow: true}, resultTabs => {
tabs[0] = resultTabs[0].id;
nextTest();
@ -148,39 +148,39 @@ add_task(function* testTabSwitchContext() {
getTests(tabs, expectDefaults) {
let details = [
{ "icon": browser.runtime.getURL("default.png"),
"popup": browser.runtime.getURL("default.html"),
"title": "Default Title",
"badge": "",
"badgeBackgroundColor": null },
{ "icon": browser.runtime.getURL("1.png"),
"popup": browser.runtime.getURL("default.html"),
"title": "Default Title",
"badge": "",
"badgeBackgroundColor": null },
{ "icon": browser.runtime.getURL("2.png"),
"popup": browser.runtime.getURL("2.html"),
"title": "Title 2",
"badge": "2",
"badgeBackgroundColor": [0xff, 0, 0, 0xff],
"disabled": true },
{ "icon": browser.runtime.getURL("1.png"),
"popup": browser.runtime.getURL("default-2.html"),
"title": "Default Title 2",
"badge": "d2",
"badgeBackgroundColor": [0, 0xff, 0, 0xff],
"disabled": true },
{ "icon": browser.runtime.getURL("1.png"),
"popup": browser.runtime.getURL("default-2.html"),
"title": "Default Title 2",
"badge": "d2",
"badgeBackgroundColor": [0, 0xff, 0, 0xff],
"disabled": false },
{ "icon": browser.runtime.getURL("default-2.png"),
"popup": browser.runtime.getURL("default-2.html"),
"title": "Default Title 2",
"badge": "d2",
"badgeBackgroundColor": [0, 0xff, 0, 0xff] },
{"icon": browser.runtime.getURL("default.png"),
"popup": browser.runtime.getURL("default.html"),
"title": "Default Title",
"badge": "",
"badgeBackgroundColor": null},
{"icon": browser.runtime.getURL("1.png"),
"popup": browser.runtime.getURL("default.html"),
"title": "Default Title",
"badge": "",
"badgeBackgroundColor": null},
{"icon": browser.runtime.getURL("2.png"),
"popup": browser.runtime.getURL("2.html"),
"title": "Title 2",
"badge": "2",
"badgeBackgroundColor": [0xff, 0, 0, 0xff],
"disabled": true},
{"icon": browser.runtime.getURL("1.png"),
"popup": browser.runtime.getURL("default-2.html"),
"title": "Default Title 2",
"badge": "d2",
"badgeBackgroundColor": [0, 0xff, 0, 0xff],
"disabled": true},
{"icon": browser.runtime.getURL("1.png"),
"popup": browser.runtime.getURL("default-2.html"),
"title": "Default Title 2",
"badge": "d2",
"badgeBackgroundColor": [0, 0xff, 0, 0xff],
"disabled": false},
{"icon": browser.runtime.getURL("default-2.png"),
"popup": browser.runtime.getURL("default-2.html"),
"title": "Default Title 2",
"badge": "d2",
"badgeBackgroundColor": [0, 0xff, 0, 0xff]},
];
return [
@ -192,14 +192,14 @@ add_task(function* testTabSwitchContext() {
},
expect => {
browser.test.log("Change the icon in the current tab. Expect default properties excluding the icon.");
browser.browserAction.setIcon({ tabId: tabs[0], path: "1.png" });
browser.browserAction.setIcon({tabId: tabs[0], path: "1.png"});
expectDefaults(details[0]).then(() => {
expect(details[1]);
});
},
expect => {
browser.test.log("Create a new tab. Expect default properties.");
browser.tabs.create({ active: true, url: "about:blank?0" }, tab => {
browser.tabs.create({active: true, url: "about:blank?0"}, tab => {
tabs.push(tab.id);
expectDefaults(details[0]).then(() => {
expect(details[0]);
@ -209,11 +209,11 @@ add_task(function* testTabSwitchContext() {
expect => {
browser.test.log("Change properties. Expect new properties.");
let tabId = tabs[1];
browser.browserAction.setIcon({ tabId, path: "2.png" });
browser.browserAction.setPopup({ tabId, popup: "2.html" });
browser.browserAction.setTitle({ tabId, title: "Title 2" });
browser.browserAction.setBadgeText({ tabId, text: "2" });
browser.browserAction.setBadgeBackgroundColor({ tabId, color: [0xff, 0, 0, 0xff] });
browser.browserAction.setIcon({tabId, path: "2.png"});
browser.browserAction.setPopup({tabId, popup: "2.html"});
browser.browserAction.setTitle({tabId, title: "Title 2"});
browser.browserAction.setBadgeText({tabId, text: "2"});
browser.browserAction.setBadgeBackgroundColor({tabId, color: [0xff, 0, 0, 0xff]});
browser.browserAction.disable(tabId);
expectDefaults(details[0]).then(() => {
@ -232,21 +232,21 @@ add_task(function* testTabSwitchContext() {
}
});
browser.tabs.update(tabs[1], { url: "about:blank?1" });
browser.tabs.update(tabs[1], {url: "about:blank?1"});
},
expect => {
browser.test.log("Switch back to the first tab. Expect previously set properties.");
browser.tabs.update(tabs[0], { active: true }, () => {
browser.tabs.update(tabs[0], {active: true}, () => {
expect(details[1]);
});
},
expect => {
browser.test.log("Change default values, expect those changes reflected.");
browser.browserAction.setIcon({ path: "default-2.png" });
browser.browserAction.setPopup({ popup: "default-2.html" });
browser.browserAction.setTitle({ title: "Default Title 2" });
browser.browserAction.setBadgeText({ text: "d2" });
browser.browserAction.setBadgeBackgroundColor({ color: [0, 0xff, 0, 0xff] });
browser.browserAction.setIcon({path: "default-2.png"});
browser.browserAction.setPopup({popup: "default-2.html"});
browser.browserAction.setTitle({title: "Default Title 2"});
browser.browserAction.setBadgeText({text: "d2"});
browser.browserAction.setBadgeBackgroundColor({color: [0, 0xff, 0, 0xff]});
browser.browserAction.disable();
expectDefaults(details[3]).then(() => {
expect(details[3]);
@ -261,7 +261,7 @@ add_task(function* testTabSwitchContext() {
},
expect => {
browser.test.log("Switch back to tab 2. Expect former value, unaffected by changes to defaults in previous step.");
browser.tabs.update(tabs[1], { active: true }, () => {
browser.tabs.update(tabs[1], {active: true}, () => {
expectDefaults(details[3]).then(() => {
expect(details[2]);
});
@ -275,7 +275,7 @@ add_task(function* testTabSwitchContext() {
},
expect => {
browser.test.log("Create a new tab. Expect new default properties.");
browser.tabs.create({ active: true, url: "about:blank?2" }, tab => {
browser.tabs.create({active: true, url: "about:blank?2"}, tab => {
tabs.push(tab.id);
expect(details[5]);
});
@ -305,26 +305,26 @@ add_task(function* testDefaultTitle() {
getTests(tabs, expectDefaults) {
let details = [
{ "title": "Foo Extension",
"popup": "",
"badge": "",
"badgeBackgroundColor": null,
"icon": browser.runtime.getURL("icon.png") },
{ "title": "Foo Title",
"popup": "",
"badge": "",
"badgeBackgroundColor": null,
"icon": browser.runtime.getURL("icon.png") },
{ "title": "Bar Title",
"popup": "",
"badge": "",
"badgeBackgroundColor": null,
"icon": browser.runtime.getURL("icon.png") },
{ "title": "",
"popup": "",
"badge": "",
"badgeBackgroundColor": null,
"icon": browser.runtime.getURL("icon.png") },
{"title": "Foo Extension",
"popup": "",
"badge": "",
"badgeBackgroundColor": null,
"icon": browser.runtime.getURL("icon.png")},
{"title": "Foo Title",
"popup": "",
"badge": "",
"badgeBackgroundColor": null,
"icon": browser.runtime.getURL("icon.png")},
{"title": "Bar Title",
"popup": "",
"badge": "",
"badgeBackgroundColor": null,
"icon": browser.runtime.getURL("icon.png")},
{"title": "",
"popup": "",
"badge": "",
"badgeBackgroundColor": null,
"icon": browser.runtime.getURL("icon.png")},
];
return [
@ -336,28 +336,28 @@ add_task(function* testDefaultTitle() {
},
expect => {
browser.test.log("Change the title. Expect new title.");
browser.browserAction.setTitle({ tabId: tabs[0], title: "Foo Title" });
browser.browserAction.setTitle({tabId: tabs[0], title: "Foo Title"});
expectDefaults(details[0]).then(() => {
expect(details[1]);
});
},
expect => {
browser.test.log("Change the default. Expect same properties.");
browser.browserAction.setTitle({ title: "Bar Title" });
browser.browserAction.setTitle({title: "Bar Title"});
expectDefaults(details[2]).then(() => {
expect(details[1]);
});
},
expect => {
browser.test.log("Clear the title. Expect new default title.");
browser.browserAction.setTitle({ tabId: tabs[0], title: "" });
browser.browserAction.setTitle({tabId: tabs[0], title: ""});
expectDefaults(details[2]).then(() => {
expect(details[2]);
});
},
expect => {
browser.test.log("Set default title to null string. Expect null string from API, extension title in UI.");
browser.browserAction.setTitle({ title: "" });
browser.browserAction.setTitle({title: ""});
expectDefaults(details[3]).then(() => {
expect(details[3]);
});

View File

@ -31,100 +31,100 @@ add_task(function* testDetailsObjects() {
/* eslint-disable comma-dangle, indent */
let iconDetails = [
// Only paths.
{ details: { "path": "a.png" },
{details: {"path": "a.png"},
resolutions: {
"1": browser.runtime.getURL("data/a.png"),
"2": browser.runtime.getURL("data/a.png"), } },
{ details: { "path": "/a.png" },
"2": browser.runtime.getURL("data/a.png")}},
{details: {"path": "/a.png"},
resolutions: {
"1": browser.runtime.getURL("a.png"),
"2": browser.runtime.getURL("a.png"), } },
{ details: { "path": { "19": "a.png" } },
"2": browser.runtime.getURL("a.png")}},
{details: {"path": {"19": "a.png"}},
resolutions: {
"1": browser.runtime.getURL("data/a.png"),
"2": browser.runtime.getURL("data/a.png"), } },
{ details: { "path": { "38": "a.png" } },
"2": browser.runtime.getURL("data/a.png")}},
{details: {"path": {"38": "a.png"}},
resolutions: {
"1": browser.runtime.getURL("data/a.png"),
"2": browser.runtime.getURL("data/a.png"), } },
{ details: { "path": { "19": "a.png", "38": "a-x2.png" } },
"2": browser.runtime.getURL("data/a.png")}},
{details: {"path": {"19": "a.png", "38": "a-x2.png"}},
resolutions: {
"1": browser.runtime.getURL("data/a.png"),
"2": browser.runtime.getURL("data/a-x2.png"), } },
"2": browser.runtime.getURL("data/a-x2.png")}},
// Only ImageData objects.
{ details: { "imageData": imageData.red.imageData },
{details: {"imageData": imageData.red.imageData},
resolutions: {
"1": imageData.red.url,
"2": imageData.red.url, } },
{ details: { "imageData": { "19": imageData.red.imageData } },
"2": imageData.red.url}},
{details: {"imageData": {"19": imageData.red.imageData}},
resolutions: {
"1": imageData.red.url,
"2": imageData.red.url, } },
{ details: { "imageData": { "38": imageData.red.imageData } },
"2": imageData.red.url}},
{details: {"imageData": {"38": imageData.red.imageData}},
resolutions: {
"1": imageData.red.url,
"2": imageData.red.url, } },
{ details: { "imageData": {
"2": imageData.red.url}},
{details: {"imageData": {
"19": imageData.red.imageData,
"38": imageData.green.imageData } },
"38": imageData.green.imageData}},
resolutions: {
"1": imageData.red.url,
"2": imageData.green.url, } },
"2": imageData.green.url}},
// Mixed path and imageData objects.
//
// The behavior is currently undefined if both |path| and
// |imageData| specify icons of the same size.
{ details: {
"path": { "19": "a.png" },
"imageData": { "38": imageData.red.imageData } },
{details: {
"path": {"19": "a.png"},
"imageData": {"38": imageData.red.imageData}},
resolutions: {
"1": browser.runtime.getURL("data/a.png"),
"2": imageData.red.url, } },
{ details: {
"path": { "38": "a.png" },
"imageData": { "19": imageData.red.imageData } },
"2": imageData.red.url}},
{details: {
"path": {"38": "a.png"},
"imageData": {"19": imageData.red.imageData}},
resolutions: {
"1": imageData.red.url,
"2": browser.runtime.getURL("data/a.png"), } },
"2": browser.runtime.getURL("data/a.png")}},
// A path or ImageData object by itself is treated as a 19px icon.
{ details: {
{details: {
"path": "a.png",
"imageData": { "38": imageData.red.imageData } },
"imageData": {"38": imageData.red.imageData}},
resolutions: {
"1": browser.runtime.getURL("data/a.png"),
"2": imageData.red.url, } },
{ details: {
"path": { "38": "a.png" },
"imageData": imageData.red.imageData, },
"2": imageData.red.url}},
{details: {
"path": {"38": "a.png"},
"imageData": imageData.red.imageData},
resolutions: {
"1": imageData.red.url,
"2": browser.runtime.getURL("data/a.png"), } },
"2": browser.runtime.getURL("data/a.png")}},
// Various resolutions
{ details: { "path": { "18": "a.png", "32": "a-x2.png" } },
{details: {"path": {"18": "a.png", "32": "a-x2.png"}},
resolutions: {
"1": browser.runtime.getURL("data/a.png"),
"2": browser.runtime.getURL("data/a-x2.png"), } },
{ details: { "path": { "16": "16.png", "100": "100.png" } },
"2": browser.runtime.getURL("data/a-x2.png")}},
{details: {"path": {"16": "16.png", "100": "100.png"}},
resolutions: {
"1": browser.runtime.getURL("data/100.png"),
"2": browser.runtime.getURL("data/100.png"), } },
{ details: { "path": { "2": "2.png"} },
"2": browser.runtime.getURL("data/100.png")}},
{details: {"path": {"2": "2.png"}},
resolutions: {
"1": browser.runtime.getURL("data/2.png"),
"2": browser.runtime.getURL("data/2.png"), } },
{ details: { "path": {
"2": browser.runtime.getURL("data/2.png")}},
{details: {"path": {
"6": "6.png",
"18": "18.png",
"32": "32.png",
"48": "48.png",
"128": "128.png" } },
"128": "128.png"}},
resolutions: {
"1": browser.runtime.getURL("data/18.png"),
"2": browser.runtime.getURL("data/48.png"), } },
"2": browser.runtime.getURL("data/48.png")}},
];
// Allow serializing ImageData objects for logging.
@ -162,7 +162,7 @@ add_task(function* testDetailsObjects() {
let tests = [];
for (let [idx, icon] of iconDetails.entries()) {
for (let res of Object.keys(icon.resolutions)) {
tests.push({ index: idx, resolution: Number(res) });
tests.push({index: idx, resolution: Number(res)});
}
}
@ -170,7 +170,7 @@ add_task(function* testDetailsObjects() {
// between each test.
tests.sort(test => test.resolution);
browser.tabs.query({ active: true, currentWindow: true }, tabs => {
browser.tabs.query({active: true, currentWindow: true}, tabs => {
tabId = tabs[0].id;
browser.pageAction.show(tabId);
@ -230,7 +230,7 @@ add_task(function* testInvalidIconSizes() {
},
background: function() {
browser.tabs.query({ active: true, currentWindow: true }, tabs => {
browser.tabs.query({active: true, currentWindow: true}, tabs => {
let tabId = tabs[0].id;
let promises = [];
@ -255,16 +255,16 @@ add_task(function* testInvalidIconSizes() {
for (let type of ["path", "imageData"]) {
let img = type == "imageData" ? imageData : "test.png";
assertSetIconThrows({ [type]: { "abcdef": img } });
assertSetIconThrows({ [type]: { "48px": img } });
assertSetIconThrows({ [type]: { "20.5": img } });
assertSetIconThrows({ [type]: { "5.0": img } });
assertSetIconThrows({ [type]: { "-300": img } });
assertSetIconThrows({ [type]: { "abc": img, "5": img }});
assertSetIconThrows({[type]: {"abcdef": img}});
assertSetIconThrows({[type]: {"48px": img}});
assertSetIconThrows({[type]: {"20.5": img}});
assertSetIconThrows({[type]: {"5.0": img}});
assertSetIconThrows({[type]: {"-300": img}});
assertSetIconThrows({[type]: {"abc": img, "5": img}});
}
assertSetIconThrows({ imageData: { "abcdef": imageData }, path: {"5": "test.png"} });
assertSetIconThrows({ path: { "abcdef": "test.png" }, imageData: {"5": imageData} });
assertSetIconThrows({imageData: {"abcdef": imageData}, path: {"5": "test.png"}});
assertSetIconThrows({path: {"abcdef": "test.png"}, imageData: {"5": imageData}});
}
Promise.all(promises).then(() => {
@ -287,9 +287,9 @@ add_task(function* testDefaultDetails() {
let icons = [
"foo/bar.png",
"/foo/bar.png",
{ "19": "foo/bar.png" },
{ "38": "foo/bar.png" },
{ "19": "foo/bar.png", "38": "baz/quux.png" },
{"19": "foo/bar.png"},
{"38": "foo/bar.png"},
{"19": "foo/bar.png", "38": "baz/quux.png"},
];
let expectedURL = new RegExp(String.raw`^moz-extension://[^/]+/foo/bar\.png$`);
@ -297,12 +297,12 @@ add_task(function* testDefaultDetails() {
for (let icon of icons) {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
"browser_action": { "default_icon": icon },
"page_action": { "default_icon": icon },
"browser_action": {"default_icon": icon},
"page_action": {"default_icon": icon},
},
background: function() {
browser.tabs.query({ active: true, currentWindow: true }, tabs => {
browser.tabs.query({active: true, currentWindow: true}, tabs => {
let tabId = tabs[0].id;
browser.pageAction.show(tabId);
@ -345,7 +345,7 @@ add_task(function* testSecureURLsDenied() {
},
background: function() {
browser.tabs.query({ active: true, currentWindow: true }, tabs => {
browser.tabs.query({active: true, currentWindow: true}, tabs => {
let tabId = tabs[0].id;
let urls = ["chrome://browser/content/browser.xul",

View File

@ -30,34 +30,34 @@ function* testInArea(area) {
let sendClick;
let tests = [
() => {
sendClick({ expectEvent: false, expectPopup: "a" });
sendClick({expectEvent: false, expectPopup: "a"});
},
() => {
sendClick({ expectEvent: false, expectPopup: "a" });
sendClick({expectEvent: false, expectPopup: "a"});
},
() => {
browser.browserAction.setPopup({ popup: "popup-b.html" });
sendClick({ expectEvent: false, expectPopup: "b" });
browser.browserAction.setPopup({popup: "popup-b.html"});
sendClick({expectEvent: false, expectPopup: "b"});
},
() => {
sendClick({ expectEvent: false, expectPopup: "b" });
sendClick({expectEvent: false, expectPopup: "b"});
},
() => {
browser.browserAction.setPopup({ popup: "" });
sendClick({ expectEvent: true, expectPopup: null });
browser.browserAction.setPopup({popup: ""});
sendClick({expectEvent: true, expectPopup: null});
},
() => {
sendClick({ expectEvent: true, expectPopup: null });
sendClick({expectEvent: true, expectPopup: null});
},
() => {
browser.browserAction.setPopup({ popup: "/popup-a.html" });
sendClick({ expectEvent: false, expectPopup: "a" });
browser.browserAction.setPopup({popup: "/popup-a.html"});
sendClick({expectEvent: false, expectPopup: "a"});
},
];
let expect = {};
sendClick = ({ expectEvent, expectPopup }) => {
expect = { event: expectEvent, popup: expectPopup };
sendClick = ({expectEvent, expectPopup}) => {
expect = {event: expectEvent, popup: expectPopup};
browser.test.sendMessage("send-click");
};

View File

@ -43,7 +43,7 @@ add_task(function* () {
});
});
browser.tabs.executeScript({ file: "script.js" });
browser.tabs.executeScript({file: "script.js"});
},
files: {

View File

@ -22,14 +22,14 @@ add_task(function* () {
browser.test.sendMessage("menuItemClick", JSON.stringify(info));
}
browser.contextMenus.create({ contexts: ["all"], type: "separator" });
browser.contextMenus.create({contexts: ["all"], type: "separator"});
let contexts = ["page", "selection", "image"];
for (let i = 0; i < contexts.length; i++) {
let context = contexts[i];
let title = context;
browser.contextMenus.create({ title: title, contexts: [context], id: "ext-" + context,
onclick: genericOnClick });
browser.contextMenus.create({title: title, contexts: [context], id: "ext-" + context,
onclick: genericOnClick});
if (context == "selection") {
browser.contextMenus.update("ext-selection", {
title: "selection is: '%s'",
@ -41,20 +41,20 @@ add_task(function* () {
}
}
let parent = browser.contextMenus.create({ title: "parent" });
let parent = browser.contextMenus.create({title: "parent"});
browser.contextMenus.create(
{ title: "child1", parentId: parent, onclick: genericOnClick });
{title: "child1", parentId: parent, onclick: genericOnClick});
let child2 = browser.contextMenus.create(
{ title: "child2", parentId: parent, onclick: genericOnClick });
{title: "child2", parentId: parent, onclick: genericOnClick});
let parentToDel = browser.contextMenus.create({ title: "parentToDel" });
let parentToDel = browser.contextMenus.create({title: "parentToDel"});
browser.contextMenus.create(
{ title: "child1", parentId: parentToDel, onclick: genericOnClick });
{title: "child1", parentId: parentToDel, onclick: genericOnClick});
browser.contextMenus.create(
{ title: "child2", parentId: parentToDel, onclick: genericOnClick });
{title: "child2", parentId: parentToDel, onclick: genericOnClick});
browser.contextMenus.remove(parentToDel);
browser.contextMenus.update(parent, { parentId: child2 }).then(
browser.contextMenus.update(parent, {parentId: child2}).then(
() => {
browser.test.notifyFail();
},
@ -81,7 +81,7 @@ add_task(function* () {
let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
let popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown");
yield BrowserTestUtils.synthesizeMouseAtCenter("#img1",
{ type: "contextmenu", button: 2 }, gBrowser.selectedBrowser);
{type: "contextmenu", button: 2}, gBrowser.selectedBrowser);
yield popupShownPromise;
// Check some menu items
@ -134,7 +134,7 @@ add_task(function* () {
// Bring up context menu again
popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown");
yield BrowserTestUtils.synthesizeMouse(null, 1, 1,
{ type: "contextmenu", button: 2 }, gBrowser.selectedBrowser);
{type: "contextmenu", button: 2}, gBrowser.selectedBrowser);
yield popupShownPromise;
items = contentAreaContextMenu.getElementsByAttribute("ext-type", "top-level-menu");
@ -163,7 +163,7 @@ add_task(function* () {
popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown");
yield BrowserTestUtils.synthesizeMouseAtCenter("#img1",
{ type: "contextmenu", button: 2 }, gBrowser.selectedBrowser);
{type: "contextmenu", button: 2}, gBrowser.selectedBrowser);
yield popupShownPromise;
items = contentAreaContextMenu.getElementsByAttribute("ext-type", "top-level-menu");

View File

@ -37,7 +37,7 @@ add_task(function* testLastError() {
SimpleTest.monitorConsole(resolve, [{message: /Invalid extension ID/, forbid: true}]);
});
yield sendMessage({ checkLastError: api });
yield sendMessage({checkLastError: api});
SimpleTest.endMonitorConsole();
yield waitForConsole;

View File

@ -11,7 +11,7 @@ function* runTests(options) {
// promise that resolves to an object containing them.
function getDetails() {
return new Promise(resolve => {
return browser.tabs.query({ active: true, currentWindow: true }, resolve);
return browser.tabs.query({active: true, currentWindow: true}, resolve);
}).then(([tab]) => {
let tabId = tab.id;
browser.test.log(`Get details: tab={id: ${tabId}, url: ${JSON.stringify(tab.url)}}`);
@ -19,8 +19,8 @@ function* runTests(options) {
browser.pageAction.getTitle({tabId}),
browser.pageAction.getPopup({tabId})]);
}).then(details => {
return Promise.resolve({ title: details[0],
popup: details[1] });
return Promise.resolve({title: details[0],
popup: details[1]});
});
}
@ -59,7 +59,7 @@ function* runTests(options) {
tabs = [];
tests = getTests(tabs);
browser.tabs.query({ active: true, currentWindow: true }, resultTabs => {
browser.tabs.query({active: true, currentWindow: true}, resultTabs => {
tabs[0] = resultTabs[0].id;
nextTest();
@ -163,18 +163,18 @@ add_task(function* testTabSwitchContext() {
getTests(tabs) {
let details = [
{ "icon": browser.runtime.getURL("default.png"),
"popup": browser.runtime.getURL("default.html"),
"title": "Default Title \u263a" },
{ "icon": browser.runtime.getURL("1.png"),
"popup": browser.runtime.getURL("default.html"),
"title": "Default Title \u263a" },
{ "icon": browser.runtime.getURL("2.png"),
"popup": browser.runtime.getURL("2.html"),
"title": "Title 2" },
{ "icon": browser.runtime.getURL("2.png"),
"popup": browser.runtime.getURL("2.html"),
"title": "Default Title \u263a" },
{"icon": browser.runtime.getURL("default.png"),
"popup": browser.runtime.getURL("default.html"),
"title": "Default Title \u263a"},
{"icon": browser.runtime.getURL("1.png"),
"popup": browser.runtime.getURL("default.html"),
"title": "Default Title \u263a"},
{"icon": browser.runtime.getURL("2.png"),
"popup": browser.runtime.getURL("2.html"),
"title": "Title 2"},
{"icon": browser.runtime.getURL("2.png"),
"popup": browser.runtime.getURL("2.html"),
"title": "Default Title \u263a"},
];
let promiseTabLoad = details => {
@ -201,13 +201,13 @@ add_task(function* testTabSwitchContext() {
},
expect => {
browser.test.log("Change the icon. Expect default properties excluding the icon.");
browser.pageAction.setIcon({ tabId: tabs[0], path: "1.png" });
browser.pageAction.setIcon({tabId: tabs[0], path: "1.png"});
expect(details[1]);
},
expect => {
browser.test.log("Create a new tab. No icon visible.");
browser.tabs.create({ active: true, url: "about:blank?0" }, tab => {
tabLoadPromise = promiseTabLoad({ url: "about:blank?0", id: tab.id });
browser.tabs.create({active: true, url: "about:blank?0"}, tab => {
tabLoadPromise = promiseTabLoad({url: "about:blank?0", id: tab.id});
tabs.push(tab.id);
expect(null);
});
@ -222,15 +222,15 @@ add_task(function* testTabSwitchContext() {
browser.test.log("Change properties. Expect new properties.");
let tabId = tabs[1];
browser.pageAction.show(tabId);
browser.pageAction.setIcon({ tabId, path: "2.png" });
browser.pageAction.setPopup({ tabId, popup: "2.html" });
browser.pageAction.setTitle({ tabId, title: "Title 2" });
browser.pageAction.setIcon({tabId, path: "2.png"});
browser.pageAction.setPopup({tabId, popup: "2.html"});
browser.pageAction.setTitle({tabId, title: "Title 2"});
expect(details[2]);
},
expect => {
browser.test.log("Clear the title. Expect default title.");
browser.pageAction.setTitle({ tabId: tabs[1], title: "" });
browser.pageAction.setTitle({tabId: tabs[1], title: ""});
expect(details[3]);
},
@ -239,11 +239,11 @@ add_task(function* testTabSwitchContext() {
// TODO: This listener should not be necessary, but the |tabs.update|
// callback currently fires too early in e10s windows.
promiseTabLoad({ id: tabs[1], url: "about:blank?1" }).then(() => {
promiseTabLoad({id: tabs[1], url: "about:blank?1"}).then(() => {
expect(null);
});
browser.tabs.update(tabs[1], { url: "about:blank?1" });
browser.tabs.update(tabs[1], {url: "about:blank?1"});
},
expect => {
browser.test.log("Show the icon. Expect default properties again.");
@ -252,14 +252,14 @@ add_task(function* testTabSwitchContext() {
},
expect => {
browser.test.log("Switch back to the first tab. Expect previously set properties.");
browser.tabs.update(tabs[0], { active: true }, () => {
browser.tabs.update(tabs[0], {active: true}, () => {
expect(details[1]);
});
},
expect => {
browser.test.log("Hide the icon on tab 2. Switch back, expect hidden.");
browser.pageAction.hide(tabs[1]);
browser.tabs.update(tabs[1], { active: true }, () => {
browser.tabs.update(tabs[1], {active: true}, () => {
expect(null);
});
},
@ -293,12 +293,12 @@ add_task(function* testDefaultTitle() {
getTests(tabs) {
let details = [
{ "title": "Foo Extension",
"popup": "",
"icon": browser.runtime.getURL("icon.png") },
{ "title": "Foo Title",
"popup": "",
"icon": browser.runtime.getURL("icon.png") },
{"title": "Foo Extension",
"popup": "",
"icon": browser.runtime.getURL("icon.png")},
{"title": "Foo Title",
"popup": "",
"icon": browser.runtime.getURL("icon.png")},
];
return [
@ -313,12 +313,12 @@ add_task(function* testDefaultTitle() {
},
expect => {
browser.test.log("Change the title. Expect new title.");
browser.pageAction.setTitle({ tabId: tabs[0], title: "Foo Title" });
browser.pageAction.setTitle({tabId: tabs[0], title: "Foo Title"});
expect(details[1]);
},
expect => {
browser.test.log("Clear the title. Expect extension title.");
browser.pageAction.setTitle({ tabId: tabs[0], title: "" });
browser.pageAction.setTitle({tabId: tabs[0], title: ""});
expect(details[0]);
},
];

View File

@ -34,34 +34,34 @@ add_task(function* testPageActionPopup() {
let sendClick;
let tests = [
() => {
sendClick({ expectEvent: false, expectPopup: "a" });
sendClick({expectEvent: false, expectPopup: "a"});
},
() => {
sendClick({ expectEvent: false, expectPopup: "a" });
sendClick({expectEvent: false, expectPopup: "a"});
},
() => {
browser.pageAction.setPopup({ tabId, popup: "popup-b.html" });
sendClick({ expectEvent: false, expectPopup: "b" });
browser.pageAction.setPopup({tabId, popup: "popup-b.html"});
sendClick({expectEvent: false, expectPopup: "b"});
},
() => {
sendClick({ expectEvent: false, expectPopup: "b" });
sendClick({expectEvent: false, expectPopup: "b"});
},
() => {
browser.pageAction.setPopup({ tabId, popup: "" });
sendClick({ expectEvent: true, expectPopup: null });
browser.pageAction.setPopup({tabId, popup: ""});
sendClick({expectEvent: true, expectPopup: null});
},
() => {
sendClick({ expectEvent: true, expectPopup: null });
sendClick({expectEvent: true, expectPopup: null});
},
() => {
browser.pageAction.setPopup({ tabId, popup: "/popup-a.html" });
sendClick({ expectEvent: false, expectPopup: "a" });
browser.pageAction.setPopup({tabId, popup: "/popup-a.html"});
sendClick({expectEvent: false, expectPopup: "a"});
},
];
let expect = {};
sendClick = ({ expectEvent, expectPopup }) => {
expect = { event: expectEvent, popup: expectPopup };
sendClick = ({expectEvent, expectPopup}) => {
expect = {event: expectEvent, popup: expectPopup};
browser.test.sendMessage("send-click");
};
@ -101,7 +101,7 @@ add_task(function* testPageActionPopup() {
}
});
browser.tabs.query({ active: true, currentWindow: true }, tabs => {
browser.tabs.query({active: true, currentWindow: true}, tabs => {
tabId = tabs[0].id;
browser.pageAction.show(tabId);
@ -165,7 +165,7 @@ add_task(function* testPageActionSecurity() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
[api]: { "default_popup": URL },
[api]: {"default_popup": URL},
},
});

View File

@ -27,15 +27,15 @@ add_task(function* testPageActionPopup() {
background: function() {
let tabId;
browser.tabs.query({ active: true, currentWindow: true }, tabs => {
browser.tabs.query({active: true, currentWindow: true}, tabs => {
tabId = tabs[0].id;
browser.pageAction.show(tabId);
browser.test.sendMessage("ready");
});
browser.test.onMessage.addListener(() => {
browser.browserAction.setPopup({ popup: "/popup-a.html" });
browser.pageAction.setPopup({ tabId, popup: "popup-b.html" });
browser.browserAction.setPopup({popup: "/popup-a.html"});
browser.pageAction.setPopup({tabId, popup: "popup-b.html"});
browser.test.sendMessage("ok");
});

View File

@ -1,7 +1,7 @@
"use strict";
let { AddonManager } = Components.utils.import("resource://gre/modules/AddonManager.jsm", {});
let { Extension } = Components.utils.import("resource://gre/modules/Extension.jsm", {});
let {AddonManager} = Components.utils.import("resource://gre/modules/AddonManager.jsm", {});
let {Extension} = Components.utils.import("resource://gre/modules/Extension.jsm", {});
function install(url) {
return new Promise((resolve, reject) => {
@ -78,7 +78,7 @@ add_task(function* test_setuninstallurl_badargs() {
add_task(function* test_setuninstall_empty_url() {
function backgroundScript() {
browser.runtime.setUninstallURL("")
.then(() => browser.tabs.create({ url: "http://example.com/addon_loaded" }));
.then(() => browser.tabs.create({url: "http://example.com/addon_loaded"}));
}
let addon = yield makeAndInstallXPI("test_uinstallurl2@tests.mozilla.org",
@ -95,7 +95,7 @@ add_task(function* test_setuninstall_empty_url() {
add_task(function* test_setuninstallurl() {
function backgroundScript() {
browser.runtime.setUninstallURL("http://example.com/addon_uninstalled")
.then(() => browser.tabs.create({ url: "http://example.com/addon_loaded" }));
.then(() => browser.tabs.create({url: "http://example.com/addon_loaded"}));
}
let addon = yield makeAndInstallXPI("test_uinstallurl@tests.mozilla.org",

View File

@ -38,16 +38,16 @@ add_task(function* () {
});
});
browser.tabs.create({ url: "tab.html" },
browser.tabs.create({url: "tab.html"},
(tab) => { tabId = tab.id; });
},
files: {
"tab.js": function() {
let port = browser.runtime.connect({ name: "tab-connection-name"});
let port = browser.runtime.connect({name: "tab-connection-name"});
port.postMessage("tab to background port message");
port.onMessage.addListener((msg) => {
port.postMessage({ tabReceived: msg });
port.postMessage({tabReceived: msg});
});
},
"tab.html": `

View File

@ -49,7 +49,7 @@ add_task(function* () {
let windowId;
let tabIds;
promiseTabs.query({ lastFocusedWindow: true }).then(tabs => {
promiseTabs.query({lastFocusedWindow: true}).then(tabs => {
browser.test.assertEq(tabs.length, 3, "We have three tabs");
for (let tab of tabs) {
@ -65,10 +65,10 @@ add_task(function* () {
browser.test.log("Test initial queries for muted and audible return no tabs");
return Promise.all([
promiseTabs.query({ windowId, audible: false }),
promiseTabs.query({ windowId, audible: true }),
promiseTabs.query({ windowId, muted: true }),
promiseTabs.query({ windowId, muted: false }),
promiseTabs.query({windowId, audible: false}),
promiseTabs.query({windowId, audible: true}),
promiseTabs.query({windowId, muted: true}),
promiseTabs.query({windowId, muted: false}),
]);
}).then(([silent, audible, muted, nonMuted]) => {
browser.test.assertEq(3, silent.length, "Three silent tabs");
@ -95,10 +95,10 @@ add_task(function* () {
browser.test.log("Re-check queries. Expect one audible and one muted tab");
return Promise.all([
promiseTabs.query({ windowId, audible: false }),
promiseTabs.query({ windowId, audible: true }),
promiseTabs.query({ windowId, muted: true }),
promiseTabs.query({ windowId, muted: false }),
promiseTabs.query({windowId, audible: false}),
promiseTabs.query({windowId, audible: true}),
promiseTabs.query({windowId, muted: true}),
promiseTabs.query({windowId, muted: false}),
]);
}).then(([silent, audible, muted, nonMuted]) => {
browser.test.assertEq(2, silent.length, "Two silent tabs");
@ -116,8 +116,8 @@ add_task(function* () {
return Promise.all([
promiseUpdated(tabIds[0], "mutedInfo"),
promiseUpdated(tabIds[1], "mutedInfo"),
promiseTabs.update(tabIds[0], { muted: false }),
promiseTabs.update(tabIds[1], { muted: true }),
promiseTabs.update(tabIds[0], {muted: false}),
promiseTabs.update(tabIds[1], {muted: true}),
]);
}).then(([unmuted, muted]) => {
for (let obj of [unmuted.changeInfo, unmuted.tab]) {

View File

@ -39,11 +39,11 @@ function* runTest(options) {
browser.test.log(`Test color ${options.color} at fullZoom=${options.fullZoom}`);
promiseTabs.query({ currentWindow: true, active: true }).then(([tab]) => {
promiseTabs.query({currentWindow: true, active: true}).then(([tab]) => {
return Promise.all([
promiseTabs.captureVisibleTab(tab.windowId, { format: "jpeg", quality: 95 }),
promiseTabs.captureVisibleTab(tab.windowId, { format: "png", quality: 95 }),
promiseTabs.captureVisibleTab(tab.windowId, { quality: 95 }),
promiseTabs.captureVisibleTab(tab.windowId, {format: "jpeg", quality: 95}),
promiseTabs.captureVisibleTab(tab.windowId, {format: "png", quality: 95}),
promiseTabs.captureVisibleTab(tab.windowId, {quality: 95}),
promiseTabs.captureVisibleTab(tab.windowId),
]).then(([jpeg, png, ...pngs]) => {
browser.test.assertTrue(pngs.every(url => url == png), "All PNGs are identical");
@ -60,7 +60,7 @@ function* runTest(options) {
}).then(([jpeg, png]) => {
let tabDims = `${tab.width}\u00d7${tab.height}`;
let images = { jpeg, png };
let images = {jpeg, png};
for (let format of Object.keys(images)) {
let img = images[format];
@ -78,17 +78,17 @@ function* runTest(options) {
// Check the colors of the first and last pixels of the image, to make
// sure we capture the entire frame, and scale it correctly.
let coords = [
{ x: 0, y: 0,
color: options.color },
{ x: img.width - 1,
y: img.height - 1,
color: options.color },
{ x: img.width / 2 | 0,
y: img.height / 2 | 0,
color: options.neutral },
{x: 0, y: 0,
color: options.color},
{x: img.width - 1,
y: img.height - 1,
color: options.color},
{x: img.width / 2 | 0,
y: img.height / 2 | 0,
color: options.neutral},
];
for (let { x, y, color } of coords) {
for (let {x, y, color} of coords) {
let imageData = ctx.getImageData(x, y, 1, 1).data;
if (format == "png") {
@ -133,13 +133,13 @@ function* runTest(options) {
}
add_task(function* testCaptureVisibleTab() {
yield runTest({ color: [0, 0, 0], fullZoom: 1 });
yield runTest({color: [0, 0, 0], fullZoom: 1});
yield runTest({ color: [0, 0, 0], fullZoom: 2 });
yield runTest({color: [0, 0, 0], fullZoom: 2});
yield runTest({ color: [0, 0, 0], fullZoom: 0.5 });
yield runTest({color: [0, 0, 0], fullZoom: 0.5});
yield runTest({ color: [255, 255, 255], fullZoom: 1 });
yield runTest({color: [255, 255, 255], fullZoom: 1});
});
add_task(function* testCaptureVisibleTabPermissions() {
@ -149,7 +149,7 @@ add_task(function* testCaptureVisibleTabPermissions() {
},
background: function(x) {
browser.tabs.query({ currentWindow: true, active: true }, tab => {
browser.tabs.query({currentWindow: true, active: true}, tab => {
browser.tabs.captureVisibleTab(tab.windowId).then(
() => {
browser.test.notifyFail("captureVisibleTabPermissions");

View File

@ -19,7 +19,7 @@ add_task(function* () {
manifest: {
"permissions": ["tabs"],
"background": { "page": "bg/background.html" },
"background": {"page": "bg/background.html"},
},
files: {
@ -45,48 +45,48 @@ add_task(function* () {
let tests = [
{
create: { url: "http://example.com/" },
result: { url: "http://example.com/" },
create: {url: "http://example.com/"},
result: {url: "http://example.com/"},
},
{
create: { url: "blank.html" },
result: { url: browser.runtime.getURL("bg/blank.html") },
create: {url: "blank.html"},
result: {url: browser.runtime.getURL("bg/blank.html")},
},
{
create: {},
result: { url: "about:newtab" },
result: {url: "about:newtab"},
},
{
create: { active: false },
result: { active: false },
create: {active: false},
result: {active: false},
},
{
create: { active: true },
result: { active: true },
create: {active: true},
result: {active: true},
},
{
create: { pinned: true },
result: { pinned: true, index: 0 },
create: {pinned: true},
result: {pinned: true, index: 0},
},
{
create: { pinned: true, active: true },
result: { pinned: true, active: true, index: 0 },
create: {pinned: true, active: true},
result: {pinned: true, active: true, index: 0},
},
{
create: { pinned: true, active: false },
result: { pinned: true, active: false, index: 0 },
create: {pinned: true, active: false},
result: {pinned: true, active: false, index: 0},
},
{
create: { index: 1 },
result: { index: 1 },
create: {index: 1},
result: {index: 1},
},
{
create: { index: 1, active: false },
result: { index: 1, active: false },
create: {index: 1, active: false},
result: {index: 1, active: false},
},
{
create: { windowId: activeWindow },
result: { windowId: activeWindow },
create: {windowId: activeWindow},
result: {windowId: activeWindow},
},
];
@ -141,7 +141,7 @@ add_task(function* () {
return browser.tabs.remove(tabId);
}).then(() => {
return browser.tabs.update(activeTab, { active: true });
return browser.tabs.update(activeTab, {active: true});
}).then(() => {
nextTest();
});
@ -150,7 +150,7 @@ add_task(function* () {
nextTest();
}
browser.tabs.query({ active: true, currentWindow: true }, tabs => {
browser.tabs.query({active: true, currentWindow: true}, tabs => {
activeTab = tabs[0].id;
activeWindow = tabs[0].windowId;

View File

@ -14,7 +14,7 @@ function* testHasNoPermission(params) {
browser.test.onMessage.addListener(msg => {
browser.test.assertEq(msg, "execute-script");
browser.tabs.query({ currentWindow: true }, tabs => {
browser.tabs.query({currentWindow: true}, tabs => {
browser.tabs.executeScript({
file: "script.js",
});
@ -70,12 +70,12 @@ add_task(function* testBadPermissions() {
info("Test no special permissions");
yield testHasNoPermission({
manifest: { "permissions": ["http://example.com/"] },
manifest: {"permissions": ["http://example.com/"]},
});
info("Test tabs permissions");
yield testHasNoPermission({
manifest: { "permissions": ["http://example.com/", "tabs"] },
manifest: {"permissions": ["http://example.com/", "tabs"]},
});
info("Test active tab, browser action, no click");
@ -94,7 +94,7 @@ add_task(function* testBadPermissions() {
},
contentSetup() {
return new Promise(resolve => {
browser.tabs.query({ active: true, currentWindow: true }, tabs => {
browser.tabs.query({active: true, currentWindow: true}, tabs => {
browser.pageAction.show(tabs[0].id);
resolve();
});
@ -108,7 +108,7 @@ add_task(function* testBadPermissions() {
add_task(function* testBadURL() {
function background() {
browser.tabs.query({ currentWindow: true }, tabs => {
browser.tabs.query({currentWindow: true}, tabs => {
let promises = [
new Promise(resolve => {
browser.tabs.executeScript({

View File

@ -61,17 +61,17 @@ add_task(function* testGoodPermissions() {
info("Test explicit host permission");
yield testHasPermission({
manifest: { "permissions": ["http://mochi.test/"] },
manifest: {"permissions": ["http://mochi.test/"]},
});
info("Test explicit host subdomain permission");
yield testHasPermission({
manifest: { "permissions": ["http://*.mochi.test/"] },
manifest: {"permissions": ["http://*.mochi.test/"]},
});
info("Test explicit <all_urls> permission");
yield testHasPermission({
manifest: { "permissions": ["<all_urls>"] },
manifest: {"permissions": ["<all_urls>"]},
});
info("Test activeTab permission with a browser action click");
@ -98,7 +98,7 @@ add_task(function* testGoodPermissions() {
},
contentSetup() {
return new Promise(resolve => {
browser.tabs.query({ active: true, currentWindow: true }, tabs => {
browser.tabs.query({active: true, currentWindow: true}, tabs => {
browser.pageAction.show(tabs[0].id);
resolve();
});
@ -112,7 +112,7 @@ add_task(function* testGoodPermissions() {
yield testHasPermission({
manifest: {
"permissions": ["activeTab"],
"browser_action": { "default_popup": "_blank.html" },
"browser_action": {"default_popup": "_blank.html"},
},
setup: clickBrowserAction,
tearDown: closeBrowserAction,
@ -122,11 +122,11 @@ add_task(function* testGoodPermissions() {
yield testHasPermission({
manifest: {
"permissions": ["activeTab"],
"page_action": { "default_popup": "_blank.html" },
"page_action": {"default_popup": "_blank.html"},
},
contentSetup() {
return new Promise(resolve => {
browser.tabs.query({ active: true, currentWindow: true }, tabs => {
browser.tabs.query({active: true, currentWindow: true}, tabs => {
browser.pageAction.show(tabs[0].id);
resolve();
});
@ -142,7 +142,7 @@ add_task(function* testGoodPermissions() {
"permissions": ["activeTab", "contextMenus"],
},
contentSetup() {
browser.contextMenus.create({ title: "activeTab", contexts: ["all"] });
browser.contextMenus.create({title: "activeTab", contexts: ["all"]});
return Promise.resolve();
},
setup: function* (extension) {
@ -150,7 +150,7 @@ add_task(function* testGoodPermissions() {
let awaitPopupShown = BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
let awaitPopupHidden = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden");
yield BrowserTestUtils.synthesizeMouseAtCenter("a[href]", { type: "contextmenu", button: 2 },
yield BrowserTestUtils.synthesizeMouseAtCenter("a[href]", {type: "contextmenu", button: 2},
gBrowser.selectedBrowser);
yield awaitPopupShown;

View File

@ -7,7 +7,7 @@ add_task(function* () {
manifest: {
"permissions": ["tabs"],
"browser_action": { "default_popup": "popup.html" },
"browser_action": {"default_popup": "popup.html"},
},
files: {
@ -18,7 +18,7 @@ add_task(function* () {
browser.test.assertEq(currentTab.url, url, "getCurrent in non-active background tab");
// Activate the tab.
browser.tabs.onActivated.addListener(function listener({ tabId }) {
browser.tabs.onActivated.addListener(function listener({tabId}) {
if (tabId == currentTab.id) {
browser.tabs.onActivated.removeListener(listener);
@ -31,7 +31,7 @@ add_task(function* () {
});
}
});
browser.tabs.update(currentTab.id, { active: true });
browser.tabs.update(currentTab.id, {active: true});
});
},
@ -52,7 +52,7 @@ add_task(function* () {
browser.test.sendMessage("background-finished");
});
browser.tabs.create({ url: "tab.html", active: false });
browser.tabs.create({url: "tab.html", active: false});
},
});

View File

@ -62,7 +62,7 @@ add_task(function* testExecuteScript() {
return;
}
let { promise, background, foreground } = promises.shift();
let {promise, background, foreground} = promises.shift();
new Promise(promise).then(() => {
browser.tabs.executeScript({
code: `(${checkCSS})()`,

View File

@ -20,7 +20,7 @@ add_task(function* () {
let tab = tabs[0];
browser.tabs.move(tab.id, {index: 0});
browser.tabs.query(
{ lastFocusedWindow: true },
{lastFocusedWindow: true},
tabs => {
browser.test.assertEq(tabs[0].url, tab.url, "should be first tab");
browser.test.notifyPass("tabs.move.single");
@ -40,12 +40,12 @@ add_task(function* () {
background: function() {
browser.tabs.query(
{ lastFocusedWindow: true },
{lastFocusedWindow: true},
tabs => {
tabs.sort(function(a, b) { return a.url > b.url; });
browser.tabs.move(tabs.map(tab => tab.id), {index: 0});
browser.tabs.query(
{ lastFocusedWindow: true },
{lastFocusedWindow: true},
tabs => {
browser.test.assertEq(tabs[0].url, "about:blank", "should be first tab");
browser.test.assertEq(tabs[1].url, "about:config", "should be second tab");
@ -67,13 +67,13 @@ add_task(function* () {
background: function() {
browser.tabs.query(
{ lastFocusedWindow: true },
{lastFocusedWindow: true},
tabs => {
let tab = tabs[0];
// Assuming that tab.id of 12345 does not exist.
browser.tabs.move([12345, tab.id], {index: 0});
browser.tabs.query(
{ lastFocusedWindow: true },
{lastFocusedWindow: true},
tabs => {
browser.test.assertEq(tabs[0].url, tab.url, "should be first tab");
browser.test.notifyPass("tabs.move.invalid");
@ -93,12 +93,12 @@ add_task(function* () {
background: function() {
browser.tabs.query(
{ lastFocusedWindow: true },
{lastFocusedWindow: true},
tabs => {
let tab = tabs[0];
browser.tabs.move(tab.id, {index: -1});
browser.tabs.query(
{ lastFocusedWindow: true },
{lastFocusedWindow: true},
tabs => {
browser.test.assertEq(tabs[2].url, tab.url, "should be last tab");
browser.test.notifyPass("tabs.move.last");

View File

@ -21,7 +21,7 @@ add_task(function* () {
browser.tabs.move(source.id, {windowId: destination.windowId, index: 0});
browser.tabs.query(
{ url: "<all_urls>" },
{url: "<all_urls>"},
tabs => {
browser.test.assertEq(tabs[0].url, "http://example.com/");
browser.test.assertEq(tabs[0].windowId, destination.windowId);
@ -54,14 +54,14 @@ add_task(function* () {
background: function() {
browser.tabs.query(
{ url: "<all_urls>" },
{url: "<all_urls>"},
tabs => {
let destination = tabs[0];
let source = tabs[1]; // remember, pinning moves it to the left.
browser.tabs.move(source.id, {windowId: destination.windowId, index: 0});
browser.tabs.query(
{ url: "<all_urls>" },
{url: "<all_urls>"},
tabs => {
browser.test.assertEq(true, tabs[0].pinned);
browser.test.notifyPass("tabs.move.pin");
@ -94,13 +94,13 @@ add_task(function* () {
background: function() {
browser.tabs.query(
{ url: "<all_urls>" },
{url: "<all_urls>"},
tabs => {
let move1 = tabs[1];
let move3 = tabs[3];
browser.tabs.move([move1.id, move3.id], {index: 0});
browser.tabs.query(
{ url: "<all_urls>" },
{url: "<all_urls>"},
tabs => {
browser.test.assertEq(tabs[0].url, move1.url);
browser.test.assertEq(tabs[2].url, move3.url);

View File

@ -23,9 +23,9 @@ add_task(function* () {
let pageURL = "http://mochi.test:8888/browser/browser/components/extensions/test/browser/context_tabs_onUpdated_page.html";
let expectedSequence = [
{ status: "loading" },
{ status: "loading", url: pageURL },
{ status: "complete" },
{status: "loading"},
{status: "loading", url: pageURL},
{status: "complete"},
];
let collectedSequence = [];
@ -60,7 +60,7 @@ add_task(function* () {
browser.test.notifyPass("tabs.onUpdated");
});
browser.tabs.create({ url: pageURL });
browser.tabs.create({url: pageURL});
},
files: {
"content-script.js": `

View File

@ -9,7 +9,7 @@ add_task(function* tabsSendMessageNoExceptionOnNonExistentTab() {
},
background: function() {
browser.tabs.create({ url: "about:robots"}, tab => {
browser.tabs.create({url: "about:robots"}, tab => {
let exception;
try {
browser.tabs.sendMessage(tab.id, "message");

View File

@ -8,7 +8,7 @@ add_task(function* testWebNavigationGetNonExistentTab() {
let results = [
// There is no "tabId = 0" because the id assigned by TabManager (defined in ext-utils.js)
// starts from 1.
browser.webNavigation.getAllFrames({ tabId: 0 }).then(() => {
browser.webNavigation.getAllFrames({tabId: 0}).then(() => {
browser.test.fail("getAllFrames Promise should be rejected on error");
}, (error) => {
browser.test.assertEq("No tab found with tabId: 0", error.message,
@ -16,7 +16,7 @@ add_task(function* testWebNavigationGetNonExistentTab() {
}),
// There is no "tabId = 0" because the id assigned by TabManager (defined in ext-utils.js)
// starts from 1, processId is currently marked as optional and it is ignored.
browser.webNavigation.getFrame({ tabId: 0, frameId: 15, processId: 20 }).then(() => {
browser.webNavigation.getFrame({tabId: 0, frameId: 15, processId: 20}).then(() => {
browser.test.fail("getFrame Promise should be rejected on error");
}, (error) => {
browser.test.assertEq("No tab found with tabId: 0", error.message,
@ -57,11 +57,11 @@ add_task(function* testWebNavigationFrames() {
return;
}
browser.webNavigation.getAllFrames({ tabId }).then((getAllFramesDetails) => {
browser.webNavigation.getAllFrames({tabId}).then((getAllFramesDetails) => {
let getFramePromises = getAllFramesDetails.map((frameDetail) => {
let { frameId } = frameDetail;
let {frameId} = frameDetail;
// processId is currently marked as optional and it is ignored.
return browser.webNavigation.getFrame({ tabId, frameId, processId: 0 });
return browser.webNavigation.getFrame({tabId, frameId, processId: 0});
});
Promise.all(getFramePromises).then((getFrameResults) => {
@ -81,7 +81,7 @@ add_task(function* testWebNavigationFrames() {
}
// Check that getFrame Promise is rejected with the expected error message on nonexistent frameId.
browser.webNavigation.getFrame({ tabId, frameId: nonExistentFrameId, processId: 20 }).then(() => {
browser.webNavigation.getFrame({tabId, frameId: nonExistentFrameId, processId: 20}).then(() => {
browser.test.fail("getFrame promise should be rejected for an unexistent frameId");
}, (error) => {
browser.test.assertEq(`No frame found with frameId: ${nonExistentFrameId}`, error.message,
@ -93,7 +93,7 @@ add_task(function* testWebNavigationFrames() {
});
});
browser.tabs.create({ url: "tab.html" }, (tab) => {
browser.tabs.create({url: "tab.html"}, (tab) => {
tabId = tab.id;
});
} + ")();",

View File

@ -43,9 +43,12 @@
// Always require spacing around a single line block
"block-spacing": 1,
// Forbid spaces inside the curly brackets of object literals.
"object-curly-spacing": [2, "never"],
// Enforce one true brace style (opening brace on the same line) and avoid
// start and end braces on the same line.
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"brace-style": [2, "1tbs", {"allowSingleLine": true}],
// No space before always a space after a comma
"comma-spacing": [2, {"before": false, "after": true}],
@ -69,10 +72,10 @@
"generator-star-spacing": [2, {"before": false, "after": true}],
// Two space indent
"indent": [2, 2, { "SwitchCase": 1 }],
"indent": [2, 2, {"SwitchCase": 1}],
// Space after colon not before in property declarations
"key-spacing": [2, { "beforeColon": false, "afterColon": true, "mode": "minimum" }],
"key-spacing": [2, {"beforeColon": false, "afterColon": true, "mode": "minimum"}],
// Unix linebreaks
"linebreak-style": [2, "unix"],
@ -189,7 +192,7 @@
"no-unused-expressions": 2,
// No declaring variables that are never used
"no-unused-vars": [2, { "args": "none", "varsIgnorePattern": "^(Cc|Ci|Cr|Cu|EXPORTED_SYMBOLS)$" }],
"no-unused-vars": [2, {"args": "none", "varsIgnorePattern": "^(Cc|Ci|Cr|Cu|EXPORTED_SYMBOLS)$"}],
// No using variables before defined
"no-use-before-define": 2,
@ -207,7 +210,7 @@
"space-before-blocks": 2,
// Never use spaces before function parentheses
"space-before-function-paren": [2, { "anonymous": "never", "named": "never" }],
"space-before-function-paren": [2, {"anonymous": "never", "named": "never"}],
// Require spaces before finally, catch, etc.
"space-before-keywords": [2, "always"],
@ -223,7 +226,7 @@
"space-return-throw-case": 2,
// ++ and -- should not need spacing
"space-unary-ops": [1, { "nonwords": false }],
"space-unary-ops": [1, {"nonwords": false}],
// No comparisons to NaN
"use-isnan": 2,

View File

@ -416,7 +416,7 @@ GlobalManager = {
promise = Promise.reject(e);
} else {
Cu.reportError(e);
promise = Promise.reject({ message: "An unexpected error occurred" });
promise = Promise.reject({message: "An unexpected error occurred"});
}
}
@ -451,7 +451,7 @@ GlobalManager = {
let id = ExtensionManagement.getAddonIdForWindow(contentWindow);
// We don't inject privileged APIs into sub-frames of a UI page.
const { FULL_PRIVILEGES } = ExtensionManagement.API_LEVELS;
const {FULL_PRIVILEGES} = ExtensionManagement.API_LEVELS;
if (ExtensionManagement.getAPILevelForWindow(contentWindow, id) !== FULL_PRIVILEGES) {
return;
}
@ -611,7 +611,7 @@ ExtensionData.prototype = {
}
try {
let text = NetUtil.readInputStreamToString(inputStream, inputStream.available(),
{ charset: "utf-8" });
{charset: "utf-8"});
resolve(JSON.parse(text));
} catch (e) {
reject(e);
@ -768,7 +768,7 @@ ExtensionData.prototype = {
let promises = [this.readLocaleFile(locale)];
let { defaultLocale } = this;
let {defaultLocale} = this;
if (locale != defaultLocale && !this.localeData.has(defaultLocale)) {
promises.push(this.readLocaleFile(defaultLocale));
}
@ -1100,7 +1100,7 @@ Extension.prototype = extend(Object.create(ExtensionData.prototype), {
let locales = yield this.promiseLocales();
let localeList = Array.from(locales.keys(), locale => {
return { name: locale, locales: [locale] };
return {name: locale, locales: [locale]};
});
let match = Locale.findClosestLocale(localeList);
@ -1193,7 +1193,7 @@ Extension.prototype = extend(Object.create(ExtensionData.prototype), {
Services.ppmm.broadcastAsyncMessage("Extension:Shutdown", {id: this.id});
MessageChannel.abortResponses({ extensionId: this.id });
MessageChannel.abortResponses({extensionId: this.id});
ExtensionManagement.shutdownExtension(this.uuid);

View File

@ -243,7 +243,7 @@ class ExtensionContext extends BaseContext {
constructor(extensionId, contentWindow, contextOptions = {}) {
super();
let { isExtensionPage } = contextOptions;
let {isExtensionPage} = contextOptions;
this.isExtensionPage = isExtensionPage;
this.extension = ExtensionManager.get(extensionId);
@ -341,8 +341,8 @@ class ExtensionContext extends BaseContext {
// defined in the content window (See Bug 1214658 for rationale).
if (this.isExtensionPage && !Cu.isDeadWrapper(this.contentWindow) &&
Cu.waiveXrays(this.contentWindow).browser === this.chromeObj) {
Cu.createObjectIn(this.contentWindow, { defineAs: "browser" });
Cu.createObjectIn(this.contentWindow, { defineAs: "chrome" });
Cu.createObjectIn(this.contentWindow, {defineAs: "browser"});
Cu.createObjectIn(this.contentWindow, {defineAs: "chrome"});
}
Cu.nukeSandbox(this.sandbox);
this.sandbox = null;
@ -404,7 +404,7 @@ var DocumentManager = {
// Enable the content script APIs should be available in subframes' window
// if it is recognized as a valid addon id (see Bug 1214658 for rationale).
const { CONTENTSCRIPT_PRIVILEGES } = ExtensionManagement.API_LEVELS;
const {CONTENTSCRIPT_PRIVILEGES} = ExtensionManagement.API_LEVELS;
let extensionId = ExtensionManagement.getAddonIdForWindow(window);
if (ExtensionManagement.getAPILevelForWindow(window, extensionId) == CONTENTSCRIPT_PRIVILEGES &&
@ -420,7 +420,7 @@ var DocumentManager = {
} else if (topic == "inner-window-destroyed") {
let windowId = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
MessageChannel.abortResponses({ innerWindowID: windowId });
MessageChannel.abortResponses({innerWindowID: windowId});
// Close any existent content-script context for the destroyed window.
if (this.contentScriptWindows.has(windowId)) {
@ -506,7 +506,7 @@ var DocumentManager = {
let context = this.extensionPageWindows.get(winId);
if (!context) {
let context = new ExtensionContext(extensionId, window, { isExtensionPage: true });
let context = new ExtensionContext(extensionId, window, {isExtensionPage: true});
this.extensionPageWindows.set(winId, context);
}
@ -553,7 +553,7 @@ var DocumentManager = {
}
}
MessageChannel.abortResponses({ extensionId });
MessageChannel.abortResponses({extensionId});
this.extensionCount--;
if (this.extensionCount == 0) {
@ -681,11 +681,11 @@ class ExtensionGlobal {
.getInterface(Ci.nsIDOMWindowUtils)
.outerWindowID;
global.sendAsyncMessage("Extension:TopWindowID", { windowId: this.windowId });
global.sendAsyncMessage("Extension:TopWindowID", {windowId: this.windowId});
}
uninit() {
this.global.sendAsyncMessage("Extension:RemoveTopWindowID", { windowId: this.windowId });
this.global.sendAsyncMessage("Extension:RemoveTopWindowID", {windowId: this.windowId});
}
get messageFilter() {
@ -697,7 +697,7 @@ class ExtensionGlobal {
};
}
receiveMessage({ target, messageName, recipient, data }) {
receiveMessage({target, messageName, recipient, data}) {
switch (messageName) {
case "Extension:Capture":
return this.handleExtensionCapture(data.width, data.height, data.options);
@ -734,12 +734,12 @@ class ExtensionGlobal {
handleExtensionExecute(target, recipient, options) {
let deferred = PromiseUtils.defer();
let script = new Script(options, deferred);
let { extensionId } = recipient;
let {extensionId} = recipient;
DocumentManager.executeScript(target, extensionId, script);
return deferred.promise;
}
handleWebNavigationGetFrame({ frameId }) {
handleWebNavigationGetFrame({frameId}) {
return WebNavigationFrames.getFrame(this.global.docShell, frameId);
}

View File

@ -228,7 +228,7 @@ const API_LEVELS = Object.freeze({
// Finds the API Level ("FULL_PRIVILEGES", "CONTENTSCRIPT_PRIVILEGES", "NO_PRIVILEGES")
// with a given a window object.
function getAPILevelForWindow(window, addonId) {
const { NO_PRIVILEGES, CONTENTSCRIPT_PRIVILEGES, FULL_PRIVILEGES } = API_LEVELS;
const {NO_PRIVILEGES, CONTENTSCRIPT_PRIVILEGES, FULL_PRIVILEGES} = API_LEVELS;
// Non WebExtension URLs and WebExtension URLs from a different extension
// has no access to APIs.

View File

@ -149,16 +149,16 @@ class FilteringMessageManager {
* Receives a message from our message manager, maps it to a handler, and
* passes the result to our message callback.
*/
receiveMessage({ data, target }) {
receiveMessage({data, target}) {
let handlers = Array.from(this.getHandlers(data.messageName, data.recipient));
let result = {};
if (handlers.length == 0) {
result.error = { result: MessageChannel.RESULT_NO_HANDLER,
message: "No matching message handler" };
result.error = {result: MessageChannel.RESULT_NO_HANDLER,
message: "No matching message handler"};
} else if (handlers.length > 1) {
result.error = { result: MessageChannel.RESULT_MULTIPLE_HANDLERS,
message: `Multiple matching handlers for ${data.messageName}` };
result.error = {result: MessageChannel.RESULT_MULTIPLE_HANDLERS,
message: `Multiple matching handlers for ${data.messageName}`};
} else {
result.handler = handlers[0];
}
@ -414,7 +414,7 @@ this.MessageChannel = {
*/
sendMessage(target, messageName, data, recipient = {}, sender = {}) {
let channelId = gChannelId++;
let message = { messageName, channelId, sender, recipient, data };
let message = {messageName, channelId, sender, recipient, data};
let deferred = PromiseUtils.defer();
deferred.messageFilter = {};
@ -446,11 +446,11 @@ this.MessageChannel = {
* Each handler object is a `MessageReceiver` object as passed to
* `addListener`.
*/
_handleMessage({ handler, error }, data) {
_handleMessage({handler, error}, data) {
// The target passed to `receiveMessage` is sometimes a message manager
// owner instead of a message manager, so make sure to convert it to a
// message manager first if necessary.
let { target } = data;
let {target} = data;
if (!(target instanceof Ci.nsIMessageSender)) {
target = target.messageManager;
}
@ -513,7 +513,7 @@ this.MessageChannel = {
* Each handler object is a deferred object created by `sendMessage`, and
* should be resolved or rejected based on the contents of the response.
*/
_handleResponse({ handler, error }, data) {
_handleResponse({handler, error}, data) {
if (error) {
// If we have an error at this point, we have handler to report it to,
// so just log it.

View File

@ -1,6 +1,6 @@
"use strict";
var { classes: Cc, interfaces: Ci, utils: Cu } = Components;
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/ExtensionUtils.jsm");
var {

View File

@ -1,6 +1,6 @@
"use strict";
var { interfaces: Ci, utils: Cu } = Components;
var {interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/Services.jsm");

View File

@ -1,6 +1,6 @@
"use strict";
const { interfaces: Ci, utils: Cu } = Components;
const {interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/ExtensionUtils.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
@ -280,7 +280,7 @@ extensions.registerSchemaAPI("cookies", "cookies", (extension, context) => {
let expiry = isSession ? 0 : details.expirationDate;
// Ignore storeID.
let cookieAttrs = { host: details.domain, path: path, isSecure: secure };
let cookieAttrs = {host: details.domain, path: path, isSecure: secure};
if (!checkSetCookiePermissions(extension, uri, cookieAttrs)) {
return Promise.reject({message: `Permission denied to set cookie ${JSON.stringify(details)}`});
}

View File

@ -1,6 +1,6 @@
"use strict";
var { classes: Cc, interfaces: Ci, utils: Cu } = Components;
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/ExtensionUtils.jsm");
const {

View File

@ -1,6 +1,6 @@
"use strict";
var { classes: Cc, interfaces: Ci, utils: Cu } = Components;
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/ExtensionUtils.jsm");
var {

View File

@ -1,6 +1,6 @@
"use strict";
var { classes: Cc, interfaces: Ci, utils: Cu } = Components;
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
@ -48,7 +48,7 @@ extensions.registerSchemaAPI("runtime", null, (extension, context) => {
let recipient = {extensionId: extensionId ? extensionId : extension.id};
if (!GlobalManager.extensionMap.has(recipient.extensionId)) {
return context.wrapPromise(Promise.reject({ message: "Invalid extension ID" }),
return context.wrapPromise(Promise.reject({message: "Invalid extension ID"}),
responseCallback);
}
return context.messenger.sendMessage(Services.cpmm, message, recipient, responseCallback);
@ -95,11 +95,11 @@ extensions.registerSchemaAPI("runtime", null, (extension, context) => {
try {
uri = NetUtil.newURI(url);
} catch (e) {
return Promise.reject({ message: `Invalid URL: ${JSON.stringify(url)}` });
return Promise.reject({message: `Invalid URL: ${JSON.stringify(url)}`});
}
if (uri.scheme != "http" && uri.scheme != "https") {
return Promise.reject({ message: "url must have the scheme http or https" });
return Promise.reject({message: "url must have the scheme http or https"});
}
extension.uninstallURL = url;

View File

@ -1,6 +1,6 @@
"use strict";
var { classes: Cc, interfaces: Ci, utils: Cu } = Components;
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
XPCOMUtils.defineLazyModuleGetter(this, "ExtensionStorage",
"resource://gre/modules/ExtensionStorage.jsm");

View File

@ -1,6 +1,6 @@
"use strict";
var { classes: Cc, interfaces: Ci, utils: Cu } = Components;
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
@ -83,11 +83,11 @@ extensions.registerSchemaAPI("webNavigation", "webNavigation", (extension, conte
getAllFrames(details) {
let tab = TabManager.getTab(details.tabId);
if (!tab) {
return Promise.reject({ message: `No tab found with tabId: ${details.tabId}`});
return Promise.reject({message: `No tab found with tabId: ${details.tabId}`});
}
let { innerWindowID, messageManager } = tab.linkedBrowser;
let recipient = { innerWindowID };
let {innerWindowID, messageManager} = tab.linkedBrowser;
let recipient = {innerWindowID};
return context.sendMessage(messageManager, "WebNavigation:GetAllFrames", {}, recipient)
.then((results) => results.map(convertGetFrameResult.bind(null, details.tabId)));
@ -95,7 +95,7 @@ extensions.registerSchemaAPI("webNavigation", "webNavigation", (extension, conte
getFrame(details) {
let tab = TabManager.getTab(details.tabId);
if (!tab) {
return Promise.reject({ message: `No tab found with tabId: ${details.tabId}`});
return Promise.reject({message: `No tab found with tabId: ${details.tabId}`});
}
let recipient = {
@ -103,11 +103,11 @@ extensions.registerSchemaAPI("webNavigation", "webNavigation", (extension, conte
};
let mm = tab.linkedBrowser.messageManager;
return context.sendMessage(mm, "WebNavigation:GetFrame", { options: details }, recipient)
return context.sendMessage(mm, "WebNavigation:GetFrame", {options: details}, recipient)
.then((result) => {
return result ?
convertGetFrameResult(details.tabId, result) :
Promise.reject({ message: `No frame found with frameId: ${details.frameId}`});
Promise.reject({message: `No frame found with frameId: ${details.frameId}`});
});
},
},

View File

@ -1,6 +1,6 @@
"use strict";
var { classes: Cc, interfaces: Ci, utils: Cu } = Components;
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");

View File

@ -1,12 +1,12 @@
"use strict";
var { interfaces: Ci } = Components;
var {interfaces: Ci} = Components;
Components.utils.import("resource://gre/modules/Services.jsm");
Services.console.registerListener(function listener(message) {
if (/WebExt Privilege Escalation/.test(message.message)) {
Services.console.unregisterListener(listener);
sendAsyncMessage("console-message", { message: message.message });
sendAsyncMessage("console-message", {message: message.message});
}
});

View File

@ -19,7 +19,7 @@ function backgroundScript() {
const invalid_connect_params = [
// too many params
["fake-extensions-id", { name: "fake-conn-name" }, "unexpected third params"],
["fake-extensions-id", {name: "fake-conn-name"}, "unexpected third params"],
// invalid params format
[{}, {}],
["fake-extensions-id", "invalid-connect-info-format"],
@ -56,7 +56,7 @@ function backgroundScript() {
assertInvalidConnectParamsException(params);
}
browser.runtime.connect(browser.runtime.id, { name: "check-results"});
browser.runtime.connect(browser.runtime.id, {name: "check-results"});
}
let extensionData = {

View File

@ -27,21 +27,21 @@
add_task(function* test_contentscript_create_iframe() {
function backgroundScript() {
browser.runtime.onMessage.addListener((msg, sender) => {
let { name, availableAPIs, manifest, testGetManifest } = msg;
let {name, availableAPIs, manifest, testGetManifest} = msg;
let hasExtTabsAPI = availableAPIs.indexOf("tabs") > 0;
let hasExtWindowsAPI = availableAPIs.indexOf("windows") > 0;
browser.test.assertFalse(hasExtTabsAPI, "the created iframe should not be able to use privileged APIs (tabs)");
browser.test.assertFalse(hasExtWindowsAPI, "the created iframe should not be able to use privileged APIs (windows)");
let { applications: { gecko: { id: expectedManifestGeckoId } } } = chrome.runtime.getManifest();
let { applications: { gecko: { id: actualManifestGeckoId } } } = manifest;
let {applications: {gecko: {id: expectedManifestGeckoId}}} = chrome.runtime.getManifest();
let {applications: {gecko: {id: actualManifestGeckoId}}} = manifest;
browser.test.assertEq(actualManifestGeckoId, expectedManifestGeckoId,
"the add-on manifest should be accessible from the created iframe"
);
let { applications: { gecko: { id: testGetManifestGeckoId } } } = testGetManifest;
let {applications: {gecko: {id: testGetManifestGeckoId}}} = testGetManifest;
browser.test.assertEq(testGetManifestGeckoId, expectedManifestGeckoId,
"GET_MANIFEST() returns manifest data before extension unload"

View File

@ -36,7 +36,7 @@ function* testCookies(options) {
// Try to access some cookies in various ways.
let { url, domain, secure } = options;
let {url, domain, secure} = options;
let failures = 0;
let tallyFailure = error => {
@ -44,11 +44,11 @@ function* testCookies(options) {
};
awaitChanges.then(() => {
return browser.cookies.get({ url, name: "foo" });
return browser.cookies.get({url, name: "foo"});
}).then(cookie => {
browser.test.assertEq(options.shouldPass, cookie != null, "should pass == get cookie");
return browser.cookies.getAll({ domain });
return browser.cookies.getAll({domain});
}).then(cookies => {
if (options.shouldPass) {
browser.test.assertEq(2, cookies.length, "expected number of cookies");
@ -57,9 +57,9 @@ function* testCookies(options) {
}
return Promise.all([
browser.cookies.set({ url, domain, secure, name: "foo", "value": "baz", expirationDate: options.expiry }).catch(tallyFailure),
browser.cookies.set({ url, domain, secure, name: "bar", "value": "quux", expirationDate: options.expiry }).catch(tallyFailure),
browser.cookies.remove({ url, name: "deleted" }),
browser.cookies.set({url, domain, secure, name: "foo", "value": "baz", expirationDate: options.expiry}).catch(tallyFailure),
browser.cookies.set({url, domain, secure, name: "bar", "value": "quux", expirationDate: options.expiry}).catch(tallyFailure),
browser.cookies.remove({url, name: "deleted"}),
]);
}).then(() => {
if (options.shouldPass) {

View File

@ -62,8 +62,8 @@ add_task(function* test_i18n() {
"default_locale": "jp",
content_scripts: [
{ "matches": ["http://mochi.test/*/file_sample.html"],
"js": ["content.js"] },
{"matches": ["http://mochi.test/*/file_sample.html"],
"js": ["content.js"]},
],
},

View File

@ -1,6 +1,6 @@
"use strict";
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

View File

@ -384,28 +384,28 @@ add_task(function* () {
root.testing.bar(true);
verify("call", "testing", "bar", [null, true]);
root.testing.baz({ prop1: "hello", prop2: 22 });
verify("call", "testing", "baz", [{ prop1: "hello", prop2: 22 }]);
root.testing.baz({prop1: "hello", prop2: 22});
verify("call", "testing", "baz", [{prop1: "hello", prop2: 22}]);
root.testing.baz({ prop1: "hello" });
verify("call", "testing", "baz", [{ prop1: "hello", prop2: null }]);
root.testing.baz({prop1: "hello"});
verify("call", "testing", "baz", [{prop1: "hello", prop2: null}]);
root.testing.baz({ prop1: "hello", prop2: null });
verify("call", "testing", "baz", [{ prop1: "hello", prop2: null }]);
root.testing.baz({prop1: "hello", prop2: null});
verify("call", "testing", "baz", [{prop1: "hello", prop2: null}]);
Assert.throws(() => root.testing.baz({ prop2: 12 }),
Assert.throws(() => root.testing.baz({prop2: 12}),
/Property "prop1" is required/,
"should throw without required property");
Assert.throws(() => root.testing.baz({ prop1: "hi", prop3: 12 }),
Assert.throws(() => root.testing.baz({prop1: "hi", prop3: 12}),
/Property "prop3" is unsupported by Firefox/,
"should throw with unsupported property");
Assert.throws(() => root.testing.baz({ prop1: "hi", prop4: 12 }),
Assert.throws(() => root.testing.baz({prop1: "hi", prop4: 12}),
/Unexpected property "prop4"/,
"should throw with unexpected property");
Assert.throws(() => root.testing.baz({ prop1: 12 }),
Assert.throws(() => root.testing.baz({prop1: 12}),
/Expected string instead of 12/,
"should throw with wrong type");

View File

@ -118,7 +118,7 @@ add_task(function* testInvalidUUID() {
}, expectInvalidContextException);
Assert.throws(() => {
let listener = { QueryInterface: XPCOMUtils.generateQI([Ci.nsIStreamListener]) };
let listener = {QueryInterface: XPCOMUtils.generateQI([Ci.nsIStreamListener])};
convService.asyncConvertData(FROM_TYPE, TO_TYPE, listener, uri);
}, expectInvalidContextException);

View File

@ -153,7 +153,7 @@ MatchPattern.prototype = {
// So, instead, we need to manually check our filters, and accept any
// with hosts that end with our cookie's host.
let { host, isSecure } = cookie;
let {host, isSecure} = cookie;
for (let matcher of this.matchers) {
let schemes = matcher.schemes;

View File

@ -432,7 +432,7 @@ HttpObserverManager = {
onChannelReplaced(oldChannel, newChannel) {
this.runChannelListener(oldChannel, this.getLoadContext(oldChannel),
"onRedirect", { redirectUrl: newChannel.URI.spec });
"onRedirect", {redirectUrl: newChannel.URI.spec});
},
onStartRequest(channel, loadContext) {