Merge m-c to graphics

MozReview-Commit-ID: 7PVyxahE0p6
This commit is contained in:
Kartikaya Gupta 2017-01-31 09:04:18 -05:00
commit 1c269ab364
913 changed files with 30883 additions and 24006 deletions

View File

@ -68,7 +68,8 @@ browser/components/sessionstore/**
browser/components/tabview/**
# generated files in cld2
browser/components/translation/cld2/cld-worker.js
browser/extensions/pdfjs/content/**
browser/extensions/pdfjs/content/build**
browser/extensions/pdfjs/content/web**
# generated or library files in pocket
browser/extensions/pocket/content/panels/js/tmpl.js
browser/extensions/pocket/content/panels/js/vendor/**
@ -181,7 +182,6 @@ mobile/android/modules/HomeProvider.jsm
services/sync/modules/constants.js
# Third party services
services/sync/tps/extensions/mozmill/resource/stdlib/json2.js
services/common/kinto-http-client.js
services/common/kinto-offline-client.js
services/sync/tps/extensions/mozmill

View File

@ -6,6 +6,7 @@ module.exports = {
"mozilla"
],
"rules": {
"mozilla/avoid-removeChild": "error",
"mozilla/import-globals": "warn",
"mozilla/no-import-into-var-and-global": "error",
"mozilla/no-useless-parameters": "error",

View File

@ -117,8 +117,7 @@ function* testContainer1(browser, accDoc) {
/* ================ Remove element ======================================== */
onReorder = waitForEvent(EVENT_REORDER, id);
yield ContentTask.spawn(browser, {}, () =>
content.document.getElementById('t1_span').parentNode.removeChild(
content.document.getElementById('t1_span')));
content.document.getElementById('t1_span').remove());
yield onReorder;
// subdiv should go away

View File

@ -119,7 +119,7 @@ function* testContainer(browser) {
onReorder = waitForEvent(EVENT_REORDER, id);
yield ContentTask.spawn(browser, {}, () => {
let mapNode = content.document.getElementById('map');
mapNode.parentNode.removeChild(mapNode);
mapNode.remove();
});
yield onReorder;

View File

@ -28,7 +28,7 @@
this.invoke = function removeElm_invoke()
{
this.node.parentNode.removeChild(this.node);
this.node.remove();
}
this.check = function removeElm_check()

View File

@ -202,7 +202,7 @@
testGroupAttrs("tree4_ti2", 2, 2, 1);
var tree4element = document.getElementById("tree4_ti1");
var tree4acc = getAccessible("tree4");
tree4element.parentNode.removeChild(tree4element);
tree4element.remove();
waitForEvent(EVENT_REORDER, tree4acc, function() {
testGroupAttrs("tree4_ti2", 1, 1, 1);
SimpleTest.finish();

View File

@ -74,7 +74,7 @@
{
switch (aAction) {
case kRemoveElm:
aNode.parentNode.removeChild(aNode);
aNode.remove();
break;
case kHideElm:
@ -328,8 +328,8 @@
this.invoke = function removeGrandChildrenNHideParent_invoke()
{
this.child1.parentNode.removeChild(this.child1);
this.child2.parentNode.removeChild(this.child2);
this.child1.remove();
this.child2.remove();
this.parent.hidden = true;
}

View File

@ -202,7 +202,7 @@
this.invoke = function removeFromDOM_invoke()
{
this.DOMNode.parentNode.removeChild(this.DOMNode);
this.DOMNode.remove();
}
this.getID = function removeFromDOM_getID()
@ -387,12 +387,12 @@
this.invoke = function hideNDestroyDoc_invoke()
{
this.txt = getAccessible('c5').firstChild.firstChild;
this.txt.DOMNode.parentNode.removeChild(this.txt.DOMNode);
this.txt.DOMNode.remove();
}
this.check = function hideNDestroyDoc_check()
{
getNode('c5').parentNode.removeChild(getNode('c5'));
getNode('c5').remove();
}
this.getID = function hideNDestroyDoc_getID()
@ -420,7 +420,7 @@
this.check = function hideHideNDestroyDoc_check()
{
getNode('c6').parentNode.removeChild(getNode('c6'));
getNode('c6').remove();
}
this.getID = function hideHideNDestroyDoc_getID()

View File

@ -476,7 +476,7 @@ function removeVCPositionInvoker(aDocAcc, aPosNode)
this.invoke = function removeVCPositionInvoker_invoke()
{
aDocAcc.virtualCursor.position = this.accessible;
aPosNode.parentNode.removeChild(aPosNode);
aPosNode.remove();
};
this.getID = function removeVCPositionInvoker_getID()
@ -523,7 +523,7 @@ function removeVCRootInvoker(aRootNode)
this.invoke = function removeVCRootInvoker_invoke()
{
this.pivot.position = this.pivot.root.firstChild;
aRootNode.parentNode.removeChild(aRootNode);
aRootNode.remove();
};
this.getID = function removeVCRootInvoker_getID()

View File

@ -223,7 +223,7 @@
this.invoke = function removeEl_invoke()
{
// remove a container of t1_subdiv
getNode("t1_span").parentNode.removeChild(getNode("t1_span"));
getNode("t1_span").remove();
}
this.finalCheck = function removeEl_finalCheck()
@ -523,7 +523,7 @@
{
getNode(aChild).setAttribute("aria-owns", "no_id");
getNode(aParent).removeChild(getNode(aChild));
getNode(aParent).parentNode.removeChild(getNode(aParent));
getNode(aParent).remove();
}
this.getID = function setARIAOwnsOnElToRemove_getID()

View File

@ -273,7 +273,7 @@
this.invoke = function removeMap_invoke()
{
this.imageMap = getAccessible(aImageMapID);
this.mapNode.parentNode.removeChild(this.mapNode);
this.mapNode.remove();
}
this.finalCheck = function removeMap_finalCheck()

View File

@ -55,7 +55,7 @@
{
this.lastItem = getAccessible(aID).lastChild;
this.lastCell = this.lastItem.lastChild;
getNode(aID).parentNode.removeChild(getNode(aID));
getNode(aID).remove();
};
this.check = function check(aEvent)

View File

@ -61,5 +61,5 @@ exports.window = window;
// Still close window on unload to claim memory back early.
unload(function() {
window.close()
frame.parentNode.removeChild(frame);
frame.remove();
});

View File

@ -966,14 +966,14 @@ var MenuWrapper = Class({
if (toplevel.length == 0) {
let separator = this.separator;
if (separator)
separator.parentNode.removeChild(separator);
separator.remove();
}
}
else if (parent == this.overflowPopup) {
// If there are no more items then remove the overflow menu and separator
if (parent.childNodes.length == 0) {
let separator = this.separator;
separator.parentNode.removeChild(separator);
separator.remove();
this.contextMenu.removeChild(parent.parentNode);
}
}

View File

@ -108,7 +108,7 @@ function removeHiddenFrame(frame) {
cache.delete(frame);
emit(frame, "unload")
let element = frame.element
if (element) element.parentNode.removeChild(element)
if (element) element.remove()
}
exports.remove = removeHiddenFrame;

View File

@ -367,7 +367,7 @@ function attach(panel, document) {
exports.attach = attach;
function detach(panel) {
if (panel.parentNode) panel.parentNode.removeChild(panel);
if (panel.parentNode) panel.remove();
}
exports.detach = detach;

View File

@ -44,7 +44,7 @@ function create(window, details) {
exports.create = create;
function dispose(menuitem) {
menuitem.parentNode.removeChild(menuitem);
menuitem.remove();
}
exports.dispose = dispose;

View File

@ -54,7 +54,7 @@ function createProxyTest(html, callback) {
if (isDone)
return;
isDone = true;
element.parentNode.removeChild(element);
element.remove();
done();
}
};

View File

@ -51,7 +51,7 @@ exports.testMembranelessMode = function(assert, done) {
worker.port.on("done", () => {
// cleanup
element.parentNode.removeChild(element);
element.remove();
worker.destroy();
loader.unload();

View File

@ -54,7 +54,7 @@ function createProxyTest(html, callback) {
if (isDone)
return;
isDone = true;
element.parentNode.removeChild(element);
element.remove();
done();
}
};

View File

@ -2631,7 +2631,7 @@ exports.testItemNoLabel = function (assert, done) {
test.done();
}
/* bug 1302854 - disabled this subtest as it is intermittent
// Tests that items can have an empty data property
exports.testItemNoData = function (assert, done) {
let test = new TestHelper(assert, done);
@ -2686,6 +2686,7 @@ exports.testItemNoData = function (assert, done) {
});
});
}
*/
exports.testItemNoAccessKey = function (assert, done) {

View File

@ -1059,7 +1059,7 @@ exports.testAttachToTabsOnly = function(assert, done) {
iframe.setAttribute('type', 'content');
iframe.setAttribute('src', 'data:text/html;charset=utf-8,foobar');
iframe.addEventListener('DOMContentLoaded', function() {
iframe.parentNode.removeChild(iframe);
iframe.remove();
openTabWithIframes();
}, {once: true});
document.documentElement.appendChild(iframe);

View File

@ -104,7 +104,7 @@ this.SafeMode = {
break;
case "mozContentEvent":
content.removeEventListener("mozContentEvent", handleEvent, true);
contentBrowser.parentNode.removeChild(contentBrowser);
contentBrowser.remove();
if (e.detail == "safemode-yes") {
// Really starting in safe mode, let's disable add-ons first.

View File

@ -1,7 +1,6 @@
MOZ_AUTOMATION_L10N_CHECK=0
MOZ_AUTOMATION_UPLOAD_SYMBOLS=0
MOZ_AUTOMATION_UPDATE_PACKAGING=0
MOZ_AUTOMATION_SDK=0
. "$topsrcdir/b2g/config/mozconfigs/common"
. "$topsrcdir/build/unix/mozconfig.linux32"

View File

@ -1,7 +1,6 @@
MOZ_AUTOMATION_L10N_CHECK=0
MOZ_AUTOMATION_UPLOAD_SYMBOLS=0
MOZ_AUTOMATION_UPDATE_PACKAGING=0
MOZ_AUTOMATION_SDK=0
. "$topsrcdir/b2g/config/mozconfigs/common"
. "$topsrcdir/build/unix/mozconfig.linux"

View File

@ -1,6 +1,5 @@
MOZ_AUTOMATION_UPLOAD_SYMBOLS=0
MOZ_AUTOMATION_UPDATE_PACKAGING=0
MOZ_AUTOMATION_SDK=0
. "$topsrcdir/b2g/config/mozconfigs/common"
# Use sccache

View File

@ -1,7 +1,6 @@
MOZ_AUTOMATION_L10N_CHECK=0
MOZ_AUTOMATION_UPLOAD_SYMBOLS=0
MOZ_AUTOMATION_UPDATE_PACKAGING=0
MOZ_AUTOMATION_SDK=0
. "$topsrcdir/b2g/config/mozconfigs/common"
ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}

View File

@ -1,7 +1,6 @@
MOZ_AUTOMATION_L10N_CHECK=0
MOZ_AUTOMATION_UPLOAD_SYMBOLS=0
MOZ_AUTOMATION_UPDATE_PACKAGING=0
MOZ_AUTOMATION_SDK=0
. "$topsrcdir/browser/config/mozconfigs/linux64/nightly"
ac_add_options --enable-application=b2g/dev

View File

@ -1,7 +1,6 @@
MOZ_AUTOMATION_L10N_CHECK=0
MOZ_AUTOMATION_UPLOAD_SYMBOLS=0
MOZ_AUTOMATION_UPDATE_PACKAGING=0
MOZ_AUTOMATION_SDK=0
. "$topsrcdir/browser/config/mozconfigs/linux64/nightly"
ac_add_options --enable-application=b2g/dev

View File

@ -1,7 +1,6 @@
MOZ_AUTOMATION_L10N_CHECK=0
MOZ_AUTOMATION_UPLOAD_SYMBOLS=0
MOZ_AUTOMATION_UPDATE_PACKAGING=0
MOZ_AUTOMATION_SDK=0
. "$topsrcdir/browser/config/mozconfigs/linux64/nightly"
ac_add_options --enable-application=b2g/dev

View File

@ -2,7 +2,6 @@ MOZ_AUTOMATION_BUILD_SYMBOLS=0
MOZ_AUTOMATION_PACKAGE_TESTS=0
MOZ_AUTOMATION_UPLOAD_SYMBOLS=0
MOZ_AUTOMATION_UPDATE_PACKAGING=0
MOZ_AUTOMATION_SDK=0
. $topsrcdir/build/macosx/mozconfig.common
ac_add_options --enable-application=b2g/dev

View File

@ -4,7 +4,6 @@ MOZ_AUTOMATION_PACKAGE_TESTS=0
MOZ_AUTOMATION_INSTALLER=0
MOZ_AUTOMATION_UPLOAD_SYMBOLS=0
MOZ_AUTOMATION_UPDATE_PACKAGING=0
MOZ_AUTOMATION_SDK=0
. "$topsrcdir/browser/config/mozconfigs/win32/nightly"
ac_add_options --enable-application=b2g/dev

View File

@ -6,7 +6,6 @@
# This needs to be set prior to the next include for it to take effect.
MOZ_AUTOMATION_PACKAGE_TESTS=0
MOZ_AUTOMATION_L10N_CHECK=0
MOZ_AUTOMATION_SDK=0
. "$topsrcdir/build/mozconfig.common"

View File

@ -6,7 +6,6 @@
# This needs to be set prior to the next include for it to take effect.
MOZ_AUTOMATION_PACKAGE_TESTS=0
MOZ_AUTOMATION_L10N_CHECK=0
MOZ_AUTOMATION_SDK=0
. "$topsrcdir/build/mozconfig.common"

View File

@ -1015,6 +1015,8 @@ pref("security.sandbox.content.level", 1);
// This setting may not be required anymore once we decide to permanently
// enable the content sandbox.
pref("security.sandbox.content.level", 2);
pref("security.sandbox.content.write_path_whitelist", "");
pref("security.sandbox.content.syscall_whitelist", "");
#endif
#if defined(XP_MACOSX) || defined(XP_WIN)

View File

@ -232,7 +232,7 @@
// remove undisplayed errors to avoid bug 39098
var errContainer = document.getElementById("errorContainer");
errContainer.parentNode.removeChild(errContainer);
errContainer.remove();
var className = getCSSClass();
if (className && className != "expertBadCert") {

View File

@ -97,29 +97,29 @@
if (error !== "malware") {
el = document.getElementById("errorTitleText_malware");
el.parentNode.removeChild(el);
el.remove();
el = document.getElementById("errorShortDescText_malware");
el.parentNode.removeChild(el);
el.remove();
el = document.getElementById("errorLongDescText_malware");
el.parentNode.removeChild(el);
el.remove();
}
if (error !== "phishing") {
el = document.getElementById("errorTitleText_phishing");
el.parentNode.removeChild(el);
el.remove();
el = document.getElementById("errorShortDescText_phishing");
el.parentNode.removeChild(el);
el.remove();
el = document.getElementById("errorLongDescText_phishing");
el.parentNode.removeChild(el);
el.remove();
}
if (error !== "unwanted") {
el = document.getElementById("errorTitleText_unwanted");
el.parentNode.removeChild(el);
el.remove();
el = document.getElementById("errorShortDescText_unwanted");
el.parentNode.removeChild(el);
el.remove();
el = document.getElementById("errorLongDescText_unwanted");
el.parentNode.removeChild(el);
el.remove();
}
// Set sitename
@ -130,7 +130,7 @@
if (!getOverride()) {
var btn = document.getElementById("ignoreWarningButton");
if (btn) {
btn.parentNode.removeChild(btn);
btn.remove();
}
}

View File

@ -918,7 +918,7 @@ var gHistorySwipeAnimation = {
this._prevBox = null;
this._nextBox = null;
if (this._container)
this._container.parentNode.removeChild(this._container);
this._container.remove();
this._container = null;
this._boxWidth = -1;
this._boxHeight = -1;

View File

@ -658,7 +658,7 @@ var gPopupBlockerObserver = {
let item = aEvent.target.lastChild;
while (item && item.getAttribute("observes") != "blockedPopupsSeparator") {
let next = item.previousSibling;
item.parentNode.removeChild(item);
item.remove();
item = next;
}
},
@ -2542,7 +2542,7 @@ function UpdateUrlbarSearchSplitterState() {
}
urlbar.parentNode.insertBefore(splitter, ibefore);
} else if (splitter)
splitter.parentNode.removeChild(splitter);
splitter.remove();
}
function UpdatePageProxyState() {

View File

@ -336,7 +336,7 @@ Site.prototype = {
let button = this._querySelector(buttonClass);
if (button.hasAttribute("active")) {
let explain = this._querySelector(explanationTextClass);
explain.parentNode.removeChild(explain);
explain.remove();
button.removeAttribute("active");
}

View File

@ -138,7 +138,7 @@ var gUpdater = {
let node = aSite.node;
// Remove the site from the DOM.
node.parentNode.removeChild(node);
node.remove();
resolve();
});
}));

View File

@ -1706,8 +1706,9 @@
}
// Abort if we're not going to change anything
let currentRemoteType = aBrowser.getAttribute("remoteType");
if (isRemote == aShouldBeRemote && !aOptions.newFrameloader && !aOptions.freshProcess &&
(!isRemote || aBrowser.getAttribute("remoteType") == aOptions.remoteType) &&
(!isRemote || currentRemoteType == aOptions.remoteType) &&
!aBrowser.frameLoader.isFreshProcess) {
return false;
}
@ -1754,8 +1755,12 @@
}
// NB: This works with the hack in the browser constructor that
// turns this normal property into a field.
aBrowser.relatedBrowser = relatedBrowser;
// turns this normal property into a field. When switching remote
// type copying related browser would stop the switch and the
// previously related browser will no longer be relevant.
if (!aShouldBeRemote || currentRemoteType == aOptions.remoteType) {
aBrowser.relatedBrowser = relatedBrowser;
}
if (aOptions.opener) {
// Set the opener window on the browser, such that when the frame
@ -2765,7 +2770,7 @@
// This will unload the document. An unload handler could remove
// dependant tabs, so it's important that the tabbrowser is now in
// a consistent state (tab removed, tab positions updated, etc.).
browser.parentNode.removeChild(browser);
browser.remove();
// Release the browser in case something is erroneously holding a
// reference to the tab after its removal.

View File

@ -45,7 +45,7 @@ add_task(function *() {
focusedId = yield performAccessKeyForChrome("z");
is(focusedId, "chromebutton", "chromebutton accesskey");
newButton.parentNode.removeChild(newButton);
newButton.remove();
gBrowser.removeTab(tab1);
gBrowser.removeTab(tab2);

View File

@ -34,9 +34,9 @@ add_task(function* () {
let pluginRemovedPromise = waitForEvent(gBrowser.selectedBrowser, "PluginRemoved", null, true, true);
yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
let plugin = content.document.getElementById("secondtestA");
plugin.parentNode.removeChild(plugin);
plugin.remove();
plugin = content.document.getElementById("secondtestB");
plugin.parentNode.removeChild(plugin);
plugin.remove();
let image = content.document.createElement("object");
image.type = "image/png";
@ -50,7 +50,7 @@ add_task(function* () {
yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
let plugin = content.document.getElementById("test");
plugin.parentNode.removeChild(plugin);
plugin.remove();
});
popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser);

View File

@ -166,7 +166,7 @@ var tests = [
},
onHidden(popup) {
this.notification.remove();
this.box.parentNode.removeChild(this.box);
this.box.remove();
}
},
// Test that popupnotifications without popups have anchor icons shown

View File

@ -2,6 +2,7 @@
support-files =
dummy_page.html
[browser_allow_process_switches_despite_related_browser.js]
[browser_tabSpinnerProbe.js]
skip-if = !e10s # Tab spinner is e10s only.
[browser_tabSwitchPrintPreview.js]

View File

@ -0,0 +1,32 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
const DUMMY_FILE = "dummy_page.html";
// Test for bug 1328829.
add_task(function* () {
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser,
"data:text/html,Hi");
registerCleanupFunction(function* () {
yield BrowserTestUtils.removeTab(tab);
});
let promiseTab =
BrowserTestUtils.waitForNewTab(gBrowser, "view-source:data:text/html,Hi");
BrowserViewSource(tab.linkedBrowser);
let viewSourceTab = yield promiseTab;
registerCleanupFunction(function* () {
yield BrowserTestUtils.removeTab(viewSourceTab);
});
let dummyPage = getChromeDir(getResolvedURI(gTestPath));
dummyPage.append(DUMMY_FILE);
const uriString = Services.io.newFileURI(dummyPage).spec;
let viewSourceBrowser = viewSourceTab.linkedBrowser;
viewSourceBrowser.loadURI(uriString);
let href = yield BrowserTestUtils.browserLoaded(viewSourceBrowser);
is(href, uriString,
"Check file:// URI loads in a browser that was previously for view-source");
});

View File

@ -14,9 +14,6 @@ package-compare:
stage-package:
@$(MAKE) -C browser/installer stage-package
sdk:
@$(MAKE) -C browser/installer make-sdk
install::
@$(MAKE) -C browser/installer install

View File

@ -0,0 +1,64 @@
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
/* global getDevToolsTargetForContext */
Cu.import("resource://gre/modules/ExtensionUtils.jsm");
const {
SpreadArgs,
} = ExtensionUtils;
extensions.registerSchemaAPI("devtools.inspectedWindow", "devtools_parent", context => {
const {
WebExtensionInspectedWindowFront,
} = require("devtools/shared/fronts/webextension-inspected-window");
// Lazily retrieve and store an inspectedWindow actor front per child context.
let waitForInspectedWindowFront;
async function getInspectedWindowFront() {
// If there is not yet a front instance, then a lazily cloned target for the context is
// retrieved using the DevtoolsParentContextsManager helper (which is an asynchronous operation,
// because the first time that the target has been cloned, it is not ready to be used to create
// the front instance until it is connected to the remote debugger successfully).
const clonedTarget = await getDevToolsTargetForContext(context);
return new WebExtensionInspectedWindowFront(clonedTarget.client, clonedTarget.form);
}
// TODO(rpl): retrive a more detailed callerInfo object, like the filename and
// lineNumber of the actual extension called, in the child process.
const callerInfo = {
addonId: context.extension.id,
url: context.extension.baseURI.spec,
};
return {
devtools: {
inspectedWindow: {
async eval(expression, options) {
if (!waitForInspectedWindowFront) {
waitForInspectedWindowFront = getInspectedWindowFront();
}
const front = await waitForInspectedWindowFront;
return front.eval(callerInfo, expression, options || {}).then(evalResult => {
// TODO(rpl): check for additional undocumented behaviors on chrome
// (e.g. if we should also print error to the console or set lastError?).
return new SpreadArgs([evalResult.value, evalResult.exceptionInfo]);
});
},
async reload(options) {
const {ignoreCache, userAgent, injectedScript} = options || {};
if (!waitForInspectedWindowFront) {
waitForInspectedWindowFront = getInspectedWindowFront();
}
const front = await waitForInspectedWindowFront;
front.reload(callerInfo, {ignoreCache, userAgent, injectedScript});
},
},
},
};
});

View File

@ -1,3 +1,5 @@
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
Cu.import("resource://gre/modules/Services.jsm");
@ -5,6 +7,8 @@ Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
"resource://gre/modules/Preferences.jsm");
let themeExtensions = new WeakSet();
/* eslint-disable mozilla/balanced-listeners */
extensions.on("manifest_theme", (type, directive, extension, manifest) => {
let enabled = Preferences.get("extensions.webextensions.themes.enabled");
@ -50,6 +54,7 @@ extensions.on("manifest_theme", (type, directive, extension, manifest) => {
if (lwtStyles.headerURL &&
lwtStyles.accentcolor &&
lwtStyles.textcolor) {
themeExtensions.add(extension);
Services.obs.notifyObservers(null,
"lightweight-theme-styling-update",
JSON.stringify(lwtStyles));
@ -57,6 +62,8 @@ extensions.on("manifest_theme", (type, directive, extension, manifest) => {
});
extensions.on("shutdown", (type, extension) => {
Services.obs.notifyObservers(null, "lightweight-theme-styling-update", null);
if (themeExtensions.has(extension)) {
Services.obs.notifyObservers(null, "lightweight-theme-styling-update", null);
}
});
/* eslint-enable mozilla/balanced-listeners */

View File

@ -6,6 +6,7 @@ category webextension-scripts commands chrome://browser/content/ext-commands.js
category webextension-scripts contextMenus chrome://browser/content/ext-contextMenus.js
category webextension-scripts desktop-runtime chrome://browser/content/ext-desktop-runtime.js
category webextension-scripts devtools chrome://browser/content/ext-devtools.js
category webextension-scripts devtools-inspectedWindow chrome://browser/content/ext-devtools-inspectedWindow.js
category webextension-scripts history chrome://browser/content/ext-history.js
category webextension-scripts omnibox chrome://browser/content/ext-omnibox.js
category webextension-scripts pageAction chrome://browser/content/ext-pageAction.js

View File

@ -19,6 +19,7 @@ browser.jar:
content/browser/ext-contextMenus.js
content/browser/ext-desktop-runtime.js
content/browser/ext-devtools.js
content/browser/ext-devtools-inspectedWindow.js
content/browser/ext-history.js
content/browser/ext-omnibox.js
content/browser/ext-pageAction.js

View File

@ -93,7 +93,6 @@
"functions": [
{
"name": "eval",
"unsupported": true,
"type": "function",
"description": "Evaluates a JavaScript expression in the context of the main frame of the inspected page. The expression must evaluate to a JSON-compliant object, otherwise an exception is thrown. The eval function can report either a DevTools-side error or a JavaScript exception that occurs during evaluation. In either case, the <code>result</code> parameter of the callback is <code>undefined</code>. In the case of a DevTools-side error, the <code>isException</code> parameter is non-null and has <code>isError</code> set to true and <code>code</code> set to an error code. In the case of a JavaScript error, <code>isException</code> is set to true and <code>value</code> is set to the string value of thrown object.",
"async": "callback",
@ -179,7 +178,6 @@
},
{
"name": "reload",
"unsupported": true,
"type": "function",
"description": "Reloads the inspected page.",
"parameters": [

View File

@ -17,6 +17,7 @@ support-files =
file_language_ja.html
file_language_tlh.html
file_dummy.html
file_inspectedwindow_reload_target.sjs
file_serviceWorker.html
serviceWorker.js
searchSuggestionEngine.xml
@ -50,6 +51,7 @@ support-files =
[browser_ext_contextMenus_urlPatterns.js]
[browser_ext_currentWindow.js]
[browser_ext_devtools_inspectedWindow.js]
[browser_ext_devtools_inspectedWindow_reload.js]
[browser_ext_devtools_page.js]
[browser_ext_getViews.js]
[browser_ext_incognito_views.js]

View File

@ -15,6 +15,12 @@ XPCOMUtils.defineLazyModuleGetter(this, "devtools",
* in the background page using the tabs API namespace.
* - devtools API is available in the devtools page sub-frames when a valid
* extension URL has been loaded.
* - devtools.inspectedWindow.eval:
* - returns a serialized version of the evaluation result.
* - returns the expected error object when the return value serialization raises a
* "TypeError: cyclic object value" exception.
* - returns the expected exception when an exception has been raised from the evaluated
* javascript code.
*/
add_task(function* test_devtools_inspectedWindow_tabId() {
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/");
@ -108,3 +114,125 @@ add_task(function* test_devtools_inspectedWindow_tabId() {
yield BrowserTestUtils.removeTab(tab);
});
add_task(function* test_devtools_inspectedWindow_eval() {
const TEST_TARGET_URL = "http://mochi.test:8888/";
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_TARGET_URL);
function devtools_page() {
browser.test.onMessage.addListener(async (msg, ...args) => {
if (msg !== "inspectedWindow-eval-request") {
browser.test.fail(`Unexpected test message received: ${msg}`);
return;
}
try {
const [evalResult, errorResult] = await browser.devtools.inspectedWindow.eval(...args);
browser.test.sendMessage("inspectedWindow-eval-result", {
evalResult,
errorResult,
});
} catch (err) {
browser.test.sendMessage("inspectedWindow-eval-result");
browser.test.fail(`Error: ${err} :: ${err.stack}`);
}
});
}
let extension = ExtensionTestUtils.loadExtension({
manifest: {
devtools_page: "devtools_page.html",
},
files: {
"devtools_page.html": `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script text="text/javascript" src="devtools_page.js"></script>
</head>
<body>
</body>
</html>`,
"devtools_page.js": devtools_page,
},
});
yield extension.startup();
let target = devtools.TargetFactory.forTab(tab);
yield gDevTools.showToolbox(target, "webconsole");
info("developer toolbox opened");
const evalTestCases = [
// Successful evaluation results.
{
args: ["window.location.href"],
expectedResults: {evalResult: TEST_TARGET_URL, errorResult: undefined},
},
// Error evaluation results.
{
args: ["window"],
expectedResults: {
evalResult: undefined,
errorResult: {
isError: true,
code: "E_PROTOCOLERROR",
description: "Inspector protocol error: %s",
details: [
"TypeError: cyclic object value",
],
},
},
},
// Exception evaluation results.
{
args: ["throw new Error('fake eval exception');"],
expectedResults: {
evalResult: undefined,
errorResult: {
isException: true,
value: /Error: fake eval exception\n.*moz-extension:\/\//,
},
},
},
];
for (let testCase of evalTestCases) {
info(`test inspectedWindow.eval with ${JSON.stringify(testCase)}`);
const {args, expectedResults} = testCase;
extension.sendMessage(`inspectedWindow-eval-request`, ...args);
const {evalResult, errorResult} = yield extension.awaitMessage(`inspectedWindow-eval-result`);
Assert.deepEqual(evalResult, expectedResults.evalResult, "Got the expected eval result");
if (errorResult) {
for (const errorPropName of Object.keys(expectedResults.errorResult)) {
const expected = expectedResults.errorResult[errorPropName];
const actual = errorResult[errorPropName];
if (expected instanceof RegExp) {
ok(expected.test(actual),
`Got exceptionInfo.${errorPropName} value ${actual} matches ${expected}`);
} else {
Assert.deepEqual(actual, expected,
`Got the expected exceptionInfo.${errorPropName} value`);
}
}
}
}
yield gDevTools.closeToolbox(target);
yield target.destroy();
yield extension.unload();
yield BrowserTestUtils.removeTab(tab);
});

View File

@ -0,0 +1,336 @@
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
// Like most of the mochitest-browser devtools test,
// on debug test slave, it takes about 50s to run the test.
requestLongerTimeout(4);
XPCOMUtils.defineLazyModuleGetter(this, "gDevTools",
"resource://devtools/client/framework/gDevTools.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "devtools",
"resource://devtools/shared/Loader.jsm");
// Small helper which provides the common steps to the following reload test cases.
function* runReloadTestCase({urlParams, background, devtoolsPage, testCase}) {
const BASE = "http://mochi.test:8888/browser/browser/components/extensions/test/browser/";
const TEST_TARGET_URL = `${BASE}file_inspectedwindow_reload_target.sjs?${urlParams}`;
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_TARGET_URL);
let extension = ExtensionTestUtils.loadExtension({
background,
manifest: {
devtools_page: "devtools_page.html",
permissions: ["webNavigation", "<all_urls>"],
},
files: {
"devtools_page.html": `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="devtools_page.js"></script>
</head>
<body>
</body>
</html>`,
"devtools_page.js": devtoolsPage,
},
});
yield extension.startup();
let target = devtools.TargetFactory.forTab(tab);
yield gDevTools.showToolbox(target, "webconsole");
info("developer toolbox opened");
// Wait the test extension to be ready.
yield extension.awaitMessage("devtools_inspected_window_reload.ready");
info("devtools page ready");
// Run the test case.
yield testCase(extension);
yield gDevTools.closeToolbox(target);
yield target.destroy();
yield BrowserTestUtils.removeTab(tab);
yield extension.unload();
}
add_task(function* test_devtools_inspectedWindow_reload_ignore_cache() {
function background() {
// Wait until the devtools page is ready to run the test.
browser.runtime.onMessage.addListener(async (msg) => {
if (msg !== "devtools_page.ready") {
browser.test.fail(`Unexpected message received: ${msg}`);
return;
}
const tabs = await browser.tabs.query({active: true});
const activeTabId = tabs[0].id;
let reloads = 0;
browser.webNavigation.onCompleted.addListener(async (details) => {
if (details.tabId == activeTabId && details.frameId == 0) {
reloads++;
// This test expects two `devtools.inspectedWindow.reload` calls:
// the first one without any options and the second one with
// `ignoreCache=true`.
let expectedContent;
let enabled;
switch (reloads) {
case 1:
enabled = false;
expectedContent = "empty cache headers";
break;
case 2:
enabled = true;
expectedContent = "no-cache:no-cache";
break;
}
if (!expectedContent) {
browser.test.fail(`Unexpected number of tab reloads: ${reloads}`);
} else {
try {
const code = `document.body.textContent`;
const [text] = await browser.tabs.executeScript(activeTabId, {code});
browser.test.assertEq(text, expectedContent,
`Got the expected cache headers with ignoreCache=${enabled}`);
} catch (err) {
browser.test.fail(`Error: ${err.message} - ${err.stack}`);
}
}
browser.test.sendMessage("devtools_inspectedWindow_reload_checkIgnoreCache.done");
}
});
browser.test.sendMessage("devtools_inspected_window_reload.ready");
});
}
async function devtoolsPage() {
browser.test.onMessage.addListener(msg => {
switch (msg) {
case "no-ignore-cache":
browser.devtools.inspectedWindow.reload();
break;
case "ignore-cache":
browser.devtools.inspectedWindow.reload({ignoreCache: true});
break;
default:
browser.test.fail(`Unexpected test message received: ${msg}`);
}
});
browser.runtime.sendMessage("devtools_page.ready");
}
yield runReloadTestCase({
urlParams: "test=cache",
background, devtoolsPage,
testCase: function* (extension) {
for (const testMessage of ["no-ignore-cache", "ignore-cache"]) {
extension.sendMessage(testMessage);
yield extension.awaitMessage("devtools_inspectedWindow_reload_checkIgnoreCache.done");
}
},
});
});
add_task(function* test_devtools_inspectedWindow_reload_custom_user_agent() {
function background() {
browser.runtime.onMessage.addListener(async (msg) => {
if (msg !== "devtools_page.ready") {
browser.test.fail(`Unexpected message received: ${msg}`);
return;
}
const tabs = await browser.tabs.query({active: true});
const activeTabId = tabs[0].id;
let reloads = 0;
browser.webNavigation.onCompleted.addListener(async (details) => {
if (details.tabId == activeTabId && details.frameId == 0) {
reloads++;
let expectedContent;
let enabled;
switch (reloads) {
case 1:
enabled = false;
expectedContent = window.navigator.userAgent;
break;
case 2:
enabled = true;
expectedContent = "CustomizedUserAgent";
break;
}
if (!expectedContent) {
browser.test.fail(`Unexpected number of tab reloads: ${reloads}`);
} else {
const code = `document.body.textContent`;
try {
const [text] = await browser.tabs.executeScript(activeTabId, {code});
browser.test.assertEq(expectedContent, text,
`Got the expected userAgent with userAgent=${enabled}`);
} catch (err) {
browser.test.fail(`Error: ${err.message} - ${err.stack}`);
}
}
browser.test.sendMessage("devtools_inspectedWindow_reload_checkUserAgent.done");
}
});
browser.test.sendMessage("devtools_inspected_window_reload.ready");
});
}
function devtoolsPage() {
browser.test.onMessage.addListener(msg => {
switch (msg) {
case "no-custom-user-agent":
browser.devtools.inspectedWindow.reload({});
break;
case "custom-user-agent":
browser.devtools.inspectedWindow.reload({userAgent: "CustomizedUserAgent"});
break;
default:
browser.test.fail(`Unexpected test message received: ${msg}`);
}
});
browser.runtime.sendMessage("devtools_page.ready");
}
yield runReloadTestCase({
urlParams: "test=user-agent",
background, devtoolsPage,
testCase: function* (extension) {
extension.sendMessage("no-custom-user-agent");
yield extension.awaitMessage("devtools_inspectedWindow_reload_checkUserAgent.done");
extension.sendMessage("custom-user-agent");
yield extension.awaitMessage("devtools_inspectedWindow_reload_checkUserAgent.done");
},
});
});
add_task(function* test_devtools_inspectedWindow_reload_injected_script() {
function background() {
function getIframesTextContent() {
let docs = [];
for (let iframe, doc = document; doc; doc = iframe && iframe.contentDocument) {
docs.push(doc);
iframe = doc.querySelector("iframe");
}
return docs.map(doc => doc.querySelector("pre").textContent);
}
browser.runtime.onMessage.addListener(async (msg) => {
if (msg !== "devtools_page.ready") {
browser.test.fail(`Unexpected message received: ${msg}`);
return;
}
const tabs = await browser.tabs.query({active: true});
const activeTabId = tabs[0].id;
let reloads = 0;
browser.webNavigation.onCompleted.addListener(async (details) => {
if (details.tabId == activeTabId && details.frameId == 0) {
reloads++;
let expectedContent;
let enabled;
switch (reloads) {
case 1:
enabled = false;
expectedContent = "injected script NOT executed";
break;
case 2:
enabled = true;
expectedContent = "injected script executed first";
break;
default:
browser.test.fail(`Unexpected number of tab reloads: ${reloads}`);
}
if (!expectedContent) {
browser.test.fail(`Unexpected number of tab reloads: ${reloads}`);
} else {
let expectedResults = (new Array(4)).fill(expectedContent);
let code = `(${getIframesTextContent})()`;
try {
let [results] = await browser.tabs.executeScript(activeTabId, {code});
browser.test.assertEq(JSON.stringify(expectedResults), JSON.stringify(results),
`Got the expected result with injectScript=${enabled}`);
} catch (err) {
browser.test.fail(`Error: ${err.message} - ${err.stack}`);
}
}
browser.test.sendMessage(`devtools_inspectedWindow_reload_injectedScript.done`);
}
});
browser.test.sendMessage("devtools_inspected_window_reload.ready");
});
}
function devtoolsPage() {
function injectedScript() {
if (!window.pageScriptExecutedFirst) {
window.addEventListener("DOMContentLoaded", function listener() {
document.querySelector("pre").textContent = "injected script executed first";
}, {once: true});
}
}
browser.test.onMessage.addListener(msg => {
switch (msg) {
case "no-injected-script":
browser.devtools.inspectedWindow.reload({});
break;
case "injected-script":
browser.devtools.inspectedWindow.reload({injectedScript: `new ${injectedScript}`});
break;
default:
browser.test.fail(`Unexpected test message received: ${msg}`);
}
});
browser.runtime.sendMessage("devtools_page.ready");
}
yield runReloadTestCase({
urlParams: "test=injected-script&frames=3",
background, devtoolsPage,
testCase: function* (extension) {
extension.sendMessage("no-injected-script");
yield extension.awaitMessage("devtools_inspectedWindow_reload_injectedScript.done");
extension.sendMessage("injected-script");
yield extension.awaitMessage("devtools_inspectedWindow_reload_injectedScript.done");
},
});
});

View File

@ -0,0 +1,74 @@
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80 ft=javascript: */
"use strict";
Components.utils.importGlobalProperties(["URLSearchParams"]);
function handleRequest(request, response) {
let params = new URLSearchParams(request.queryString);
switch(params.get("test")) {
case "cache":
handleCacheTestRequest(request, response);
break;
case "user-agent":
handleUserAgentTestRequest(request, response);
break;
case "injected-script":
handleInjectedScriptTestRequest(request, response, params);
break;
}
}
function handleCacheTestRequest(request, response) {
response.setHeader("Content-Type", "text/plain; charset=UTF-8", false);
if (request.hasHeader("pragma") && request.hasHeader("cache-control")) {
response.write(`${request.getHeader("pragma")}:${request.getHeader("cache-control")}`);
} else {
response.write("empty cache headers");
}
}
function handleUserAgentTestRequest(request, response) {
response.setHeader("Content-Type", "text/plain; charset=UTF-8", false);
if (request.hasHeader("user-agent")) {
response.write(request.getHeader("user-agent"));
} else {
response.write("no user agent header");
}
}
function handleInjectedScriptTestRequest(request, response, params) {
response.setHeader("Content-Type", "text/html; charset=UTF-8", false);
let content = "";
const frames = parseInt(params.get("frames"));
if (frames > 0) {
// Output an iframe in seamless mode, so that there is an higher chance that in case
// of test failures we get a screenshot where the nested iframes are all visible.
content = `<iframe seamless src="?test=injected-script&frames=${frames - 1}"></iframe>`;
}
response.write(`<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
iframe { width: 100%; height: ${frames * 150}px; }
</style>
</head>
<body>
<h1>IFRAME ${frames}</h1>
<pre>injected script NOT executed</pre>
<script type="text/javascript">
window.pageScriptExecutedFirst = true;
</script>
${content}
</body>
</html>
`);
}

View File

@ -286,7 +286,7 @@ PlacesViewBase.prototype = {
if (document.popupNode == aChild)
document.popupNode = null;
aChild.parentNode.removeChild(aChild);
aChild.remove();
},
_setEmptyPopupStatus:

View File

@ -8,6 +8,8 @@ Cu.import("resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "OfflineAppCacheHelper",
"resource:///modules/offlineAppCache.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ContextualIdentityService",
"resource://gre/modules/ContextualIdentityService.jsm");
this.EXPORTED_SYMBOLS = [
"SiteDataManager"
@ -29,6 +31,7 @@ this.SiteDataManager = {
// - quotaUsage: the usage of indexedDB and localStorage.
// - appCacheList: an array of app cache; instances of nsIApplicationCache
// - diskCacheList: an array. Each element is object holding metadata of http cache:
// - uri: the uri of that http cache
// - dataSize: that http cache size
// - idEnhance: the id extension of that http cache
_sites: new Map(),
@ -53,7 +56,7 @@ this.SiteDataManager = {
status = Services.perms.testExactPermissionFromPrincipal(perm.principal, "persistent-storage");
if (status === Ci.nsIPermissionManager.ALLOW_ACTION ||
status === Ci.nsIPermissionManager.DENY_ACTION) {
this._sites.set(perm.principal.origin, {
this._sites.set(perm.principal.URI.spec, {
perm,
status,
quotaUsage: 0,
@ -125,6 +128,7 @@ this.SiteDataManager = {
for (let site of sites.values()) {
if (site.perm.matchesURI(uri, true)) {
site.diskCacheList.push({
uri,
dataSize,
idEnhance
});
@ -161,25 +165,6 @@ this.SiteDataManager = {
});
},
_removePermission(site) {
Services.perms.removePermission(site.perm);
},
_removeQuotaUsage(site) {
this._qms.clearStoragesForPrincipal(site.perm.principal, null, true);
},
removeAll() {
for (let site of this._sites.values()) {
this._removePermission(site);
this._removeQuotaUsage(site);
}
Services.cache2.clear();
Services.cookies.removeAll();
OfflineAppCacheHelper.clear();
this.updateSites();
},
getSites() {
return Promise.all([this._updateQuotaPromise, this._updateDiskCachePromise])
.then(() => {
@ -201,5 +186,70 @@ this.SiteDataManager = {
}
return list;
});
},
_removePermission(site) {
Services.perms.removePermission(site.perm);
},
_removeQuotaUsage(site) {
this._qms.clearStoragesForPrincipal(site.perm.principal, null, true);
},
_removeDiskCache(site) {
for (let cache of site.diskCacheList) {
this._diskCache.asyncDoomURI(cache.uri, cache.idEnhance, null);
}
},
_removeAppCache(site) {
for (let cache of site.appCacheList) {
cache.discard();
}
},
_removeCookie(site) {
let host = site.perm.principal.URI.host;
let e = Services.cookies.getCookiesFromHost(host, {});
while (e.hasMoreElements()) {
let cookie = e.getNext();
if (cookie instanceof Components.interfaces.nsICookie) {
if (this.isPrivateCookie(cookie)) {
continue;
}
Services.cookies.remove(
cookie.host, cookie.name, cookie.path, false, cookie.originAttributes);
}
}
},
remove(uris) {
for (let uri of uris) {
let site = this._sites.get(uri.spec);
if (site) {
this._removePermission(site);
this._removeQuotaUsage(site);
this._removeDiskCache(site);
this._removeAppCache(site);
this._removeCookie(site);
}
}
this.updateSites();
},
removeAll() {
for (let site of this._sites.values()) {
this._removePermission(site);
this._removeQuotaUsage(site);
}
Services.cache2.clear();
Services.cookies.removeAll();
OfflineAppCacheHelper.clear();
this.updateSites();
},
isPrivateCookie(cookie) {
let { userContextId } = cookie.originAttributes;
return userContextId && !ContextualIdentityService.getIdentityFromId(userContextId).public;
}
};

View File

@ -10,6 +10,8 @@ Components.utils.import("resource://gre/modules/PluralForm.jsm");
Components.utils.import("resource://gre/modules/Services.jsm")
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SiteDataManager",
"resource:///modules/SiteDataManager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ContextualIdentityService",
"resource://gre/modules/ContextualIdentityService.jsm");
@ -76,21 +78,12 @@ var gCookiesWindow = {
aCookieB.originAttributes);
},
_isPrivateCookie(aCookie) {
let { userContextId } = aCookie.originAttributes;
if (!userContextId) {
// Default identity is public.
return false;
}
return !ContextualIdentityService.getIdentityFromId(userContextId).public;
},
observe(aCookie, aTopic, aData) {
if (aTopic != "cookie-changed")
return;
if (aCookie instanceof Components.interfaces.nsICookie) {
if (this._isPrivateCookie(aCookie)) {
if (SiteDataManager.isPrivateCookie(aCookie)) {
return;
}
@ -484,7 +477,7 @@ var gCookiesWindow = {
while (e.hasMoreElements()) {
var cookie = e.getNext();
if (cookie && cookie instanceof Components.interfaces.nsICookie) {
if (this._isPrivateCookie(cookie)) {
if (SiteDataManager.isPrivateCookie(cookie)) {
continue;
}

View File

@ -397,9 +397,9 @@ EngineStore.prototype = {
if (index == -1)
throw new Error("invalid engine?");
this._engines.splice(index, 1);
let removedEngine = this._engines.splice(index, 1)[0];
if (this._defaultEngines.some(this._isSameEngine, this._engines[index]))
if (this._defaultEngines.some(this._isSameEngine, removedEngine))
gSearchPane.showRestoreDefaults(true);
gSearchPane.buildDefaultEngineDropDown();
return index;

0
browser/components/preferences/in-content/sync.xul Normal file → Executable file
View File

View File

@ -115,6 +115,12 @@ function addPersistentStoragePerm(origin) {
Services.perms.addFromPrincipal(principal, "persistent-storage", Ci.nsIPermissionManager.ALLOW_ACTION);
}
function removePersistentStoragePerm(origin) {
let uri = NetUtil.newURI(origin);
let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
Services.perms.removeFromPrincipal(principal, "persistent-storage");
}
function getPersistentStoragePermStatus(origin) {
let uri = NetUtil.newURI(origin);
let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
@ -144,6 +150,33 @@ function getCacheUsage() {
});
}
function openSettingsDialog() {
let doc = gBrowser.selectedBrowser.contentDocument;
let settingsBtn = doc.getElementById("siteDataSettings");
let dialogOverlay = doc.getElementById("dialogOverlay");
let dialogLoadPromise = promiseLoadSubDialog("chrome://browser/content/preferences/siteDataSettings.xul");
let dialogInitPromise = TestUtils.topicObserved("sitedata-settings-init", () => true);
let fullyLoadPromise = Promise.all([ dialogLoadPromise, dialogInitPromise ]).then(() => {
is(dialogOverlay.style.visibility, "visible", "The Settings dialog should be visible");
});
settingsBtn.doCommand();
return fullyLoadPromise;
}
function promiseSettingsDialogClose() {
return new Promise(resolve => {
let doc = gBrowser.selectedBrowser.contentDocument;
let dialogOverlay = doc.getElementById("dialogOverlay");
let win = content.gSubDialog._frame.contentWindow;
win.addEventListener("unload", function unload() {
if (win.document.documentURI === "chrome://browser/content/preferences/siteDataSettings.xul") {
isnot(dialogOverlay.style.visibility, "visible", "The Settings dialog should be hidden");
resolve();
}
}, { once: true });
});
}
function promiseSitesUpdated() {
return TestUtils.topicObserved("sitedatamanager:sites-updated", () => true);
}
@ -237,16 +270,9 @@ add_task(function* () {
let updatePromise = promiseSitesUpdated();
yield openPreferencesViaOpenPreferencesAPI("advanced", "networkTab", { leaveOpen: true });
yield updatePromise;
yield openSettingsDialog();
// Open the siteDataSettings subdialog
let doc = gBrowser.selectedBrowser.contentDocument;
let settingsBtn = doc.getElementById("siteDataSettings");
let dialogOverlay = doc.getElementById("dialogOverlay");
let dialogPromise = promiseLoadSubDialog("chrome://browser/content/preferences/siteDataSettings.xul");
settingsBtn.doCommand();
yield dialogPromise;
is(dialogOverlay.style.visibility, "visible", "The dialog should be visible");
let dialogFrame = doc.getElementById("dialogFrame");
let frameDoc = dialogFrame.contentDocument;
let hostCol = frameDoc.getElementById("hostCol");
@ -335,16 +361,9 @@ add_task(function* () {
let updatePromise = promiseSitesUpdated();
yield openPreferencesViaOpenPreferencesAPI("advanced", "networkTab", { leaveOpen: true });
yield updatePromise;
yield openSettingsDialog();
// Open the siteDataSettings subdialog
let doc = gBrowser.selectedBrowser.contentDocument;
let settingsBtn = doc.getElementById("siteDataSettings");
let dialogOverlay = doc.getElementById("dialogOverlay");
let dialogPromise = promiseLoadSubDialog("chrome://browser/content/preferences/siteDataSettings.xul");
settingsBtn.doCommand();
yield dialogPromise;
is(dialogOverlay.style.visibility, "visible", "The dialog should be visible");
let frameDoc = doc.getElementById("dialogFrame").contentDocument;
let searchBox = frameDoc.getElementById("searchBox");
let mockOrigins = Array.from(mockSiteDataManager.sites.keys());
@ -374,3 +393,202 @@ add_task(function* () {
});
}
});
// Test selecting and removing all sites one by one
add_task(function* () {
yield SpecialPowers.pushPrefEnv({set: [["browser.storageManager.enabled", true]]});
let fakeOrigins = [
"https://news.foo.com/",
"https://mails.bar.com/",
"https://videos.xyz.com/",
"https://books.foo.com/",
"https://account.bar.com/",
"https://shopping.xyz.com/"
];
fakeOrigins.forEach(origin => addPersistentStoragePerm(origin));
let updatePromise = promiseSitesUpdated();
yield openPreferencesViaOpenPreferencesAPI("advanced", "networkTab", { leaveOpen: true });
yield updatePromise;
yield openSettingsDialog();
let doc = gBrowser.selectedBrowser.contentDocument;
let frameDoc = null;
let saveBtn = null;
let cancelBtn = null;
let settingsDialogClosePromise = null;
// Test the initial state
assertAllSitesListed();
// Test the "Cancel" button
settingsDialogClosePromise = promiseSettingsDialogClose();
frameDoc = doc.getElementById("dialogFrame").contentDocument;
cancelBtn = frameDoc.getElementById("cancel");
removeAllSitesOneByOne();
assertAllSitesNotListed();
cancelBtn.doCommand();
yield settingsDialogClosePromise;
yield openSettingsDialog();
assertAllSitesListed();
// Test the "Save Changes" button but cancelling save
let cancelPromise = promiseAlertDialogOpen("cancel");
settingsDialogClosePromise = promiseSettingsDialogClose();
frameDoc = doc.getElementById("dialogFrame").contentDocument;
saveBtn = frameDoc.getElementById("save");
removeAllSitesOneByOne();
assertAllSitesNotListed();
saveBtn.doCommand();
yield cancelPromise;
yield settingsDialogClosePromise;
yield openSettingsDialog();
assertAllSitesListed();
// Test the "Save Changes" button and accepting save
let acceptPromise = promiseAlertDialogOpen("accept");
settingsDialogClosePromise = promiseSettingsDialogClose();
updatePromise = promiseSitesUpdated();
frameDoc = doc.getElementById("dialogFrame").contentDocument;
saveBtn = frameDoc.getElementById("save");
removeAllSitesOneByOne();
assertAllSitesNotListed();
saveBtn.doCommand();
yield acceptPromise;
yield settingsDialogClosePromise;
yield updatePromise;
yield openSettingsDialog();
assertAllSitesNotListed();
// Always clean up the fake origins
fakeOrigins.forEach(origin => removePersistentStoragePerm(origin));
yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
function removeAllSitesOneByOne() {
frameDoc = doc.getElementById("dialogFrame").contentDocument;
let removeBtn = frameDoc.getElementById("removeSelected");
let sitesList = frameDoc.getElementById("sitesList");
let sites = sitesList.getElementsByTagName("richlistitem");
for (let i = sites.length - 1; i >= 0; --i) {
sites[i].click();
removeBtn.doCommand();
}
}
function assertAllSitesListed() {
frameDoc = doc.getElementById("dialogFrame").contentDocument;
let removeBtn = frameDoc.getElementById("removeSelected");
let sitesList = frameDoc.getElementById("sitesList");
let sites = sitesList.getElementsByTagName("richlistitem");
is(sites.length, fakeOrigins.length, "Should list all sites");
is(removeBtn.disabled, false, "Should enable the removeSelected button");
}
function assertAllSitesNotListed() {
frameDoc = doc.getElementById("dialogFrame").contentDocument;
let removeBtn = frameDoc.getElementById("removeSelected");
let sitesList = frameDoc.getElementById("sitesList");
let sites = sitesList.getElementsByTagName("richlistitem");
is(sites.length, 0, "Should not list all sites");
is(removeBtn.disabled, true, "Should disable the removeSelected button");
}
});
// Test selecting and removing partial sites
add_task(function* () {
yield SpecialPowers.pushPrefEnv({set: [["browser.storageManager.enabled", true]]});
let fakeOrigins = [
"https://news.foo.com/",
"https://mails.bar.com/",
"https://videos.xyz.com/",
"https://books.foo.com/",
"https://account.bar.com/",
"https://shopping.xyz.com/"
];
fakeOrigins.forEach(origin => addPersistentStoragePerm(origin));
let updatePromise = promiseSitesUpdated();
yield openPreferencesViaOpenPreferencesAPI("advanced", "networkTab", { leaveOpen: true });
yield updatePromise;
yield openSettingsDialog();
const removeDialogURL = "chrome://browser/content/preferences/siteDataRemoveSelected.xul";
let doc = gBrowser.selectedBrowser.contentDocument;
let frameDoc = null;
let saveBtn = null;
let cancelBtn = null;
let removeDialogOpenPromise = null;
let settingsDialogClosePromise = null;
// Test the initial state
assertSitesListed(fakeOrigins);
// Test the "Cancel" button
settingsDialogClosePromise = promiseSettingsDialogClose();
frameDoc = doc.getElementById("dialogFrame").contentDocument;
cancelBtn = frameDoc.getElementById("cancel");
removeSelectedSite(fakeOrigins.slice(0, 4));
assertSitesListed(fakeOrigins.slice(4));
cancelBtn.doCommand();
yield settingsDialogClosePromise;
yield openSettingsDialog();
assertSitesListed(fakeOrigins);
// Test the "Save Changes" button but canceling save
removeDialogOpenPromise = promiseWindowDialogOpen("cancel", removeDialogURL);
settingsDialogClosePromise = promiseSettingsDialogClose();
frameDoc = doc.getElementById("dialogFrame").contentDocument;
saveBtn = frameDoc.getElementById("save");
removeSelectedSite(fakeOrigins.slice(0, 4));
assertSitesListed(fakeOrigins.slice(4));
saveBtn.doCommand();
yield removeDialogOpenPromise;
yield settingsDialogClosePromise;
yield openSettingsDialog();
assertSitesListed(fakeOrigins);
// Test the "Save Changes" button and accepting save
removeDialogOpenPromise = promiseWindowDialogOpen("accept", removeDialogURL);
settingsDialogClosePromise = promiseSettingsDialogClose();
frameDoc = doc.getElementById("dialogFrame").contentDocument;
saveBtn = frameDoc.getElementById("save");
removeSelectedSite(fakeOrigins.slice(0, 4));
assertSitesListed(fakeOrigins.slice(4));
saveBtn.doCommand();
yield removeDialogOpenPromise;
yield settingsDialogClosePromise;
yield openSettingsDialog();
assertSitesListed(fakeOrigins.slice(4));
// Always clean up the fake origins
fakeOrigins.forEach(origin => removePersistentStoragePerm(origin));
yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
function removeSelectedSite(origins) {
frameDoc = doc.getElementById("dialogFrame").contentDocument;
let removeBtn = frameDoc.getElementById("removeSelected");
let sitesList = frameDoc.getElementById("sitesList");
origins.forEach(origin => {
let site = sitesList.querySelector(`richlistitem[data-origin="${origin}"]`);
if (site) {
site.click();
removeBtn.doCommand();
} else {
ok(false, `Should not select and remove inexisted site of ${origin}`);
}
});
}
function assertSitesListed(origins) {
frameDoc = doc.getElementById("dialogFrame").contentDocument;
let removeBtn = frameDoc.getElementById("removeSelected");
let sitesList = frameDoc.getElementById("sitesList");
let totalSitesNumber = sitesList.getElementsByTagName("richlistitem").length;
is(totalSitesNumber, origins.length, "Should list the right sites number");
origins.forEach(origin => {
let site = sitesList.querySelector(`richlistitem[data-origin="${origin}"]`);
ok(!!site, `Should list the site of ${origin}`);
});
is(removeBtn.disabled, false, "Should enable the removeSelected button");
}
});

View File

@ -161,12 +161,12 @@ function waitForCondition(aConditionFn, aMaxTries = 50, aCheckInterval = 100) {
});
}
function promiseAlertDialogOpen(buttonAction) {
function promiseWindowDialogOpen(buttonAction, url) {
return new Promise(resolve => {
Services.ww.registerNotification(function onOpen(subj, topic, data) {
if (topic == "domwindowopened" && subj instanceof Ci.nsIDOMWindow) {
subj.addEventListener("load", function() {
if (subj.document.documentURI == "chrome://global/content/commonDialog.xul") {
subj.addEventListener("load", function onLoad() {
if (subj.document.documentURI == url) {
Services.ww.unregisterNotification(onOpen);
let doc = subj.document.documentElement;
doc.getButton(buttonAction).click();
@ -177,3 +177,7 @@ function promiseAlertDialogOpen(buttonAction) {
});
});
}
function promiseAlertDialogOpen(buttonAction) {
return promiseWindowDialogOpen(buttonAction, "chrome://global/content/commonDialog.xul");
}

View File

@ -30,6 +30,8 @@ browser.jar:
content/browser/preferences/siteDataSettings.xul
content/browser/preferences/siteDataSettings.js
content/browser/preferences/siteDataSettings.css
* content/browser/preferences/siteDataRemoveSelected.xul
content/browser/preferences/siteDataRemoveSelected.js
content/browser/preferences/siteListItem.xml
content/browser/preferences/translation.xul
content/browser/preferences/translation.js

View File

@ -19,7 +19,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk2', 'gtk3', 'cocoa'):
JAR_MANIFESTS += ['jar.mn']
EXTRA_JS_MODULES += [
'SiteDataManager.jsm',
'SiteDataManager.jsm'
]
with Files('**'):

View File

@ -0,0 +1,197 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
/* 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/. */
const { utils: Cu } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
"use strict";
let gSiteDataRemoveSelected = {
_tree: null,
init() {
// Organize items for the tree from the argument
let hostsTable = window.arguments[0].hostsTable;
let visibleItems = [];
let itemsTable = new Map();
for (let [ baseDomain, hosts ] of hostsTable) {
// In the beginning, only display base domains in the topmost level.
visibleItems.push({
level: 0,
opened: false,
host: baseDomain
});
// Other hosts are in the second level.
let items = hosts.map(host => {
return { host, level: 1 };
});
items.sort(sortByHost);
itemsTable.set(baseDomain, items);
}
visibleItems.sort(sortByHost);
this._view.itemsTable = itemsTable;
this._view.visibleItems = visibleItems;
this._tree = document.getElementById("sitesTree");
this._tree.view = this._view;
function sortByHost(a, b) {
let aHost = a.host.toLowerCase();
let bHost = b.host.toLowerCase();
return aHost.localeCompare(bHost);
}
},
ondialogaccept() {
window.arguments[0].allowed = true;
},
ondialogcancel() {
window.arguments[0].allowed = false;
},
_view: {
_selection: null,
itemsTable: null,
visibleItems: null,
get rowCount() {
return this.visibleItems.length;
},
getCellText(index, column) {
let item = this.visibleItems[index];
return item ? item.host : "";
},
isContainer(index) {
let item = this.visibleItems[index];
if (item && item.level === 0) {
return true;
}
return false;
},
isContainerEmpty() {
return false;
},
isContainerOpen(index) {
let item = this.visibleItems[index];
if (item && item.level === 0) {
return item.opened;
}
return false;
},
getLevel(index) {
let item = this.visibleItems[index];
return item ? item.level : 0;
},
hasNextSibling(index, afterIndex) {
let item = this.visibleItems[index];
if (item) {
let thisLV = this.getLevel(index);
for (let i = afterIndex + 1; i < this.rowCount; ++i) {
let nextLV = this.getLevel(i);
if (nextLV == thisLV) {
return true;
}
if (nextLV < thisLV) {
break;
}
}
}
return false;
},
getParentIndex(index) {
if (!this.isContainer(index)) {
for (let i = index - 1; i >= 0; --i) {
if (this.isContainer(i)) {
return i;
}
}
}
return -1;
},
toggleOpenState(index) {
let item = this.visibleItems[index];
if (!this.isContainer(index)) {
return;
}
if (item.opened) {
item.opened = false;
let deleteCount = 0;
for (let i = index + 1; i < this.visibleItems.length; ++i) {
if (!this.isContainer(i)) {
++deleteCount;
} else {
break;
}
}
if (deleteCount) {
this.visibleItems.splice(index + 1, deleteCount);
this.treeBox.rowCountChanged(index + 1, -deleteCount);
}
} else {
item.opened = true;
let childItems = this.itemsTable.get(item.host);
for (let i = 0; i < childItems.length; ++i) {
this.visibleItems.splice(index + i + 1, 0, childItems[i]);
}
this.treeBox.rowCountChanged(index + 1, childItems.length);
}
this.treeBox.invalidateRow(index);
},
get selection() {
return this._selection;
},
set selection(v) {
this._selection = v;
return v;
},
setTree(treeBox) {
this.treeBox = treeBox;
},
isSeparator(index) {
return false;
},
isSorted(index) {
return false;
},
canDrop() {
return false;
},
drop() {},
getRowProperties() {},
getCellProperties() {},
getColumnProperties() {},
hasPreviousSibling(index) {},
getImageSrc() {},
getProgressMode() {},
getCellValue() {},
cycleHeader() {},
selectionChanged() {},
cycleCell() {},
isEditable() {},
isSelectable() {},
setCellValue() {},
setCellText() {},
performAction() {},
performActionOnRow() {},
performActionOnCell() {}
}
};

View File

@ -0,0 +1,58 @@
<?xml version="1.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/. -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/preferences/siteDataSettings.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/skin/preferences/in-content/siteDataSettings.css" type="text/css"?>
<!DOCTYPE dialog SYSTEM "chrome://browser/locale/preferences/siteDataSettings.dtd" >
<dialog id="SiteDataRemoveSelectedDialog"
windowtype="Browser:SiteDataRemoveSelected"
width="500"
title="&removingDialog.title;"
onload="gSiteDataRemoveSelected.init();"
ondialogaccept="gSiteDataRemoveSelected.ondialogaccept(); return true;"
ondialogcancel="gSiteDataRemoveSelected.ondialogcancel(); return true;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://browser/content/preferences/siteDataRemoveSelected.js"/>
<stringbundle id="bundlePreferences"
src="chrome://browser/locale/preferences/preferences.properties"/>
<vbox id="contentContainer">
<hbox flex="1">
<vbox>
<image class="question-icon"/>
</vbox>
<vbox flex="1">
<!-- Only show this label on OS X because of no dialog title -->
<label id="removing-label"
#ifndef XP_MACOSX
hidden="true"
#endif
>&removingDialog.title;</label>
<separator class="thin"/>
<description id="removing-description">&removingDialog.description;</description>
</vbox>
</hbox>
<separator />
<vbox flex="1">
<label>&siteTree.label;</label>
<separator class="thin"/>
<tree id="sitesTree" flex="1" seltype="single" hidecolumnpicker="true">
<treecols>
<treecol primary="true" flex="1" hideheader="true"/>
</treecols>
<treechildren />
</tree>
</vbox>
</vbox>
</dialog>

View File

@ -2,18 +2,10 @@
* 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/. */
#searchBoxContainer {
-moz-box-align: center;
}
#sitesList {
min-height: 20em;
}
#sitesList > richlistitem {
-moz-binding: url("chrome://browser/content/preferences/siteListItem.xml#siteListItem");
}
.item-box {
padding: 5px 8px;
#SiteDataRemoveSelectedDialog {
-moz-binding: url("chrome://global/content/bindings/dialog.xml#dialog");
}

View File

@ -20,6 +20,8 @@ let gSiteDataSettings = {
// - uri: uri of site; instance of nsIURI
// - status: persistent-storage permission status
// - usage: disk usage which site uses
// - userAction: "remove" or "update-permission"; the action user wants to take.
// If not specified, means no action to take
_sites: null,
_list: null,
@ -38,12 +40,23 @@ let gSiteDataSettings = {
let sortCol = document.getElementById("hostCol");
this._sortSites(this._sites, sortCol);
this._buildSitesList(this._sites);
this._updateButtonsState();
Services.obs.notifyObservers(null, "sitedata-settings-init", null);
});
setEventListener("hostCol", "click", this.onClickTreeCol);
setEventListener("usageCol", "click", this.onClickTreeCol);
setEventListener("statusCol", "click", this.onClickTreeCol);
setEventListener("searchBox", "command", this.onCommandSearch);
setEventListener("cancel", "command", this.close);
setEventListener("save", "command", this.saveChanges);
setEventListener("removeSelected", "command", this.removeSelected);
},
_updateButtonsState() {
let items = this._list.getElementsByTagName("richlistitem");
let removeBtn = document.getElementById("removeSelected");
removeBtn.disabled = !(items.length > 0);
},
/**
@ -110,6 +123,10 @@ let gSiteDataSettings = {
continue;
}
if (data.userAction === "remove") {
continue;
}
let statusStrId = data.status === Ci.nsIPermissionManager.ALLOW_ACTION ? "important" : "default";
let size = DownloadUtils.convertByteUnits(data.usage);
let item = document.createElement("richlistitem");
@ -128,5 +145,95 @@ let gSiteDataSettings = {
onCommandSearch() {
this._buildSitesList(this._sites);
},
removeSelected() {
let selected = this._list.selectedItem;
if (selected) {
let origin = selected.getAttribute("data-origin");
for (let site of this._sites) {
if (site.uri.spec === origin) {
site.userAction = "remove";
break;
}
}
this._list.removeChild(selected);
this._updateButtonsState();
}
},
saveChanges() {
let allowed = true;
// Confirm user really wants to remove site data starts
let removals = [];
this._sites = this._sites.filter(site => {
if (site.userAction === "remove") {
removals.push(site.uri);
return false;
}
return true;
});
if (removals.length > 0) {
if (this._sites.length == 0) {
// User selects all sites so equivalent to clearing all data
let flags =
Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0 +
Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1 +
Services.prompt.BUTTON_POS_0_DEFAULT;
let prefStrBundle = document.getElementById("bundlePreferences");
let title = prefStrBundle.getString("clearSiteDataPromptTitle");
let text = prefStrBundle.getString("clearSiteDataPromptText");
let btn0Label = prefStrBundle.getString("clearSiteDataNow");
let result = Services.prompt.confirmEx(window, title, text, flags, btn0Label, null, null, null, {});
allowed = result == 0;
if (allowed) {
SiteDataManager.removeAll();
}
} else {
// User only removes partial sites.
// We will remove cookies based on base domain, say, user selects "news.foo.com" to remove.
// The cookies under "music.foo.com" will be removed together.
// We have to prmopt user about this action.
let hostsTable = new Map();
// Group removed sites by base domain
for (let uri of removals) {
let baseDomain = Services.eTLD.getBaseDomain(uri);
let hosts = hostsTable.get(baseDomain);
if (!hosts) {
hosts = [];
hostsTable.set(baseDomain, hosts);
}
hosts.push(uri.host);
}
// Pick out sites with the same base domain as removed sites
for (let site of this._sites) {
let baseDomain = Services.eTLD.getBaseDomain(site.uri);
let hosts = hostsTable.get(baseDomain);
if (hosts) {
hosts.push(site.uri.host);
}
}
let args = {
hostsTable,
allowed: false
};
let features = "centerscreen,chrome,modal,resizable=no";
window.openDialog("chrome://browser/content/preferences/siteDataRemoveSelected.xul", "", features, args);
allowed = args.allowed;
if (allowed) {
SiteDataManager.remove(removals);
}
}
}
// Confirm user really wants to remove site data ends
this.close();
},
close() {
window.close();
}
};

View File

@ -7,6 +7,7 @@
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/preferences/siteDataSettings.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/skin/preferences/in-content/siteDataSettings.css" type="text/css"?>
<!DOCTYPE dialog SYSTEM "chrome://browser/locale/preferences/siteDataSettings.dtd" >
@ -41,4 +42,15 @@
</richlistbox>
</vbox>
<hbox align="start">
<button id="removeSelected" label="&removeSelected.label;" accesskey="&removeSelected.accesskey;"/>
</hbox>
<vbox align="end">
<hbox>
<button id="cancel" label="&cancel.label;" accesskey="&cancel.accesskey;"/>
<button id="save" label="&save.label;" accesskey="&save.accesskey;"/>
</hbox>
</vbox>
</window>

View File

@ -52,7 +52,7 @@ function checkState(tab) {
let doc = contentWindow.document;
let newElem = doc.getElementById("new-elem");
ok(newElem, "doc should contain new-elem.");
newElem.parentNode.removeChild(newElem);
newElem.remove();
ok(!doc.getElementById("new-elem"), "new-elem should be removed.");
tab.linkedBrowser.removeEventListener("popstate", arguments.callee, true);

View File

@ -1,4 +1,3 @@
MOZ_AUTOMATION_SDK=${MOZ_AUTOMATION_SDK-1}
if [ -n "$ENABLE_RELEASE_PROMOTION" ]; then
MOZ_AUTOMATION_UPLOAD_SYMBOLS=${MOZ_AUTOMATION_UPLOAD_SYMBOLS-1}
MOZ_AUTOMATION_UPDATE_PACKAGING=1

View File

@ -1,6 +1,5 @@
# This make file should be identical to the beta mozconfig, apart from the
# safeguard below
MOZ_AUTOMATION_SDK=${MOZ_AUTOMATION_SDK-1}
if [ -n "$ENABLE_RELEASE_PROMOTION" ]; then
MOZ_AUTOMATION_UPLOAD_SYMBOLS=${MOZ_AUTOMATION_UPLOAD_SYMBOLS-1}

View File

@ -1,4 +1,3 @@
MOZ_AUTOMATION_SDK=${MOZ_AUTOMATION_SDK-1}
if [ -n "$ENABLE_RELEASE_PROMOTION" ]; then
MOZ_AUTOMATION_UPLOAD_SYMBOLS=${MOZ_AUTOMATION_UPLOAD_SYMBOLS-1}
MOZ_AUTOMATION_UPDATE_PACKAGING=1

View File

@ -1,6 +1,5 @@
# This make file should be identical to the beta mozconfig, apart from the
# safeguard below
MOZ_AUTOMATION_SDK=${MOZ_AUTOMATION_SDK-1}
if [ -n "$ENABLE_RELEASE_PROMOTION" ]; then
MOZ_AUTOMATION_UPLOAD_SYMBOLS=${MOZ_AUTOMATION_UPLOAD_SYMBOLS-1}

View File

@ -1,5 +1,3 @@
MOZ_AUTOMATION_SDK=${MOZ_AUTOMATION_SDK-1}
if [ -n "$ENABLE_RELEASE_PROMOTION" ]; then
MOZ_AUTOMATION_UPLOAD_SYMBOLS=${MOZ_AUTOMATION_UPLOAD_SYMBOLS-1}
MOZ_AUTOMATION_UPDATE_PACKAGING=1

View File

@ -1,6 +1,5 @@
# This make file should be identical to the beta mozconfig, apart from the
# safeguard below
MOZ_AUTOMATION_SDK=${MOZ_AUTOMATION_SDK-1}
if [ -n "$ENABLE_RELEASE_PROMOTION" ]; then
MOZ_AUTOMATION_UPLOAD_SYMBOLS=${MOZ_AUTOMATION_UPLOAD_SYMBOLS-1}

View File

@ -1,5 +1,3 @@
MOZ_AUTOMATION_SDK=${MOZ_AUTOMATION_SDK-1}
if [ -n "$ENABLE_RELEASE_PROMOTION" ]; then
MOZ_AUTOMATION_UPLOAD_SYMBOLS=1
MOZ_AUTOMATION_UPDATE_PACKAGING=1

View File

@ -1,6 +1,5 @@
# This make file should be identical to the beta mozconfig, apart from the
# safeguard below
MOZ_AUTOMATION_SDK=${MOZ_AUTOMATION_SDK-1}
if [ -n "$ENABLE_RELEASE_PROMOTION" ]; then
MOZ_AUTOMATION_UPLOAD_SYMBOLS=1

View File

@ -78,7 +78,6 @@ for platform in all_platforms:
'MOZ_AUTOMATION_UPLOAD_SYMBOLS=1',
'MOZ_AUTOMATION_UPDATE_PACKAGING=1',
'fi',
'MOZ_AUTOMATION_SDK=${MOZ_AUTOMATION_SDK-1}',
]
whitelist['release']['win32'] += ['mk_add_options MOZ_PGO=1']
whitelist['release']['win64'] += ['mk_add_options MOZ_PGO=1']

View File

@ -1,5 +1,3 @@
MOZ_AUTOMATION_SDK=${MOZ_AUTOMATION_SDK-1}
if [ -n "$ENABLE_RELEASE_PROMOTION" ]; then
MOZ_AUTOMATION_UPLOAD_SYMBOLS=1
MOZ_AUTOMATION_UPDATE_PACKAGING=1

View File

@ -1,6 +1,5 @@
# This make file should be identical to the beta mozconfig, apart from the
# safeguard below
MOZ_AUTOMATION_SDK=${MOZ_AUTOMATION_SDK-1}
if [ -n "$ENABLE_RELEASE_PROMOTION" ]; then
MOZ_AUTOMATION_UPLOAD_SYMBOLS=1

View File

@ -1,5 +1,3 @@
MOZ_AUTOMATION_SDK=${MOZ_AUTOMATION_SDK-1}
if [ -n "$ENABLE_RELEASE_PROMOTION" ]; then
MOZ_AUTOMATION_UPLOAD_SYMBOLS=1
MOZ_AUTOMATION_UPDATE_PACKAGING=1

View File

@ -1,6 +1,5 @@
# This make file should be identical to the beta mozconfig, apart from the
# safeguard below
MOZ_AUTOMATION_SDK=${MOZ_AUTOMATION_SDK-1}
if [ -n "$ENABLE_RELEASE_PROMOTION" ]; then
MOZ_AUTOMATION_UPLOAD_SYMBOLS=1

View File

@ -1,3 +1,3 @@
This is the pdf.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 1.7.227
Current extension version is: 1.7.235

View File

@ -15,9 +15,9 @@
/* globals Components, Services, XPCOMUtils, PdfjsChromeUtils,
PdfjsContentUtils, PdfStreamConverter */
'use strict';
"use strict";
var EXPORTED_SYMBOLS = ['PdfJs'];
var EXPORTED_SYMBOLS = ["PdfJs"];
const Cc = Components.classes;
const Ci = Components.interfaces;
@ -25,32 +25,32 @@ const Cr = Components.results;
const Cm = Components.manager;
const Cu = Components.utils;
const PREF_PREFIX = 'pdfjs';
const PREF_DISABLED = PREF_PREFIX + '.disabled';
const PREF_MIGRATION_VERSION = PREF_PREFIX + '.migrationVersion';
const PREF_PREVIOUS_ACTION = PREF_PREFIX + '.previousHandler.preferredAction';
const PREF_PREFIX = "pdfjs";
const PREF_DISABLED = PREF_PREFIX + ".disabled";
const PREF_MIGRATION_VERSION = PREF_PREFIX + ".migrationVersion";
const PREF_PREVIOUS_ACTION = PREF_PREFIX + ".previousHandler.preferredAction";
const PREF_PREVIOUS_ASK = PREF_PREFIX +
'.previousHandler.alwaysAskBeforeHandling';
const PREF_DISABLED_PLUGIN_TYPES = 'plugin.disable_full_page_plugin_for_types';
const TOPIC_PDFJS_HANDLER_CHANGED = 'pdfjs:handlerChanged';
const TOPIC_PLUGINS_LIST_UPDATED = 'plugins-list-updated';
const TOPIC_PLUGIN_INFO_UPDATED = 'plugin-info-updated';
const PDF_CONTENT_TYPE = 'application/pdf';
".previousHandler.alwaysAskBeforeHandling";
const PREF_DISABLED_PLUGIN_TYPES = "plugin.disable_full_page_plugin_for_types";
const TOPIC_PDFJS_HANDLER_CHANGED = "pdfjs:handlerChanged";
const TOPIC_PLUGINS_LIST_UPDATED = "plugins-list-updated";
const TOPIC_PLUGIN_INFO_UPDATED = "plugin-info-updated";
const PDF_CONTENT_TYPE = "application/pdf";
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/Services.jsm');
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
var Svc = {};
XPCOMUtils.defineLazyServiceGetter(Svc, 'mime',
'@mozilla.org/mime;1',
'nsIMIMEService');
XPCOMUtils.defineLazyServiceGetter(Svc, 'pluginHost',
'@mozilla.org/plugin/host;1',
'nsIPluginHost');
XPCOMUtils.defineLazyModuleGetter(this, 'PdfjsChromeUtils',
'resource://pdf.js/PdfjsChromeUtils.jsm');
XPCOMUtils.defineLazyModuleGetter(this, 'PdfjsContentUtils',
'resource://pdf.js/PdfjsContentUtils.jsm');
XPCOMUtils.defineLazyServiceGetter(Svc, "mime",
"@mozilla.org/mime;1",
"nsIMIMEService");
XPCOMUtils.defineLazyServiceGetter(Svc, "pluginHost",
"@mozilla.org/plugin/host;1",
"nsIPluginHost");
XPCOMUtils.defineLazyModuleGetter(this, "PdfjsChromeUtils",
"resource://pdf.js/PdfjsChromeUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PdfjsContentUtils",
"resource://pdf.js/PdfjsContentUtils.jsm");
function getBoolPref(aPref, aDefaultValue) {
try {
@ -98,18 +98,18 @@ function initializeDefaultPreferences() {
}
var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + '.');
var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + ".");
var defaultValue;
for (var key in DEFAULT_PREFERENCES) {
defaultValue = DEFAULT_PREFERENCES[key];
switch (typeof defaultValue) {
case 'boolean':
case "boolean":
defaultBranch.setBoolPref(key, defaultValue);
break;
case 'number':
case "number":
defaultBranch.setIntPref(key, defaultValue);
break;
case 'string':
case "string":
defaultBranch.setCharPref(key, defaultValue);
break;
}
@ -155,8 +155,8 @@ var PdfJs = {
init: function init(remote) {
if (Services.appinfo.processType !==
Services.appinfo.PROCESS_TYPE_DEFAULT) {
throw new Error('PdfJs.init should only get called ' +
'in the parent process.');
throw new Error("PdfJs.init should only get called " +
"in the parent process.");
}
PdfjsChromeUtils.init();
if (!remote) {
@ -219,13 +219,13 @@ var PdfJs = {
}
if (currentVersion < 2) {
// cleaning up of unused database preference (see #3994)
Services.prefs.clearUserPref(PREF_PREFIX + '.database');
Services.prefs.clearUserPref(PREF_PREFIX + ".database");
}
Services.prefs.setIntPref(PREF_MIGRATION_VERSION, VERSION);
},
_becomeHandler: function _becomeHandler() {
let handlerInfo = Svc.mime.getFromTypeAndExtension(PDF_CONTENT_TYPE, 'pdf');
let handlerInfo = Svc.mime.getFromTypeAndExtension(PDF_CONTENT_TYPE, "pdf");
let prefs = Services.prefs;
if (handlerInfo.preferredAction !== Ci.nsIHandlerInfo.handleInternally &&
handlerInfo.preferredAction !== false) {
@ -236,7 +236,7 @@ var PdfJs = {
prefs.setBoolPref(PREF_PREVIOUS_ASK, handlerInfo.alwaysAskBeforeHandling);
}
let handlerService = Cc['@mozilla.org/uriloader/handler-service;1'].
let handlerService = Cc["@mozilla.org/uriloader/handler-service;1"].
getService(Ci.nsIHandlerService);
// Change and save mime handler settings.
@ -245,24 +245,24 @@ var PdfJs = {
handlerService.store(handlerInfo);
// Also disable any plugins for pdfs.
var stringTypes = '';
var stringTypes = "";
var types = [];
if (prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES)) {
stringTypes = prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES);
}
if (stringTypes !== '') {
types = stringTypes.split(',');
if (stringTypes !== "") {
types = stringTypes.split(",");
}
if (types.indexOf(PDF_CONTENT_TYPE) === -1) {
types.push(PDF_CONTENT_TYPE);
}
prefs.setCharPref(PREF_DISABLED_PLUGIN_TYPES, types.join(','));
prefs.setCharPref(PREF_DISABLED_PLUGIN_TYPES, types.join(","));
// Update the category manager in case the plugins are already loaded.
let categoryManager = Cc['@mozilla.org/categorymanager;1'];
let categoryManager = Cc["@mozilla.org/categorymanager;1"];
categoryManager.getService(Ci.nsICategoryManager).
deleteCategoryEntry('Gecko-Content-Viewers',
deleteCategoryEntry("Gecko-Content-Viewers",
PDF_CONTENT_TYPE,
false);
},
@ -272,7 +272,7 @@ var PdfJs = {
this.updateRegistration();
if (Services.appinfo.processType ===
Services.appinfo.PROCESS_TYPE_DEFAULT) {
let jsm = 'resource://pdf.js/PdfjsChromeUtils.jsm';
let jsm = "resource://pdf.js/PdfjsChromeUtils.jsm";
let PdfjsChromeUtils = Components.utils.import(jsm, {}).PdfjsChromeUtils;
PdfjsChromeUtils.notifyChildOfSettingsChange();
}
@ -297,7 +297,7 @@ var PdfJs = {
// Check if we have disabled plugin handling of 'application/pdf' in prefs
if (Services.prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES)) {
let disabledPluginTypes =
Services.prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES).split(',');
Services.prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES).split(",");
if (disabledPluginTypes.indexOf(PDF_CONTENT_TYPE) >= 0) {
return true;
}
@ -306,7 +306,7 @@ var PdfJs = {
// Check if there is an enabled pdf plugin.
// Note: this check is performed last because getPluginTags() triggers
// costly plugin list initialization (bug 881575)
let tags = Cc['@mozilla.org/plugin/host;1'].
let tags = Cc["@mozilla.org/plugin/host;1"].
getService(Ci.nsIPluginHost).
getPluginTags();
let enabledPluginFound = tags.some(function(tag) {
@ -328,7 +328,7 @@ var PdfJs = {
return;
}
this._pdfStreamConverterFactory = new Factory();
Cu.import('resource://pdf.js/PdfStreamConverter.jsm');
Cu.import("resource://pdf.js/PdfStreamConverter.jsm");
this._pdfStreamConverterFactory.register(PdfStreamConverter);
this._registered = true;
@ -339,7 +339,7 @@ var PdfJs = {
return;
}
this._pdfStreamConverterFactory.unregister();
Cu.unload('resource://pdf.js/PdfStreamConverter.jsm');
Cu.unload("resource://pdf.js/PdfStreamConverter.jsm");
delete this._pdfStreamConverterFactory;
this._registered = false;

View File

@ -14,14 +14,14 @@
*/
/* globals Components, Services */
'use strict';
"use strict";
Components.utils.import('resource://gre/modules/Services.jsm');
Components.utils.import("resource://gre/modules/Services.jsm");
var EXPORTED_SYMBOLS = ['NetworkManager'];
var EXPORTED_SYMBOLS = ["NetworkManager"];
function log(aMsg) {
var msg = 'PdfJsNetwork.jsm: ' + (aMsg.join ? aMsg.join('') : aMsg);
var msg = "PdfJsNetwork.jsm: " + (aMsg.join ? aMsg.join("") : aMsg);
Services.console.logStringMessage(msg);
}
@ -32,7 +32,7 @@ var NetworkManager = (function NetworkManagerClosure() {
function getArrayBuffer(xhr) {
var data = xhr.response;
if (typeof data !== 'string') {
if (typeof data !== "string") {
return data;
}
var length = data.length;
@ -82,18 +82,18 @@ var NetworkManager = (function NetworkManagerClosure() {
xhr,
};
xhr.open('GET', this.url);
xhr.open("GET", this.url);
xhr.withCredentials = this.withCredentials;
for (var property in this.httpHeaders) {
var value = this.httpHeaders[property];
if (typeof value === 'undefined') {
if (typeof value === "undefined") {
continue;
}
xhr.setRequestHeader(property, value);
}
if (this.isHttp && 'begin' in args && 'end' in args) {
var rangeStr = args.begin + '-' + (args.end - 1);
xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
if (this.isHttp && "begin" in args && "end" in args) {
var rangeStr = args.begin + "-" + (args.end - 1);
xhr.setRequestHeader("Range", "bytes=" + rangeStr);
pendingRequest.expectedStatus = 206;
} else {
pendingRequest.expectedStatus = 200;
@ -101,11 +101,11 @@ var NetworkManager = (function NetworkManagerClosure() {
var useMozChunkedLoading = !!args.onProgressiveData;
if (useMozChunkedLoading) {
xhr.responseType = 'moz-chunked-arraybuffer';
xhr.responseType = "moz-chunked-arraybuffer";
pendingRequest.onProgressiveData = args.onProgressiveData;
pendingRequest.mozChunked = true;
} else {
xhr.responseType = 'arraybuffer';
xhr.responseType = "arraybuffer";
}
if (args.onError) {
@ -197,7 +197,7 @@ var NetworkManager = (function NetworkManagerClosure() {
var chunk = getArrayBuffer(xhr);
if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
var rangeHeader = xhr.getResponseHeader('Content-Range');
var rangeHeader = xhr.getResponseHeader("Content-Range");
var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
var begin = parseInt(matches[1], 10);
pendingRequest.onDone({

View File

@ -15,56 +15,56 @@
/* eslint max-len: ["error", 100] */
/* globals Components, Services */
'use strict';
"use strict";
this.EXPORTED_SYMBOLS = ['PdfJsTelemetry'];
this.EXPORTED_SYMBOLS = ["PdfJsTelemetry"];
const Cu = Components.utils;
Cu.import('resource://gre/modules/Services.jsm');
Cu.import("resource://gre/modules/Services.jsm");
this.PdfJsTelemetry = {
onViewerIsUsed() {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_USED');
let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_USED");
histogram.add(true);
},
onFallback() {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_FALLBACK_SHOWN');
let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_FALLBACK_SHOWN");
histogram.add(true);
},
onDocumentSize(size) {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_DOCUMENT_SIZE_KB');
let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_DOCUMENT_SIZE_KB");
histogram.add(size / 1024);
},
onDocumentVersion(versionId) {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_DOCUMENT_VERSION');
let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_DOCUMENT_VERSION");
histogram.add(versionId);
},
onDocumentGenerator(generatorId) {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_DOCUMENT_GENERATOR');
let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_DOCUMENT_GENERATOR");
histogram.add(generatorId);
},
onEmbed(isObject) {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_EMBED');
let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_EMBED");
histogram.add(isObject);
},
onFontType(fontTypeId) {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_FONT_TYPES');
let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_FONT_TYPES");
histogram.add(fontTypeId);
},
onForm(isAcroform) {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_FORM');
let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_FORM");
histogram.add(isAcroform);
},
onPrint() {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_PRINT');
let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_PRINT");
histogram.add(true);
},
onStreamType(streamTypeId) {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_STREAM_TYPES');
let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_STREAM_TYPES");
histogram.add(streamTypeId);
},
onTimeToView(ms) {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_TIME_TO_VIEW_MS');
let histogram = Services.telemetry.getHistogramById("PDF_VIEWER_TIME_TO_VIEW_MS");
histogram.add(ms);
}
};

View File

@ -15,43 +15,43 @@
/* globals Components, Services, XPCOMUtils, NetUtil, PrivateBrowsingUtils,
dump, NetworkManager, PdfJsTelemetry, PdfjsContentUtils */
'use strict';
"use strict";
var EXPORTED_SYMBOLS = ['PdfStreamConverter'];
var EXPORTED_SYMBOLS = ["PdfStreamConverter"];
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
// True only if this is the version of pdf.js that is included with firefox.
const MOZ_CENTRAL = JSON.parse('true');
const PDFJS_EVENT_ID = 'pdf.js.message';
const PDF_CONTENT_TYPE = 'application/pdf';
const PREF_PREFIX = 'pdfjs';
const PDF_VIEWER_WEB_PAGE = 'resource://pdf.js/web/viewer.html';
const MOZ_CENTRAL = JSON.parse("true");
const PDFJS_EVENT_ID = "pdf.js.message";
const PDF_CONTENT_TYPE = "application/pdf";
const PREF_PREFIX = "pdfjs";
const PDF_VIEWER_WEB_PAGE = "resource://pdf.js/web/viewer.html";
const MAX_NUMBER_OF_PREFS = 50;
const MAX_STRING_PREF_LENGTH = 128;
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/Services.jsm');
Cu.import('resource://gre/modules/NetUtil.jsm');
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyModuleGetter(this, 'NetworkManager',
'resource://pdf.js/PdfJsNetwork.jsm');
XPCOMUtils.defineLazyModuleGetter(this, "NetworkManager",
"resource://pdf.js/PdfJsNetwork.jsm");
XPCOMUtils.defineLazyModuleGetter(this, 'PrivateBrowsingUtils',
'resource://gre/modules/PrivateBrowsingUtils.jsm');
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, 'PdfJsTelemetry',
'resource://pdf.js/PdfJsTelemetry.jsm');
XPCOMUtils.defineLazyModuleGetter(this, "PdfJsTelemetry",
"resource://pdf.js/PdfJsTelemetry.jsm");
XPCOMUtils.defineLazyModuleGetter(this, 'PdfjsContentUtils',
'resource://pdf.js/PdfjsContentUtils.jsm');
XPCOMUtils.defineLazyModuleGetter(this, "PdfjsContentUtils",
"resource://pdf.js/PdfjsContentUtils.jsm");
var Svc = {};
XPCOMUtils.defineLazyServiceGetter(Svc, 'mime',
'@mozilla.org/mime;1',
'nsIMIMEService');
XPCOMUtils.defineLazyServiceGetter(Svc, "mime",
"@mozilla.org/mime;1",
"nsIMIMEService");
function getContainingBrowser(domWindow) {
return domWindow.QueryInterface(Ci.nsIInterfaceRequestor)
@ -62,7 +62,7 @@ function getContainingBrowser(domWindow) {
function getFindBar(domWindow) {
if (PdfjsContentUtils.isRemote) {
throw new Error('FindBar is not accessible from the content process.');
throw new Error("FindBar is not accessible from the content process.");
}
try {
var browser = getContainingBrowser(domWindow);
@ -101,12 +101,12 @@ function getStringPref(pref, def) {
}
function log(aMsg) {
if (!getBoolPref(PREF_PREFIX + '.pdfBugEnabled', false)) {
if (!getBoolPref(PREF_PREFIX + ".pdfBugEnabled", false)) {
return;
}
var msg = 'PdfStreamConverter.js: ' + (aMsg.join ? aMsg.join('') : aMsg);
var msg = "PdfStreamConverter.js: " + (aMsg.join ? aMsg.join("") : aMsg);
Services.console.logStringMessage(msg);
dump(msg + '\n');
dump(msg + "\n");
}
function getDOMWindow(aChannel) {
@ -118,16 +118,16 @@ function getDOMWindow(aChannel) {
}
function getLocalizedStrings(path) {
var stringBundle = Cc['@mozilla.org/intl/stringbundle;1'].
var stringBundle = Cc["@mozilla.org/intl/stringbundle;1"].
getService(Ci.nsIStringBundleService).
createBundle('chrome://pdf.js/locale/' + path);
createBundle("chrome://pdf.js/locale/" + path);
var map = {};
var enumerator = stringBundle.getSimpleEnumeration();
while (enumerator.hasMoreElements()) {
var string = enumerator.getNext().QueryInterface(Ci.nsIPropertyElement);
var key = string.key, property = 'textContent';
var i = key.lastIndexOf('.');
var key = string.key, property = "textContent";
var i = key.lastIndexOf(".");
if (i >= 0) {
property = key.substring(i + 1);
key = key.substring(0, i);
@ -140,7 +140,7 @@ function getLocalizedStrings(path) {
return map;
}
function getLocalizedString(strings, id, property) {
property = property || 'textContent';
property = property || "textContent";
if (id in strings) {
return strings[id][property];
}
@ -233,13 +233,13 @@ class ChromeActions {
// the original url.
var originalUri = NetUtil.newURI(originalUrl);
var filename = data.filename;
if (typeof filename !== 'string' ||
if (typeof filename !== "string" ||
(!/\.pdf$/i.test(filename) && !data.isAttachment)) {
filename = 'document.pdf';
filename = "document.pdf";
}
var blobUri = NetUtil.newURI(blobUrl);
var extHelperAppSvc =
Cc['@mozilla.org/uriloader/external-helper-app-service;1'].
Cc["@mozilla.org/uriloader/external-helper-app-service;1"].
getService(Ci.nsIExternalHelperAppService);
var docIsPrivate = this.isInPrivateBrowsing();
@ -247,7 +247,7 @@ class ChromeActions {
uri: blobUri,
loadUsingSystemPrincipal: true,
});
if ('nsIPrivateBrowsingChannel' in Ci &&
if ("nsIPrivateBrowsingChannel" in Ci &&
netChannel instanceof Ci.nsIPrivateBrowsingChannel) {
netChannel.setPrivate(docIsPrivate);
}
@ -260,7 +260,7 @@ class ChromeActions {
}
// Create a nsIInputStreamChannel so we can set the url on the channel
// so the filename will be correct.
var channel = Cc['@mozilla.org/network/input-stream-channel;1'].
var channel = Cc["@mozilla.org/network/input-stream-channel;1"].
createInstance(Ci.nsIInputStreamChannel);
channel.QueryInterface(Ci.nsIChannel);
try {
@ -275,7 +275,7 @@ class ChromeActions {
channel.setURI(originalUri);
channel.loadInfo = netChannel.loadInfo;
channel.contentStream = aInputStream;
if ('nsIPrivateBrowsingChannel' in Ci &&
if ("nsIPrivateBrowsingChannel" in Ci &&
channel instanceof Ci.nsIPrivateBrowsingChannel) {
channel.setPrivate(docIsPrivate);
}
@ -288,8 +288,8 @@ class ChromeActions {
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsILoadContext);
this.extListener = extHelperAppSvc.doContent(
(data.isAttachment ? 'application/octet-stream' :
'application/pdf'),
(data.isAttachment ? "application/octet-stream" :
"application/pdf"),
aRequest, loadContext, false);
this.extListener.onStartRequest(aRequest, aContext);
},
@ -313,20 +313,20 @@ class ChromeActions {
}
getLocale() {
return getStringPref('general.useragent.locale', 'en-US');
return getStringPref("general.useragent.locale", "en-US");
}
getStrings(data) {
try {
// Lazy initialization of localizedStrings
if (!('localizedStrings' in this)) {
this.localizedStrings = getLocalizedStrings('viewer.properties');
if (!("localizedStrings" in this)) {
this.localizedStrings = getLocalizedStrings("viewer.properties");
}
var result = this.localizedStrings[data];
return JSON.stringify(result || null);
} catch (e) {
log('Unable to retrieve localized strings: ' + e);
return 'null';
log("Unable to retrieve localized strings: " + e);
return "null";
}
}
@ -343,52 +343,52 @@ class ChromeActions {
// ... or when the new find events code exists.
var findBar = getFindBar(this.domWindow);
return !!findBar && ('updateControlState' in findBar);
return !!findBar && ("updateControlState" in findBar);
}
supportsDocumentFonts() {
var prefBrowser = getIntPref('browser.display.use_document_fonts', 1);
var prefGfx = getBoolPref('gfx.downloadable_fonts.enabled', true);
var prefBrowser = getIntPref("browser.display.use_document_fonts", 1);
var prefGfx = getBoolPref("gfx.downloadable_fonts.enabled", true);
return (!!prefBrowser && prefGfx);
}
supportsDocumentColors() {
return getIntPref('browser.display.document_color_use', 0) !== 2;
return getIntPref("browser.display.document_color_use", 0) !== 2;
}
supportedMouseWheelZoomModifierKeys() {
return {
ctrlKey: getIntPref('mousewheel.with_control.action', 3) === 3,
metaKey: getIntPref('mousewheel.with_meta.action', 1) === 3,
ctrlKey: getIntPref("mousewheel.with_control.action", 3) === 3,
metaKey: getIntPref("mousewheel.with_meta.action", 1) === 3,
};
}
reportTelemetry(data) {
var probeInfo = JSON.parse(data);
switch (probeInfo.type) {
case 'documentInfo':
case "documentInfo":
if (!this.telemetryState.documentInfo) {
PdfJsTelemetry.onDocumentVersion(probeInfo.version | 0);
PdfJsTelemetry.onDocumentGenerator(probeInfo.generator | 0);
if (probeInfo.formType) {
PdfJsTelemetry.onForm(probeInfo.formType === 'acroform');
PdfJsTelemetry.onForm(probeInfo.formType === "acroform");
}
this.telemetryState.documentInfo = true;
}
break;
case 'pageInfo':
case "pageInfo":
if (!this.telemetryState.firstPageInfo) {
var duration = Date.now() - this.telemetryState.startAt;
PdfJsTelemetry.onTimeToView(duration);
this.telemetryState.firstPageInfo = true;
}
break;
case 'documentStats':
case "documentStats":
// documentStats can be called several times for one documents.
// if stream/font types are reported, trying not to submit the same
// enumeration value multiple times.
var documentStats = probeInfo.stats;
if (!documentStats || typeof documentStats !== 'object') {
if (!documentStats || typeof documentStats !== "object") {
break;
}
var i, streamTypes = documentStats.streamTypes;
@ -414,7 +414,7 @@ class ChromeActions {
}
}
break;
case 'print':
case "print":
PdfJsTelemetry.onPrint();
break;
}
@ -428,29 +428,29 @@ class ChromeActions {
var featureId = args.featureId;
var domWindow = this.domWindow;
var strings = getLocalizedStrings('chrome.properties');
var strings = getLocalizedStrings("chrome.properties");
var message;
if (featureId === 'forms') {
message = getLocalizedString(strings, 'unsupported_feature_forms');
if (featureId === "forms") {
message = getLocalizedString(strings, "unsupported_feature_forms");
} else {
message = getLocalizedString(strings, 'unsupported_feature');
message = getLocalizedString(strings, "unsupported_feature");
}
PdfJsTelemetry.onFallback();
PdfjsContentUtils.displayWarning(domWindow, message,
getLocalizedString(strings, 'open_with_different_viewer'),
getLocalizedString(strings, 'open_with_different_viewer', 'accessKey'));
getLocalizedString(strings, "open_with_different_viewer"),
getLocalizedString(strings, "open_with_different_viewer", "accessKey"));
let winmm = domWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
winmm.addMessageListener('PDFJS:Child:fallbackDownload',
winmm.addMessageListener("PDFJS:Child:fallbackDownload",
function fallbackDownload(msg) {
let data = msg.data;
sendResponse(data.download);
winmm.removeMessageListener('PDFJS:Child:fallbackDownload',
winmm.removeMessageListener("PDFJS:Child:fallbackDownload",
fallbackDownload);
});
}
@ -463,8 +463,8 @@ class ChromeActions {
var result = data.result;
var findPrevious = data.findPrevious;
var findPreviousType = typeof findPrevious;
if ((typeof result !== 'number' || result < 0 || result > 3) ||
(findPreviousType !== 'undefined' && findPreviousType !== 'boolean')) {
if ((typeof result !== "number" || result < 0 || result > 3) ||
(findPreviousType !== "undefined" && findPreviousType !== "boolean")) {
return;
}
@ -473,34 +473,34 @@ class ChromeActions {
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
winmm.sendAsyncMessage('PDFJS:Parent:updateControlState', data);
winmm.sendAsyncMessage("PDFJS:Parent:updateControlState", data);
}
setPreferences(prefs, sendResponse) {
var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + '.');
var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + ".");
var numberOfPrefs = 0;
var prefValue, prefName;
for (var key in prefs) {
if (++numberOfPrefs > MAX_NUMBER_OF_PREFS) {
log('setPreferences - Exceeded the maximum number of preferences ' +
'that is allowed to be set at once.');
log("setPreferences - Exceeded the maximum number of preferences " +
"that is allowed to be set at once.");
break;
} else if (!defaultBranch.getPrefType(key)) {
continue;
}
prefValue = prefs[key];
prefName = (PREF_PREFIX + '.' + key);
prefName = (PREF_PREFIX + "." + key);
switch (typeof prefValue) {
case 'boolean':
case "boolean":
PdfjsContentUtils.setBoolPref(prefName, prefValue);
break;
case 'number':
case "number":
PdfjsContentUtils.setIntPref(prefName, prefValue);
break;
case 'string':
case "string":
if (prefValue.length > MAX_STRING_PREF_LENGTH) {
log('setPreferences - Exceeded the maximum allowed length ' +
'for a string preference.');
log("setPreferences - Exceeded the maximum allowed length " +
"for a string preference.");
} else {
PdfjsContentUtils.setStringPref(prefName, prefValue);
}
@ -513,36 +513,36 @@ class ChromeActions {
}
getPreferences(prefs, sendResponse) {
var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + '.');
var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + ".");
var currentPrefs = {}, numberOfPrefs = 0;
var prefValue, prefName;
for (var key in prefs) {
if (++numberOfPrefs > MAX_NUMBER_OF_PREFS) {
log('getPreferences - Exceeded the maximum number of preferences ' +
'that is allowed to be fetched at once.');
log("getPreferences - Exceeded the maximum number of preferences " +
"that is allowed to be fetched at once.");
break;
} else if (!defaultBranch.getPrefType(key)) {
continue;
}
prefValue = prefs[key];
prefName = (PREF_PREFIX + '.' + key);
prefName = (PREF_PREFIX + "." + key);
switch (typeof prefValue) {
case 'boolean':
case "boolean":
currentPrefs[key] = getBoolPref(prefName, prefValue);
break;
case 'number':
case "number":
currentPrefs[key] = getIntPref(prefName, prefValue);
break;
case 'string':
case "string":
currentPrefs[key] = getStringPref(prefName, prefValue);
break;
}
}
let result = JSON.stringify(currentPrefs);
if (sendResponse) {
sendResponse(JSON.stringify(currentPrefs));
} else {
return JSON.stringify(currentPrefs);
sendResponse(result);
}
return result;
}
}
@ -566,7 +566,7 @@ class RangedChromeActions extends ChromeActions {
var httpHeaderVisitor = {
headers: {},
visitHeader(aHeader, aValue) {
if (aHeader === 'Range') {
if (aHeader === "Range") {
// When loading the PDF from cache, firefox seems to set the Range
// request header to fetch only the unfetched portions of the file
// (e.g. 'Range: bytes=1024-'). However, we want to set this header
@ -584,7 +584,7 @@ class RangedChromeActions extends ChromeActions {
var xhr_onreadystatechange = function xhr_onreadystatechange() {
if (this.readyState === 1) { // LOADING
var netChannel = this.channel;
if ('nsIPrivateBrowsingChannel' in Ci &&
if ("nsIPrivateBrowsingChannel" in Ci &&
netChannel instanceof Ci.nsIPrivateBrowsingChannel) {
var docIsPrivate = self.isInPrivateBrowsing();
netChannel.setPrivate(docIsPrivate);
@ -593,9 +593,9 @@ class RangedChromeActions extends ChromeActions {
};
var getXhr = function getXhr() {
const XMLHttpRequest = Components.Constructor(
'@mozilla.org/xmlextras/xmlhttprequest;1');
"@mozilla.org/xmlextras/xmlhttprequest;1");
var xhr = new XMLHttpRequest();
xhr.addEventListener('readystatechange', xhr_onreadystatechange);
xhr.addEventListener("readystatechange", xhr_onreadystatechange);
return xhr;
};
@ -606,7 +606,7 @@ class RangedChromeActions extends ChromeActions {
// If we are in range request mode, this means we manually issued xhr
// requests, which we need to abort when we leave the page
domWindow.addEventListener('unload', function unload(e) {
domWindow.addEventListener("unload", function unload(e) {
domWindow.removeEventListener(e.type, unload);
self.abortLoading();
});
@ -624,11 +624,11 @@ class RangedChromeActions extends ChromeActions {
this.dataListener.onprogress = (loaded, total) => {
this.domWindow.postMessage({
pdfjsLoadAction: 'progressiveRead',
pdfjsLoadAction: "progressiveRead",
loaded,
total,
chunk: this.dataListener.readData(),
}, '*');
}, "*");
};
this.dataListener.oncomplete = () => {
this.dataListener = null;
@ -636,13 +636,13 @@ class RangedChromeActions extends ChromeActions {
}
this.domWindow.postMessage({
pdfjsLoadAction: 'supportsRangedLoading',
pdfjsLoadAction: "supportsRangedLoading",
rangeEnabled: this.rangeEnabled,
streamingEnabled: this.streamingEnabled,
pdfUrl: this.pdfUrl,
length: this.contentLength,
data,
}, '*');
}, "*");
return true;
}
@ -661,16 +661,16 @@ class RangedChromeActions extends ChromeActions {
this.networkManager.requestRange(begin, end, {
onDone: function RangedChromeActions_onDone(aArgs) {
domWindow.postMessage({
pdfjsLoadAction: 'range',
pdfjsLoadAction: "range",
begin: aArgs.begin,
chunk: aArgs.chunk,
}, '*');
}, "*");
},
onProgress: function RangedChromeActions_onProgress(evt) {
domWindow.postMessage({
pdfjsLoadAction: 'rangeProgress',
pdfjsLoadAction: "rangeProgress",
loaded: evt.loaded,
}, '*');
}, "*");
}
});
}
@ -703,18 +703,18 @@ class StandardChromeActions extends ChromeActions {
this.dataListener.onprogress = (loaded, total) => {
this.domWindow.postMessage({
pdfjsLoadAction: 'progress',
pdfjsLoadAction: "progress",
loaded,
total,
}, '*');
}, "*");
};
this.dataListener.oncomplete = (data, errorCode) => {
this.domWindow.postMessage({
pdfjsLoadAction: 'complete',
pdfjsLoadAction: "complete",
data,
errorCode,
}, '*');
}, "*");
this.dataListener = null;
this.originalRequest = null;
@ -749,7 +749,7 @@ class RequestListener {
var sync = event.detail.sync;
var actions = this.actions;
if (!(action in actions)) {
log('Unknown action: ' + action);
log("Unknown action: " + action);
return;
}
var response;
@ -763,9 +763,9 @@ class RequestListener {
} else {
response = function sendResponse(aResponse) {
try {
var listener = doc.createEvent('CustomEvent');
var listener = doc.createEvent("CustomEvent");
let detail = Cu.cloneInto({ response: aResponse }, doc.defaultView);
listener.initCustomEvent('pdf.js.response', true, false, detail);
listener.initCustomEvent("pdf.js.response", true, false, detail);
return message.dispatchEvent(listener);
} catch (e) {
// doc is no longer accessible because the requestor is already
@ -797,14 +797,14 @@ class FindEventManager {
this.unbind();
this.contentWindow.removeEventListener(e.type, unload);
}.bind(this);
this.contentWindow.addEventListener('unload', unload);
this.contentWindow.addEventListener("unload", unload);
// We cannot directly attach listeners to for the find events
// since the FindBar is in the parent process. Instead we're
// asking the PdfjsChromeUtils to do it for us and forward
// all the find events to us.
this.winmm.sendAsyncMessage('PDFJS:Parent:addEventListener');
this.winmm.addMessageListener('PDFJS:Child:handleEvent', this);
this.winmm.sendAsyncMessage("PDFJS:Parent:addEventListener");
this.winmm.addMessageListener("PDFJS:Child:handleEvent", this);
}
receiveMessage(msg) {
@ -813,13 +813,13 @@ class FindEventManager {
var contentWindow = this.contentWindow;
detail = Cu.cloneInto(detail, contentWindow);
var forward = contentWindow.document.createEvent('CustomEvent');
var forward = contentWindow.document.createEvent("CustomEvent");
forward.initCustomEvent(type, true, true, detail);
contentWindow.dispatchEvent(forward);
}
unbind() {
this.winmm.sendAsyncMessage('PDFJS:Parent:removeEventListener');
this.winmm.sendAsyncMessage("PDFJS:Parent:removeEventListener");
}
}
@ -829,12 +829,12 @@ function PdfStreamConverter() {
PdfStreamConverter.prototype = {
// properties required for XPCOM registration:
classID: Components.ID('{d0c5195d-e798-49d4-b1d3-9324328b2291}'),
classDescription: 'pdf.js Component',
contractID: '@mozilla.org/streamconv;1?from=application/pdf&to=*/*',
classID: Components.ID("{d0c5195d-e798-49d4-b1d3-9324328b2291}"),
classDescription: "pdf.js Component",
contractID: "@mozilla.org/streamconv;1?from=application/pdf&to=*/*",
classID2: Components.ID('{d0c5195d-e798-49d4-b1d3-9324328b2292}'),
contractID2: '@mozilla.org/streamconv;1?from=application/pdf&to=text/html',
classID2: Components.ID("{d0c5195d-e798-49d4-b1d3-9324328b2292}"),
contractID2: "@mozilla.org/streamconv;1?from=application/pdf&to=text/html",
QueryInterface: XPCOMUtils.generateQI([
Ci.nsISupports,
@ -894,29 +894,29 @@ PdfStreamConverter.prototype = {
var rangeRequest = false;
var streamRequest = false;
if (isHttpRequest) {
var contentEncoding = 'identity';
var contentEncoding = "identity";
try {
contentEncoding = aRequest.getResponseHeader('Content-Encoding');
contentEncoding = aRequest.getResponseHeader("Content-Encoding");
} catch (e) {}
var acceptRanges;
try {
acceptRanges = aRequest.getResponseHeader('Accept-Ranges');
acceptRanges = aRequest.getResponseHeader("Accept-Ranges");
} catch (e) {}
var hash = aRequest.URI.ref;
var isPDFBugEnabled = getBoolPref(PREF_PREFIX + '.pdfBugEnabled', false);
rangeRequest = contentEncoding === 'identity' &&
acceptRanges === 'bytes' &&
var isPDFBugEnabled = getBoolPref(PREF_PREFIX + ".pdfBugEnabled", false);
rangeRequest = contentEncoding === "identity" &&
acceptRanges === "bytes" &&
aRequest.contentLength >= 0 &&
!getBoolPref(PREF_PREFIX + '.disableRange', false) &&
!getBoolPref(PREF_PREFIX + ".disableRange", false) &&
(!isPDFBugEnabled ||
hash.toLowerCase().indexOf('disablerange=true') < 0);
streamRequest = contentEncoding === 'identity' &&
hash.toLowerCase().indexOf("disablerange=true") < 0);
streamRequest = contentEncoding === "identity" &&
aRequest.contentLength >= 0 &&
!getBoolPref(PREF_PREFIX + '.disableStream', false) &&
!getBoolPref(PREF_PREFIX + ".disableStream", false) &&
(!isPDFBugEnabled ||
hash.toLowerCase().indexOf('disablestream=true') < 0);
hash.toLowerCase().indexOf("disablestream=true") < 0);
}
aRequest.QueryInterface(Ci.nsIChannel);
@ -929,15 +929,15 @@ PdfStreamConverter.prototype = {
} catch (e) {}
// Change the content type so we don't get stuck in a loop.
aRequest.setProperty('contentType', aRequest.contentType);
aRequest.contentType = 'text/html';
aRequest.setProperty("contentType", aRequest.contentType);
aRequest.contentType = "text/html";
if (isHttpRequest) {
// We trust PDF viewer, using no CSP
aRequest.setResponseHeader('Content-Security-Policy', '', false);
aRequest.setResponseHeader('Content-Security-Policy-Report-Only', '',
aRequest.setResponseHeader("Content-Security-Policy", "", false);
aRequest.setResponseHeader("Content-Security-Policy-Report-Only", "",
false);
// The viewer does not need to handle HTTP Refresh header.
aRequest.setResponseHeader('Refresh', '', false);
aRequest.setResponseHeader("Refresh", "", false);
}
PdfJsTelemetry.onViewerIsUsed();
@ -946,7 +946,7 @@ PdfStreamConverter.prototype = {
// Creating storage for PDF data
var contentLength = aRequest.contentLength;
this.dataListener = new PdfDataListener(contentLength);
this.binaryStream = Cc['@mozilla.org/binaryinputstream;1']
this.binaryStream = Cc["@mozilla.org/binaryinputstream;1"]
.createInstance(Ci.nsIBinaryInputStream);
// Create a new channel that is viewer loaded as a resource.
@ -993,8 +993,8 @@ PdfStreamConverter.prototype = {
listener.onStopRequest(aRequest, aContext, statusCode);
if (domWindow.frameElement) {
var isObjectEmbed = domWindow.frameElement.tagName !== 'IFRAME' ||
domWindow.frameElement.className === 'previewPluginContentFrame';
var isObjectEmbed = domWindow.frameElement.tagName !== "IFRAME" ||
domWindow.frameElement.className === "previewPluginContentFrame";
PdfJsTelemetry.onEmbed(isObjectEmbed);
}
}
@ -1008,7 +1008,7 @@ PdfStreamConverter.prototype = {
// We can use the resource principal when data is fetched by the chrome,
// e.g. useful for NoScript. Make make sure we reuse the origin attributes
// from the request channel to keep isolation consistent.
var ssm = Cc['@mozilla.org/scriptsecuritymanager;1']
var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager);
var uri = NetUtil.newURI(PDF_VIEWER_WEB_PAGE);
var resourcePrincipal =

View File

@ -14,25 +14,25 @@
*/
/* globals Components, Services, XPCOMUtils */
'use strict';
"use strict";
var EXPORTED_SYMBOLS = ['PdfjsChromeUtils'];
var EXPORTED_SYMBOLS = ["PdfjsChromeUtils"];
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
const PREF_PREFIX = 'pdfjs';
const PDF_CONTENT_TYPE = 'application/pdf';
const PREF_PREFIX = "pdfjs";
const PDF_CONTENT_TYPE = "application/pdf";
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/Services.jsm');
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
var Svc = {};
XPCOMUtils.defineLazyServiceGetter(Svc, 'mime',
'@mozilla.org/mime;1',
'nsIMIMEService');
XPCOMUtils.defineLazyServiceGetter(Svc, "mime",
"@mozilla.org/mime;1",
"nsIMIMEService");
var DEFAULT_PREFERENCES =
{
@ -71,46 +71,46 @@ var PdfjsChromeUtils = {
this._browsers = new WeakSet();
if (!this._ppmm) {
// global parent process message manager (PPMM)
this._ppmm = Cc['@mozilla.org/parentprocessmessagemanager;1'].
this._ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"].
getService(Ci.nsIMessageBroadcaster);
this._ppmm.addMessageListener('PDFJS:Parent:clearUserPref', this);
this._ppmm.addMessageListener('PDFJS:Parent:setIntPref', this);
this._ppmm.addMessageListener('PDFJS:Parent:setBoolPref', this);
this._ppmm.addMessageListener('PDFJS:Parent:setCharPref', this);
this._ppmm.addMessageListener('PDFJS:Parent:setStringPref', this);
this._ppmm.addMessageListener('PDFJS:Parent:isDefaultHandlerApp', this);
this._ppmm.addMessageListener("PDFJS:Parent:clearUserPref", this);
this._ppmm.addMessageListener("PDFJS:Parent:setIntPref", this);
this._ppmm.addMessageListener("PDFJS:Parent:setBoolPref", this);
this._ppmm.addMessageListener("PDFJS:Parent:setCharPref", this);
this._ppmm.addMessageListener("PDFJS:Parent:setStringPref", this);
this._ppmm.addMessageListener("PDFJS:Parent:isDefaultHandlerApp", this);
// global dom message manager (MMg)
this._mmg = Cc['@mozilla.org/globalmessagemanager;1'].
this._mmg = Cc["@mozilla.org/globalmessagemanager;1"].
getService(Ci.nsIMessageListenerManager);
this._mmg.addMessageListener('PDFJS:Parent:displayWarning', this);
this._mmg.addMessageListener("PDFJS:Parent:displayWarning", this);
this._mmg.addMessageListener('PDFJS:Parent:addEventListener', this);
this._mmg.addMessageListener('PDFJS:Parent:removeEventListener', this);
this._mmg.addMessageListener('PDFJS:Parent:updateControlState', this);
this._mmg.addMessageListener("PDFJS:Parent:addEventListener", this);
this._mmg.addMessageListener("PDFJS:Parent:removeEventListener", this);
this._mmg.addMessageListener("PDFJS:Parent:updateControlState", this);
// observer to handle shutdown
Services.obs.addObserver(this, 'quit-application', false);
Services.obs.addObserver(this, "quit-application", false);
}
},
uninit() {
if (this._ppmm) {
this._ppmm.removeMessageListener('PDFJS:Parent:clearUserPref', this);
this._ppmm.removeMessageListener('PDFJS:Parent:setIntPref', this);
this._ppmm.removeMessageListener('PDFJS:Parent:setBoolPref', this);
this._ppmm.removeMessageListener('PDFJS:Parent:setCharPref', this);
this._ppmm.removeMessageListener('PDFJS:Parent:setStringPref', this);
this._ppmm.removeMessageListener('PDFJS:Parent:isDefaultHandlerApp',
this._ppmm.removeMessageListener("PDFJS:Parent:clearUserPref", this);
this._ppmm.removeMessageListener("PDFJS:Parent:setIntPref", this);
this._ppmm.removeMessageListener("PDFJS:Parent:setBoolPref", this);
this._ppmm.removeMessageListener("PDFJS:Parent:setCharPref", this);
this._ppmm.removeMessageListener("PDFJS:Parent:setStringPref", this);
this._ppmm.removeMessageListener("PDFJS:Parent:isDefaultHandlerApp",
this);
this._mmg.removeMessageListener('PDFJS:Parent:displayWarning', this);
this._mmg.removeMessageListener("PDFJS:Parent:displayWarning", this);
this._mmg.removeMessageListener('PDFJS:Parent:addEventListener', this);
this._mmg.removeMessageListener('PDFJS:Parent:removeEventListener', this);
this._mmg.removeMessageListener('PDFJS:Parent:updateControlState', this);
this._mmg.removeMessageListener("PDFJS:Parent:addEventListener", this);
this._mmg.removeMessageListener("PDFJS:Parent:removeEventListener", this);
this._mmg.removeMessageListener("PDFJS:Parent:updateControlState", this);
Services.obs.removeObserver(this, 'quit-application');
Services.obs.removeObserver(this, "quit-application");
this._mmg = null;
this._ppmm = null;
@ -131,7 +131,7 @@ var PdfjsChromeUtils = {
// manager, which means this is going to fire to every child process
// we have open. Unfortunately I can't find a way to get at that
// process specific mm from js.
this._ppmm.broadcastAsyncMessage('PDFJS:Child:refreshSettings', {});
this._ppmm.broadcastAsyncMessage("PDFJS:Child:refreshSettings", {});
}
},
@ -140,42 +140,42 @@ var PdfjsChromeUtils = {
*/
observe(aSubject, aTopic, aData) {
if (aTopic === 'quit-application') {
if (aTopic === "quit-application") {
this.uninit();
}
},
receiveMessage(aMsg) {
switch (aMsg.name) {
case 'PDFJS:Parent:clearUserPref':
case "PDFJS:Parent:clearUserPref":
this._clearUserPref(aMsg.data.name);
break;
case 'PDFJS:Parent:setIntPref':
case "PDFJS:Parent:setIntPref":
this._setIntPref(aMsg.data.name, aMsg.data.value);
break;
case 'PDFJS:Parent:setBoolPref':
case "PDFJS:Parent:setBoolPref":
this._setBoolPref(aMsg.data.name, aMsg.data.value);
break;
case 'PDFJS:Parent:setCharPref':
case "PDFJS:Parent:setCharPref":
this._setCharPref(aMsg.data.name, aMsg.data.value);
break;
case 'PDFJS:Parent:setStringPref':
case "PDFJS:Parent:setStringPref":
this._setStringPref(aMsg.data.name, aMsg.data.value);
break;
case 'PDFJS:Parent:isDefaultHandlerApp':
case "PDFJS:Parent:isDefaultHandlerApp":
return this.isDefaultHandlerApp();
case 'PDFJS:Parent:displayWarning':
case "PDFJS:Parent:displayWarning":
this._displayWarning(aMsg);
break;
case 'PDFJS:Parent:updateControlState':
case "PDFJS:Parent:updateControlState":
return this._updateControlState(aMsg);
case 'PDFJS:Parent:addEventListener':
case "PDFJS:Parent:addEventListener":
return this._addEventListener(aMsg);
case 'PDFJS:Parent:removeEventListener':
case "PDFJS:Parent:removeEventListener":
return this._removeEventListener(aMsg);
}
return undefined;
},
/*
@ -208,25 +208,25 @@ var PdfjsChromeUtils = {
let browser = aEvent.currentTarget.browser;
if (!this._browsers.has(browser)) {
throw new Error('FindEventManager was not bound ' +
'for the current browser.');
throw new Error("FindEventManager was not bound " +
"for the current browser.");
}
// Only forward the events if the current browser is a registered browser.
let mm = browser.messageManager;
mm.sendAsyncMessage('PDFJS:Child:handleEvent', { type, detail, });
mm.sendAsyncMessage("PDFJS:Child:handleEvent", { type, detail, });
aEvent.preventDefault();
},
_types: ['find',
'findagain',
'findhighlightallchange',
'findcasesensitivitychange'],
_types: ["find",
"findagain",
"findhighlightallchange",
"findcasesensitivitychange"],
_addEventListener(aMsg) {
let browser = aMsg.target;
if (this._browsers.has(browser)) {
throw new Error('FindEventManager was bound 2nd time ' +
'without unbinding it first.');
throw new Error("FindEventManager was bound 2nd time " +
"without unbinding it first.");
}
// Since this jsm is global, we need to store all the browsers
@ -244,7 +244,7 @@ var PdfjsChromeUtils = {
_removeEventListener(aMsg) {
let browser = aMsg.target;
if (!this._browsers.has(browser)) {
throw new Error('FindEventManager was unbound without binding it first.');
throw new Error("FindEventManager was unbound without binding it first.");
}
this._browsers.delete(browser);
@ -258,11 +258,11 @@ var PdfjsChromeUtils = {
},
_ensurePreferenceAllowed(aPrefName) {
let unPrefixedName = aPrefName.split(PREF_PREFIX + '.');
if (unPrefixedName[0] !== '' ||
let unPrefixedName = aPrefName.split(PREF_PREFIX + ".");
if (unPrefixedName[0] !== "" ||
this._allowedPrefNames.indexOf(unPrefixedName[1]) === -1) {
let msg = '"' + aPrefName + '" ' +
'can\'t be accessed from content. See PdfjsChromeUtils.';
let msg = "\"" + aPrefName + "\" " +
"can't be accessed from content. See PdfjsChromeUtils.";
throw new Error(msg);
}
},
@ -289,7 +289,7 @@ var PdfjsChromeUtils = {
_setStringPref(aPrefName, aPrefValue) {
this._ensurePreferenceAllowed(aPrefName);
let str = Cc['@mozilla.org/supports-string;1']
let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = aPrefValue;
Services.prefs.setComplexValue(aPrefName, Ci.nsISupportsString, str);
@ -301,7 +301,7 @@ var PdfjsChromeUtils = {
* parent.
*/
isDefaultHandlerApp() {
var handlerInfo = Svc.mime.getFromTypeAndExtension(PDF_CONTENT_TYPE, 'pdf');
var handlerInfo = Svc.mime.getFromTypeAndExtension(PDF_CONTENT_TYPE, "pdf");
return (!handlerInfo.alwaysAskBeforeHandling &&
handlerInfo.preferredAction === Ci.nsIHandlerInfo.handleInternally);
},
@ -323,7 +323,7 @@ var PdfjsChromeUtils = {
let messageSent = false;
function sendMessage(download) {
let mm = browser.messageManager;
mm.sendAsyncMessage('PDFJS:Child:fallbackDownload', { download, });
mm.sendAsyncMessage("PDFJS:Child:fallbackDownload", { download, });
}
let buttons = [{
label: data.label,
@ -333,13 +333,13 @@ var PdfjsChromeUtils = {
sendMessage(true);
}
}];
notificationBox.appendNotification(data.message, 'pdfjs-fallback', null,
notificationBox.appendNotification(data.message, "pdfjs-fallback", null,
notificationBox.PRIORITY_INFO_LOW,
buttons,
function eventsCallback(eventType) {
// Currently there is only one event "removed" but if there are any other
// added in the future we still only care about removed at the moment.
if (eventType !== 'removed') {
if (eventType !== "removed") {
return;
}
// Don't send a response again if we already responded when the button was

View File

@ -14,17 +14,17 @@
*/
/* globals Components, Services, XPCOMUtils */
'use strict';
"use strict";
var EXPORTED_SYMBOLS = ['PdfjsContentUtils'];
var EXPORTED_SYMBOLS = ["PdfjsContentUtils"];
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/Services.jsm');
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
var PdfjsContentUtils = {
_mm: null,
@ -42,17 +42,17 @@ var PdfjsContentUtils = {
// child *process* mm, or when loaded into the parent for in-content
// support the psuedo child process mm 'child PPMM'.
if (!this._mm) {
this._mm = Cc['@mozilla.org/childprocessmessagemanager;1'].
this._mm = Cc["@mozilla.org/childprocessmessagemanager;1"].
getService(Ci.nsISyncMessageSender);
this._mm.addMessageListener('PDFJS:Child:refreshSettings', this);
Services.obs.addObserver(this, 'quit-application', false);
this._mm.addMessageListener("PDFJS:Child:refreshSettings", this);
Services.obs.addObserver(this, "quit-application", false);
}
},
uninit() {
if (this._mm) {
this._mm.removeMessageListener('PDFJS:Child:refreshSettings', this);
Services.obs.removeObserver(this, 'quit-application');
this._mm.removeMessageListener("PDFJS:Child:refreshSettings", this);
Services.obs.removeObserver(this, "quit-application");
}
this._mm = null;
},
@ -64,34 +64,34 @@ var PdfjsContentUtils = {
*/
clearUserPref(aPrefName) {
this._mm.sendSyncMessage('PDFJS:Parent:clearUserPref', {
this._mm.sendSyncMessage("PDFJS:Parent:clearUserPref", {
name: aPrefName
});
},
setIntPref(aPrefName, aPrefValue) {
this._mm.sendSyncMessage('PDFJS:Parent:setIntPref', {
this._mm.sendSyncMessage("PDFJS:Parent:setIntPref", {
name: aPrefName,
value: aPrefValue
});
},
setBoolPref(aPrefName, aPrefValue) {
this._mm.sendSyncMessage('PDFJS:Parent:setBoolPref', {
this._mm.sendSyncMessage("PDFJS:Parent:setBoolPref", {
name: aPrefName,
value: aPrefValue
});
},
setCharPref(aPrefName, aPrefValue) {
this._mm.sendSyncMessage('PDFJS:Parent:setCharPref', {
this._mm.sendSyncMessage("PDFJS:Parent:setCharPref", {
name: aPrefName,
value: aPrefValue
});
},
setStringPref(aPrefName, aPrefValue) {
this._mm.sendSyncMessage('PDFJS:Parent:setStringPref', {
this._mm.sendSyncMessage("PDFJS:Parent:setStringPref", {
name: aPrefName,
value: aPrefValue
});
@ -102,7 +102,7 @@ var PdfjsContentUtils = {
* handler app settings only available in the parent process.
*/
isDefaultHandlerApp() {
return this._mm.sendSyncMessage('PDFJS:Parent:isDefaultHandlerApp')[0];
return this._mm.sendSyncMessage("PDFJS:Parent:isDefaultHandlerApp")[0];
},
/*
@ -115,7 +115,7 @@ var PdfjsContentUtils = {
.getInterface(Ci.nsIDocShell)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
winmm.sendAsyncMessage('PDFJS:Parent:displayWarning', {
winmm.sendAsyncMessage("PDFJS:Parent:displayWarning", {
message: aMessage,
label: aLabel,
accessKey: aAccessKey,
@ -127,18 +127,18 @@ var PdfjsContentUtils = {
*/
observe(aSubject, aTopic, aData) {
if (aTopic === 'quit-application') {
if (aTopic === "quit-application") {
this.uninit();
}
},
receiveMessage(aMsg) {
switch (aMsg.name) {
case 'PDFJS:Child:refreshSettings':
case "PDFJS:Child:refreshSettings":
// Only react to this if we are remote.
if (Services.appinfo.processType ===
Services.appinfo.PROCESS_TYPE_CONTENT) {
let jsm = 'resource://pdf.js/PdfJs.jsm';
let jsm = "resource://pdf.js/PdfJs.jsm";
let pdfjs = Components.utils.import(jsm, {}).PdfJs;
pdfjs.updateRegistration();
}

View File

@ -23,8 +23,8 @@
}
}(this, function (exports) {
'use strict';
var pdfjsVersion = '1.7.227';
var pdfjsBuild = 'e132fa97';
var pdfjsVersion = '1.7.235';
var pdfjsBuild = '3f320f0b';
var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
var pdfjsLibs = {};
(function pdfjsWrapper() {
@ -4693,13 +4693,7 @@
needRestore = true;
}
if (this.pendingEOFill) {
if (ctx.mozFillRule !== undefined) {
ctx.mozFillRule = 'evenodd';
ctx.fill();
ctx.mozFillRule = 'nonzero';
} else {
ctx.fill('evenodd');
}
ctx.fill('evenodd');
this.pendingEOFill = false;
} else {
ctx.fill();
@ -5531,13 +5525,7 @@
var ctx = this.ctx;
if (this.pendingClip) {
if (this.pendingClip === EO_CLIP) {
if (ctx.mozFillRule !== undefined) {
ctx.mozFillRule = 'evenodd';
ctx.clip();
ctx.mozFillRule = 'nonzero';
} else {
ctx.clip('evenodd');
}
ctx.clip('evenodd');
} else {
ctx.clip();
}

File diff suppressed because it is too large Load Diff

View File

@ -14,16 +14,16 @@
*/
/* globals Components, PdfjsContentUtils, PdfJs, Services */
'use strict';
"use strict";
/*
* pdfjschildbootstrap.js loads into the content process to take care of
* initializing our built-in version of pdfjs when running remote.
*/
Components.utils.import('resource://gre/modules/Services.jsm');
Components.utils.import('resource://pdf.js/PdfJs.jsm');
Components.utils.import('resource://pdf.js/PdfjsContentUtils.jsm');
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://pdf.js/PdfJs.jsm");
Components.utils.import("resource://pdf.js/PdfjsContentUtils.jsm");
// init content utils shim pdfjs will use to access privileged apis.
PdfjsContentUtils.init();

View File

@ -1,17 +1,17 @@
'use strict';
"use strict";
// Small subset of the webL10n API by Fabien Cazenave for pdf.js extension.
(function(window) {
var gLanguage = '';
var gLanguage = "";
var gExternalLocalizerServices = null;
var gReadyState = 'loading';
var gReadyState = "loading";
// fetch an l10n objects
function getL10nData(key) {
var response = gExternalLocalizerServices.getStrings(key);
var data = JSON.parse(response);
if (!data) {
console.warn('[l10n] #' + key + ' missing for [' + gLanguage + ']');
console.warn("[l10n] #" + key + " missing for [" + gLanguage + "]");
}
return data;
}
@ -22,25 +22,25 @@
return text;
}
return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function(all, name) {
return (name in args ? args[name] : '{{' + name + '}}');
return (name in args ? args[name] : "{{" + name + "}}");
});
}
// translate a string
function translateString(key, args, fallback) {
var i = key.lastIndexOf('.');
var i = key.lastIndexOf(".");
var name, property;
if (i >= 0) {
name = key.substring(0, i);
property = key.substring(i + 1);
} else {
name = key;
property = 'textContent';
property = "textContent";
}
var data = getL10nData(name);
var value = (data && data[property]) || fallback;
if (!value) {
return '{{' + key + '}}';
return "{{" + key + "}}";
}
return substArguments(value, args);
}
@ -65,7 +65,7 @@
try {
args = JSON.parse(element.dataset.l10nArgs);
} catch (e) {
console.warn('[l10n] could not parse arguments for #' + key + '');
console.warn("[l10n] could not parse arguments for #" + key + "");
}
}
@ -79,10 +79,10 @@
// translate an HTML subtree
function translateFragment(element) {
element = element || document.querySelector('html');
element = element || document.querySelector("html");
// check all translatable children (= w/ a `data-l10n-id' attribute)
var children = element.querySelectorAll('*[data-l10n-id]');
var children = element.querySelectorAll("*[data-l10n-id]");
var elementCount = children.length;
for (var i = 0; i < elementCount; i++) {
translateElement(children[i]);
@ -99,16 +99,16 @@
translateFragment();
gReadyState = 'complete';
gReadyState = "complete";
// fire a 'localized' DOM event
var evtObject = document.createEvent('Event');
evtObject.initEvent('localized', false, false);
var evtObject = document.createEvent("Event");
evtObject.initEvent("localized", false, false);
evtObject.language = gLanguage;
window.dispatchEvent(evtObject);
}
window.addEventListener('DOMContentLoaded', function() {
window.addEventListener("DOMContentLoaded", function() {
if (gExternalLocalizerServices) {
translateDocument();
}
@ -129,12 +129,12 @@
getDirection() {
// http://www.w3.org/International/questions/qa-scripts
// Arabic, Hebrew, Farsi, Pashto, Urdu
var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
var rtlList = ["ar", "he", "fa", "ps", "ur"];
// use the short language code for "full" codes like 'ar-sa' (issue 5440)
var shortCode = gLanguage.split('-')[0];
var shortCode = gLanguage.split("-")[0];
return (rtlList.indexOf(shortCode) >= 0) ? 'rtl' : 'ltr';
return (rtlList.indexOf(shortCode) >= 0) ? "rtl" : "ltr";
},
getReadyState() {
@ -145,8 +145,8 @@
gExternalLocalizerServices = externalLocalizerServices;
// ... in case if we missed DOMContentLoaded above.
if (window.document.readyState === 'interactive' ||
window.document.readyState === 'complete') {
if (window.document.readyState === "interactive" ||
window.document.readyState === "complete") {
translateDocument();
}
},

View File

@ -620,7 +620,7 @@ var pktUIMessaging = (function() {
callback(panelId, data, nodePrincipal);
// Cleanup the element
e.target.parentNode.removeChild(e.target);
e.target.remove();
}, false, true);
}

View File

@ -73,9 +73,9 @@ this.shutdown = function(data, reason) {
}
const modules = [
"data/EventEmitter.js",
"lib/CleanupManager.jsm",
"lib/EnvExpressions.jsm",
"lib/EventEmitter.jsm",
"lib/Heartbeat.jsm",
"lib/LogManager.jsm",
"lib/NormandyApi.jsm",

View File

@ -1,34 +1,39 @@
/* 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/. */
// This file is meant to run inside action sandboxes
"use strict";
const {utils: Cu} = Components;
Cu.import("resource://shield-recipe-client/lib/LogManager.jsm");
this.EventEmitter = function(driver) {
if (!driver) {
throw new Error("driver must be provided");
}
this.EXPORTED_SYMBOLS = ["EventEmitter"];
const log = LogManager.getLogger("event-emitter");
this.EventEmitter = function(sandboxManager) {
const listeners = {};
return {
createSandboxedEmitter() {
return sandboxManager.cloneInto({
on: this.on.bind(this),
off: this.off.bind(this),
once: this.once.bind(this),
}, {cloneFunctions: true});
},
emit(eventName, event) {
// Fire events async
Promise.resolve()
.then(() => {
if (!(eventName in listeners)) {
driver.log(`EventEmitter: Event fired with no listeners: ${eventName}`);
log.info(`EventEmitter: Event fired with no listeners: ${eventName}`);
return;
}
// freeze event to prevent handlers from modifying it
const frozenEvent = Object.freeze(event);
// Clone callbacks array to avoid problems with mutation while iterating
const callbacks = Array.from(listeners[eventName]);
for (const cb of callbacks) {
cb(frozenEvent);
cb(sandboxManager.cloneInto(event));
}
});
},

View File

@ -10,6 +10,7 @@ Cu.import("resource://gre/modules/Preferences.jsm");
Cu.import("resource://gre/modules/TelemetryController.jsm");
Cu.import("resource://gre/modules/Timer.jsm"); /* globals setTimeout, clearTimeout */
Cu.import("resource://shield-recipe-client/lib/CleanupManager.jsm");
Cu.import("resource://shield-recipe-client/lib/EventEmitter.jsm");
Cu.import("resource://shield-recipe-client/lib/LogManager.jsm");
Cu.importGlobalProperties(["URL"]); /* globals URL */
@ -25,8 +26,6 @@ const NOTIFICATION_TIME = 3000;
*
* @param chromeWindow
* The chrome window that the heartbeat notification is displayed in.
* @param eventEmitter
* An EventEmitter instance to report status to.
* @param sandboxManager
* The manager for the sandbox this was called from. Heartbeat will
* increment the hold counter on the manager.
@ -56,7 +55,7 @@ const NOTIFICATION_TIME = 3000;
* The url to visit after the user answers the question.
*/
this.Heartbeat = class {
constructor(chromeWindow, eventEmitter, sandboxManager, options) {
constructor(chromeWindow, sandboxManager, options) {
if (typeof options.flowId !== "string") {
throw new Error("flowId must be a string");
}
@ -92,7 +91,7 @@ this.Heartbeat = class {
}
this.chromeWindow = chromeWindow;
this.eventEmitter = eventEmitter;
this.eventEmitter = new EventEmitter(sandboxManager);
this.sandboxManager = sandboxManager;
this.options = options;
this.surveyResults = {};
@ -261,7 +260,7 @@ this.Heartbeat = class {
data.timestamp = timestamp;
data.flowId = this.options.flowId;
this.eventEmitter.emit(name, Cu.cloneInto(data, this.sandboxManager.sandbox));
this.eventEmitter.emit(name, data);
if (sendPing) {
// Send the ping to Telemetry
@ -279,7 +278,7 @@ this.Heartbeat = class {
});
// only for testing
this.eventEmitter.emit("TelemetrySent", Cu.cloneInto(payload, this.sandboxManager.sandbox));
this.eventEmitter.emit("TelemetrySent", payload);
// Survey is complete, clear out the expiry timer & survey configuration
this.endTimerIfPresent("surveyEndTimer");

Some files were not shown because too many files have changed in this diff Show More