merge m-c to fx-team

This commit is contained in:
Tim Taubert 2011-11-01 13:23:20 +01:00
commit 2e1a3af9d9
58 changed files with 6296 additions and 511 deletions

View File

@ -54,6 +54,10 @@ pref("browser.hiddenWindowChromeURL", "chrome://browser/content/hiddenWindow.xul
// Enables some extra Extension System Logging (can reduce performance)
pref("extensions.logging.enabled", false);
// Enables strict compatibility. To be toggled in bug 698653, to make addons
// compatibile by default.
pref("extensions.strictCompatibility", true);
// Preferences for AMO integration
pref("extensions.getAddons.cache.enabled", true);
pref("extensions.getAddons.maxResults", 15);

View File

@ -866,6 +866,7 @@ function test() {
waitForExplicitFinish();
Services.prefs.setBoolPref("extensions.logging.enabled", true);
Services.prefs.setBoolPref("extensions.strictCompatibility", true);
Services.obs.addObserver(XPInstallObserver, "addon-install-started", false);
Services.obs.addObserver(XPInstallObserver, "addon-install-blocked", false);
@ -884,6 +885,7 @@ function test() {
});
Services.prefs.clearUserPref("extensions.logging.enabled");
Services.prefs.clearUserPref("extensions.strictCompatibility");
Services.obs.removeObserver(XPInstallObserver, "addon-install-started");
Services.obs.removeObserver(XPInstallObserver, "addon-install-blocked");

View File

@ -49,6 +49,7 @@ copy({
ORION_EDITOR + "/orion/textview/rulers.js",
ORION_EDITOR + "/orion/textview/undoStack.js",
ORION_EDITOR + "/orion/textview/textModel.js",
ORION_EDITOR + "/orion/textview/tooltip.js",
ORION_EDITOR + "/orion/textview/textView.js",
ORION_EDITOR + "/orion/editor/htmlGrammar.js",
ORION_EDITOR + "/orion/editor/textMateStyler.js",

View File

@ -8,8 +8,20 @@ The Orion editor web site: http://www.eclipse.org/orion
To upgrade Orion to a newer version see the UPGRADE file.
Orion version: git clone from 2011-10-07
commit hash eedba6403b6dff4536bc0469d31126c3485deb56
Orion version: git clone from 2011-10-26
commit hash 0ab295660e1f7d33ca2bfb8558b3b7492d2c5aa5
+ patch for Eclipse Bug 358623 - Drag and Drop support:
https://github.com/mihaisucan/orion.client/tree/bug-358623
see https://bugs.eclipse.org/bugs/show_bug.cgi?id=358623
+ patch for Eclipse Bug 362286 - Monaco font line height:
https://github.com/mihaisucan/orion.client/tree/bug-362286
see https://bugs.eclipse.org/bugs/show_bug.cgi?id=362286
+ patch for Eclipse Bug 362107 - Ctrl-Up/Down failure on Linux:
https://github.com/mihaisucan/orion.client/tree/bug-362107
see https://bugs.eclipse.org/bugs/show_bug.cgi?id=362107
+ patch for Eclipse Bug 362428 - _getXToOffset() throws:
https://github.com/mihaisucan/orion.client/tree/bug-362428
see https://bugs.eclipse.org/bugs/show_bug.cgi?id=362428
# License

View File

@ -8,4 +8,6 @@
min-width: 1.4em;
padding-left: 4px;
padding-right: 4px;
text-align: end;
}

View File

@ -34,25 +34,6 @@
}
.rulerLines.even
.rulerLines.odd {
}
/* Styles for the ruler tooltips */
.rulerTooltip {
font-family: monospace;
font-size: 10pt;
background-color: InfoBackground;
color: InfoText;
padding: 2px;
border-radius: 4px;
border: 1px solid black;
z-index: 100;
position: absolute;
overflow: hidden;
white-space: pre;
}
.rulerTooltip em {
font-style: normal;
font-weight: bold;
}.token_singleline_comment {
color: green;
}
@ -138,4 +119,4 @@
.invalid {
color: red;
font-weight: bold;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -46,6 +46,10 @@ include $(topsrcdir)/config/rules.mk
_BROWSER_TEST_FILES = \
browser_sourceeditor_initialization.js \
browser_bug684862_paste_html.js \
browser_bug687573_vscroll.js \
browser_bug687568_pagescroll.js \
browser_bug687580_drag_and_drop.js \
libs:: $(_BROWSER_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)

View File

@ -0,0 +1,114 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
Cu.import("resource:///modules/source-editor.jsm");
let testWin;
let editor;
function test()
{
waitForExplicitFinish();
const pageUrl = "data:text/html,<ul><li>test<li>foobarBug684862";
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
waitForFocus(pageLoaded, content);
}, true);
content.location = pageUrl;
}
function pageLoaded()
{
const windowUrl = "data:application/vnd.mozilla.xul+xml,<?xml version='1.0'?>" +
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
" title='test for bug 684862 - paste HTML' width='600' height='500'>" +
"<script type='application/javascript' src='chrome://global/content/globalOverlay.js'/>" +
"<box flex='1'/></window>";
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
let doCopy = function() {
content.focus();
EventUtils.synthesizeKey("a", {accelKey: true}, content);
EventUtils.synthesizeKey("c", {accelKey: true}, content);
};
let clipboardValidator = function(aData) aData.indexOf("foobarBug684862") > -1;
let onCopy = function() {
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
testWin.addEventListener("load", function onWindowLoad() {
testWin.removeEventListener("load", onWindowLoad, false);
waitForFocus(initEditor, testWin);
}, false);
};
waitForClipboard(clipboardValidator, doCopy, onCopy, testEnd);
}
function initEditor()
{
let box = testWin.document.querySelector("box");
editor = new SourceEditor();
editor.init(box, {}, editorLoaded);
}
function editorLoaded()
{
editor.focus();
ok(!editor.getText(), "editor has no content");
is(editor.getCaretOffset(), 0, "caret location");
let onPaste = function() {
editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onPaste);
let text = editor.getText();
ok(text, "editor has content after paste");
isnot(text.indexOf("foobarBug684862"), -1, "editor content is correct");
executeSoon(function() {
editor.setCaretOffset(4);
EventUtils.synthesizeKey("a", {}, testWin);
EventUtils.synthesizeKey("VK_RIGHT", {}, testWin);
text = editor.getText();
isnot(text.indexOf("foobarBug684862"), -1,
"editor content is correct after navigation");
is(editor.getCaretOffset(), 6, "caret location");
executeSoon(testEnd);
});
};
editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onPaste);
// Do paste
executeSoon(function() {
testWin.goDoCommand("cmd_paste");
});
}
function testEnd()
{
if (editor) {
editor.destroy();
}
if (testWin) {
testWin.close();
}
testWin = editor = null;
gBrowser.removeCurrentTab();
waitForFocus(finish, window);
}

View File

@ -0,0 +1,87 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
Cu.import("resource:///modules/source-editor.jsm");
let testWin;
let editor;
function test()
{
let component = Services.prefs.getCharPref(SourceEditor.PREFS.COMPONENT);
if (component != "orion") {
ok(true, "skip test for bug 687568: only applicable for Orion");
return; // Testing for the fix requires direct Orion API access.
}
waitForExplicitFinish();
const windowUrl = "data:application/vnd.mozilla.xul+xml,<?xml version='1.0'?>" +
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
" title='test for bug 687568 - page scroll' width='600' height='500'>" +
"<box flex='1'/></window>";
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
testWin.addEventListener("load", function onWindowLoad() {
testWin.removeEventListener("load", onWindowLoad, false);
waitForFocus(initEditor, testWin);
}, false);
}
function initEditor()
{
let box = testWin.document.querySelector("box");
editor = new SourceEditor();
editor.init(box, { showLineNumbers: true }, editorLoaded);
}
function editorLoaded()
{
editor.focus();
let view = editor._view;
let model = editor._model;
let lineHeight = view.getLineHeight();
let editorHeight = view.getClientArea().height;
let linesPerPage = Math.floor(editorHeight / lineHeight);
let totalLines = 3 * linesPerPage;
let text = "";
for (let i = 0; i < totalLines; i++) {
text += "l" + i + "\n";
}
editor.setText(text);
editor.setCaretOffset(0);
EventUtils.synthesizeKey("VK_DOWN", {shiftKey: true}, testWin);
EventUtils.synthesizeKey("VK_DOWN", {shiftKey: true}, testWin);
EventUtils.synthesizeKey("VK_DOWN", {shiftKey: true}, testWin);
let bottomLine = view.getBottomIndex(true);
view.setTopIndex(bottomLine + 1);
executeSoon(function() {
EventUtils.synthesizeKey("VK_PAGE_DOWN", {shiftKey: true}, testWin);
executeSoon(function() {
let topLine = view.getTopIndex(true);
let topLineOffset = model.getLineStart(topLine);
let selection = editor.getSelection();
ok(selection.start < topLineOffset && topLineOffset < selection.end,
"top visible line is selected");
editor.destroy();
testWin.close();
testWin = editor = null;
waitForFocus(finish, window);
});
});
}

View File

@ -0,0 +1,131 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
Cu.import("resource:///modules/source-editor.jsm");
let testWin;
let editor;
function test()
{
let component = Services.prefs.getCharPref(SourceEditor.PREFS.COMPONENT);
if (component == "textarea") {
ok(true, "skip test for bug 687573: not applicable for TEXTAREAs");
return; // TEXTAREAs have different behavior
}
waitForExplicitFinish();
const windowUrl = "data:application/vnd.mozilla.xul+xml,<?xml version='1.0'?>" +
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
" title='test for bug 687573 - vertical scroll' width='300' height='500'>" +
"<box flex='1'/></window>";
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
testWin.addEventListener("load", function onWindowLoad() {
testWin.removeEventListener("load", onWindowLoad, false);
waitForFocus(initEditor, testWin);
}, false);
}
function initEditor()
{
let box = testWin.document.querySelector("box");
let text = "abba\n" +
"\n" +
"abbaabbaabbaabbaabbaabbaabbaabbaabbaabba\n" +
"abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba\n" +
"abbaabbaabbaabbaabbaabbaabbaabbaabbaabba\n" +
"\n" +
"abba\n";
let config = {
showLineNumbers: true,
placeholderText: text,
};
editor = new SourceEditor();
editor.init(box, config, editorLoaded);
}
function editorLoaded()
{
let VK_LINE_END = "VK_END";
let VK_LINE_END_OPT = {};
let OS = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS;
if (OS == "Darwin") {
VK_LINE_END = "VK_RIGHT";
VK_LINE_END_OPT = {accelKey: true};
}
editor.focus();
editor.setCaretOffset(0);
is(editor.getCaretOffset(), 0, "caret location at start");
EventUtils.synthesizeKey("VK_DOWN", {}, testWin);
EventUtils.synthesizeKey("VK_DOWN", {}, testWin);
// line 3
is(editor.getCaretOffset(), 6, "caret location, keypress Down two times, line 3");
// line 3 end
EventUtils.synthesizeKey(VK_LINE_END, VK_LINE_END_OPT, testWin);
is(editor.getCaretOffset(), 46, "caret location, keypress End, line 3 end");
// line 4
EventUtils.synthesizeKey("VK_DOWN", {}, testWin);
is(editor.getCaretOffset(), 87, "caret location, keypress Down, line 4");
// line 4 end
EventUtils.synthesizeKey(VK_LINE_END, VK_LINE_END_OPT, testWin);
is(editor.getCaretOffset(), 135, "caret location, keypress End, line 4 end");
// line 5 end
EventUtils.synthesizeKey("VK_DOWN", {}, testWin);
is(editor.getCaretOffset(), 176, "caret location, keypress Down, line 5 end");
// line 6 end
EventUtils.synthesizeKey("VK_DOWN", {}, testWin);
is(editor.getCaretOffset(), 177, "caret location, keypress Down, line 6 end");
// The executeSoon() calls are needed to allow reflows...
EventUtils.synthesizeKey("VK_UP", {}, testWin);
executeSoon(function() {
// line 5 end
is(editor.getCaretOffset(), 176, "caret location, keypress Up, line 5 end");
EventUtils.synthesizeKey("VK_UP", {}, testWin);
executeSoon(function() {
// line 4 end
is(editor.getCaretOffset(), 135, "caret location, keypress Up, line 4 end");
// line 3 end
EventUtils.synthesizeKey("VK_UP", {}, testWin);
is(editor.getCaretOffset(), 46, "caret location, keypress Up, line 3 end");
// line 2 end
EventUtils.synthesizeKey("VK_UP", {}, testWin);
is(editor.getCaretOffset(), 5, "caret location, keypress Up, line 2 end");
// line 3 end
EventUtils.synthesizeKey("VK_DOWN", {}, testWin);
is(editor.getCaretOffset(), 46, "caret location, keypress Down, line 3 end");
// line 4 end
EventUtils.synthesizeKey("VK_DOWN", {}, testWin);
is(editor.getCaretOffset(), 135, "caret location, keypress Down, line 4 end");
editor.destroy();
testWin.close();
testWin = editor = null;
waitForFocus(finish, window);
});
});
}

View File

@ -0,0 +1,159 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
Cu.import("resource:///modules/source-editor.jsm");
let testWin;
let editor;
function test()
{
let component = Services.prefs.getCharPref(SourceEditor.PREFS.COMPONENT);
if (component != "orion") {
ok(true, "skip test for bug 687580: only applicable for Orion");
return; // Testing for the fix requires direct Orion API access.
}
waitForExplicitFinish();
const windowUrl = "data:application/vnd.mozilla.xul+xml,<?xml version='1.0'?>" +
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
" title='test for bug 687580 - drag and drop' width='600' height='500'>" +
"<box flex='1'/></window>";
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
testWin.addEventListener("load", function onWindowLoad() {
testWin.removeEventListener("load", onWindowLoad, false);
waitForFocus(initEditor, testWin);
}, false);
}
function initEditor()
{
let box = testWin.document.querySelector("box");
editor = new SourceEditor();
editor.init(box, {}, editorLoaded);
}
function editorLoaded()
{
editor.focus();
let view = editor._view;
let model = editor._model;
let lineHeight = view.getLineHeight();
let editorHeight = view.getClientArea().height;
let linesPerPage = Math.floor(editorHeight / lineHeight);
let totalLines = 2 * linesPerPage;
let text = "foobarBug687580-";
for (let i = 0; i < totalLines; i++) {
text += "l" + i + "\n";
}
editor.setText(text);
editor.setCaretOffset(0);
let bottomPixel = view.getBottomPixel();
EventUtils.synthesizeKey("VK_DOWN", {shiftKey: true}, testWin);
EventUtils.synthesizeKey("VK_DOWN", {shiftKey: true}, testWin);
EventUtils.synthesizeKey("VK_DOWN", {shiftKey: true}, testWin);
let initialSelection = editor.getSelection();
let ds = Cc["@mozilla.org/widget/dragservice;1"].
getService(Ci.nsIDragService);
let target = view._dragNode;
let targetWin = target.ownerDocument.defaultView;
let dataTransfer = null;
let onDragStart = function(aEvent) {
target.removeEventListener("dragstart", onDragStart, false);
dataTransfer = aEvent.dataTransfer;
ok(dataTransfer, "dragstart event fired");
ok(dataTransfer.types.contains("text/plain"),
"dataTransfer text/plain available");
let text = dataTransfer.getData("text/plain");
isnot(text.indexOf("foobarBug687580"), -1, "text/plain data is correct");
dataTransfer.dropEffect = "move";
};
let onDrop = executeSoon.bind(null, function() {
target.removeEventListener("drop", onDrop, false);
let selection = editor.getSelection();
is(selection.start, selection.end, "selection is collapsed");
is(editor.getText(0, 2), "l3", "drag and drop worked");
let offset = editor.getCaretOffset();
ok(offset > initialSelection.end, "new caret location");
let initialLength = initialSelection.end - initialSelection.start;
let dropText = editor.getText(offset - initialLength, offset);
isnot(dropText.indexOf("foobarBug687580"), -1, "drop text is correct");
editor.destroy();
testWin.close();
testWin = editor = null;
waitForFocus(finish, window);
});
executeSoon(function() {
ds.startDragSession();
target.addEventListener("dragstart", onDragStart, false);
target.addEventListener("drop", onDrop, false);
EventUtils.synthesizeMouse(target, 10, 10, {type: "mousedown"}, targetWin);
EventUtils.synthesizeMouse(target, 11, bottomPixel - 25, {type: "mousemove"},
targetWin);
EventUtils.synthesizeMouse(target, 12, bottomPixel - 15, {type: "mousemove"},
targetWin);
let clientX = 5;
let clientY = bottomPixel - 10;
let event = targetWin.document.createEvent("DragEvents");
event.initDragEvent("dragenter", true, true, targetWin, 0, 0, 0, clientX,
clientY, false, false, false, false, 0, null,
dataTransfer);
target.dispatchEvent(event);
event = targetWin.document.createEvent("DragEvents");
event.initDragEvent("dragover", true, true, targetWin, 0, 0, 0, clientX + 1,
clientY + 2, false, false, false, false, 0, null,
dataTransfer);
target.dispatchEvent(event);
EventUtils.synthesizeMouse(target, clientX + 2, clientY + 1,
{type: "mouseup"}, targetWin);
event = targetWin.document.createEvent("DragEvents");
event.initDragEvent("drop", true, true, targetWin, 0, 0, 0, clientX + 2,
clientY + 3, false, false, false, false, 0, null,
dataTransfer);
target.dispatchEvent(event);
event = targetWin.document.createEvent("DragEvents");
event.initDragEvent("dragend", true, true, targetWin, 0, 0, 0, clientX + 3,
clientY + 2, false, false, false, false, 0, null,
dataTransfer);
target.dispatchEvent(event);
ds.endDragSession(true);
});
}

View File

@ -174,6 +174,8 @@ function editorLoaded()
EventUtils.synthesizeKey("VK_TAB", {shiftKey: true}, testWin);
is(editor.getText(), " a\n b\n c", "lines outdented (shift-tab)");
testEclipseBug362107();
testBug687577();
testBackspaceKey();
testReturnKey();
}
@ -396,3 +398,66 @@ function testClipboardEvents()
waitForClipboard("foobar", doCut, onCut, testEnd);
}
function testEclipseBug362107()
{
// Test for Eclipse Bug 362107:
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=362107
let OS = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS;
if (OS != "Linux") {
return;
}
editor.setText("line 1\nline 2\nline 3");
editor.setCaretOffset(16);
EventUtils.synthesizeKey("VK_UP", {ctrlKey: true}, testWin);
is(editor.getCaretOffset(), 7, "Ctrl-Up works");
EventUtils.synthesizeKey("VK_UP", {ctrlKey: true}, testWin);
is(editor.getCaretOffset(), 0, "Ctrl-Up works twice");
EventUtils.synthesizeKey("VK_DOWN", {ctrlKey: true}, testWin);
is(editor.getCaretOffset(), 13, "Ctrl-Down works");
EventUtils.synthesizeKey("VK_DOWN", {ctrlKey: true}, testWin);
is(editor.getCaretOffset(), 20, "Ctrl-Down works twice");
}
function testBug687577()
{
// Test for Mozilla Bug 687577:
// https://bugzilla.mozilla.org/show_bug.cgi?id=687577
let OS = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS;
if (OS != "Linux") {
return;
}
editor.setText("line foobar 1\nline foobar 2\nline foobar 3");
editor.setCaretOffset(39);
EventUtils.synthesizeKey("VK_LEFT", {ctrlKey: true, shiftKey: true}, testWin);
let selection = editor.getSelection();
is(selection.start, 33, "select.start after Ctrl-Shift-Left");
is(selection.end, 39, "select.end after Ctrl-Shift-Left");
EventUtils.synthesizeKey("VK_UP", {ctrlKey: true, shiftKey: true}, testWin);
selection = editor.getSelection();
is(selection.start, 14, "select.start after Ctrl-Shift-Up");
is(selection.end, 39, "select.end after Ctrl-Shift-Up");
EventUtils.synthesizeKey("VK_UP", {ctrlKey: true, shiftKey: true}, testWin);
selection = editor.getSelection();
is(selection.start, 0, "select.start after Ctrl-Shift-Up (again)");
is(selection.end, 39, "select.end after Ctrl-Shift-Up (again)");
EventUtils.synthesizeKey("VK_DOWN", {ctrlKey: true, shiftKey: true}, testWin);
selection = editor.getSelection();
is(selection.start, 27, "select.start after Ctrl-Shift-Down");
is(selection.end, 39, "select.end after Ctrl-Shift-Down");
EventUtils.synthesizeKey("VK_DOWN", {ctrlKey: true, shiftKey: true}, testWin);
selection = editor.getSelection();
is(selection.start, 39, "select.start after Ctrl-Shift-Down (again)");
is(selection.end, 41, "select.end after Ctrl-Shift-Down (again)");
}

View File

@ -48,6 +48,9 @@ const PREF_EM_UPDATE_ENABLED = "extensions.update.enabled";
const PREF_EM_LAST_APP_VERSION = "extensions.lastAppVersion";
const PREF_EM_LAST_PLATFORM_VERSION = "extensions.lastPlatformVersion";
const PREF_EM_AUTOUPDATE_DEFAULT = "extensions.update.autoUpdateDefault";
const PREF_EM_STRICT_COMPATIBILITY = "extensions.strictCompatibility";
const STRICT_COMPATIBILITY_DEFAULT = true;
const VALID_TYPES_REGEXP = /^[\w\-]+$/;
@ -281,6 +284,7 @@ function AddonType(aId, aLocaleURI, aLocaleKey, aViewType, aUIPriority, aFlags)
}
var gStarted = false;
var gStrictCompatibility = STRICT_COMPATIBILITY_DEFAULT;
/**
* This is the real manager, kept here rather than in AddonManager to keep its
@ -374,6 +378,11 @@ var AddonManagerInternal = {
(appChanged === undefined ? 0 : -1));
}
try {
gStrictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY);
} catch (e) {}
Services.prefs.addObserver(PREF_EM_STRICT_COMPATIBILITY, this, false);
// Ensure all default providers have had a chance to register themselves
DEFAULT_PROVIDERS.forEach(function(url) {
try {
@ -495,6 +504,8 @@ var AddonManagerInternal = {
* up everything in order for automated tests to fake restarts.
*/
shutdown: function AMI_shutdown() {
Services.prefs.removeObserver(PREF_EM_STRICT_COMPATIBILITY, this);
this.providers.forEach(function(provider) {
callProvider(provider, "shutdown");
});
@ -507,6 +518,31 @@ var AddonManagerInternal = {
gStarted = false;
},
/**
* Notified when a preference we're interested in has changed.
*
* @see nsIObserver
*/
observe: function AMI_observe(aSubject, aTopic, aData) {
switch (aData) {
case PREF_EM_STRICT_COMPATIBILITY:
let oldValue = gStrictCompatibility;
try {
gStrictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY);
} catch(e) {
gStrictCompatibility = STRICT_COMPATIBILITY_DEFAULT;
}
// XXXunf Currently, this won't notify listeners that an addon's
// compatibility status has changed if the addon's appDisabled state
// doesn't change.
if (gStrictCompatibility != oldValue)
this.updateAddonAppDisabledStates();
break;
}
},
/**
* Performs a background update check by starting an update for all add-ons
* that can be updated.
@ -1095,6 +1131,10 @@ var AddonManagerInternal = {
return Services.prefs.getBoolPref(PREF_EM_AUTOUPDATE_DEFAULT);
} catch(e) { }
return true;
},
get strictCompatibility() {
return gStrictCompatibility;
}
};
@ -1415,6 +1455,10 @@ var AddonManager = {
if (aAddon.applyBackgroundUpdates == AddonManager.AUTOUPDATE_DISABLE)
return false;
return this.autoUpdateDefault;
},
get strictCompatibility() {
return AddonManagerInternal.strictCompatibility;
}
};

View File

@ -0,0 +1,192 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Extension Manager.
*
* The Initial Developer of the Original Code is
* the Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Blair McBride <bmcbride@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
"use strict";
var EXPORTED_SYMBOLS = ["ChromeManifestParser"];
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
const MSG_JAR_FLUSH = "AddonJarFlush";
/**
* Sends local and remote notifications to flush a JAR file cache entry
*
* @param aJarFile
* The ZIP/XPI/JAR file as a nsIFile
*/
function flushJarCache(aJarFile) {
Services.obs.notifyObservers(aJarFile, "flush-cache-entry", null);
Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIChromeFrameMessageManager)
.sendAsyncMessage(MSG_JAR_FLUSH, aJarFile.path);
}
/**
* Parses chrome manifest files.
*/
var ChromeManifestParser = {
/**
* Reads and parses a chrome manifest file located at a specified URI, and all
* secondary manifests it references.
*
* @param aURI
* A nsIURI pointing to a chrome manifest.
* Typically a file: or jar: URI.
* @return Array of objects describing each manifest instruction, in the form:
* { type: instruction-type, baseURI: string-uri, args: [arguments] }
**/
parseSync: function CMP_parseSync(aURI) {
function parseLine(aLine) {
let line = aLine.trim();
if (line.length == 0 || line.charAt(0) == '#')
return;
let tokens = line.split(/\s+/);
let type = tokens.shift();
if (type == "manifest") {
let uri = NetUtil.newURI(tokens.shift(), null, aURI);
data = data.concat(this.parseSync(uri));
} else {
data.push({type: type, baseURI: baseURI, args: tokens});
}
}
let contents = "";
try {
if (aURI.scheme == "jar")
contents = this._readFromJar(aURI);
else
contents = this._readFromFile(aURI);
} catch (e) {
// Silently fail.
}
if (!contents)
return [];
let baseURI = NetUtil.newURI(".", null, aURI).spec;
let data = [];
let lines = contents.split("\n");
lines.forEach(parseLine.bind(this));
return data;
},
_readFromJar: function CMP_readFromJar(aURI) {
let data = "";
let entries = [];
let readers = [];
try {
// Deconstrict URI, which can be nested jar: URIs.
let uri = aURI.clone();
while (uri instanceof Ci.nsIJARURI) {
entries.push(uri.JAREntry);
uri = uri.JARFile;
}
// Open the base jar.
let reader = Cc["@mozilla.org/libjar/zip-reader;1"].
createInstance(Ci.nsIZipReader);
reader.open(uri.QueryInterface(Ci.nsIFileURL).file);
readers.push(reader);
// Open the nested jars.
for (let i = entries.length - 1; i > 0; i--) {
let innerReader = Cc["@mozilla.org/libjar/zip-reader;1"].
createInstance(Ci.nsIZipReader);
innerReader.openInner(reader, entries[i]);
readers.push(innerReader);
reader = innerReader;
}
// First entry is the actual file we want to read.
let zis = reader.getInputStream(entries[0]);
data = NetUtil.readInputStreamToString(zis, zis.available());
}
finally {
// Close readers in reverse order.
for (let i = readers.length - 1; i >= 0; i--) {
readers[i].close();
flushJarCache(readers[i].file);
}
}
return data;
},
_readFromFile: function CMP_readFromFile(aURI) {
let file = aURI.QueryInterface(Ci.nsIFileURL).file;
if (!file.exists() || !file.isFile())
return "";
let data = "";
let fis = Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(Ci.nsIFileInputStream);
try {
fis.init(file, -1, -1, false);
data = NetUtil.readInputStreamToString(fis, fis.available());
} finally {
fis.close();
}
return data;
},
/**
* Detects if there were any instructions of a specified type in a given
* chrome manifest.
*
* @param aManifest
* Manifest data, as returned by ChromeManifestParser.parseSync().
* @param aType
* Instruction type to filter by.
* @return True if any matching instructions were found in the manifest.
*/
hasType: function CMP_hasType(aManifest, aType) {
return aManifest.some(function(aEntry) {
return aEntry.type == aType;
});
}
};

View File

@ -71,6 +71,7 @@ EXTRA_PP_JS_MODULES = \
$(NULL)
EXTRA_JS_MODULES = \
ChromeManifestParser.jsm \
LightweightThemeManager.jsm \
SpellCheckDictionaryBootstrap.js \
$(NULL)

View File

@ -21,6 +21,7 @@
#
# Contributor(s):
# Dave Townsend <dtownsend@oxymoronical.com>
# Blair McBride <bmcbride@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@ -48,6 +49,7 @@ var EXPORTED_SYMBOLS = [];
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/AddonManager.jsm");
Components.utils.import("resource://gre/modules/AddonRepository.jsm");
Components.utils.import("resource://gre/modules/ChromeManifestParser.jsm");
Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm");
Components.utils.import("resource://gre/modules/FileUtils.jsm");
Components.utils.import("resource://gre/modules/NetUtil.jsm");
@ -122,7 +124,7 @@ const TOOLKIT_ID = "toolkit@mozilla.org";
const BRANCH_REGEXP = /^([^\.]+\.[0-9]+[a-z]*).*/gi;
const DB_SCHEMA = 6;
const DB_SCHEMA = 8;
const REQ_VERSION = 2;
#ifdef MOZ_COMPATIBILITY_NIGHTLY
@ -146,7 +148,8 @@ const DB_METADATA = ["installDate", "updateDate", "size", "sourceURI",
"releaseNotesURI", "applyBackgroundUpdates"];
const DB_BOOL_METADATA = ["visible", "active", "userDisabled", "appDisabled",
"pendingUninstall", "bootstrap", "skinnable",
"softDisabled", "foreignInstall"];
"softDisabled", "foreignInstall",
"hasBinaryComponents", "strictCompatibility"];
const BOOTSTRAP_REASONS = {
APP_STARTUP : 1,
@ -704,9 +707,10 @@ function loadManifestFromRDF(aUri, aStream) {
throw new Error("No version in install manifest");
}
// Only read the bootstrapped property for extensions
// Only read the bootstrap and strictCompatibility properties for extensions.
if (addon.type == "extension") {
addon.bootstrap = getRDFProperty(ds, root, "bootstrap") == "true";
addon.strictCompatibility = getRDFProperty(ds, root, "strictCompatibility") == "true";
if (addon.optionsType &&
addon.optionsType != AddonManager.OPTIONS_TYPE_DIALOG &&
addon.optionsType != AddonManager.OPTIONS_TYPE_INLINE &&
@ -724,6 +728,7 @@ function loadManifestFromRDF(aUri, aStream) {
addon.optionsURL = null;
addon.optionsType = null;
addon.aboutURL = null;
addon.strictCompatibility = true;
if (addon.type == "theme") {
if (!addon.internalName)
@ -850,6 +855,13 @@ function loadManifestFromDir(aDir) {
let addon = loadManifestFromRDF(Services.io.newFileURI(file), bis);
addon._sourceBundle = aDir.clone().QueryInterface(Ci.nsILocalFile);
addon.size = getFileSize(aDir);
file = aDir.clone();
file.append("chrome.manifest");
let chromeManifest = ChromeManifestParser.parseSync(Services.io.newFileURI(file));
addon.hasBinaryComponents = ChromeManifestParser.hasType(chromeManifest,
"binary-component");
return addon;
}
finally {
@ -882,6 +894,16 @@ function loadManifestFromZipReader(aZipReader) {
while (entries.hasMore())
addon.size += aZipReader.getEntry(entries.getNext()).realSize;
// Binary components can only be loaded from unpacked addons.
if (addon.unpack) {
uri = buildJarURI(aZipReader.file, "chrome.manifest");
let chromeManifest = ChromeManifestParser.parseSync(uri);
addon.hasBinaryComponents = ChromeManifestParser.hasType(chromeManifest,
"binary-component");
} else {
addon.hasBinaryComponents = false;
}
return addon;
}
finally {
@ -3880,7 +3902,7 @@ const FIELDS_ADDON = "internal_id, id, location, version, type, internalName, "
"userDisabled, appDisabled, pendingUninstall, descriptor, " +
"installDate, updateDate, applyBackgroundUpdates, bootstrap, " +
"skinnable, size, sourceURI, releaseNotesURI, softDisabled, " +
"foreignInstall";
"foreignInstall, hasBinaryComponents, strictCompatibility";
/**
* A helper function to log an SQL error.
@ -4026,7 +4048,8 @@ var XPIDatabase = {
":descriptor, :installDate, :updateDate, " +
":applyBackgroundUpdates, :bootstrap, :skinnable, " +
":size, :sourceURI, :releaseNotesURI, :softDisabled, " +
":foreignInstall)",
":foreignInstall, :hasBinaryComponents, " +
":strictCompatibility)",
addAddonMetadata_addon_locale: "INSERT INTO addon_locale VALUES " +
"(:internal_id, :name, :locale)",
addAddonMetadata_locale: "INSERT INTO locale (name, description, creator, " +
@ -4560,6 +4583,8 @@ var XPIDatabase = {
"size INTEGER, sourceURI TEXT, " +
"releaseNotesURI TEXT, softDisabled INTEGER, " +
"foreignInstall INTEGER, " +
"hasBinaryComponents INTEGER, " +
"strictCompatibility INTEGER, " +
"UNIQUE (id, location)");
this.connection.createTable("targetApplication",
"addon_internal_id INTEGER, " +
@ -6908,6 +6933,13 @@ AddonInternal.prototype = {
if (!app)
return false;
// Only extensions can be compatible by default; themes always use strict
// compatibility checking.
if (this.type == "extension" && !AddonManager.strictCompatibility &&
!this.strictCompatibility && !this.hasBinaryComponents) {
return true;
}
if (!aAppVersion)
aAppVersion = Services.appinfo.version;
if (!aPlatformVersion)
@ -7123,7 +7155,8 @@ function AddonWrapper(aAddon) {
["id", "version", "type", "isCompatible", "isPlatformCompatible",
"providesUpdatesSecurely", "blocklistState", "blocklistURL", "appDisabled",
"softDisabled", "skinnable", "size", "foreignInstall"].forEach(function(aProp) {
"softDisabled", "skinnable", "size", "foreignInstall", "hasBinaryComponents",
"strictCompatibility"].forEach(function(aProp) {
this.__defineGetter__(aProp, function() aAddon[aProp]);
}, this);

View File

@ -0,0 +1,6 @@
content test-addon-1 chrome/content
# comment!
locale test-addon-1 en-US locale/en-US
# commentaire!
locale test-addon-1 fr-FR locale/fr-FR
overlay chrome://browser/content/browser.xul chrome://test-addon-1/content/overlay.xul

View File

@ -0,0 +1,23 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>addon1@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<!-- Front End MetaData -->
<em:name>Test 1</em:name>
<em:description>Test Description</em:description>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>2</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

View File

@ -0,0 +1,7 @@
content test-addon-1 chrome/content
locale test-addon-1 en-US locale/en-US
locale test-addon-1 fr-FR locale/fr-FR
overlay chrome://browser/content/browser.xul chrome://test-addon-1/content/overlay.xul
binary-component components/something.so
manifest thisdoesntexist.manifest

View File

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>addon2@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<!-- Front End MetaData -->
<em:name>Test 2</em:name>
<em:description>Test Description</em:description>
<em:unpack>true</em:unpack>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>2</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

View File

@ -0,0 +1,9 @@
content test-addon-1 chrome/content
locale test-addon-1 en-US locale/en-US
locale test-addon-1 fr-FR locale/fr-FR
overlay chrome://browser/content/browser.xul chrome://test-addon-1/content/overlay.xul
binary-component components/something.so
manifest jar:inner.jar!/nested.manifest

View File

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>addon3@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<!-- Front End MetaData -->
<em:name>Test 3</em:name>
<em:description>Test Description</em:description>
<em:unpack>true</em:unpack>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

View File

@ -0,0 +1,6 @@
content test-addon-1 chrome/content
locale test-addon-1 en-US locale/en-US
locale test-addon-1 fr-FR locale/fr-FR
overlay chrome://browser/content/browser.xul chrome://test-addon-1/content/overlay.xul
manifest components/components.manifest

View File

@ -0,0 +1,2 @@
binary-component mycomponent.dll
manifest other/something.manifest

View File

@ -0,0 +1 @@
binary-component thermalnuclearwar.dll

View File

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>addon4@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<!-- Front End MetaData -->
<em:name>Test 4</em:name>
<em:description>Test Description</em:description>
<em:unpack>true</em:unpack>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

View File

@ -0,0 +1,7 @@
content test-addon-1 chrome/content
locale test-addon-1 en-US locale/en-US
locale test-addon-1 fr-FR locale/fr-FR
overlay chrome://browser/content/browser.xul chrome://test-addon-1/content/overlay.xul
binary-component components/something.so

View File

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>addon5@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<!-- Front End MetaData -->
<em:name>Test 5</em:name>
<em:description>Test Description</em:description>
<em:unpack>false</em:unpack>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>2</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

View File

@ -0,0 +1,6 @@
content test-addon-1 chrome/content
locale test-addon-1 en-US locale/en-US
locale test-addon-1 fr-FR locale/fr-FR
overlay chrome://browser/content/browser.xul chrome://test-addon-1/content/overlay.xul
binary-component components/something.so

View File

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>addon8@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<!-- Front End MetaData -->
<em:name>Test 8</em:name>
<em:description>Test Description</em:description>
<em:unpack>true</em:unpack>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>2</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

View File

@ -7,6 +7,8 @@
const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true);
/**
* Test add-ons:
*

View File

@ -26,6 +26,7 @@ const MANAGER_URI = "about:addons";
const INSTALL_URI = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";
const PREF_LOGGING_ENABLED = "extensions.logging.enabled";
const PREF_SEARCH_MAXRESULTS = "extensions.getAddons.maxResults";
const PREF_STRICT_COMPAT = "extensions.strictCompatibility";
var gPendingTests = [];
var gTestsRun = 0;
@ -44,9 +45,10 @@ registerCleanupFunction(function() {
Services.prefs.clearUserPref(PREF_LOGGING_ENABLED);
try {
Services.prefs.clearUserPref(PREF_SEARCH_MAXRESULTS);
}
catch (e) {
}
} catch (e) {}
try {
Services.prefs.clearUserPref(PREF_STRICT_COMPAT);
} catch (e) {}
Services.prefs.setCharPref(PREF_DISCOVERURL, gDiscoveryURL);
Services.prefs.setCharPref(PREF_UPDATEURL, gUpdateURL);

View File

@ -8,6 +8,9 @@ const AM_Ci = Components.interfaces;
const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
const XULAPPINFO_CID = Components.ID("{c763b610-9d49-455a-bbd2-ede71682a1ac}");
const PREF_EM_CHECK_UPDATE_SECURITY = "extensions.checkUpdateSecurity";
const PREF_EM_STRICT_COMPATIBILITY = "extensions.strictCompatibility";
Components.utils.import("resource://gre/modules/AddonManager.jsm");
Components.utils.import("resource://gre/modules/AddonRepository.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
@ -494,7 +497,7 @@ function createInstallRDF(aData) {
["id", "version", "type", "internalName", "updateURL", "updateKey",
"optionsURL", "optionsType", "aboutURL", "iconURL", "icon64URL",
"skinnable", "bootstrap"].forEach(function(aProp) {
"skinnable", "bootstrap", "strictCompatibility"].forEach(function(aProp) {
if (aProp in aData)
rdf += "<em:" + aProp + ">" + escapeXML(aData[aProp]) + "</em:" + aProp + ">\n";
});
@ -1103,6 +1106,10 @@ Services.prefs.setCharPref("extensions.blocklist.url", "http://127.0.0.1/blockli
// By default ignore bundled add-ons
Services.prefs.setBoolPref("extensions.installDistroAddons", false);
// By default use strict compatibility
Services.prefs.setBoolPref("extensions.strictCompatibility", true);
// Register a temporary directory for the tests.
const gTmpD = gProfD.clone();
gTmpD.append("temp");
@ -1146,4 +1153,12 @@ do_register_cleanup(function() {
do_check_false(testDir.exists());
shutdownManager();
// Clear commonly set prefs.
try {
Services.prefs.clearUserPref(PREF_EM_CHECK_UPDATE_SECURITY);
} catch (e) {}
try {
Services.prefs.clearUserPref(PREF_EM_STRICT_COMPATIBILITY);
} catch (e) {}
});

View File

@ -0,0 +1,108 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Tests ChromeManifestParser.js
Components.utils.import("resource://gre/modules/ChromeManifestParser.jsm");
function run_test() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
startupManager();
installAllFiles([do_get_addon("test_chromemanifest_1"),
do_get_addon("test_chromemanifest_2"),
do_get_addon("test_chromemanifest_3"),
do_get_addon("test_chromemanifest_4")],
function() {
restartManager();
run_test_1();
});
}
function run_test_1() {
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org"],
function([a1, a2, a3, a4]) {
// addon1
let a1Uri = a1.getResourceURI("/").spec;
let expected = [
{type: "content", baseURI: a1Uri, args: ["test-addon-1", "chrome/content"]},
{type: "locale", baseURI: a1Uri, args: ["test-addon-1", "en-US", "locale/en-US"]},
{type: "locale", baseURI: a1Uri, args: ["test-addon-1", "fr-FR", "locale/fr-FR"]},
{type: "overlay", baseURI: a1Uri, args: ["chrome://browser/content/browser.xul", "chrome://test-addon-1/content/overlay.xul"]}
];
let manifestURI = a1.getResourceURI("chrome.manifest");
let manifest = ChromeManifestParser.parseSync(manifestURI);
do_check_true(Array.isArray(manifest));
do_check_eq(manifest.length, expected.length);
for (let i = 0; i < manifest.length; i++) {
do_check_eq(JSON.stringify(manifest[i]), JSON.stringify(expected[i]));
}
// addon2
let a2Uri = a2.getResourceURI("/").spec;
expected = [
{type: "content", baseURI: a2Uri, args: ["test-addon-1", "chrome/content"]},
{type: "locale", baseURI: a2Uri, args: ["test-addon-1", "en-US", "locale/en-US"]},
{type: "locale", baseURI: a2Uri, args: ["test-addon-1", "fr-FR", "locale/fr-FR"]},
{type: "overlay", baseURI: a2Uri, args: ["chrome://browser/content/browser.xul", "chrome://test-addon-1/content/overlay.xul"]},
{type: "binary-component", baseURI: a2Uri, args: ["components/something.so"]}
];
manifestURI = a2.getResourceURI("chrome.manifest");
manifest = ChromeManifestParser.parseSync(manifestURI);
do_check_true(Array.isArray(manifest));
do_check_eq(manifest.length, expected.length);
for (let i = 0; i < manifest.length; i++) {
do_check_eq(JSON.stringify(manifest[i]), JSON.stringify(expected[i]));
}
// addon3
let a3Uri = a3.getResourceURI("/").spec;
expected = [
{type: "content", baseURI: a3Uri, args: ["test-addon-1", "chrome/content"]},
{type: "locale", baseURI: a3Uri, args: ["test-addon-1", "en-US", "locale/en-US"]},
{type: "locale", baseURI: a3Uri, args: ["test-addon-1", "fr-FR", "locale/fr-FR"]},
{type: "overlay", baseURI: a3Uri, args: ["chrome://browser/content/browser.xul", "chrome://test-addon-1/content/overlay.xul"]},
{type: "binary-component", baseURI: a3Uri, args: ["components/something.so"]},
{type: "locale", baseURI: "jar:" + a3.getResourceURI("/inner.jar").spec + "!/", args: ["test-addon-1", "en-NZ", "locale/en-NZ"]},
];
manifestURI = a3.getResourceURI("chrome.manifest");
manifest = ChromeManifestParser.parseSync(manifestURI);
do_check_true(Array.isArray(manifest));
do_check_eq(manifest.length, expected.length);
for (let i = 0; i < manifest.length; i++) {
do_check_eq(JSON.stringify(manifest[i]), JSON.stringify(expected[i]));
}
// addon4
let a4Uri = a4.getResourceURI("/").spec;
expected = [
{type: "content", baseURI: a4Uri, args: ["test-addon-1", "chrome/content"]},
{type: "locale", baseURI: a4Uri, args: ["test-addon-1", "en-US", "locale/en-US"]},
{type: "locale", baseURI: a4Uri, args: ["test-addon-1", "fr-FR", "locale/fr-FR"]},
{type: "overlay", baseURI: a4Uri, args: ["chrome://browser/content/browser.xul", "chrome://test-addon-1/content/overlay.xul"]},
{type: "binary-component", baseURI: a4.getResourceURI("components/").spec, args: ["mycomponent.dll"]},
{type: "binary-component", baseURI: a4.getResourceURI("components/other/").spec, args: ["thermalnuclearwar.dll"]}
];
manifestURI = a4.getResourceURI("chrome.manifest");
manifest = ChromeManifestParser.parseSync(manifestURI);
do_check_true(Array.isArray(manifest));
do_check_eq(manifest.length, expected.length);
for (let i = 0; i < manifest.length; i++) {
do_check_eq(JSON.stringify(manifest[i]), JSON.stringify(expected[i]));
}
do_test_finished();
});
}

View File

@ -37,7 +37,8 @@
*/
// Disables security checking our updates which haven't been signed
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
var ADDONS = [
"test_bug470377_1",
@ -70,8 +71,8 @@ function run_test() {
"bug470377_5@tests.mozilla.org"],
function([a1, a2, a3, a4, a5]) {
do_check_eq(a1, null);
do_check_eq(a2, null);
do_check_eq(a3, null);
do_check_neq(a2, null);
do_check_neq(a3, null);
do_check_neq(a4, null);
do_check_neq(a5, null);

View File

@ -0,0 +1,82 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Dave Townsend <dtownsend@oxymoronical.com>.
*
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL
*
* ***** END LICENSE BLOCK *****
*/
// Disables security checking our updates which haven't been signed
Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, true);
var ADDONS = [
"test_bug470377_1",
"test_bug470377_2",
"test_bug470377_3",
"test_bug470377_4",
"test_bug470377_5",
];
do_load_httpd_js();
var server;
function run_test() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
server = new nsHttpServer();
server.registerDirectory("/", do_get_file("data/test_bug470377"));
server.start(4444);
startupManager();
installAllFiles([do_get_addon(a) for each (a in ADDONS)], function() {
restartManager();
AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org",
"bug470377_2@tests.mozilla.org",
"bug470377_3@tests.mozilla.org",
"bug470377_4@tests.mozilla.org",
"bug470377_5@tests.mozilla.org"],
function([a1, a2, a3, a4, a5]) {
do_check_eq(a1, null);
do_check_eq(a2, null);
do_check_eq(a3, null);
do_check_neq(a4, null);
do_check_neq(a5, null);
server.stop(do_test_finished);
});
}, true);
}

View File

@ -36,6 +36,8 @@
* ***** END LICENSE BLOCK *****
*/
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
function run_test() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2.2.3", "2");
@ -87,9 +89,9 @@ function run_test_1() {
do_check_neq(a1, null);
do_check_false(a1.isActive);
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.isActive);
do_check_neq(a3, null);
do_check_false(a3.isActive);
do_check_true(a3.isActive);
do_check_neq(a4, null);
do_check_true(a4.isActive);
do_check_neq(a5, null);

View File

@ -0,0 +1,140 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Dave Townsend <dtownsend@oxymoronical.com>.
*
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL
*
* ***** END LICENSE BLOCK *****
*/
function run_test() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2.2.3", "2");
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, true);
// inject the add-ons into the profile
var dest = gProfD.clone();
dest.append("extensions");
dest.append("bug470377_1@tests.mozilla.org");
dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
var source = do_get_file("data/test_bug470377/install_1.rdf");
source.copyTo(dest, "install.rdf");
dest = gProfD.clone();
dest.append("extensions");
dest.append("bug470377_2@tests.mozilla.org");
dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source = do_get_file("data/test_bug470377/install_2.rdf");
source.copyTo(dest, "install.rdf");
dest = gProfD.clone();
dest.append("extensions");
dest.append("bug470377_3@tests.mozilla.org");
dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source = do_get_file("data/test_bug470377/install_3.rdf");
source.copyTo(dest, "install.rdf");
dest = gProfD.clone();
dest.append("extensions");
dest.append("bug470377_4@tests.mozilla.org");
dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source = do_get_file("data/test_bug470377/install_4.rdf");
source.copyTo(dest, "install.rdf");
dest = gProfD.clone();
dest.append("extensions");
dest.append("bug470377_5@tests.mozilla.org");
dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source = do_get_file("data/test_bug470377/install_5.rdf");
source.copyTo(dest, "install.rdf");
startupManager();
run_test_1();
}
function run_test_1() {
AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org",
"bug470377_2@tests.mozilla.org",
"bug470377_3@tests.mozilla.org",
"bug470377_4@tests.mozilla.org",
"bug470377_5@tests.mozilla.org"],
function([a1, a2, a3, a4, a5]) {
do_check_neq(a1, null);
do_check_false(a1.isActive);
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_neq(a3, null);
do_check_false(a3.isActive);
do_check_neq(a4, null);
do_check_true(a4.isActive);
do_check_neq(a5, null);
do_check_true(a5.isActive);
run_test_2();
});
}
function run_test_2() {
// Disable compatibility checks
var channel = "default";
try {
channel = Services.prefs.getCharPref("app.update.channel");
}
catch (e) { }
if (channel != "aurora" &&
channel != "beta" &&
channel != "release") {
Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false);
}
else {
Services.prefs.setBoolPref("extensions.checkCompatibility.2.2", false);
}
restartManager();
AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org",
"bug470377_2@tests.mozilla.org",
"bug470377_3@tests.mozilla.org",
"bug470377_4@tests.mozilla.org",
"bug470377_5@tests.mozilla.org"],
function([a1, a2, a3, a4, a5]) {
do_check_neq(a1, null);
do_check_false(a1.isActive);
do_check_neq(a2, null);
do_check_true(a2.isActive);
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_neq(a4, null);
do_check_true(a4.isActive);
do_check_neq(a5, null);
do_check_true(a5.isActive);
do_test_finished();
});
}

View File

@ -9,7 +9,8 @@ do_load_httpd_js();
var testserver;
// The test extension uses an insecure update url.
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
// Will be enabled
var addon1 = {
@ -35,7 +36,7 @@ var addon2 = {
}]
};
// Will get a compatibility update and be enabled
// Will get a compatibility update and stay enabled
var addon3 = {
id: "addon3@tests.mozilla.org",
version: "1.0",
@ -48,7 +49,7 @@ var addon3 = {
}]
};
// Will get a compatibility update and be disabled
// Will get a compatibility update and be enabled
var addon4 = {
id: "addon4@tests.mozilla.org",
version: "1.0",
@ -61,7 +62,7 @@ var addon4 = {
}]
};
// Stays incompatible
// Would stay incompatible with strict compat
var addon5 = {
id: "addon5@tests.mozilla.org",
version: "1.0",
@ -217,9 +218,9 @@ function run_test_1() {
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a6, null);
@ -285,21 +286,23 @@ function run_test_1() {
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_true(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_DISABLE);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
// The compatibility update won't be recovered and it will not have been
// able to tell that it was previously userDisabled
// The compatibility update won't be recovered and with strict
// compatibility it would not have been able to tell that it was
// previously userDisabled. However, without strict compat, it wasn't
// appDisabled, so it knows it must have been userDisabled.
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_false(a4.userDisabled);
do_check_true(a4.appDisabled);
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a6, null);
@ -354,21 +357,21 @@ function run_test_1() {
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a3, null);
do_check_false(a3.isActive);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_true(a3.appDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_false(a4.userDisabled);
do_check_true(a4.appDisabled);
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a6, null);

View File

@ -0,0 +1,403 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Checks that we rebuild something sensible from a corrupt database
do_load_httpd_js();
var testserver;
// The test extension uses an insecure update url.
Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, true);
// Will be enabled
var addon1 = {
id: "addon1@tests.mozilla.org",
version: "1.0",
name: "Test 1",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "2",
maxVersion: "2"
}]
};
// Will be disabled
var addon2 = {
id: "addon2@tests.mozilla.org",
version: "1.0",
name: "Test 2",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "2",
maxVersion: "2"
}]
};
// Will get a compatibility update and be enabled
var addon3 = {
id: "addon3@tests.mozilla.org",
version: "1.0",
name: "Test 3",
updateURL: "http://localhost:4444/data/test_corrupt.rdf",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}]
};
// Will get a compatibility update and be disabled
var addon4 = {
id: "addon4@tests.mozilla.org",
version: "1.0",
name: "Test 4",
updateURL: "http://localhost:4444/data/test_corrupt.rdf",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}]
};
// Stays incompatible
var addon5 = {
id: "addon5@tests.mozilla.org",
version: "1.0",
name: "Test 5",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}]
};
// Enabled bootstrapped
var addon6 = {
id: "addon6@tests.mozilla.org",
version: "1.0",
name: "Test 6",
bootstrap: "true",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "2",
maxVersion: "2"
}]
};
// Disabled bootstrapped
var addon7 = {
id: "addon7@tests.mozilla.org",
version: "1.0",
name: "Test 7",
bootstrap: "true",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "2",
maxVersion: "2"
}]
};
// The default theme
var theme1 = {
id: "theme1@tests.mozilla.org",
version: "1.0",
name: "Theme 1",
internalName: "classic/1.0",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "2",
maxVersion: "2"
}]
};
// The selected theme
var theme2 = {
id: "theme2@tests.mozilla.org",
version: "1.0",
name: "Theme 2",
internalName: "test/1.0",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "2",
maxVersion: "2"
}]
};
const profileDir = gProfD.clone();
profileDir.append("extensions");
function run_test() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
writeInstallRDFForExtension(addon1, profileDir);
writeInstallRDFForExtension(addon2, profileDir);
writeInstallRDFForExtension(addon3, profileDir);
writeInstallRDFForExtension(addon4, profileDir);
writeInstallRDFForExtension(addon5, profileDir);
writeInstallRDFForExtension(addon6, profileDir);
writeInstallRDFForExtension(addon7, profileDir);
writeInstallRDFForExtension(theme1, profileDir);
writeInstallRDFForExtension(theme2, profileDir);
// Create and configure the HTTP server.
testserver = new nsHttpServer();
testserver.registerDirectory("/addons/", do_get_file("addons"));
testserver.registerDirectory("/data/", do_get_file("data"));
testserver.start(4444);
// Startup the profile and setup the initial state
startupManager();
AddonManager.getAddonsByIDs(["addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon7@tests.mozilla.org",
"theme2@tests.mozilla.org"], function([a2, a3, a4,
a7, t2]) {
// Set up the initial state
a2.userDisabled = true;
a4.userDisabled = true;
a7.userDisabled = true;
t2.userDisabled = false;
a3.findUpdates({
onUpdateFinished: function() {
a4.findUpdates({
onUpdateFinished: function() {
restartManager();
run_test_1();
}
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
}
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
});
}
function end_test() {
testserver.stop(do_test_finished);
}
function run_test_1() {
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org",
"addon7@tests.mozilla.org",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"], function([a1, a2, a3,
a4, a5, a6,
a7, t1, t2]) {
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
// After restarting the database won't be open and so can be replaced with
// a bad file
restartManager();
var dbfile = gProfD.clone();
dbfile.append("extensions.sqlite");
dbfile.remove(true);
dbfile.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
// Accessing the add-ons should open and recover the database
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org",
"addon7@tests.mozilla.org",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"], function([a1, a2, a3,
a4, a5, a6,
a7, t1, t2]) {
// Should be correctly recovered
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
// Should be correctly recovered
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
// The compatibility update won't be recovered but it should still be
// active for this session
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_true(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_DISABLE);
// The compatibility update won't be recovered and it will not have been
// able to tell that it was previously userDisabled
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_false(a4.userDisabled);
do_check_true(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
// Should be correctly recovered
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
// Should be correctly recovered
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
restartManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org",
"addon7@tests.mozilla.org",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"], function([a1, a2, a3,
a4, a5, a6,
a7, t1, t2]) {
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a3, null);
do_check_false(a3.isActive);
do_check_false(a3.userDisabled);
do_check_true(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_false(a4.userDisabled);
do_check_true(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
end_test();
});
});
});
}

View File

@ -0,0 +1,82 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Tests detection of binary components via parsing of chrome manifests.
const profileDir = gProfD.clone();
profileDir.append("extensions");
function run_test() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
startupManager();
installAllFiles([do_get_addon("test_chromemanifest_1"),
do_get_addon("test_chromemanifest_2"),
do_get_addon("test_chromemanifest_3"),
do_get_addon("test_chromemanifest_4"),
do_get_addon("test_chromemanifest_5")],
function() {
restartManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org"],
function([a1, a2, a3, a4, a5]) {
// addon1 has no binary components
do_check_neq(a1, null);
do_check_false(a1.userDisabled);
do_check_false(a1.hasBinaryComponents);
do_check_true(a1.isCompatible);
do_check_false(a1.appDisabled);
do_check_true(a1.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
// addon2 has a binary component, is compatible
do_check_neq(a2, null);
do_check_false(a2.userDisabled);
do_check_true(a2.hasBinaryComponents);
do_check_true(a2.isCompatible);
do_check_false(a2.appDisabled);
do_check_true(a2.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
// addon3 has a binary component, is incompatible
do_check_neq(a3, null);
do_check_false(a3.userDisabled);
do_check_true(a2.hasBinaryComponents);
do_check_false(a3.isCompatible);
do_check_true(a3.appDisabled);
do_check_false(a3.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
// addon4 has a binary component listed in a sub-manifest, is incompatible
do_check_neq(a4, null);
do_check_false(a4.userDisabled);
do_check_true(a2.hasBinaryComponents);
do_check_false(a4.isCompatible);
do_check_true(a4.appDisabled);
do_check_false(a4.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
// addon5 has a binary component, but is set to not unpack
do_check_neq(a5, null);
do_check_false(a5.userDisabled);
if (TEST_UNPACKED)
do_check_true(a5.hasBinaryComponents);
else
do_check_false(a5.hasBinaryComponents);
do_check_true(a5.isCompatible);
do_check_false(a5.appDisabled);
do_check_true(a5.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_test_finished();
});
});
}

View File

@ -21,7 +21,8 @@ var gInstallDate;
var gInstall = null;
// The test extension uses an insecure update url.
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
const profileDir = gProfD.clone();
profileDir.append("extensions");
@ -671,14 +672,14 @@ function run_test_11() {
do_check_true(hasFlag(installs[1].addon.operationsRequiringRestart,
AddonManager.OP_NEEDS_RESTART_INSTALL));
// Comes from addon6.xpi and is incompatible
// Comes from addon6.xpi and would be incompatible with strict compat enabled
do_check_eq(installs[2].sourceURI, install.sourceURI);
do_check_eq(installs[2].addon.id, "addon6@tests.mozilla.org");
do_check_true(installs[2].addon.appDisabled);
do_check_false(installs[2].addon.appDisabled);
do_check_eq(installs[2].version, "2.0");
do_check_eq(installs[2].name, "Multi Test 3");
do_check_eq(installs[2].state, AddonManager.STATE_DOWNLOADED);
do_check_false(hasFlag(installs[2].addon.operationsRequiringRestart,
do_check_true(hasFlag(installs[2].addon.operationsRequiringRestart,
AddonManager.OP_NEEDS_RESTART_INSTALL));
// Comes from addon7.jar and is made compatible by an update check
@ -702,8 +703,7 @@ function run_test_11() {
"onInstalling"
],
"addon6@tests.mozilla.org": [
["onInstalling", false],
"onInstalled"
"onInstalling"
],
"addon7@tests.mozilla.org": [
"onInstalling"
@ -787,8 +787,7 @@ function run_test_12() {
"onInstalling"
],
"addon6@tests.mozilla.org": [
["onInstalling", false],
"onInstalled"
"onInstalling"
],
"addon7@tests.mozilla.org": [
"onInstalling"
@ -851,10 +850,10 @@ function check_test_12() {
do_check_eq(installs[1].name, "Multi Test 2");
do_check_eq(installs[1].state, AddonManager.STATE_INSTALLED);
// Comes from addon6.xpi and is incompatible
// Comes from addon6.xpi and would be incompatible with strict compat enabled
do_check_eq(installs[2].sourceURI, gInstall.sourceURI);
do_check_eq(installs[2].addon.id, "addon6@tests.mozilla.org");
do_check_true(installs[2].addon.appDisabled);
do_check_false(installs[2].addon.appDisabled);
do_check_eq(installs[2].version, "2.0");
do_check_eq(installs[2].name, "Multi Test 3");
do_check_eq(installs[2].state, AddonManager.STATE_INSTALLED);

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,8 @@ do_load_httpd_js();
var testserver;
// The test extension uses an insecure update url.
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
// Will be enabled
var addon1 = {
@ -35,7 +36,7 @@ var addon2 = {
}]
};
// Will get a compatibility update and be enabled
// Will get a compatibility update and stay enabled
var addon3 = {
id: "addon3@tests.mozilla.org",
version: "1.0",
@ -48,7 +49,7 @@ var addon3 = {
}]
};
// Will get a compatibility update and be disabled
// Will get a compatibility update and be enabled
var addon4 = {
id: "addon4@tests.mozilla.org",
version: "1.0",
@ -61,7 +62,7 @@ var addon4 = {
}]
};
// Stays incompatible
// Would stay incompatible with strict compat
var addon5 = {
id: "addon5@tests.mozilla.org",
version: "1.0",
@ -217,9 +218,9 @@ function run_test_1() {
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a6, null);
@ -285,21 +286,23 @@ function run_test_1() {
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_true(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_DISABLE);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
// The compatibility update won't be recovered and it will not have been
// able to tell that it was previously userDisabled
// The compatibility update won't be recovered and with strict
// compatibility it would not have been able to tell that it was
// previously userDisabled. However, without strict compat, it wasn't
// appDisabled, so it knows it must have been userDisabled.
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_false(a4.userDisabled);
do_check_true(a4.appDisabled);
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a6, null);
@ -357,21 +360,21 @@ function run_test_1() {
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a3, null);
do_check_false(a3.isActive);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_true(a3.appDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_false(a4.userDisabled);
do_check_true(a4.appDisabled);
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a6, null);

View File

@ -0,0 +1,407 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Checks that we rebuild something sensible from a corrupt database
do_load_httpd_js();
var testserver;
// The test extension uses an insecure update url.
Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, true);
// Will be enabled
var addon1 = {
id: "addon1@tests.mozilla.org",
version: "1.0",
name: "Test 1",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "2",
maxVersion: "2"
}]
};
// Will be disabled
var addon2 = {
id: "addon2@tests.mozilla.org",
version: "1.0",
name: "Test 2",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "2",
maxVersion: "2"
}]
};
// Will get a compatibility update and be enabled
var addon3 = {
id: "addon3@tests.mozilla.org",
version: "1.0",
name: "Test 3",
updateURL: "http://localhost:4444/data/test_corrupt.rdf",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}]
};
// Will get a compatibility update and be disabled
var addon4 = {
id: "addon4@tests.mozilla.org",
version: "1.0",
name: "Test 4",
updateURL: "http://localhost:4444/data/test_corrupt.rdf",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}]
};
// Stays incompatible
var addon5 = {
id: "addon5@tests.mozilla.org",
version: "1.0",
name: "Test 5",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}]
};
// Enabled bootstrapped
var addon6 = {
id: "addon6@tests.mozilla.org",
version: "1.0",
name: "Test 6",
bootstrap: "true",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "2",
maxVersion: "2"
}]
};
// Disabled bootstrapped
var addon7 = {
id: "addon7@tests.mozilla.org",
version: "1.0",
name: "Test 7",
bootstrap: "true",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "2",
maxVersion: "2"
}]
};
// The default theme
var theme1 = {
id: "theme1@tests.mozilla.org",
version: "1.0",
name: "Theme 1",
internalName: "classic/1.0",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "2",
maxVersion: "2"
}]
};
// The selected theme
var theme2 = {
id: "theme2@tests.mozilla.org",
version: "1.0",
name: "Theme 2",
internalName: "test/1.0",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "2",
maxVersion: "2"
}]
};
const profileDir = gProfD.clone();
profileDir.append("extensions");
function run_test() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
writeInstallRDFForExtension(addon1, profileDir);
writeInstallRDFForExtension(addon2, profileDir);
writeInstallRDFForExtension(addon3, profileDir);
writeInstallRDFForExtension(addon4, profileDir);
writeInstallRDFForExtension(addon5, profileDir);
writeInstallRDFForExtension(addon6, profileDir);
writeInstallRDFForExtension(addon7, profileDir);
writeInstallRDFForExtension(theme1, profileDir);
writeInstallRDFForExtension(theme2, profileDir);
// Create and configure the HTTP server.
testserver = new nsHttpServer();
testserver.registerDirectory("/addons/", do_get_file("addons"));
testserver.registerDirectory("/data/", do_get_file("data"));
testserver.start(4444);
// Startup the profile and setup the initial state
startupManager();
AddonManager.getAddonsByIDs(["addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon7@tests.mozilla.org",
"theme2@tests.mozilla.org"], function([a2, a3, a4,
a7, t2]) {
// Set up the initial state
a2.userDisabled = true;
a4.userDisabled = true;
a7.userDisabled = true;
t2.userDisabled = false;
a3.findUpdates({
onUpdateFinished: function() {
a4.findUpdates({
onUpdateFinished: function() {
restartManager();
run_test_1();
}
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
}
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
});
}
function end_test() {
testserver.stop(do_test_finished);
}
function run_test_1() {
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org",
"addon7@tests.mozilla.org",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"], function([a1, a2, a3,
a4, a5, a6,
a7, t1, t2]) {
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
// After restarting the database won't be open so lock the file for writing
restartManager();
var dbfile = gProfD.clone();
dbfile.append("extensions.sqlite");
var fstream = AM_Cc["@mozilla.org/network/file-output-stream;1"].
createInstance(AM_Ci.nsIFileOutputStream);
fstream.init(dbfile, FileUtils.MODE_TRUNCATE | FileUtils.MODE_WRONLY, FileUtils.PERMS_FILE, 0);
// Accessing the add-ons should open and recover the database
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org",
"addon7@tests.mozilla.org",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"], function([a1, a2, a3,
a4, a5, a6,
a7, t1, t2]) {
// Should be correctly recovered
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
// Should be correctly recovered
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
// The compatibility update won't be recovered but it should still be
// active for this session
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_true(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_DISABLE);
// The compatibility update won't be recovered and it will not have been
// able to tell that it was previously userDisabled
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_false(a4.userDisabled);
do_check_true(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
// Should be correctly recovered
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
// Should be correctly recovered
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
// Restarting will actually apply changes to extensions.ini which will
// then be put into the in-memory database when we next fail to load the
// real thing
restartManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org",
"addon7@tests.mozilla.org",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"], function([a1, a2, a3,
a4, a5, a6,
a7, t1, t2]) {
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a3, null);
do_check_false(a3.isActive);
do_check_false(a3.userDisabled);
do_check_true(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_false(a4.userDisabled);
do_check_true(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
fstream.close();
end_test();
});
});
});
}

View File

@ -116,6 +116,13 @@ function run_test() {
addon7.copyTo(stagedXPIs, "tmp.xpi");
stagedXPIs = stagedXPIs.parent;
stagedXPIs.append("addon8@tests.mozilla.org");
stagedXPIs.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
let addon7 = do_get_addon("test_migrate8");
addon7.copyTo(stagedXPIs, "tmp.xpi");
stagedXPIs = stagedXPIs.parent;
let old = do_get_file("data/test_migrate.rdf");
old.copyTo(gProfD, "extensions.rdf");
@ -144,16 +151,19 @@ function run_test() {
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org",
"addon7@tests.mozilla.org",
"addon8@tests.mozilla.org",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"], function([a1, a2, a3,
a4, a5, a6,
a7, t1, t2]) {
a7, a8, t1,
t2]) {
// addon1 was user and app enabled in the old extensions.rdf
do_check_neq(a1, null);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_true(a1.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_false(a1.hasBinaryComponents);
// addon2 was user disabled and app enabled in the old extensions.rdf
do_check_neq(a2, null);
@ -161,6 +171,7 @@ function run_test() {
do_check_false(a2.appDisabled);
do_check_false(a2.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_false(a2.hasBinaryComponents);
// addon3 was pending user disable and app disabled in the old extensions.rdf
do_check_neq(a3, null);
@ -168,6 +179,7 @@ function run_test() {
do_check_true(a3.appDisabled);
do_check_false(a3.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
do_check_false(a3.hasBinaryComponents);
// addon4 was pending user enable and app disabled in the old extensions.rdf
do_check_neq(a4, null);
@ -175,6 +187,7 @@ function run_test() {
do_check_true(a4.appDisabled);
do_check_false(a4.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_false(a4.hasBinaryComponents);
// addon5 was disabled and compatible but a new version has been installed
// since, it should still be disabled but should be incompatible
@ -183,6 +196,7 @@ function run_test() {
do_check_true(a5.appDisabled);
do_check_false(a5.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a5.id));
do_check_false(a5.hasBinaryComponents);
// addon6 should be installed and compatible and packed unless unpacking is
// forced
@ -195,6 +209,7 @@ function run_test() {
do_check_eq(a6.getResourceURI("install.rdf").scheme, "file");
else
do_check_eq(a6.getResourceURI("install.rdf").scheme, "jar");
do_check_false(a6.hasBinaryComponents);
// addon7 should be installed and compatible and unpacked
do_check_neq(a7, null);
@ -203,6 +218,15 @@ function run_test() {
do_check_true(a7.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a7.id));
do_check_eq(a7.getResourceURI("install.rdf").scheme, "file");
do_check_false(a7.hasBinaryComponents);
// addon8 should be installed and compatible and have binary components
do_check_neq(a8, null);
do_check_false(a8.userDisabled);
do_check_false(a8.appDisabled);
do_check_true(a8.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a8.id));
do_check_true(a8.hasBinaryComponents);
// Theme 1 was previously enabled
do_check_neq(t1, null);

View File

@ -41,6 +41,7 @@ var addon4 = {
id: "addon4@tests.mozilla.org",
version: "2.0",
name: "Test 4",
strictCompatibility: true,
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
@ -157,32 +158,38 @@ function run_test() {
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_true(a1.isActive);
do_check_false(a1.strictCompatibility);
// addon2 was disabled in the database
do_check_neq(a2, null);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_false(a2.isActive);
do_check_false(a2.strictCompatibility);
// addon3 was pending-disable in the database
do_check_neq(a3, null);
do_check_true(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_false(a3.isActive);
do_check_false(a3.strictCompatibility);
// addon4 was pending-enable in the database
do_check_neq(a4, null);
do_check_false(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_true(a4.isActive);
do_check_true(a4.strictCompatibility);
// addon5 was enabled in the database but needed a compatibiltiy update
do_check_neq(a5, null);
do_check_false(a5.userDisabled);
do_check_false(a5.appDisabled);
do_check_true(a5.isActive);
do_check_false(a5.strictCompatibility);
// addon6 was disabled and compatible but a new version has been installed
// since, it should still be disabled but should be incompatible
do_check_neq(a6, null);
do_check_true(a6.userDisabled);
do_check_true(a6.appDisabled);
do_check_false(a6.isActive);
do_check_false(a6.strictCompatibility);
do_test_finished();
});
}

View File

@ -44,6 +44,7 @@ var addon4 = {
id: "addon4@tests.mozilla.org",
version: "2.0",
name: "Test 4",
strictCompatibility: true,
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
@ -98,46 +99,51 @@ function prepare_profile() {
writeInstallRDFForExtension(addon6, profileDir);
startupManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org"],
function([a1, a2, a3, a4, a5, a6]) {
a2.userDisabled = true;
a2.applyBackgroundUpdates = false;
a4.userDisabled = true;
a6.userDisabled = true;
installAllFiles([do_get_addon("test_migrate8")],
function() {
restartManager();
a6.findUpdates({
onUpdateAvailable: function(aAddon, aInstall6) {
AddonManager.getInstallForURL("http://localhost:4444/addons/test_migrate4_7.xpi", function(aInstall7) {
completeAllInstalls([aInstall6, aInstall7], function() {
restartManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org"],
function([a1, a2, a3, a4, a5, a6]) {
a3.userDisabled = true;
a4.userDisabled = false;
a5.findUpdates({
onUpdateFinished: function() {
shutdownManager();
perform_migration();
}
}, AddonManager.UPDATE_WHEN_USER_REQUESTED);
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org"],
function([a1, a2, a3, a4, a5, a6]) {
a2.userDisabled = true;
a2.applyBackgroundUpdates = false;
a4.userDisabled = true;
a6.userDisabled = true;
a6.findUpdates({
onUpdateAvailable: function(aAddon, aInstall6) {
AddonManager.getInstallForURL("http://localhost:4444/addons/test_migrate4_7.xpi", function(aInstall7) {
completeAllInstalls([aInstall6, aInstall7], function() {
restartManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org"],
function([a1, a2, a3, a4, a5, a6]) {
a3.userDisabled = true;
a4.userDisabled = false;
a5.findUpdates({
onUpdateFinished: function() {
shutdownManager();
perform_migration();
}
}, AddonManager.UPDATE_WHEN_USER_REQUESTED);
});
});
});
}, "application/x-xpinstall");
}
}, AddonManager.UPDATE_WHEN_USER_REQUESTED);
}, "application/x-xpinstall");
}
}, AddonManager.UPDATE_WHEN_USER_REQUESTED);
});
});
}
@ -169,8 +175,9 @@ function test_results() {
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org",
"addon7@tests.mozilla.org"],
function([a1, a2, a3, a4, a5, a6, a7]) {
"addon7@tests.mozilla.org",
"addon8@tests.mozilla.org"],
function([a1, a2, a3, a4, a5, a6, a7, a8]) {
// addon1 was enabled
do_check_neq(a1, null);
do_check_false(a1.userDisabled);
@ -178,6 +185,8 @@ function test_results() {
do_check_true(a1.isActive);
do_check_true(a1.applyBackgroundUpdates);
do_check_true(a1.foreignInstall);
do_check_false(a1.hasBinaryComponents);
do_check_false(a1.strictCompatibility);
// addon2 was disabled
do_check_neq(a2, null);
@ -186,6 +195,8 @@ function test_results() {
do_check_false(a2.isActive);
do_check_false(a2.applyBackgroundUpdates);
do_check_true(a2.foreignInstall);
do_check_false(a2.hasBinaryComponents);
do_check_false(a2.strictCompatibility);
// addon3 was pending-disable in the database
do_check_neq(a3, null);
@ -194,6 +205,8 @@ function test_results() {
do_check_false(a3.isActive);
do_check_true(a3.applyBackgroundUpdates);
do_check_true(a3.foreignInstall);
do_check_false(a3.hasBinaryComponents);
do_check_false(a3.strictCompatibility);
// addon4 was pending-enable in the database
do_check_neq(a4, null);
@ -202,6 +215,8 @@ function test_results() {
do_check_true(a4.isActive);
do_check_true(a4.applyBackgroundUpdates);
do_check_true(a4.foreignInstall);
do_check_false(a4.hasBinaryComponents);
do_check_true(a4.strictCompatibility);
// addon5 was enabled in the database but needed a compatibiltiy update
do_check_neq(a5, null);
@ -210,6 +225,8 @@ function test_results() {
do_check_true(a5.isActive);
do_check_true(a5.applyBackgroundUpdates);
do_check_true(a5.foreignInstall);
do_check_false(a5.hasBinaryComponents);
do_check_false(a5.strictCompatibility);
// addon6 was disabled and compatible but a new version has been installed
do_check_neq(a6, null);
@ -221,6 +238,8 @@ function test_results() {
do_check_true(a6.foreignInstall);
do_check_eq(a6.sourceURI.spec, "http://localhost:4444/addons/test_migrate4_6.xpi");
do_check_eq(a6.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml");
do_check_false(a6.hasBinaryComponents);
do_check_false(a6.strictCompatibility);
// addon7 was installed manually
do_check_neq(a7, null);
@ -232,6 +251,17 @@ function test_results() {
do_check_false(a7.foreignInstall);
do_check_eq(a7.sourceURI.spec, "http://localhost:4444/addons/test_migrate4_7.xpi");
do_check_eq(a7.releaseNotesURI, null);
do_check_false(a7.hasBinaryComponents);
do_check_false(a7.strictCompatibility);
// addon8 was enabled and has binary components
do_check_neq(a8, null);
do_check_false(a8.userDisabled);
do_check_false(a8.appDisabled);
do_check_true(a8.isActive);
do_check_true(a8.hasBinaryComponents);
do_check_false(a8.strictCompatibility);
testserver.stop(do_test_finished);
});
}

View File

@ -0,0 +1,129 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests AddonManager.strictCompatibility and it's related preference,
// extensions.strictCompatibility, and the strictCompatibility option in
// install.rdf
// Always compatible
var addon1 = {
id: "addon1@tests.mozilla.org",
version: "1.0",
name: "Test 1",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}]
};
// Incompatible in strict compatibility mode
var addon2 = {
id: "addon2@tests.mozilla.org",
version: "1.0",
name: "Test 2",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "0.1",
maxVersion: "0.2"
}]
};
// Theme - always uses strict compatibility, so is always incompatible
var addon3 = {
id: "addon3@tests.mozilla.org",
version: "1.0",
name: "Test 3",
internalName: "test-theme-3",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "0.1",
maxVersion: "0.2"
}]
};
// Opt-in to strict compatibility - always incompatible
var addon4 = {
id: "addon4@tests.mozilla.org",
version: "1.0",
name: "Test 4",
strictCompatibility: true,
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "0.1",
maxVersion: "0.2"
}]
};
const profileDir = gProfD.clone();
profileDir.append("extensions");
function do_check_compat_status(aStrict, aAddonCompat, aCallback) {
do_check_eq(AddonManager.strictCompatibility, aStrict);
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org"],
function([a1, a2, a3, a4]) {
do_check_neq(a1, null);
do_check_eq(a1.isCompatible, aAddonCompat[0]);
do_check_eq(a1.appDisabled, !aAddonCompat[0]);
do_check_false(a1.strictCompatibility);
do_check_neq(a2, null);
do_check_eq(a2.isCompatible, aAddonCompat[1]);
do_check_eq(a2.appDisabled, !aAddonCompat[1]);
do_check_false(a2.strictCompatibility);
do_check_neq(a3, null);
do_check_eq(a3.isCompatible, aAddonCompat[2]);
do_check_eq(a3.appDisabled, !aAddonCompat[2]);
do_check_true(a3.strictCompatibility);
do_check_neq(a4, null);
do_check_eq(a4.isCompatible, aAddonCompat[3]);
do_check_eq(a4.appDisabled, !aAddonCompat[3]);
do_check_true(a4.strictCompatibility);
aCallback();
});
}
function run_test() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
writeInstallRDFForExtension(addon1, profileDir);
writeInstallRDFForExtension(addon2, profileDir);
writeInstallRDFForExtension(addon3, profileDir);
writeInstallRDFForExtension(addon4, profileDir);
startupManager();
// Should default to enabling strict compat.
do_check_compat_status(true, [true, false, false, false], run_test_1);
}
function run_test_1() {
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
do_check_compat_status(false, [true, true, false, false], run_test_2);
}
function run_test_2() {
restartManager();
do_check_compat_status(false, [true, true, false, false], run_test_3);
}
function run_test_3() {
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, true);
do_check_compat_status(true, [true, false, false, false], run_test_4);
}
function run_test_4() {
restartManager();
do_check_compat_status(true, [true, false, false, false], do_test_finished);
}

View File

@ -8,7 +8,8 @@ const PREF_MATCH_OS_LOCALE = "intl.locale.matchOS";
const PREF_SELECTED_LOCALE = "general.useragent.locale";
// The test extension uses an insecure update url.
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
// This test requires lightweight themes update to be enabled even if the app
// doesn't support lightweight themes.
Services.prefs.setBoolPref("lightweightThemes.update.enabled", true);
@ -235,16 +236,16 @@ function check_test_2() {
function run_test_3() {
AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_false(a2.isCompatible);
do_check_true(a2.appDisabled);
do_check_true(a2.isActive);
do_check_true(a2.isCompatible);
do_check_false(a2.appDisabled);
do_check_true(a2.isCompatibleWith("0"));
a2.findUpdates({
onCompatibilityUpdateAvailable: function(addon) {
do_check_true(a2.isCompatible);
do_check_false(a2.appDisabled);
do_check_false(a2.isActive);
do_check_true(a2.isActive);
},
onUpdateAvailable: function(addon, install) {
@ -276,11 +277,11 @@ function check_test_3() {
function run_test_4() {
AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) {
do_check_neq(a3, null);
do_check_false(a3.isActive);
do_check_false(a3.isCompatible);
do_check_true(a3.appDisabled);
do_check_true(a3.isActive);
do_check_true(a3.isCompatible);
do_check_false(a3.appDisabled);
do_check_true(a3.isCompatibleWith("5"));
do_check_false(a3.isCompatibleWith("2"));
do_check_true(a3.isCompatibleWith("2"));
a3.findUpdates({
sawUpdate: false,
@ -309,18 +310,18 @@ function run_test_4() {
function run_test_5() {
AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) {
do_check_neq(a3, null);
do_check_false(a3.isActive);
do_check_false(a3.isCompatible);
do_check_true(a3.appDisabled);
do_check_true(a3.isActive);
do_check_true(a3.isCompatible);
do_check_false(a3.appDisabled);
do_check_true(a3.isCompatibleWith("5"));
do_check_false(a3.isCompatibleWith("2"));
do_check_true(a3.isCompatibleWith("2"));
a3.findUpdates({
sawUpdate: false,
onCompatibilityUpdateAvailable: function(addon) {
do_check_false(a3.isCompatible);
do_check_true(a3.appDisabled);
do_check_false(a3.isActive);
do_check_true(a3.isCompatible);
do_check_false(a3.appDisabled);
do_check_true(a3.isActive);
this.sawUpdate = true;
},
@ -344,9 +345,9 @@ function run_test_5() {
function check_test_5() {
AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) {
do_check_neq(a3, null);
do_check_false(a3.isActive);
do_check_false(a3.isCompatible);
do_check_true(a3.appDisabled);
do_check_true(a3.isActive);
do_check_true(a3.isCompatible);
do_check_false(a3.appDisabled);
a3.uninstall();
restartManager();
@ -609,7 +610,7 @@ function run_test_8() {
case "addon3@tests.mozilla.org":
do_check_eq(item_version, "1.3+");
do_check_eq(item_maxappversion, "0");
do_check_eq(item_status, "userEnabled,incompatible");
do_check_eq(item_status, "userEnabled");
do_check_eq(app_version, "1");
do_check_eq(update_type, "112");
break;
@ -741,7 +742,7 @@ function run_test_11() {
AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) {
a4.findUpdates({
onUpdateFinished: function(addon) {
do_check_false(addon.isCompatible);
do_check_true(addon.isCompatible);
run_test_12();
}
@ -754,8 +755,8 @@ function run_test_12() {
restartManager();
AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) {
do_check_false(a4.isActive);
do_check_false(a4.isCompatible);
do_check_true(a4.isActive);
do_check_true(a4.isCompatible);
a4.uninstall();
restartManager();
@ -784,9 +785,9 @@ function run_test_13() {
AddonManager.getAddonByID("addon7@tests.mozilla.org", function(a7) {
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_false(a7.isCompatible);
do_check_true(a7.appDisabled);
do_check_true(a7.isActive);
do_check_true(a7.isCompatible);
do_check_false(a7.appDisabled);
do_check_true(a7.isCompatibleWith("0"));
a7.findUpdates({

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,10 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This verifies that app upgrades produce the expected behaviours.
// This verifies that app upgrades produce the expected behaviours,
// with strict compatibility checking disabled.
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
// Enable loading extensions from the application scope
Services.prefs.setIntPref("extensions.enabledScopes",
@ -21,7 +24,7 @@ var gInstallTime = Date.now();
function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
// Will be enabled in the first version and disabled in subsequent versions
// Will be compatible in the first version and incompatible in subsequent versions
writeInstallRDFForExtension({
id: "addon1@tests.mozilla.org",
version: "1.0",
@ -52,7 +55,7 @@ function run_test() {
]
}, profileDir);
// Will be disabled in the first version and enabled in the second.
// Will be incompatible in the first version and enabled in the second.
writeInstallRDFForExtension({
id: "addon3@tests.mozilla.org",
version: "1.0",
@ -64,7 +67,7 @@ function run_test() {
name: "Test Addon 3",
}, profileDir);
// Will be enabled in both versions but will change version in between
// Will be compatible in both versions but will change version in between
var dest = writeInstallRDFForExtension({
id: "addon4@tests.mozilla.org",
version: "1.0",
@ -110,7 +113,7 @@ function run_test_1() {
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
do_check_neq(a4, null);
do_check_true(isExtensionInAddonsList(globalDir, a4.id));
@ -120,7 +123,7 @@ function run_test_1() {
});
}
// Test that upgrading the application disables now incompatible add-ons
// Test that upgrading the application doesn't disable now incompatible add-ons
function run_test_2() {
// Upgrade the extension
var dest = writeInstallRDFForExtension({
@ -143,7 +146,7 @@ function run_test_2() {
function([a1, a2, a3, a4]) {
do_check_neq(a1, null);
do_check_false(isExtensionInAddonsList(profileDir, a1.id));
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a2, null);
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
@ -188,7 +191,7 @@ function run_test_3() {
function([a1, a2, a3, a4]) {
do_check_neq(a1, null);
do_check_false(isExtensionInAddonsList(profileDir, a1.id));
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a2, null);
do_check_true(isExtensionInAddonsList(profileDir, a2.id));

View File

@ -0,0 +1,211 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This verifies that app upgrades produce the expected behaviours,
// with strict compatibility checking enabled.
// Enable loading extensions from the application scope
Services.prefs.setIntPref("extensions.enabledScopes",
AddonManager.SCOPE_PROFILE +
AddonManager.SCOPE_APPLICATION);
const profileDir = gProfD.clone();
profileDir.append("extensions");
const globalDir = Services.dirsvc.get("XCurProcD", AM_Ci.nsILocalFile);
globalDir.append("extensions");
var gGlobalExisted = globalDir.exists();
var gInstallTime = Date.now();
function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
// Will be enabled in the first version and disabled in subsequent versions
writeInstallRDFForExtension({
id: "addon1@tests.mozilla.org",
version: "1.0",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}],
name: "Test Addon 1",
targetPlatforms: [
"XPCShell",
"WINNT_x86",
]
}, profileDir);
// Works in all tested versions
writeInstallRDFForExtension({
id: "addon2@tests.mozilla.org",
version: "1.0",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "2"
}],
name: "Test Addon 2",
targetPlatforms: [
"XPCShell_noarch-spidermonkey"
]
}, profileDir);
// Will be disabled in the first version and enabled in the second.
writeInstallRDFForExtension({
id: "addon3@tests.mozilla.org",
version: "1.0",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "2",
maxVersion: "2"
}],
name: "Test Addon 3",
}, profileDir);
// Will be enabled in both versions but will change version in between
var dest = writeInstallRDFForExtension({
id: "addon4@tests.mozilla.org",
version: "1.0",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}],
name: "Test Addon 4",
}, globalDir);
setExtensionModifiedTime(dest, gInstallTime);
do_test_pending();
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, true);
run_test_1();
}
function end_test() {
if (!gGlobalExisted) {
globalDir.remove(true);
}
else {
globalDir.append(do_get_expected_addon_name("addon4@tests.mozilla.org"));
globalDir.remove(true);
}
Services.prefs.clearUserPref(PREF_EM_STRICT_COMPATIBILITY);
do_test_finished();
}
// Test that the test extensions are all installed
function run_test_1() {
startupManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org"],
function([a1, a2, a3, a4]) {
do_check_neq(a1, null);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a2, null);
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
do_check_neq(a4, null);
do_check_true(isExtensionInAddonsList(globalDir, a4.id));
do_check_eq(a4.version, "1.0");
run_test_2();
});
}
// Test that upgrading the application disables now incompatible add-ons
function run_test_2() {
// Upgrade the extension
var dest = writeInstallRDFForExtension({
id: "addon4@tests.mozilla.org",
version: "2.0",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "2",
maxVersion: "2"
}],
name: "Test Addon 4",
}, globalDir);
setExtensionModifiedTime(dest, gInstallTime);
restartManager("2");
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org"],
function([a1, a2, a3, a4]) {
do_check_neq(a1, null);
do_check_false(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a2, null);
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
do_check_neq(a4, null);
do_check_true(isExtensionInAddonsList(globalDir, a4.id));
do_check_eq(a4.version, "2.0");
run_test_3();
});
}
// Test that nothing changes when only the build ID changes.
function run_test_3() {
// Upgrade the extension
var dest = writeInstallRDFForExtension({
id: "addon4@tests.mozilla.org",
version: "3.0",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "3",
maxVersion: "3"
}],
name: "Test Addon 4",
}, globalDir);
setExtensionModifiedTime(dest, gInstallTime);
// Simulates a simple Build ID change, the platform deletes extensions.ini
// whenever the application is changed.
var file = gProfD.clone();
file.append("extensions.ini");
file.remove(true);
restartManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org"],
function([a1, a2, a3, a4]) {
do_check_neq(a1, null);
do_check_false(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a2, null);
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
do_check_neq(a4, null);
do_check_true(isExtensionInAddonsList(globalDir, a4.id));
do_check_eq(a4.version, "2.0");
end_test();
});
}

View File

@ -70,12 +70,18 @@ skip-if = os == "android"
[test_bug470377_1.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
[test_bug470377_1_strictcompat.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
[test_bug470377_2.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
[test_bug470377_3.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
[test_bug470377_3_strictcompat.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
[test_bug470377_4.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
@ -120,7 +126,9 @@ fail-if = os == "android"
[test_bug675371.js]
[test_cacheflush.js]
[test_checkcompatibility.js]
[test_ChromeManifestParser.js]
[test_corrupt.js]
[test_corrupt_strictcompat.js]
[test_dictionary.js]
[test_disable.js]
[test_distribution.js]
@ -150,11 +158,16 @@ skip-if = os == "android"
[test_gfxBlacklist_OS.js]
[test_gfxBlacklist_Vendor.js]
[test_gfxBlacklist_prefs.js]
[test_hasbinarycomponents.js]
[test_install.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
[test_install_strictcompat.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
[test_locale.js]
[test_locked.js]
[test_locked_strictcompat.js]
[test_manifest.js]
[test_migrate1.js]
[test_migrate2.js]
@ -170,6 +183,7 @@ fail-if = os == "android"
[test_startup.js]
# Bug 676992: test consistently fails on Android
fail-if = os == "android"
[test_strictcompatibility.js]
[test_targetPlatforms.js]
[test_theme.js]
# Bug 676992: test consistently fails on Android
@ -179,6 +193,9 @@ fail-if = os == "android"
[test_update.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
[test_update_strictcompat.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
[test_updatecheck.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
@ -188,4 +205,6 @@ skip-if = os == "android"
[test_upgrade.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
[test_upgrade_strictcompat.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"

View File

@ -816,6 +816,7 @@ function setupPrefs() {
Services.prefs.setIntPref(PREF_APP_UPDATE_IDLETIME, 0);
Services.prefs.setIntPref(PREF_APP_UPDATE_PROMPTWAITTIME, 0);
Services.prefs.setBoolPref(PREF_EXTENSIONS_STRICT_COMPAT, true);
}
/**
@ -913,6 +914,10 @@ function resetPrefs() {
}
catch(e) {
}
if (Services.prefs.prefHasUserValue(PREF_EXTENSIONS_STRICT_COMPAT)) {
Services.prefs.clearUserPref(PREF_EXTENSIONS_STRICT_COMPAT);
}
}
/**

View File

@ -73,6 +73,7 @@ const PREF_DISTRIBUTION_ID = "distribution.id";
const PREF_DISTRIBUTION_VERSION = "distribution.version";
const PREF_EXTENSIONS_UPDATE_URL = "extensions.update.url";
const PREF_EXTENSIONS_STRICT_COMPAT = "extensions.strictCompatibility";
const NS_APP_PROFILE_DIR_STARTUP = "ProfDS";
const NS_APP_USER_PROFILE_50_DIR = "ProfD";