import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1143038 - Use AppConstants in tabbrowser.xml (r=gavin) (7974d0be4)
- Bug 1087726: Make JS callers of ios.newChannel call ios.newChannel2 in browser/ (r=gijs) (995267699)
- Bug 1149037 - Make nsLayoutUtils::ComputeSizeForDrawing* take a CSSIntSize param instead of a unit-less nsIntSize. r=roc (34aebc313)
- Bug 1149215 - Remove nsLayoutUtils::GetWholeImageDestination that use unitless nsIntSize. r=dholbert (dba5c0392)
- Bug 1149222 part 1 - Make nsLayoutUtils::DrawBackgroundImage and SVGImageContext use CSSIntSize instead of unitless nsIntSize. r=dholbert (32052dcf6)
- Bug 1149222 part 2 - Make nsSVGImageFrame::PaintSVG use LayoutDeviceSize & LayoutDevicePixel::ToAppUnits, when setting up its dest-rect. r=mats (d7505c2ab)
- Bug 1102048 (Part 15, VectorImage) - Make image/src files comply with the Mozilla Coding Style Guide. r=seth (c38d91d61)
- do not uselessly run the preprocessor (280c69776)
- Bug 1130816 - Bad argument passed to newChannelFromURI2 in WindowsPreviewPerTab.jsm (r=gijs) (70cd2eec7)
- AppConstants.jsm changes - Bug 1149334 - Remove preprocessing of nsUpdateService.js and use AppConstants.jsm. r=gavin.sharp (ab53e3bc2)
- Bug 1153657 - Performance Monitoring is not ready to ride the trains. r=yoric (582aef2de)
- Bug 1140672 - Remove app update file migration code for Windows. r=spohl (c7d6a39ab)
- Bug 1137901 - Remove param from refreshUpdateStatus. r=spohl (4d6bfc4e0)
- Remove FHR from app update Bug 1121018 - FHR data migration: org.mozilla.update. r=spohl (70db64336)
- lost bits of 1. main patch - Bug 843497 - Update check says 'up to date' for out (0975d2954)
- 1. File renames for Bug 1136358 - Preprocessing and file includes make it difficult to debug app update tests. r=spohl (c94361eee)
- 2. Build changes for Bug 1136358 - Preprocessing and file includes make it difficult to debug app update tests. r=spohl, r=gps (d4f2581a1)
- 3. Main patch for Bug 1136358 - Preprocessing and file includes make it difficult to debug app update tests. r=spohl (f4f7e68c6)
- 4. Use XPCOMUtils for Bug 1136358 - Preprocessing and file includes make it difficult to debug app update tests. r=spohl (0f4a9df9e)
- Bug 1137447 - New app update telemetry for patch type (complete or partial), extended error codes, and general cleanup. r=bbondy (12fb03ead)
- Bug 1149590 - Update/Upgrade for application dowloaded and installed, setting to ask/prompt for action ignored. r=spohl (2be30a384)
- changes for nsUpdateService.js - Bug 1149334 - Remove preprocessing of nsUpdateService.js and use AppConstants.jsm. r=spohl (e404305ee)
- Bug 1139958 - Start using AppConstants.jsm in Toolkit r=mossop (3e39e1160)
- Bug 1150688 - Update sections of GMPInstallManager.jsm, which were copied from nsUpdateService.js, to reflect the changes to nsUpdateService.js from bug 1149334. r=spohl (3fa552f68)
- Followup patch to Bug 1139958 forgot to add a comment to AppConstants.jsm r=mossop (be2408473)
This commit is contained in:
2020-05-30 12:09:25 +08:00
parent b6f6aa65fb
commit a2174af992
132 changed files with 7137 additions and 6440 deletions
+2
View File
@@ -324,7 +324,9 @@
@RESPATH@/components/toolkit_finalizationwitness.xpt
@RESPATH@/components/toolkit_formautofill.xpt
@RESPATH@/components/toolkit_osfile.xpt
#ifdef NIGHTLY_BUILD
@RESPATH@/components/toolkit_perfmonitoring.xpt
#endif
@RESPATH@/components/toolkit_xulstore.xpt
@RESPATH@/components/toolkitprofile.xpt
#ifdef MOZ_ENABLE_XREMOTE
+6 -1
View File
@@ -1158,7 +1158,12 @@ nsContextMenu.prototype = {
// set up a channel to do the saving
var ioService = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var channel = ioService.newChannelFromURI(makeURI(linkURL));
var channel = ioService.newChannelFromURI2(makeURI(linkURL),
doc,
null, // aLoadingPrincipal
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
if (linkDownload)
channel.contentDispositionFilename = linkDownload;
if (channel instanceof Ci.nsIPrivateBrowsingChannel) {
+90 -101
View File
@@ -9,11 +9,6 @@
%tabBrowserDTD;
]>
# MAKE_E10S_WORK surrounds code needed to have the front-end try to be smart
# about using non-remote browsers for loading certain URIs when remote tabs
# (browser.tabs.remote) are enabled.
#define MAKE_E10S_WORK 1
<bindings id="tabBrowserBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
@@ -81,6 +76,9 @@
Components.classes["@mozilla.org/autocomplete/search;1?name=history"]
.getService(Components.interfaces.mozIPlacesAutoComplete);
</field>
<field name="AppConstants" readonly="true">
(Components.utils.import("resource://gre/modules/AppConstants.jsm", {})).AppConstants;
</field>
<field name="mTabBox" readonly="true">
document.getAnonymousElementByAttribute(this, "anonid", "tabbox");
</field>
@@ -118,11 +116,7 @@
new Map();
</field>
<field name="arrowKeysShouldWrap" readonly="true">
#ifdef XP_MACOSX
true
#else
false
#endif
this.AppConstants.platform == "macosx";
</field>
<field name="_autoScrollPopup">
@@ -1387,7 +1381,6 @@
]]></body>
</method>
#ifdef MAKE_E10S_WORK
<method name="_updateBrowserRemoteness">
<parameter name="aBrowser"/>
<parameter name="aRemote"/>
@@ -1454,7 +1447,6 @@
]]>
</body>
</method>
#endif
<method name="addTab">
<parameter name="aURI"/>
@@ -1502,11 +1494,11 @@
t.setAttribute("validate", "never"); //PMed
t.setAttribute("onerror", "this.removeAttribute('image');");
t.className = "tabbrowser-tab";
#ifdef MAKE_E10S_WORK
let remote = this._shouldBrowserBeRemote(aURI);
#else
let remote = gMultiProcessBrowser;
#endif
if (this.AppConstants.E10S_TESTING_ONLY) {
let remote = this._shouldBrowserBeRemote(aURI);
} else {
let remote = gMultiProcessBrowser;
}
if (remote)
t.setAttribute("remote", "true");
@@ -2755,17 +2747,17 @@
<parameter name="aCharset"/>
<body>
<![CDATA[
#ifdef MAKE_E10S_WORK
this._updateBrowserRemoteness(this.mCurrentBrowser, this._shouldBrowserBeRemote(aURI));
try {
#endif
return this.mCurrentBrowser.loadURI(aURI, aReferrerURI, aCharset);
#ifdef MAKE_E10S_WORK
} catch (e) {
let url = this.mCurrentBrowser.currentURI.spec;
this._updateBrowserRemoteness(this.mCurrentBrowser, this._shouldBrowserBeRemote(url));
if (this.AppConstants.E10S_TESTING_ONLY) {
this._updateBrowserRemoteness(this.mCurrentBrowser, this._shouldBrowserBeRemote(aURI));
try {
return this.mCurrentBrowser.loadURI(aURI, aReferrerURI, aCharset);
} catch (e) {
let url = this.mCurrentBrowser.currentURI.spec;
this._updateBrowserRemoteness(this.mCurrentBrowser, this._shouldBrowserBeRemote(url));
}
} else {
return this.mCurrentBrowser.loadURI(aURI, aReferrerURI, aCharset);
}
#endif
]]>
</body>
</method>
@@ -2779,17 +2771,17 @@
<parameter name="aPostData"/>
<body>
<![CDATA[
#ifdef MAKE_E10S_WORK
this._updateBrowserRemoteness(this.mCurrentBrowser, this._shouldBrowserBeRemote(aURI));
try {
#endif
return this.mCurrentBrowser.loadURIWithFlags(aURI, aFlags, aReferrerURI, aCharset, aPostData);
#ifdef MAKE_E10S_WORK
} catch (e) {
let url = this.mCurrentBrowser.currentURI.spec;
this._updateBrowserRemoteness(this.mCurrentBrowser, this._shouldBrowserBeRemote(url));
if (this.AppConstants.E10S_TESTING_ONLY) {
this._updateBrowserRemoteness(this.mCurrentBrowser, this._shouldBrowserBeRemote(aURI));
try {
return this.mCurrentBrowser.loadURIWithFlags(aURI, aFlags, aReferrerURI, aCharset, aPostData);
} catch (e) {
let url = this.mCurrentBrowser.currentURI.spec;
this._updateBrowserRemoteness(this.mCurrentBrowser, this._shouldBrowserBeRemote(url));
}
} else {
return this.mCurrentBrowser.loadURIWithFlags(aURI, aFlags, aReferrerURI, aCharset, aPostData);
}
#endif
]]>
</body>
</method>
@@ -3017,30 +3009,30 @@
}
}
#ifdef XP_MACOSX
if (!aEvent.metaKey)
return;
if (this.AppConstants.platform == "macosx") {
if (!aEvent.metaKey)
return;
var offset = 1;
switch (aEvent.charCode) {
case '}'.charCodeAt(0):
offset = -1;
case '{'.charCodeAt(0):
if (window.getComputedStyle(this, null).direction == "ltr")
offset *= -1;
this.tabContainer.advanceSelectedTab(offset, true);
var offset = 1;
switch (aEvent.charCode) {
case '}'.charCodeAt(0):
offset = -1;
case '{'.charCodeAt(0):
if (window.getComputedStyle(this, null).direction == "ltr")
offset *= -1;
this.tabContainer.advanceSelectedTab(offset, true);
aEvent.stopPropagation();
aEvent.preventDefault();
}
} else {
if (aEvent.ctrlKey && !aEvent.shiftKey && !aEvent.metaKey &&
aEvent.keyCode == KeyEvent.DOM_VK_F4 &&
!this.mCurrentTab.pinned) {
this.removeCurrentTab({animate: true});
aEvent.stopPropagation();
aEvent.preventDefault();
}
}
#else
if (aEvent.ctrlKey && !aEvent.shiftKey && !aEvent.metaKey &&
aEvent.keyCode == KeyEvent.DOM_VK_F4 &&
!this.mCurrentTab.pinned) {
this.removeCurrentTab({animate: true});
aEvent.stopPropagation();
aEvent.preventDefault();
}
#endif
]]></body>
</method>
@@ -3409,15 +3401,16 @@
</xul:hbox>
<xul:arrowscrollbox anonid="arrowscrollbox" orient="horizontal" flex="1"
style="min-width: 1px;"
#ifndef XP_MACOSX
clicktoscroll="true"
#endif
class="tabbrowser-arrowscrollbox">
# This is a hack to circumvent bug 472020, otherwise the tabs show up on the
# right of the newtab button.
<!--
This is a hack to circumvent bug 472020, otherwise the tabs show up on the
right of the newtab button.
-->
<children includes="tab"/>
# This is to ensure anything extensions put here will go before the newtab
# button, necessary due to the previous hack.
<!--
This is to ensure anything extensions put here will go before the newtab
button, necessary due to the previous hack.
-->
<children/>
<xul:toolbarbutton class="tabs-newtab-button"
command="cmd_newNavigatorTab"
@@ -3713,16 +3706,17 @@
this._lastTabClosedByMouse = true;
if (this.getAttribute("overflow") == "true") {
#ifdef XP_WIN
// Don't need to do anything if we're in overflow mode and we're closing
// the last tab.
if (isEndTab)
#else
// Don't need to do anything if we're in overflow mode and aren't scrolled
// all the way to the right, or if we're closing the last tab.
if (isEndTab || !this.mTabstrip._scrollButtonDown.disabled)
#endif
return;
if (this.AppConstants.platform == "win") {
// Don't need to do anything if we're in overflow mode and we're closing
// the last tab.
if (isEndTab)
return;
} else {
// Don't need to do anything if we're in overflow mode and aren't scrolled
// all the way to the right, or if we're closing the last tab.
if (isEndTab || !this.mTabstrip._scrollButtonDown.disabled)
return;
}
// If the tab has an owner that will become the active tab, the owner will
// be to the left of it, so we actually want the left tab to slide over.
@@ -4101,11 +4095,8 @@
PrivateBrowsingUtils.isWindowPrivate(sourceNode.ownerDocument.defaultView))
return dt.effectAllowed = "none";
#ifdef XP_MACOSX
return dt.effectAllowed = event.altKey ? "copy" : "move";
#else
return dt.effectAllowed = event.ctrlKey ? "copy" : "move";
#endif
let copyModifier = this.AppConstants.platform == "macosx" ? event.altKey : event.ctrlKey;
return dt.effectAllowed = copyModifier ? "copy" : "move";
}
}
@@ -4259,14 +4250,13 @@
]]></handler>
<handler event="dblclick"><![CDATA[
#ifndef XP_MACOSX
// When the tabbar has an unified appearance with the titlebar
// and menubar, a double-click in it should have the same behavior
// as double-clicking the titlebar
if (TabsInTitlebar.enabled ||
(TabsOnTop.enabled && this.parentNode._dragBindingAlive))
return;
#endif
if (gBrowser.AppConstants.platform != "macosx") {
// When the tabbar has an unified appearance with the titlebar
// and menubar, a double-click in it should have the same behavior
// as double-clicking the titlebar
if (TabsInTitlebar.enabled || this.parentNode._dragBindingAlive)
return;
}
if (event.button != 0 ||
event.originalTarget.localName != "box")
@@ -4296,13 +4286,13 @@
]]></handler>
<handler event="keypress"><![CDATA[
if (event.altKey || event.shiftKey ||
#ifdef XP_MACOSX
!event.metaKey)
#else
!event.ctrlKey || event.metaKey)
#endif
return;
if (this.AppConstants.platform == "macosx") {
if (event.altKey || event.shiftKey || !event.metaKey)
return;
} else {
if (event.altKey || event.shiftKey || !event.ctrlKey || event.metaKey)
return;
}
switch (event.keyCode) {
case KeyEvent.DOM_VK_UP:
@@ -4625,13 +4615,12 @@
window.moveTo(left, top);
window.focus();
} else {
this.tabbrowser.replaceTabWithWindow(draggedTab, { screenX: left,
screenY: top,
#ifndef XP_WIN
outerWidth: winWidth,
outerHeight: winHeight
#endif
});
let props = { screenX: left, screenY: top };
if (this.tabbrowser.AppConstants.platform != "win") {
props.outerWidth = winWidth;
props.outerHeight = winHeight;
}
this.tabbrowser.replaceTabWithWindow(draggedTab, props);
}
event.stopPropagation();
]]></handler>
+2 -2
View File
@@ -102,13 +102,13 @@ browser.jar:
content/browser/openLocation.xul (content/openLocation.xul)
content/browser/safeMode.css (content/safeMode.css)
content/browser/safeMode.js (content/safeMode.js)
* content/browser/safeMode.xul (content/safeMode.xul)
content/browser/safeMode.xul (content/safeMode.xul)
* content/browser/sanitize.js (content/sanitize.js)
* content/browser/sanitize.xul (content/sanitize.xul)
* content/browser/sanitizeDialog.js (content/sanitizeDialog.js)
content/browser/sanitizeDialog.css (content/sanitizeDialog.css)
content/browser/tabbrowser.css (content/tabbrowser.css)
* content/browser/tabbrowser.xml (content/tabbrowser.xml)
content/browser/tabbrowser.xml (content/tabbrowser.xml)
* content/browser/urlbarBindings.xml (content/urlbarBindings.xml)
* content/browser/utilityOverlay.js (content/utilityOverlay.js)
content/browser/web-panels.js (content/web-panels.js)
@@ -201,7 +201,7 @@ function GetBookmarksResource(aProfileFolder) {
type: MigrationUtils.resourceTypes.BOOKMARKS,
migrate: function(aCallback) {
NetUtil.asyncFetch(bookmarksFile, MigrationUtils.wrapMigrateFunction(
NetUtil.asyncFetch2(bookmarksFile, MigrationUtils.wrapMigrateFunction(
function(aInputStream, aResultCode) {
if (!Components.isSuccessCode(aResultCode))
throw new Error("Could not read Bookmarks file");
@@ -237,7 +237,12 @@ function GetBookmarksResource(aProfileFolder) {
}
}
}, null);
}, aCallback));
}, aCallback),
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
}
};
}
+4
View File
@@ -521,7 +521,9 @@ BrowserGlue.prototype = {
Services.obs.notifyObservers(null, "browser-ui-startup-complete", "");
#ifdef NIGHTLY_BUILD
AddonWatcher.init(this._notifySlowAddon);
#endif
},
_setUpUserAgentOverrides: function BG__setUpUserAgentOverrides() {
@@ -625,7 +627,9 @@ BrowserGlue.prototype = {
UserAgentOverrides.uninit();
webrtcUI.uninit();
FormValidationHandler.uninit();
#ifdef NIGHTLY_BUILD
AddonWatcher.uninit();
#endif
this._dispose();
},
+2
View File
@@ -339,7 +339,9 @@
@RESPATH@/components/toolkit_finalizationwitness.xpt
@RESPATH@/components/toolkit_formautofill.xpt
@RESPATH@/components/toolkit_osfile.xpt
#ifdef NIGHTLY_BUILD
@RESPATH@/components/toolkit_perfmonitoring.xpt
#endif
@RESPATH@/components/toolkit_xulstore.xpt
@RESPATH@/components/toolkitprofile.xpt
#ifdef MOZ_ENABLE_XREMOTE
+33 -22
View File
@@ -73,15 +73,20 @@ XPCOMUtils.defineLazyServiceGetter(this, "faviconSvc",
"nsIFaviconService");
// nsIURI -> imgIContainer
function _imageFromURI(uri, privateMode, callback) {
let channel = ioSvc.newChannelFromURI(uri);
function _imageFromURI(doc, uri, privateMode, callback) {
let channel = ioSvc.newChannelFromURI2(uri,
doc,
null, // aLoadingPrincipal
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_IMAGE);
try {
channel.QueryInterface(Ci.nsIPrivateBrowsingChannel);
channel.setPrivate(privateMode);
} catch (e) {
// Ignore channels which do not support nsIPrivateBrowsingChannel
}
NetUtil.asyncFetch(channel, function(inputStream, resultCode) {
NetUtil.asyncFetch2(channel, function(inputStream, resultCode) {
if (!Components.isSuccessCode(resultCode))
return;
try {
@@ -93,17 +98,17 @@ function _imageFromURI(uri, privateMode, callback) {
// favicon).
let defaultURI = faviconSvc.defaultFavicon;
if (!defaultURI.equals(uri))
_imageFromURI(defaultURI, callback);
_imageFromURI(doc, defaultURI, privateMode, callback);
}
});
}
// string? -> imgIContainer
function getFaviconAsImage(iconurl, privateMode, callback) {
function getFaviconAsImage(doc, iconurl, privateMode, callback) {
if (iconurl)
_imageFromURI(NetUtil.newURI(iconurl), privateMode, callback);
_imageFromURI(doc, NetUtil.newURI(iconurl), privateMode, callback);
else
_imageFromURI(faviconSvc.defaultFavicon, privateMode, callback);
_imageFromURI(doc, faviconSvc.defaultFavicon, privateMode, callback);
}
// Snaps the given rectangle to be pixel-aligned at the given scale
@@ -460,13 +465,16 @@ TabWindow.prototype = {
preview.visible = AeroPeek.enabled;
preview.active = this.tabbrowser.selectedTab == controller.tab;
// Grab the default favicon
getFaviconAsImage(null, PrivateBrowsingUtils.isWindowPrivate(this.win), function (img) {
// It is possible that we've already gotten the real favicon, so make sure
// we have not set one before setting this default one.
if (!preview.icon)
preview.icon = img;
});
getFaviconAsImage(
controller.linkedBrowser.contentWindow.document,
null,
PrivateBrowsingUtils.isWindowPrivate(this.win),
function (img) {
// It is possible that we've already gotten the real favicon, so make sure
// we have not set one before setting this default one.
if (!preview.icon)
preview.icon = img;
});
return preview;
},
@@ -545,14 +553,17 @@ TabWindow.prototype = {
//// Browser progress listener
onLinkIconAvailable: function (aBrowser, aIconURL) {
let self = this;
getFaviconAsImage(aIconURL, PrivateBrowsingUtils.isWindowPrivate(this.win), function (img) {
let index = self.tabbrowser.browsers.indexOf(aBrowser);
// Only add it if we've found the index. The tab could have closed!
if (index != -1) {
let tab = self.tabbrowser.tabs[index];
self.previews.get(tab).icon = img;
}
});
getFaviconAsImage(
aBrowser.contentWindow.document,
aIconURL,PrivateBrowsingUtils.isWindowPrivate(this.win),
function (img) {
let index = self.tabbrowser.browsers.indexOf(aBrowser);
// Only add it if we've found the index. The tab could have closed!
if (index != -1) {
let tab = self.tabbrowser.tabs[index];
self.previews.get(tab).icon = img;
}
});
}
}
+3 -1
View File
@@ -114,6 +114,7 @@
#include "nsSVGLength2.h"
#include "nsDeviceContext.h"
#include "nsFontMetrics.h"
#include "Units.h"
#undef free // apparently defined by some windows header, clashing with a free()
// method in SkTypes.h
@@ -4570,7 +4571,8 @@ CanvasRenderingContext2D::DrawDirectlyToCanvas(
// FLAG_CLAMP is added for increased performance, since we never tile here.
uint32_t modifiedFlags = image.mDrawingFlags | imgIContainer::FLAG_CLAMP;
SVGImageContext svgContext(scaledImageSize, Nothing(), CurrentState().globalAlpha);
CSSIntSize sz(scaledImageSize.width, scaledImageSize.height); // XXX hmm is scaledImageSize really in CSS pixels?
SVGImageContext svgContext(sz, Nothing(), CurrentState().globalAlpha);
auto result = image.mImgContainer->
Draw(context, scaledImageSize,
+1 -1
View File
@@ -346,7 +346,7 @@ UnclipViewport(const SVGImageContext& aOldContext,
// Map the viewport to the inner image. (Note that we don't take the aSize
// parameter of Draw into account, just the clipping region.)
nsIntSize vSize(aOldContext.GetViewportSize());
CSSIntSize vSize(aOldContext.GetViewportSize());
vSize.width = ceil(vSize.width * double(innerSize.width) / clipSize.width);
vSize.height = ceil(vSize.height * double(innerSize.height) / clipSize.height);
+1 -1
View File
@@ -241,7 +241,7 @@ static SVGImageContext
OrientViewport(const SVGImageContext& aOldContext,
const Orientation& aOrientation)
{
nsIntSize viewportSize(aOldContext.GetViewportSize());
CSSIntSize viewportSize(aOldContext.GetViewportSize());
if (aOrientation.SwapsWidthAndHeight()) {
swap(viewportSize.width, viewportSize.height);
}
+68 -33
View File
@@ -104,7 +104,7 @@ protected:
if (!mInObserverList) {
nsSVGEffects::AddRenderingObserver(elem, this);
mInObserverList = true;
}
}
}
// Private data
@@ -179,9 +179,12 @@ public:
MOZ_ASSERT(mDocument, "Need an SVG document");
MOZ_ASSERT(mImage, "Need an image");
mDocument->AddEventListener(NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"), this, true, false);
mDocument->AddEventListener(NS_LITERAL_STRING("SVGAbort"), this, true, false);
mDocument->AddEventListener(NS_LITERAL_STRING("SVGError"), this, true, false);
mDocument->AddEventListener(NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"),
this, true, false);
mDocument->AddEventListener(NS_LITERAL_STRING("SVGAbort"), this, true,
false);
mDocument->AddEventListener(NS_LITERAL_STRING("SVGError"), this, true,
false);
}
private:
@@ -224,7 +227,9 @@ public:
{
MOZ_ASSERT(mDocument, "Duplicate call to Cancel");
if (mDocument) {
mDocument->RemoveEventListener(NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"), this, true);
mDocument
->RemoveEventListener(NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"),
this, true);
mDocument->RemoveEventListener(NS_LITERAL_STRING("SVGAbort"), this, true);
mDocument->RemoveEventListener(NS_LITERAL_STRING("SVGError"), this, true);
mDocument = nullptr;
@@ -249,7 +254,7 @@ public:
, mViewport(aViewport)
, mSize(aSize)
, mImageFlags(aImageFlags)
{}
{ }
virtual bool operator()(gfxContext* aContext,
const gfxRect& aFillRect,
const GraphicsFilter& aFilter,
@@ -350,8 +355,9 @@ VectorImage::Init(const char* aMimeType,
uint32_t aFlags)
{
// We don't support re-initialization
if (mIsInitialized)
if (mIsInitialized) {
return NS_ERROR_ILLEGAL_VALUE;
}
MOZ_ASSERT(!mIsFullyLoaded && !mHaveAnimations && !mError,
"Flags unexpectedly set before initialization");
@@ -410,8 +416,9 @@ VectorImage::OnImageDataComplete(nsIRequest* aRequest,
nsresult finalStatus = OnStopRequest(aRequest, aContext, aStatus);
// Give precedence to Necko failure codes.
if (NS_FAILED(aStatus))
if (NS_FAILED(aStatus)) {
finalStatus = aStatus;
}
// Actually fire OnStopRequest.
if (mProgressTracker) {
@@ -435,8 +442,9 @@ VectorImage::OnImageDataAvailable(nsIRequest* aRequest,
nsresult
VectorImage::StartAnimation()
{
if (mError)
if (mError) {
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(ShouldAnimate(), "Should not animate!");
@@ -563,19 +571,23 @@ VectorImage::GetHeight(int32_t* aHeight)
NS_IMETHODIMP
VectorImage::GetIntrinsicSize(nsSize* aSize)
{
if (mError || !mIsFullyLoaded)
if (mError || !mIsFullyLoaded) {
return NS_ERROR_FAILURE;
}
nsIFrame* rootFrame = mSVGDocumentWrapper->GetRootLayoutFrame();
if (!rootFrame)
if (!rootFrame) {
return NS_ERROR_FAILURE;
}
*aSize = nsSize(-1, -1);
IntrinsicSize rfSize = rootFrame->GetIntrinsicSize();
if (rfSize.width.GetUnit() == eStyleUnit_Coord)
if (rfSize.width.GetUnit() == eStyleUnit_Coord) {
aSize->width = rfSize.width.GetCoordValue();
if (rfSize.height.GetUnit() == eStyleUnit_Coord)
}
if (rfSize.height.GetUnit() == eStyleUnit_Coord) {
aSize->height = rfSize.height.GetCoordValue();
}
return NS_OK;
}
@@ -585,12 +597,14 @@ VectorImage::GetIntrinsicSize(nsSize* aSize)
NS_IMETHODIMP
VectorImage::GetIntrinsicRatio(nsSize* aRatio)
{
if (mError || !mIsFullyLoaded)
if (mError || !mIsFullyLoaded) {
return NS_ERROR_FAILURE;
}
nsIFrame* rootFrame = mSVGDocumentWrapper->GetRootLayoutFrame();
if (!rootFrame)
if (!rootFrame) {
return NS_ERROR_FAILURE;
}
*aRatio = rootFrame->GetIntrinsicRatio();
return NS_OK;
@@ -618,8 +632,9 @@ VectorImage::GetType(uint16_t* aType)
NS_IMETHODIMP
VectorImage::GetAnimated(bool* aAnimated)
{
if (mError || !mIsFullyLoaded)
if (mError || !mIsFullyLoaded) {
return NS_ERROR_FAILURE;
}
*aAnimated = mSVGDocumentWrapper->IsAnimated();
return NS_OK;
@@ -630,11 +645,13 @@ VectorImage::GetAnimated(bool* aAnimated)
int32_t
VectorImage::GetFirstFrameDelay()
{
if (mError)
if (mError) {
return -1;
}
if (!mSVGDocumentWrapper->IsAnimated())
if (!mSVGDocumentWrapper->IsAnimated()) {
return -1;
}
// We don't really have a frame delay, so just pretend that we constantly
// need updates.
@@ -656,11 +673,13 @@ VectorImage::GetFrame(uint32_t aWhichFrame,
{
MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE);
if (aWhichFrame > FRAME_MAX_VALUE)
if (aWhichFrame > FRAME_MAX_VALUE) {
return nullptr;
}
if (mError || !mIsFullyLoaded)
if (mError || !mIsFullyLoaded) {
return nullptr;
}
// Look up height & width
// ----------------------
@@ -669,7 +688,7 @@ VectorImage::GetFrame(uint32_t aWhichFrame,
"loading without errors");
nsIntSize imageIntSize(svgElem->GetIntrinsicWidth(),
svgElem->GetIntrinsicHeight());
if (imageIntSize.IsEmpty()) {
// We'll get here if our SVG doc has a percent-valued or negative width or
// height.
@@ -720,11 +739,16 @@ struct SVGDrawingParameters
, region(aRegion)
, filter(aFilter)
, svgContext(aSVGContext)
, viewportSize(aSVGContext ? aSVGContext->GetViewportSize() : aSize)
, viewportSize(aSize)
, animationTime(aAnimationTime)
, flags(aFlags)
, opacity(aSVGContext ? aSVGContext->GetGlobalOpacity() : 1.0)
{ }
{
if (aSVGContext) {
CSSIntSize sz = aSVGContext->GetViewportSize();
viewportSize = nsIntSize(sz.width, sz.height); // XXX losing unit
}
}
gfxContext* context;
IntSize size;
@@ -783,8 +807,9 @@ VectorImage::Draw(gfxContext* aContext,
AutoRestore<bool> autoRestoreIsDrawing(mIsDrawing);
mIsDrawing = true;
float animTime = (aWhichFrame == FRAME_FIRST) ? 0.0f
: mSVGDocumentWrapper->GetCurrentTime();
float animTime =
(aWhichFrame == FRAME_FIRST) ? 0.0f
: mSVGDocumentWrapper->GetCurrentTime();
AutoSVGRenderingState autoSVGState(aSVGContext, animTime,
mSVGDocumentWrapper->GetRootSVGElem());
@@ -863,8 +888,9 @@ VectorImage::CreateSurfaceAndShow(const SVGDrawingParameters& aParams)
bypassCache = (aParams.size.width * aParams.size.height * 4) > maxCacheElemSize;
}
if (bypassCache)
if (bypassCache) {
return Show(svgDrawable, aParams);
}
// We're about to rerasterize, which may mean that some of the previous
// surfaces we've rasterized aren't useful anymore. We can allow them to
@@ -885,14 +911,16 @@ VectorImage::CreateSurfaceAndShow(const SVGDrawingParameters& aParams)
// If we couldn't create the frame, it was probably because it would end
// up way too big. Generally it also wouldn't fit in the cache, but the prefs
// could be set such that the cache isn't the limiting factor.
if (NS_FAILED(rv))
if (NS_FAILED(rv)) {
return Show(svgDrawable, aParams);
}
// Take a strong reference to the frame's surface and make sure it hasn't
// already been purged by the operating system.
RefPtr<SourceSurface> surface = frame->GetSurface();
if (!surface)
if (!surface) {
return Show(svgDrawable, aParams);
}
// Attempt to cache the frame.
SurfaceCache::Insert(frame, ImageKey(this),
@@ -1038,8 +1066,9 @@ VectorImage::OnSurfaceDiscarded()
NS_IMETHODIMP
VectorImage::ResetAnimation()
{
if (mError)
if (mError) {
return NS_ERROR_FAILURE;
}
if (!mIsFullyLoaded || !mHaveAnimations) {
return NS_OK; // There are no animations to be reset.
@@ -1106,8 +1135,9 @@ NS_IMETHODIMP
VectorImage::OnStopRequest(nsIRequest* aRequest, nsISupports* aCtxt,
nsresult aStatus)
{
if (mError)
if (mError) {
return NS_ERROR_FAILURE;
}
return mSVGDocumentWrapper->OnStopRequest(aRequest, aCtxt, aStatus);
}
@@ -1122,7 +1152,8 @@ VectorImage::OnSVGDocumentParsed()
// This is an invalid SVG document. It may have failed to parse, or it may
// be missing the <svg> root element, or the <svg> root element may not
// declare the correct namespace. In any of these cases, we'll never be
// notified that the SVG finished loading, so we need to treat this as an error.
// notified that the SVG finished loading, so we need to treat this as an
// error.
OnSVGDocumentError();
}
}
@@ -1203,8 +1234,9 @@ VectorImage::OnDataAvailable(nsIRequest* aRequest, nsISupports* aCtxt,
nsIInputStream* aInStr, uint64_t aSourceOffset,
uint32_t aCount)
{
if (mError)
if (mError) {
return NS_ERROR_FAILURE;
}
return mSVGDocumentWrapper->OnDataAvailable(aRequest, aCtxt, aInStr,
aSourceOffset, aCount);
@@ -1224,7 +1256,10 @@ VectorImage::InvalidateObserversOnNextRefreshDriverTick()
}
nsIntSize
VectorImage::OptimalImageSizeForDest(const gfxSize& aDest, uint32_t aWhichFrame, GraphicsFilter aFilter, uint32_t aFlags)
VectorImage::OptimalImageSizeForDest(const gfxSize& aDest,
uint32_t aWhichFrame,
GraphicsFilter aFilter,
uint32_t aFlags)
{
MOZ_ASSERT(aDest.width >= 0 || ceil(aDest.width) <= INT32_MAX ||
aDest.height >= 0 || ceil(aDest.height) <= INT32_MAX,
+6 -4
View File
@@ -37,7 +37,8 @@ public:
nsresult Init(const char* aMimeType,
uint32_t aFlags) override;
virtual size_t SizeOfSourceWithComputedFallback(MallocSizeOf aMallocSizeOf) const override;
virtual size_t SizeOfSourceWithComputedFallback(MallocSizeOf aMallocSizeOf)
const override;
virtual size_t SizeOfDecoded(gfxMemoryLocation aLocation,
MallocSizeOf aMallocSizeOf) const override;
@@ -101,9 +102,10 @@ private:
/// Count of locks on this image (roughly correlated to visible instances).
uint32_t mLockCount;
bool mIsInitialized; // Have we been initalized?
bool mIsInitialized; // Have we been initialized?
bool mDiscardable; // Are we discardable?
bool mIsFullyLoaded; // Has the SVG document finished loading?
bool mIsFullyLoaded; // Has the SVG document finished
// loading?
bool mIsDrawing; // Are we currently drawing?
bool mHaveAnimations; // Is our SVG content SMIL-animated?
// (Only set after mIsFullyLoaded.)
@@ -116,7 +118,7 @@ private:
friend class ImageFactory;
};
inline NS_IMETHODIMP VectorImage::GetAnimationMode(uint16_t *aAnimationMode) {
inline NS_IMETHODIMP VectorImage::GetAnimationMode(uint16_t* aAnimationMode) {
return GetAnimationModeInternal(aAnimationMode);
}
+10
View File
@@ -208,6 +208,11 @@ struct CSSPixel {
NSToCoordRoundWithClamp(float(aPoint.y) * float(AppUnitsPerCSSPixel())));
}
static nsSize ToAppUnits(const CSSIntSize& aSize) {
return nsSize(NSToCoordRoundWithClamp(float(aSize.width) * float(AppUnitsPerCSSPixel())),
NSToCoordRoundWithClamp(float(aSize.height) * float(AppUnitsPerCSSPixel())));
}
static nsRect ToAppUnits(const CSSRect& aRect) {
return nsRect(NSToCoordRoundWithClamp(aRect.x * float(AppUnitsPerCSSPixel())),
NSToCoordRoundWithClamp(aRect.y * float(AppUnitsPerCSSPixel())),
@@ -277,6 +282,11 @@ struct LayoutDevicePixel {
aSize.height * aAppUnitsPerDevPixel);
}
static nsSize ToAppUnits(const LayoutDeviceSize& aSize, nscoord aAppUnitsPerDevPixel) {
return nsSize(NSFloatPixelsToAppUnits(aSize.width, aAppUnitsPerDevPixel),
NSFloatPixelsToAppUnits(aSize.height, aAppUnitsPerDevPixel));
}
static nsRect ToAppUnits(const LayoutDeviceRect& aRect, nscoord aAppUnitsPerDevPixel) {
return nsRect(NSFloatPixelsToAppUnits(aRect.x, aAppUnitsPerDevPixel),
NSFloatPixelsToAppUnits(aRect.y, aAppUnitsPerDevPixel),
+3 -3
View File
@@ -4787,7 +4787,7 @@ nsImageRenderer::ComputeIntrinsicSize()
case eStyleImageType_Image:
{
bool haveWidth, haveHeight;
nsIntSize imageIntSize;
CSSIntSize imageIntSize;
nsLayoutUtils::ComputeSizeForDrawing(mImageContainer, imageIntSize,
result.mRatio, haveWidth, haveHeight);
if (haveWidth) {
@@ -4996,8 +4996,8 @@ nsImageRenderer::Draw(nsPresContext* aPresContext,
switch (mType) {
case eStyleImageType_Image:
{
nsIntSize imageSize(nsPresContext::AppUnitsToIntCSSPixels(mSize.width),
nsPresContext::AppUnitsToIntCSSPixels(mSize.height));
CSSIntSize imageSize(nsPresContext::AppUnitsToIntCSSPixels(mSize.width),
nsPresContext::AppUnitsToIntCSSPixels(mSize.height));
return
nsLayoutUtils::DrawBackgroundImage(*aRenderingContext.ThebesContext(),
aPresContext,
+12 -24
View File
@@ -5743,7 +5743,7 @@ struct SnappedImageDrawingParameters {
// one has been explicitly specified. This is the same as |size| except that
// it does not take into account any transformation on the gfxContext we're
// drawing to - for example, CSS transforms are not taken into account.
nsIntSize svgViewportSize;
CSSIntSize svgViewportSize;
// Whether there's anything to draw at all.
bool shouldDraw;
@@ -5755,7 +5755,7 @@ struct SnappedImageDrawingParameters {
SnappedImageDrawingParameters(const gfxMatrix& aImageSpaceToDeviceSpace,
const nsIntSize& aSize,
const ImageRegion& aRegion,
const nsIntSize& aSVGViewportSize)
const CSSIntSize& aSVGViewportSize)
: imageSpaceToDeviceSpace(aImageSpaceToDeviceSpace)
, size(aSize)
, region(aRegion)
@@ -5881,10 +5881,10 @@ ComputeSnappedImageDrawingParameters(gfxContext* aCtx,
aGraphicsFilter, aImageFlags);
gfxSize imageSize(intImageSize.width, intImageSize.height);
nsIntSize svgViewportSize = currentMatrix.IsIdentity()
? intImageSize
: nsIntSize(NSAppUnitsToIntPixels(dest.width, aAppUnitsPerDevPixel),
NSAppUnitsToIntPixels(dest.height, aAppUnitsPerDevPixel));
CSSIntSize svgViewportSize = currentMatrix.IsIdentity()
? CSSIntSize(intImageSize.width, intImageSize.height)
: CSSIntSize(NSAppUnitsToIntPixels(dest.width, aAppUnitsPerDevPixel), //XXX BUG!
NSAppUnitsToIntPixels(dest.height, aAppUnitsPerDevPixel)); //XXX BUG!
// Compute the set of pixels that would be sampled by an ideal rendering
gfxPoint subimageTopLeft =
@@ -6083,7 +6083,7 @@ nsLayoutUtils::DrawSingleImage(gfxContext& aContext,
const nsRect* aSourceArea)
{
nscoord appUnitsPerCSSPixel = nsDeviceContext::AppUnitsPerCSSPixel();
nsIntSize pixelImageSize(ComputeSizeForDrawingWithFallback(aImage, aDest.Size()));
CSSIntSize pixelImageSize(ComputeSizeForDrawingWithFallback(aImage, aDest.Size()));
if (pixelImageSize.width < 1 || pixelImageSize.height < 1) {
NS_ASSERTION(pixelImageSize.width >= 0 && pixelImageSize.height >= 0,
"Image width or height is negative");
@@ -6127,7 +6127,7 @@ nsLayoutUtils::DrawSingleImage(gfxContext& aContext,
/* static */ void
nsLayoutUtils::ComputeSizeForDrawing(imgIContainer *aImage,
nsIntSize& aImageSize, /*outparam*/
CSSIntSize& aImageSize, /*outparam*/
nsSize& aIntrinsicRatio, /*outparam*/
bool& aGotWidth, /*outparam*/
bool& aGotHeight /*outparam*/)
@@ -6140,16 +6140,16 @@ nsLayoutUtils::ComputeSizeForDrawing(imgIContainer *aImage,
// We hit an error (say, because the image failed to load or couldn't be
// decoded) and should return zero size.
aGotWidth = aGotHeight = true;
aImageSize = nsIntSize(0, 0);
aImageSize = CSSIntSize(0, 0);
aIntrinsicRatio = nsSize(0, 0);
}
}
/* static */ nsIntSize
/* static */ CSSIntSize
nsLayoutUtils::ComputeSizeForDrawingWithFallback(imgIContainer* aImage,
const nsSize& aFallbackSize)
{
nsIntSize imageSize;
CSSIntSize imageSize;
nsSize imageRatio;
bool gotHeight, gotWidth;
ComputeSizeForDrawing(aImage, imageSize, imageRatio, gotWidth, gotHeight);
@@ -6192,7 +6192,7 @@ nsLayoutUtils::ComputeSizeForDrawingWithFallback(imgIContainer* aImage,
nsLayoutUtils::DrawBackgroundImage(gfxContext& aContext,
nsPresContext* aPresContext,
imgIContainer* aImage,
const nsIntSize& aImageSize,
const CSSIntSize& aImageSize,
GraphicsFilter aGraphicsFilter,
const nsRect& aDest,
const nsRect& aFill,
@@ -6266,18 +6266,6 @@ nsLayoutUtils::GetWholeImageDestination(const nsSize& aWholeImageSize,
nsSize(wholeSizeX, wholeSizeY));
}
/* static */ nsRect
nsLayoutUtils::GetWholeImageDestination(const nsIntSize& aWholeImageSize,
const nsRect& aImageSourceArea,
const nsRect& aDestArea)
{
nscoord appUnitsPerCSSPixel = nsDeviceContext::AppUnitsPerCSSPixel();
return GetWholeImageDestination(nsSize(aWholeImageSize.width * appUnitsPerCSSPixel,
aWholeImageSize.height * appUnitsPerCSSPixel),
aImageSourceArea,
aDestArea);
}
/* static */ already_AddRefed<imgIContainer>
nsLayoutUtils::OrientImage(imgIContainer* aContainer,
const nsStyleImageOrientation& aOrientation)
+6 -8
View File
@@ -135,6 +135,7 @@ public:
typedef FrameMetrics::ViewID ViewID;
typedef mozilla::CSSPoint CSSPoint;
typedef mozilla::CSSSize CSSSize;
typedef mozilla::CSSIntSize CSSIntSize;
typedef mozilla::ScreenMargin ScreenMargin;
typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize;
@@ -1671,7 +1672,7 @@ public:
static DrawResult DrawBackgroundImage(gfxContext& aContext,
nsPresContext* aPresContext,
imgIContainer* aImage,
const nsIntSize& aImageSize,
const CSSIntSize& aImageSize,
GraphicsFilter aGraphicsFilter,
const nsRect& aDest,
const nsRect& aFill,
@@ -1808,7 +1809,7 @@ public:
* have less information about the frame tree.
*/
static void ComputeSizeForDrawing(imgIContainer* aImage,
nsIntSize& aImageSize,
CSSIntSize& aImageSize,
nsSize& aIntrinsicRatio,
bool& aGotWidth,
bool& aGotHeight);
@@ -1821,8 +1822,9 @@ public:
* after trying all these methods, no value is available for one or both
* dimensions, the corresponding dimension of aFallbackSize is used instead.
*/
static nsIntSize ComputeSizeForDrawingWithFallback(imgIContainer* aImage,
const nsSize& aFallbackSize);
static CSSIntSize
ComputeSizeForDrawingWithFallback(imgIContainer* aImage,
const nsSize& aFallbackSize);
/**
* Given a source area of an image (in appunits) and a destination area
@@ -1831,10 +1833,6 @@ public:
* the aDest parameter of DrawImage, when we want to draw a subimage
* of an overall image.
*/
static nsRect GetWholeImageDestination(const nsIntSize& aWholeImageSize,
const nsRect& aImageSourceArea,
const nsRect& aDestArea);
static nsRect GetWholeImageDestination(const nsSize& aWholeImageSize,
const nsRect& aImageSourceArea,
const nsRect& aDestArea);
+1 -1
View File
@@ -2485,7 +2485,7 @@ nsStyleBackground::Size::DependsOnPositioningAreaSize(const nsStyleImage& aImage
nsCOMPtr<imgIContainer> imgContainer;
aImage.GetImageData()->GetImage(getter_AddRefs(imgContainer));
if (imgContainer) {
nsIntSize imageSize;
CSSIntSize imageSize;
nsSize imageRatio;
bool hasWidth, hasHeight;
nsLayoutUtils::ComputeSizeForDrawing(imgContainer, imageSize, imageRatio,
+4 -3
View File
@@ -8,6 +8,7 @@
#include "mozilla/Maybe.h"
#include "SVGPreserveAspectRatio.h"
#include "Units.h"
namespace mozilla {
@@ -23,7 +24,7 @@ public:
: mGlobalOpacity(1.0)
{ }
SVGImageContext(nsIntSize aViewportSize,
SVGImageContext(CSSIntSize aViewportSize,
Maybe<SVGPreserveAspectRatio> aPreserveAspectRatio,
gfxFloat aOpacity = 1.0)
: mViewportSize(aViewportSize)
@@ -31,7 +32,7 @@ public:
, mGlobalOpacity(aOpacity)
{ }
const nsIntSize& GetViewportSize() const {
const CSSIntSize& GetViewportSize() const {
return mViewportSize;
}
@@ -65,7 +66,7 @@ private:
return aPAR.Hash();
}
nsIntSize mViewportSize;
CSSIntSize mViewportSize;
Maybe<SVGPreserveAspectRatio> mPreserveAspectRatio;
gfxFloat mGlobalOpacity;
};
+12 -5
View File
@@ -365,13 +365,20 @@ nsSVGImageFrame::PaintSVG(gfxContext& aContext,
if (mImageContainer->GetType() == imgIContainer::TYPE_VECTOR) {
// Package up the attributes of this image element which can override the
// attributes of mImageContainer's internal SVG document.
SVGImageContext context(nsIntSize(width, height),
// attributes of mImageContainer's internal SVG document. The 'width' &
// 'height' values we're passing in here are in CSS units (though they
// come from width/height *attributes* in SVG). They influence the region
// of the SVG image's internal document that is visible, in combination
// with preserveAspectRatio and viewBox.
SVGImageContext context(CSSIntSize(width, height),
Some(imgElem->mPreserveAspectRatio.GetAnimValue()));
nsRect destRect(0, 0,
appUnitsPerDevPx * width,
appUnitsPerDevPx * height);
// For the actual draw operation to draw crisply (and at the right size),
// our destination rect needs to be |width|x|height|, *in dev pixels*.
LayoutDeviceSize devPxSize(width, height);
nsRect destRect(nsPoint(),
LayoutDevicePixel::ToAppUnits(devPxSize,
appUnitsPerDevPx));
// Note: Can't use DrawSingleUnscaledImage for the TYPE_VECTOR case.
// That method needs our image to have a fixed native width & height,
+4 -3
View File
@@ -3552,9 +3552,10 @@ nsTreeBodyFrame::PaintImage(int32_t aRowIndex,
// Essentially, we are scaling the image as dictated by the CSS destination
// height and width, and we are then clipping the scaled image by the cell
// width and height.
nsIntSize rawImageSize;
image->GetWidth(&rawImageSize.width);
image->GetHeight(&rawImageSize.height);
CSSIntSize rawImageCSSIntSize;
image->GetWidth(&rawImageCSSIntSize.width);
image->GetHeight(&rawImageCSSIntSize.height);
nsSize rawImageSize(CSSPixel::ToAppUnits(rawImageCSSIntSize));
nsRect wholeImageDest =
nsLayoutUtils::GetWholeImageDestination(rawImageSize, sourceRect,
nsRect(destRect.TopLeft(), imageDestSize));
+66 -14
View File
@@ -1,31 +1,83 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
const modules = [
Components.utils.import("resource://gre/modules/AppConstants.jsm");
const MODULE_BASE = "resource://services-common/";
const shared_modules = [
"async.js",
"bagheeraclient.js",
"logmanager.js",
"rest.js",
"storageservice.js",
"stringbundle.js",
"tokenserverclient.js",
"utils.js",
];
const test_modules = [
"bagheeraserver.js",
const non_android_modules = [
"tokenserverclient.js",
];
const non_android_healthreport_modules = [
"bagheeraclient.js",
];
const TEST_BASE = "resource://testing-common/services/common/";
const shared_test_modules = [
"logging.js",
];
const non_android_test_modules = [
"storageserver.js",
];
function run_test() {
for each (let m in modules) {
let resource = "resource://services-common/" + m;
Components.utils.import(resource, {});
}
const non_android_healthreport_test_modules = [
"bagheeraserver.js",
];
for each (let m in test_modules) {
let resource = "resource://testing-common/services/common/" + m;
Components.utils.import(resource, {});
function expectImportsToSucceed(mm, base=MODULE_BASE) {
for each (let m in mm) {
let resource = base + m;
let succeeded = false;
try {
Components.utils.import(resource, {});
succeeded = true;
} catch (e) {}
if (!succeeded) {
throw "Importing " + resource + " should have succeeded!";
}
}
}
function expectImportsToFail(mm, base=MODULE_BASE) {
for each (let m in mm) {
let resource = base + m;
let succeeded = false;
try {
Components.utils.import(resource, {});
succeeded = true;
} catch (e) {}
if (succeeded) {
throw "Importing " + resource + " should have failed!";
}
}
}
function run_test() {
expectImportsToSucceed(shared_modules);
expectImportsToSucceed(shared_test_modules, TEST_BASE);
if (AppConstants.platform != "android") {
expectImportsToSucceed(non_android_modules);
expectImportsToSucceed(non_android_test_modules, TEST_BASE);
if (AppConstants.MOZ_SERVICES_HEALTHREPORT) {
expectImportsToSucceed(non_android_healthreport_modules);
expectImportsToSucceed(non_android_healthreport_test_modules, TEST_BASE);
}
} else {
expectImportsToFail(non_android_modules);
expectImportsToFail(non_android_test_modules, TEST_BASE);
expectImportsToFail(non_android_healthreport_modules);
expectImportsToFail(non_android_healthreport_test_modules, TEST_BASE);
}
}
+23 -17
View File
@@ -15,6 +15,7 @@ if (Cu === undefined) {
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
@@ -542,20 +543,29 @@ Tester.prototype = {
// frames and browser intentionally kept alive until shutdown to
// eliminate false positives.
if (gConfig.testRoot == "browser") {
// Replace the document currently loaded in the browser's sidebar.
// This will prevent false positives for tests that were the last
// to touch the sidebar. They will thus not be blamed for leaking
// a document.
let sidebar = document.getElementById("sidebar");
sidebar.setAttribute("src", "data:text/html;charset=utf-8,");
sidebar.docShell.createAboutBlankContentViewer(null);
sidebar.setAttribute("src", "about:blank");
//Skip if SeaMonkey
if (AppConstants.MOZ_APP_NAME != "seamonkey") {
// Replace the document currently loaded in the browser's sidebar.
// This will prevent false positives for tests that were the last
// to touch the sidebar. They will thus not be blamed for leaking
// a document.
let sidebar = document.getElementById("sidebar");
sidebar.setAttribute("src", "data:text/html;charset=utf-8,");
sidebar.docShell.createAboutBlankContentViewer(null);
sidebar.setAttribute("src", "about:blank");
// Do the same for the social sidebar.
let socialSidebar = document.getElementById("social-sidebar-browser");
socialSidebar.setAttribute("src", "data:text/html;charset=utf-8,");
socialSidebar.docShell.createAboutBlankContentViewer(null);
socialSidebar.setAttribute("src", "about:blank");
// Do the same for the social sidebar.
let socialSidebar = document.getElementById("social-sidebar-browser");
socialSidebar.setAttribute("src", "data:text/html;charset=utf-8,");
socialSidebar.docShell.createAboutBlankContentViewer(null);
socialSidebar.setAttribute("src", "about:blank");
SelfSupportBackend.uninit();
CustomizationTabPreloader.uninit();
SocialFlyout.unload();
SocialShare.uninit();
TabView.uninit();
}
// Destroy BackgroundPageThumbs resources.
let {BackgroundPageThumbs} =
@@ -570,10 +580,6 @@ Tester.prototype = {
}
SelfSupportBackend.uninit();
CustomizationTabPreloader.uninit();
SocialFlyout.unload();
SocialShare.uninit();
TabView.uninit();
}
// Schedule GC and CC runs before finishing in order to detect
@@ -43,7 +43,13 @@
#include "nsTerminator.h"
#endif
#if defined(NIGHTLY_BUILD)
#define MOZ_HAS_PERFSTATS
#endif // defined(NIGHTLY_BUILD)
#if defined(MOZ_HAS_PERFSTATS)
#include "nsPerformanceStats.h"
#endif // defined (MOZ_HAS_PERFSTATS)
using namespace mozilla;
@@ -51,7 +57,9 @@ using namespace mozilla;
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAppStartup, Init)
#if defined(MOZ_HAS_PERFSTATS)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPerformanceStatsService)
#endif // defined (MOZ_HAS_PERFSTATS)
#if defined(MOZ_HAS_TERMINATOR)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTerminator)
@@ -84,7 +92,10 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(NativeFileWatcherService, Init)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(AddonPathService, AddonPathService::GetInstance)
NS_DEFINE_NAMED_CID(NS_TOOLKIT_APPSTARTUP_CID);
#if defined(MOZ_HAS_PERFSTATS)
NS_DEFINE_NAMED_CID(NS_TOOLKIT_PERFORMANCESTATSSERVICE_CID);
#endif // defined (MOZ_HAS_PERFSTATS)
#if defined(MOZ_HAS_TERMINATOR)
NS_DEFINE_NAMED_CID(NS_TOOLKIT_TERMINATOR_CID);
#endif
@@ -112,7 +123,9 @@ static const Module::CIDEntry kToolkitCIDs[] = {
#if defined(MOZ_HAS_TERMINATOR)
{ &kNS_TOOLKIT_TERMINATOR_CID, false, nullptr, nsTerminatorConstructor },
#endif
#if defined(MOZ_HAS_PERFSTATS)
{ &kNS_TOOLKIT_PERFORMANCESTATSSERVICE_CID, false, nullptr, nsPerformanceStatsServiceConstructor },
#endif // defined (MOZ_HAS_PERFSTATS)
{ &kNS_USERINFO_CID, false, nullptr, nsUserInfoConstructor },
{ &kNS_ALERTSSERVICE_CID, false, nullptr, nsAlertsServiceConstructor },
#if !defined(MOZ_DISABLE_PARENTAL_CONTROLS)
@@ -139,7 +152,9 @@ static const Module::ContractIDEntry kToolkitContracts[] = {
#if defined(MOZ_HAS_TERMINATOR)
{ NS_TOOLKIT_TERMINATOR_CONTRACTID, &kNS_TOOLKIT_TERMINATOR_CID },
#endif
#if defined(MOZ_HAS_PERFSTATS)
{ NS_TOOLKIT_PERFORMANCESTATSSERVICE_CONTRACTID, &kNS_TOOLKIT_PERFORMANCESTATSSERVICE_CID },
#endif // defined (MOZ_HAS_PERFSTATS)
{ NS_USERINFO_CONTRACTID, &kNS_USERINFO_CID },
{ NS_ALERTSERVICE_CONTRACTID, &kNS_ALERTSSERVICE_CID },
#if !defined(MOZ_DISABLE_PARENTAL_CONTROLS)
+5 -1
View File
@@ -11,7 +11,6 @@ if CONFIG['MOZ_ENABLE_XREMOTE']:
DIRS += [
'aboutcache',
'aboutmemory',
'aboutperformance',
'addoncompat',
'alerts',
'apppicker',
@@ -84,6 +83,11 @@ if CONFIG['MOZ_CAPTIVEDETECT']:
if CONFIG['MOZ_WIDGET_TOOLKIT'] != "gonk" and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
DIRS += ['terminator']
if CONFIG['NIGHTLY_BUILD']: # Bug 1136927 - Performance Monitoring is not ready for prime-time yet
DIRS += [
'aboutperformance',
]
DIRS += ['build']
EXTRA_COMPONENTS += [
+240 -78
View File
@@ -3373,105 +3373,267 @@
"n_buckets" : 10,
"description": "PLACES: Days from last maintenance"
},
"UPDATER_BACKGROUND_CHECK_CODE_EXTERNAL": {
"expires_in_version": "default",
"kind": "enumerated",
"n_values": 50,
"description": "Updater: externally initiated (typically by the application) background update check result code (see PING_BGUC_* constants defined in /toolkit/mozapps/update/nsUpdateService.js)"
"UPDATE_CHECK_NO_UPDATE_EXTERNAL" : {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of no updates were found for a background update check (externally initiated)"
},
"UPDATER_BACKGROUND_CHECK_CODE_NOTIFY": {
"expires_in_version": "40",
"kind": "enumerated",
"n_values": 50,
"description": "Updater: timer initiated background update check result code (see PING_BGUC_* constants defined in /toolkit/mozapps/update/nsUpdateService.js)"
"UPDATE_CHECK_NO_UPDATE_NOTIFY" : {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of no updates were found for a background update check (timer initiated)"
},
"UPDATER_INVALID_LASTUPDATETIME_EXTERNAL": {
"expires_in_version": "40",
"kind": "boolean",
"description": "Updater: Whether the last update time is invalid when a background update check was externally requested (typically by the application)"
},
"UPDATER_INVALID_LASTUPDATETIME_NOTIFY": {
"expires_in_version": "40",
"kind": "boolean",
"description": "Updater: Whether the last update time is invalid when a background update check was timer initiated"
},
"UPDATER_LAST_NOTIFY_INTERVAL_DAYS_EXTERNAL": {
"expires_in_version": "40",
"kind": "exponential",
"n_buckets": 10,
"high": "60",
"description": "Updater: The interval in days between the previous and the current background update check when the check was externally requested (typically by the application)"
},
"UPDATER_LAST_NOTIFY_INTERVAL_DAYS_NOTIFY": {
"expires_in_version": "40",
"kind": "exponential",
"n_buckets": 10,
"high": "60",
"description": "Updater: The interval in days between the previous and the current background update check when the check was timer initiated"
},
"UPDATER_STATUS_CODES": {
"UPDATE_CHECK_CODE_EXTERNAL": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 50,
"description": "Updater: the status of the latest update performed"
"description": "Update: background update check result code except for no updates found (externally initiated)"
},
"UPDATER_UPDATES_ENABLED": {
"expires_in_version": "default",
"UPDATE_CHECK_CODE_NOTIFY": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 50,
"description": "Update: background update check result code except for no updates found (timer initiated)"
},
"UPDATE_CHECK_EXTENDED_ERROR_EXTERNAL": {
"expires_in_version": "never",
"kind": "count",
"keyed": true,
"description": "Update: keyed count (key names are prefixed with AUS_CHECK_EX_ERR_) of background update check extended error code (externally initiated)"
},
"UPDATE_CHECK_EXTENDED_ERROR_NOTIFY": {
"expires_in_version": "never",
"kind": "count",
"keyed": true,
"description": "Update: keyed count (key names are prefixed with AUS_CHECK_EX_ERR_) of background update check extended error code (timer initiated)"
},
"UPDATE_INVALID_LASTUPDATETIME_EXTERNAL": {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of systems that have a last update time greater than the current time (externally initiated)"
},
"UPDATE_INVALID_LASTUPDATETIME_NOTIFY": {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of systems that have a last update time greater than the current time (timer initiated)"
},
"UPDATE_LAST_NOTIFY_INTERVAL_DAYS_EXTERNAL": {
"expires_in_version": "never",
"kind": "exponential",
"n_buckets": 60,
"high": "365",
"description": "Update: interval in days since the last background update check (externally initiated)"
},
"UPDATE_LAST_NOTIFY_INTERVAL_DAYS_NOTIFY": {
"expires_in_version": "never",
"kind": "exponential",
"n_buckets": 30,
"high": "180",
"description": "Update: interval in days since the last background update check (timer initiated)"
},
"UPDATE_SERVICE_INSTALLED_EXTERNAL": {
"expires_in_version": "never",
"kind": "boolean",
"description": "Updater: Whether or not updates are enabled"
"description": "Update: whether the service is installed (externally initiated)"
},
"UPDATER_UPDATES_METRO_ENABLED": {
"expires_in_version": "default",
"UPDATE_SERVICE_INSTALLED_NOTIFY": {
"expires_in_version": "never",
"kind": "boolean",
"description": "Updater: Whether or not Metro updates are enabled"
"description": "Update: whether the service is installed (timer initiated)"
},
"UPDATER_UPDATES_AUTOMATIC": {
"expires_in_version": "40",
"UPDATE_SERVICE_MANUALLY_UNINSTALLED_EXTERNAL": {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of systems that manually uninstalled the service (externally initiated)"
},
"UPDATE_SERVICE_MANUALLY_UNINSTALLED_NOTIFY": {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of systems that manually uninstalled the service (timer initiated)"
},
"UPDATE_CANNOT_APPLY_EXTERNAL": {
"expires_in_version": "never",
"kind": "boolean",
"description": "Updater: Whether or not updates are automatic"
"description": "Update: systems that cannot apply updates (externally initiated)"
},
"UPDATER_SERVICE_ENABLED": {
"expires_in_version": "default",
"UPDATE_CANNOT_APPLY_NOTIFY": {
"expires_in_version": "never",
"kind": "boolean",
"description": "Updater: Whether or not the MozillaMaintenance service is enabled"
"description": "Update: systems that cannot apply updates (timer initiated)"
},
"UPDATER_SERVICE_ERROR_CODE": {
"expires_in_version": "default",
"UPDATE_CANNOT_STAGE_EXTERNAL": {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of systems that cannot stage updates (externally initiated)"
},
"UPDATE_CANNOT_STAGE_NOTIFY": {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of systems that cannot stage updates (timer initiated)"
},
"UPDATE_HAS_PREF_URL_OVERRIDE_EXTERNAL": {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of systems that have an app.update.url.override preference (externally initiated)"
},
"UPDATE_HAS_PREF_URL_OVERRIDE_NOTIFY": {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of systems that have an app.update.url.override preference (timer initiated)"
},
"UPDATE_PREF_UPDATE_CANCELATIONS_EXTERNAL": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 100,
"description": "Updater: 0=success else SERVICE_* error code defined in /toolkit/mozapps/update/common/errors.h"
"description": "Update: number of sequential update elevation request cancelations greater than 0 (externally initiated)"
},
"UPDATER_SERVICE_ERRORS": {
"expires_in_version": "default",
"UPDATE_PREF_UPDATE_CANCELATIONS_NOTIFY": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 100,
"description": "Update: number of sequential update elevation request cancelations greater than 0 (timer initiated)"
},
"UPDATE_PREF_SERVICE_ERRORS_EXTERNAL": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 30,
"description": "Updater: The number of MozillaMaintenance service errors that have occurred"
"description": "Update: number of sequential update service errors greater than 0 (externally initiated)"
},
"UPDATER_SERVICE_INSTALLED": {
"expires_in_version": "default",
"kind": "boolean",
"description": "Updater: Whether or not the MozillaMaintenance service is installed"
},
"UPDATER_SERVICE_MANUALLY_UNINSTALLED": {
"expires_in_version": "default",
"kind": "boolean",
"description": "Updater: Whether or not someone manually uninstalled the service."
},
"UPDATER_STAGE_ENABLED": {
"expires_in_version": "40",
"kind": "boolean",
"description": "Updater: Whether or not staging updates are enabled"
},
"UPDATER_HAS_PERMISSIONS": {
"expires_in_version": "40",
"kind": "boolean",
"description": "Updater: Whether or not the updater has permissions"
},
"UPDATER_WIZ_LAST_PAGE_CODE": {
"expires_in_version": "40",
"UPDATE_PREF_SERVICE_ERRORS_NOTIFY": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 25,
"description": "Updater: The update wizard page displayed when the UI was closed (mapped in toolkit/mozapps/update/content/updates.js)"
"n_values": 30,
"description": "Update: number of sequential update service errors greater than 0 (timer initiated)"
},
"UPDATE_NOT_PREF_UPDATE_AUTO_EXTERNAL": {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of when the app.update.auto boolean preference is not the default value of true (true values are not submitted)"
},
"UPDATE_NOT_PREF_UPDATE_AUTO_NOTIFY": {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of when the app.update.auto boolean preference is not the default value of true (true values are not submitted)"
},
"UPDATE_NOT_PREF_UPDATE_ENABLED_EXTERNAL": {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of when the app.update.enabled boolean preference is not the default value of true (true values are not submitted)"
},
"UPDATE_NOT_PREF_UPDATE_ENABLED_NOTIFY": {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of when the app.update.enabled boolean preference is not the default value of true (true values are not submitted)"
},
"UPDATE_NOT_PREF_UPDATE_STAGING_ENABLED_EXTERNAL": {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of when the app.update.staging.enabled boolean preference is not the default value of true (true values are not submitted)"
},
"UPDATE_NOT_PREF_UPDATE_STAGING_ENABLED_NOTIFY": {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of when the app.update.staging.enabled boolean preference is not the default value of true (true values are not submitted)"
},
"UPDATE_NOT_PREF_UPDATE_SERVICE_ENABLED_EXTERNAL": {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of when the app.update.service.enabled boolean preference is not the default value of true (true values are not submitted)"
},
"UPDATE_NOT_PREF_UPDATE_SERVICE_ENABLED_NOTIFY": {
"expires_in_version": "never",
"kind": "count",
"description": "Update: count of when the app.update.service.enabled boolean preference is not the default value of true (true values are not submitted)"
},
"UPDATE_DOWNLOAD_CODE_COMPLETE": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 50,
"description": "Update: complete patch download result code"
},
"UPDATE_DOWNLOAD_CODE_PARTIAL": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 50,
"description": "Update: complete patch download result code"
},
"UPDATE_STATE_CODE_COMPLETE_STARTUP": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 20,
"description": "Update: the state of a complete update from update.status on startup"
},
"UPDATE_STATE_CODE_PARTIAL_STARTUP": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 20,
"description": "Update: the state of a partial patch update from update.status on startup"
},
"UPDATE_STATE_CODE_UNKNOWN_STARTUP": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 20,
"description": "Update: the state of an unknown patch update from update.status on startup"
},
"UPDATE_STATE_CODE_COMPLETE_STAGE": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 20,
"description": "Update: the state of a complete patch update from update.status after staging"
},
"UPDATE_STATE_CODE_PARTIAL_STAGE": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 20,
"description": "Update: the state of a partial patch update from update.status after staging"
},
"UPDATE_STATE_CODE_UNKNOWN_STAGE": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 20,
"description": "Update: the state of an unknown patch update from update.status after staging"
},
"UPDATE_STATUS_ERROR_CODE_COMPLETE_STARTUP": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 100,
"description": "Update: the status error code for a failed complete patch update from update.status on startup"
},
"UPDATE_STATUS_ERROR_CODE_PARTIAL_STARTUP": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 100,
"description": "Update: the status error code for a failed partial patch update from update.status on startup"
},
"UPDATE_STATUS_ERROR_CODE_UNKNOWN_STARTUP": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 100,
"description": "Update: the status error code for a failed unknown patch update from update.status on startup"
},
"UPDATE_STATUS_ERROR_CODE_COMPLETE_STAGE": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 100,
"description": "Update: the status error code for a failed complete patch update from update.status after staging"
},
"UPDATE_STATUS_ERROR_CODE_PARTIAL_STAGE": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 100,
"description": "Update: the status error code for a failed partial patch update from update.status after staging"
},
"UPDATE_STATUS_ERROR_CODE_UNKNOWN_STAGE": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 100,
"description": "Update: the status error code for a failed unknown patch update from update.status after staging"
},
"UPDATE_WIZ_LAST_PAGE_CODE": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 30,
"description": "Update: the update wizard page displayed when the UI was closed (mapped in toolkit/mozapps/update/UpdateTelemetry.jsm)"
},
"THUNDERBIRD_GLODA_SIZE_MB": {
"expires_in_version": "40",
+48 -2
View File
@@ -8,7 +8,7 @@
this.EXPORTED_SYMBOLS = ["AppConstants"];
// Immutable for export.
let AppConstants = Object.freeze({
this.AppConstants = Object.freeze({
// See this wiki page for more details about channel specific build
// defines: https://wiki.mozilla.org/Platform/Channel-specific_build_defines
NIGHTLY_BUILD:
@@ -63,6 +63,24 @@ let AppConstants = Object.freeze({
false,
#endif
MOZ_SANDBOX:
#ifdef MOZ_SANDBOX
true,
#else
false,
#endif
MOZ_SHARK:
#ifdef XP_MACOSX
#ifdef MOZ_SHARK
true,
#else
false,
#endif
#else
false,
#endif
MOZ_TELEMETRY_REPORTING:
#ifdef MOZ_TELEMETRY_REPORTING
true,
@@ -70,6 +88,13 @@ let AppConstants = Object.freeze({
false,
#endif
MOZ_UPDATER:
#ifdef MOZ_UPDATER
true,
#else
false,
#endif
MOZ_WEBRTC:
#ifdef MOZ_WEBRTC
true,
@@ -77,6 +102,8 @@ let AppConstants = Object.freeze({
false,
#endif
# NOTE! XP_LINUX has to go after MOZ_WIDGET_ANDROID otherwise Android
# builds will be misidentified as linux.
platform:
#ifdef MOZ_WIDGET_GTK
"linux",
@@ -90,6 +117,8 @@ let AppConstants = Object.freeze({
"android",
#elif MOZ_WIDGET_GONK
"gonk",
#elif XP_LINUX
"linux",
#else
"other",
#endif
@@ -101,7 +130,24 @@ let AppConstants = Object.freeze({
false,
#endif
MOZ_APP_VERSION: "@MOZ_APP_VERSION@",
MOZ_MAINTENANCE_SERVICE:
#ifdef MOZ_MAINTENANCE_SERVICE
true,
#else
false,
#endif
E10S_TESTING_ONLY:
#ifdef E10S_TESTING_ONLY
true,
#else
false,
#endif
MOZ_APP_NAME: "@MOZ_APP_NAME@",
MOZ_APP_VERSION: "@MOZ_APP_VERSION@",
MOZ_BUILD_APP: "@MOZ_BUILD_APP@",
MOZ_UPDATE_CHANNEL: "@MOZ_UPDATE_CHANNEL@",
MOZ_WIDGET_TOOLKIT: "@MOZ_WIDGET_TOOLKIT@",
ANDROID_PACKAGE_NAME: "@ANDROID_PACKAGE_NAME@",
});
-2
View File
@@ -1,9 +1,7 @@
#if 0
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#endif
this.EXPORTED_SYMBOLS = [ "BadCertHandler", "checkCert", "readCertPrefs", "validateCert" ];
const Ce = Components.Exception;
+108 -112
View File
@@ -25,6 +25,7 @@ Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/ctypes.jsm");
Cu.import("resource://gre/modules/GMPUtils.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
this.EXPORTED_SYMBOLS = ["GMPInstallManager", "GMPExtractor", "GMPDownloader",
"GMPAddon"];
@@ -62,122 +63,121 @@ function getScopedLogger(prefix) {
// TODO: refactor this out somewhere else
XPCOMUtils.defineLazyGetter(this, "gOSVersion", function aus_gOSVersion() {
let osVersion;
let sysInfo = Cc["@mozilla.org/system-info;1"].
getService(Ci.nsIPropertyBag2);
try {
osVersion = sysInfo.getProperty("name") + " " + sysInfo.getProperty("version");
osVersion = Services.sysinfo.getProperty("name") + " " +
Services.sysinfo.getProperty("version");
}
catch (e) {
LOG("gOSVersion - OS Version unknown: updates are not possible.");
}
if (osVersion) {
#ifdef XP_WIN
const BYTE = ctypes.uint8_t;
const WORD = ctypes.uint16_t;
const DWORD = ctypes.uint32_t;
const WCHAR = ctypes.char16_t;
const BOOL = ctypes.int;
// This structure is described at:
// http://msdn.microsoft.com/en-us/library/ms724833%28v=vs.85%29.aspx
const SZCSDVERSIONLENGTH = 128;
const OSVERSIONINFOEXW = new ctypes.StructType('OSVERSIONINFOEXW',
[
{dwOSVersionInfoSize: DWORD},
{dwMajorVersion: DWORD},
{dwMinorVersion: DWORD},
{dwBuildNumber: DWORD},
{dwPlatformId: DWORD},
{szCSDVersion: ctypes.ArrayType(WCHAR, SZCSDVERSIONLENGTH)},
{wServicePackMajor: WORD},
{wServicePackMinor: WORD},
{wSuiteMask: WORD},
{wProductType: BYTE},
{wReserved: BYTE}
]);
// This structure is described at:
// http://msdn.microsoft.com/en-us/library/ms724958%28v=vs.85%29.aspx
const SYSTEM_INFO = new ctypes.StructType('SYSTEM_INFO',
[
{wProcessorArchitecture: WORD},
{wReserved: WORD},
{dwPageSize: DWORD},
{lpMinimumApplicationAddress: ctypes.voidptr_t},
{lpMaximumApplicationAddress: ctypes.voidptr_t},
{dwActiveProcessorMask: DWORD.ptr},
{dwNumberOfProcessors: DWORD},
{dwProcessorType: DWORD},
{dwAllocationGranularity: DWORD},
{wProcessorLevel: WORD},
{wProcessorRevision: WORD}
]);
let kernel32 = false;
try {
kernel32 = ctypes.open("Kernel32");
} catch (e) {
LOG("gOSVersion - Unable to open kernel32! " + e);
osVersion += ".unknown (unknown)";
}
if(kernel32) {
if (AppConstants.platform == "win") {
const BYTE = ctypes.uint8_t;
const WORD = ctypes.uint16_t;
const DWORD = ctypes.uint32_t;
const WCHAR = ctypes.char16_t;
const BOOL = ctypes.int;
// This structure is described at:
// http://msdn.microsoft.com/en-us/library/ms724833%28v=vs.85%29.aspx
const SZCSDVERSIONLENGTH = 128;
const OSVERSIONINFOEXW = new ctypes.StructType('OSVERSIONINFOEXW',
[
{dwOSVersionInfoSize: DWORD},
{dwMajorVersion: DWORD},
{dwMinorVersion: DWORD},
{dwBuildNumber: DWORD},
{dwPlatformId: DWORD},
{szCSDVersion: ctypes.ArrayType(WCHAR, SZCSDVERSIONLENGTH)},
{wServicePackMajor: WORD},
{wServicePackMinor: WORD},
{wSuiteMask: WORD},
{wProductType: BYTE},
{wReserved: BYTE}
]);
// This structure is described at:
// http://msdn.microsoft.com/en-us/library/ms724958%28v=vs.85%29.aspx
const SYSTEM_INFO = new ctypes.StructType('SYSTEM_INFO',
[
{wProcessorArchitecture: WORD},
{wReserved: WORD},
{dwPageSize: DWORD},
{lpMinimumApplicationAddress: ctypes.voidptr_t},
{lpMaximumApplicationAddress: ctypes.voidptr_t},
{dwActiveProcessorMask: DWORD.ptr},
{dwNumberOfProcessors: DWORD},
{dwProcessorType: DWORD},
{dwAllocationGranularity: DWORD},
{wProcessorLevel: WORD},
{wProcessorRevision: WORD}
]);
let kernel32 = false;
try {
// Get Service pack info
kernel32 = ctypes.open("Kernel32");
} catch (e) {
LOG("gOSVersion - Unable to open kernel32! " + e);
osVersion += ".unknown (unknown)";
}
if(kernel32) {
try {
let GetVersionEx = kernel32.declare("GetVersionExW",
ctypes.default_abi,
BOOL,
OSVERSIONINFOEXW.ptr);
let winVer = OSVERSIONINFOEXW();
winVer.dwOSVersionInfoSize = OSVERSIONINFOEXW.size;
if(0 !== GetVersionEx(winVer.address())) {
osVersion += "." + winVer.wServicePackMajor
+ "." + winVer.wServicePackMinor;
} else {
LOG("gOSVersion - Unknown failure in GetVersionEX (returned 0)");
// Get Service pack info
try {
let GetVersionEx = kernel32.declare("GetVersionExW",
ctypes.default_abi,
BOOL,
OSVERSIONINFOEXW.ptr);
let winVer = OSVERSIONINFOEXW();
winVer.dwOSVersionInfoSize = OSVERSIONINFOEXW.size;
if(0 !== GetVersionEx(winVer.address())) {
osVersion += "." + winVer.wServicePackMajor
+ "." + winVer.wServicePackMinor;
} else {
LOG("gOSVersion - Unknown failure in GetVersionEX (returned 0)");
osVersion += ".unknown";
}
} catch (e) {
LOG("gOSVersion - error getting service pack information. Exception: " + e);
osVersion += ".unknown";
}
} catch (e) {
LOG("gOSVersion - error getting service pack information. Exception: " + e);
osVersion += ".unknown";
}
// Get processor architecture
let arch = "unknown";
try {
let GetNativeSystemInfo = kernel32.declare("GetNativeSystemInfo",
ctypes.default_abi,
ctypes.void_t,
SYSTEM_INFO.ptr);
let sysInfo = SYSTEM_INFO();
// Default to unknown
sysInfo.wProcessorArchitecture = 0xffff;
GetNativeSystemInfo(sysInfo.address());
switch(sysInfo.wProcessorArchitecture) {
case 9:
arch = "x64";
break;
case 6:
arch = "IA64";
break;
case 0:
arch = "x86";
break;
// Get processor architecture
let arch = "unknown";
try {
let GetNativeSystemInfo = kernel32.declare("GetNativeSystemInfo",
ctypes.default_abi,
ctypes.void_t,
SYSTEM_INFO.ptr);
let sysInfo = SYSTEM_INFO();
// Default to unknown
sysInfo.wProcessorArchitecture = 0xffff;
GetNativeSystemInfo(sysInfo.address());
switch(sysInfo.wProcessorArchitecture) {
case 9:
arch = "x64";
break;
case 6:
arch = "IA64";
break;
case 0:
arch = "x86";
break;
}
} catch (e) {
LOG("gOSVersion - error getting processor architecture. Exception: " + e);
} finally {
osVersion += " (" + arch + ")";
}
} catch (e) {
LOG("gOSVersion - error getting processor architecture. Exception: " + e);
} finally {
osVersion += " (" + arch + ")";
kernel32.close();
}
} finally {
kernel32.close();
}
}
#endif
try {
osVersion += " (" + sysInfo.getProperty("secondaryLibrary") + ")";
@@ -201,19 +201,15 @@ XPCOMUtils.defineLazyGetter(this, "gABI", function aus_gABI() {
catch (e) {
LOG("gABI - XPCOM ABI unknown: updates are not possible.");
}
#ifdef XP_MACOSX
// Mac universal build should report a different ABI than either macppc
// or mactel.
let macutils = Cc["@mozilla.org/xpcom/mac-utils;1"].
getService(Ci.nsIMacUtils);
if (AppConstants.platform == "macosx") {
// Mac universal build should report a different ABI than either macppc
// or mactel.
let macutils = Cc["@mozilla.org/xpcom/mac-utils;1"].
getService(Ci.nsIMacUtils);
if (macutils.isUniversalBinary)
abi += "-u-" + macutils.architecturesInBinary;
#ifdef MOZ_SHARK
// Disambiguate optimised and shark nightlies
abi += "-shark"
#endif
#endif
if (macutils.isUniversalBinary)
abi += "-u-" + macutils.architecturesInBinary;
}
return abi;
});
+2 -3
View File
@@ -8,6 +8,7 @@ const {utils: Cu} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeImageOptimizer",
"resource://gre/modules/addons/LightweightThemeImageOptimizer.jsm");
@@ -144,13 +145,12 @@ LightweightThemeConsumer.prototype = {
footer.removeAttribute("lwthemefooter");
}
#ifdef XP_MACOSX
// On OS X, we extend the lightweight theme into the titlebar, which means setting
// the chromemargin attribute. Some XUL applications already draw in the titlebar,
// so we need to save the chromemargin value before we overwrite it with the value
// that lets us draw in the titlebar. We stash this value on the root attribute so
// that XUL applications have the ability to invalidate the saved value.
if (stateChanging) {
if (AppConstants.platform == "macosx" && stateChanging) {
if (!root.hasAttribute("chromemargin-nonlwtheme")) {
root.setAttribute("chromemargin-nonlwtheme", root.getAttribute("chromemargin"));
}
@@ -166,7 +166,6 @@ LightweightThemeConsumer.prototype = {
}
}
}
#endif
Services.obs.notifyObservers(this._win, "lightweight-theme-window-updated",
JSON.stringify(aData));
}
+35 -25
View File
@@ -10,6 +10,7 @@ const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/AddonManager.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
let Experiments;
try {
@@ -156,9 +157,8 @@ let dataProviders = {
safeMode: Services.appinfo.inSafeMode,
};
#ifdef MOZ_UPDATER
data.updateChannel = Cu.import("resource://gre/modules/UpdateChannel.jsm", {}).UpdateChannel.get();
#endif
if (AppConstants.MOZ_UPDATER)
data.updateChannel = Cu.import("resource://gre/modules/UpdateChannel.jsm", {}).UpdateChannel.get();
try {
data.vendor = Services.prefs.getCharPref("app.support.vendor");
@@ -346,12 +346,9 @@ let dataProviders = {
}
if (!data.numAcceleratedWindows && gfxInfo) {
let feature =
#ifdef XP_WIN
gfxInfo.FEATURE_DIRECT3D_9_LAYERS;
#else
gfxInfo.FEATURE_OPENGL_LAYERS;
#endif
let win = AppConstants.platform == "win";
let feature = win ? gfxInfo.FEATURE_DIRECT3D_9_LAYERS :
gfxInfo.FEATURE_OPENGL_LAYERS;
data.numAcceleratedWindowsMessage = statusMsgForFeature(feature);
}
@@ -422,20 +419,20 @@ let dataProviders = {
+ " -- "
+ gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
} else {
let feature =
#ifdef XP_WIN
let feature;
if (AppConstants.platform == "win") {
// If ANGLE is not available but OpenGL is, we want to report on the
// OpenGL feature, because that's what's going to get used. In all
// other cases we want to report on the ANGLE feature.
gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBGL_ANGLE) !=
Ci.nsIGfxInfo.FEATURE_STATUS_OK &&
gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBGL_OPENGL) ==
Ci.nsIGfxInfo.FEATURE_STATUS_OK ?
Ci.nsIGfxInfo.FEATURE_WEBGL_OPENGL :
Ci.nsIGfxInfo.FEATURE_WEBGL_ANGLE;
#else
Ci.nsIGfxInfo.FEATURE_WEBGL_OPENGL;
#endif
let angle = gfxInfo.getFeatureStatus(gfxInfo.FEATURE_WEBGL_ANGLE) ==
gfxInfo.FEATURE_STATUS_OK;
let opengl = gfxInfo.getFeatureStatus(gfxInfo.FEATURE_WEBGL_OPENGL) ==
gfxInfo.FEATURE_STATUS_OK;
feature = !angle && opengl ? gfxInfo.FEATURE_WEBGL_OPENGL :
gfxInfo.FEATURE_WEBGL_ANGLE;
} else {
feature = gfxInfo.FEATURE_WEBGL_OPENGL;
}
data.webglRendererMessage = statusMsgForFeature(feature);
}
@@ -508,10 +505,24 @@ let dataProviders = {
done({
exists: userJSFile.exists() && userJSFile.fileSize > 0,
});
},
}
};
#if defined(XP_LINUX) && defined (MOZ_SANDBOX)
sandbox: function sandbox(done) {
if (AppConstants.MOZ_CRASHREPORTER) {
dataProviders.crashes = function crashes(done) {
let CrashReports = Cu.import("resource://gre/modules/CrashReports.jsm").CrashReports;
let reports = CrashReports.getReports();
let now = new Date();
let reportsNew = reports.filter(report => (now - report.date < Troubleshoot.kMaxCrashAge));
let reportsSubmitted = reportsNew.filter(report => (!report.pending));
let reportsPendingCount = reportsNew.length - reportsSubmitted.length;
let data = {submitted : reportsSubmitted, pending : reportsPendingCount};
done(data);
}
}
if (AppConstants.platform == "linux" && AppConstants.MOZ_SANDBOX) {
dataProviders.sandbox = function sandbox(done) {
const keys = ["hasSeccompBPF", "hasSeccompTSync",
"hasPrivilegedUserNamespaces", "hasUserNamespaces",
"canSandboxContent", "canSandboxMedia"];
@@ -526,5 +537,4 @@ let dataProviders = {
}
done(data);
}
#endif
};
}
+13 -18
View File
@@ -2,23 +2,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef XP_WIN
#define USE_HITTEST
#elifdef MOZ_WIDGET_COCOA
#define USE_HITTEST
#endif
Components.utils.import("resource://gre/modules/AppConstants.jsm");
const USE_HITTEST = /^(win|macosx)/i.test(AppConstants.platform);
this.EXPORTED_SYMBOLS = [ "WindowDraggingElement" ];
this.WindowDraggingElement = function WindowDraggingElement(elem) {
this._elem = elem;
this._window = elem.ownerDocument.defaultView;
#ifdef USE_HITTEST
if (!this.isPanel())
if (USE_HITTEST && !this.isPanel())
this._elem.addEventListener("MozMouseHittest", this, false);
else
#endif
this._elem.addEventListener("mousedown", this, false);
this._elem.addEventListener("mousedown", this, false);
};
WindowDraggingElement.prototype = {
@@ -60,24 +57,23 @@ WindowDraggingElement.prototype = {
},
handleEvent: function(aEvent) {
let isPanel = this.isPanel();
#ifdef USE_HITTEST
if (!isPanel) {
if (USE_HITTEST && !isPanel) {
if (this.shouldDrag(aEvent))
aEvent.preventDefault();
return;
}
#endif
switch (aEvent.type) {
case "mousedown":
if (!this.shouldDrag(aEvent))
return;
#ifdef MOZ_WIDGET_GTK
// On GTK, there is a toolkit-level function which handles
// window dragging, which must be used.
this._window.beginWindowMove(aEvent, isPanel ? this._elem : null);
#else
if (/^gtk/i.test(AppConstants.MOZ_WIDGET_TOOLKIT)) {
// On GTK, there is a toolkit-level function which handles
// window dragging, which must be used.
this._window.beginWindowMove(aEvent, isPanel ? this._elem : null);
break;
}
if (isPanel) {
let screenRect = this._elem.getOuterScreenRect();
this._deltaX = aEvent.screenX - screenRect.left;
@@ -90,7 +86,6 @@ WindowDraggingElement.prototype = {
this._draggingWindow = true;
this._window.addEventListener("mousemove", this, false);
this._window.addEventListener("mouseup", this, false);
#endif
break;
case "mousemove":
if (this._draggingWindow) {
+12 -13
View File
@@ -16,6 +16,7 @@ EXTRA_JS_MODULES += [
'Battery.jsm',
'BinarySearch.jsm',
'BrowserUtils.jsm',
'CertUtils.jsm',
'CharsetMenu.jsm',
'debug.js',
'DeferredTask.jsm',
@@ -24,6 +25,7 @@ EXTRA_JS_MODULES += [
'FileUtils.jsm',
'Finder.jsm',
'Geometry.jsm',
'GMPInstallManager.jsm',
'GMPUtils.jsm',
'Http.jsm',
'InlineSpellChecker.jsm',
@@ -47,6 +49,8 @@ EXTRA_JS_MODULES += [
'RemoteSecurityUI.jsm',
'RemoteWebNavigation.jsm',
'RemoteWebProgress.jsm',
'ResetProfile.jsm',
'secondscreen/RokuApp.jsm',
'secondscreen/SimpleServiceDiscovery.jsm',
'SelectContentHelper.jsm',
'SelectParentHelper.jsm',
@@ -60,24 +64,21 @@ EXTRA_JS_MODULES += [
'Task.jsm',
'TelemetryTimestamps.jsm',
'Timer.jsm',
'Troubleshoot.jsm',
'WebChannel.jsm',
'WindowDraggingUtils.jsm',
'ZipUtils.jsm',
]
EXTRA_PP_JS_MODULES += [
'CertUtils.jsm',
'GMPInstallManager.jsm',
'ResetProfile.jsm',
'secondscreen/RokuApp.jsm',
'AppConstants.jsm',
'Services.jsm',
'Troubleshoot.jsm',
'UpdateChannel.jsm',
'WindowDraggingUtils.jsm',
'WindowsPrefSync.jsm',
]
if 'Android' != CONFIG['OS_TARGET']:
EXTRA_PP_JS_MODULES += [
EXTRA_JS_MODULES += [
'LightweightThemeConsumer.jsm',
]
else:
@@ -91,14 +92,12 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
for var in ('ANDROID_PACKAGE_NAME',
'MOZ_APP_NAME',
'MOZ_APP_VERSION'):
'MOZ_APP_VERSION',
'MOZ_WIDGET_TOOLKIT'):
DEFINES[var] = CONFIG[var]
for var in ('MOZILLA_OFFICIAL',
'MOZ_TOOLKIT_SEARCH'):
'MOZ_TOOLKIT_SEARCH',
'MOZ_UPDATER'):
if CONFIG[var]:
DEFINES[var] = True
EXTRA_PP_JS_MODULES += [
'AppConstants.jsm',
]
+2 -5
View File
@@ -10,6 +10,7 @@ this.EXPORTED_SYMBOLS = ["RokuApp"];
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
const WEBRTC_PLAYER_NAME = "WebRTC Player";
const MIRROR_PORT = 8011;
@@ -28,11 +29,7 @@ const PROTOCOL_VERSION = 1;
function RokuApp(service) {
this.service = service;
this.resourceURL = this.service.location;
#ifdef RELEASE_BUILD
this.app = "Firefox";
#else
this.app = "Firefox Nightly";
#endif
this.app = AppConstants.RELEASE_BUILD ? "Firefox" : "Firefox Nightly";
this.mediaAppID = -1;
this.mirrorAppID = -1;
}
+520
View File
@@ -0,0 +1,520 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
this.EXPORTED_SYMBOLS = [
"AUSTLMY"
];
const {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components;
Cu.import("resource://gre/modules/Services.jsm", this);
this.AUSTLMY = {
// Telemetry for the application update background update check occurs when
// the background update timer fires after the update interval which is
// determined by the app.update.interval preference and its telemetry
// histogram IDs have the suffix '_NOTIFY'.
// Telemetry for the externally initiated background update check occurs when
// a call is made to |checkForBackgroundUpdates| which is typically initiated
// by an application when it has determined that the application should have
// received an update. This has separate telemetry so it is possible to
// analyze using the telemetry data systems that have not been updating when
// they should have.
// The update check was performed by the call to checkForBackgroundUpdates in
// nsUpdateService.js.
EXTERNAL: "EXTERNAL",
// The update check was performed by the call to notify in nsUpdateService.js.
NOTIFY: "NOTIFY",
/**
* Values for the UPDATE_CHECK_CODE_NOTIFY and UPDATE_CHECK_CODE_EXTERNAL
* Telemetry histograms.
*/
// No update found (no notification)
CHK_NO_UPDATE_FOUND: 0,
// No incompatible add-ons found during incompatible check (background download)
CHK_ADDON_NO_INCOMPAT: 1,
// Showing prompt due to the update.xml specifying showPrompt
// (update notification)
CHK_SHOWPROMPT_SNIPPET: 2,
// Showing prompt due to preference (update notification)
CHK_SHOWPROMPT_PREF: 3,
// Incompatible add-on check disabled by preference (background download)
CHK_ADDON_PREF_DISABLED: 4,
// Incompatible add-on checke not performed due to same app version as the
// update's app version (background download)
CHK_ADDON_SAME_APP_VER: 5,
// Incompatible add-ons found and all of them have updates (background download)
CHK_ADDON_UPDATES_FOR_INCOMPAT: 6,
// Incompatible add-ons found (update notification)
CHK_ADDON_HAVE_INCOMPAT: 7,
// Already has an active update in progress (no notification)
CHK_HAS_ACTIVEUPDATE: 8,
// A background download is already in progress (no notification)
CHK_IS_DOWNLOADING: 9,
// An update is already staged (no notification)
CHK_IS_STAGED: 10,
// An update is already downloaded (no notification)
CHK_IS_DOWNLOADED: 11,
// Background checks disabled by preference (no notification)
CHK_PREF_DISABLED: 12,
// Update checks disabled by admin locked preference (no notification)
CHK_ADMIN_DISABLED: 13,
// Unable to check for updates per hasUpdateMutex() (no notification)
CHK_NO_MUTEX: 14,
// Unable to check for updates per gCanCheckForUpdates (no notification). This
// should be covered by other codes and is recorded just in case.
CHK_UNABLE_TO_CHECK: 15,
// Background checks disabled for the current session (no notification)
CHK_DISABLED_FOR_SESSION: 16,
// Unable to perform a background check while offline (no notification)
CHK_OFFLINE: 17,
// No update found certificate check failed and threshold reached
// (possible mitm attack notification)
CHK_CERT_ATTR_NO_UPDATE_PROMPT: 18,
// No update found certificate check failed and threshold not reached
// (no notification)
CHK_CERT_ATTR_NO_UPDATE_SILENT: 19,
// Update found certificate check failed and threshold reached
// (possible mitm attack notification)
CHK_CERT_ATTR_WITH_UPDATE_PROMPT: 20,
// Update found certificate check failed and threshold not reached
// (no notification)
CHK_CERT_ATTR_WITH_UPDATE_SILENT: 21,
// General update check failure and threshold reached
// (check failure notification)
CHK_GENERAL_ERROR_PROMPT: 22,
// General update check failure and threshold not reached (no notification)
CHK_GENERAL_ERROR_SILENT: 23,
// No compatible update found though there were updates (no notification)
CHK_NO_COMPAT_UPDATE_FOUND: 24,
// Update found for a previous version (no notification)
CHK_UPDATE_PREVIOUS_VERSION: 25,
// Update found for a version with the never preference set (no notification)
CHK_UPDATE_NEVER_PREF: 26,
// Update found without a type attribute (no notification)
CHK_UPDATE_INVALID_TYPE: 27,
// The system is no longer supported (system unsupported notification)
CHK_UNSUPPORTED: 28,
// Unable to apply updates (manual install to update notification)
CHK_UNABLE_TO_APPLY: 29,
// Unable to check for updates due to no OS version (no notification)
CHK_NO_OS_VERSION: 30,
// Unable to check for updates due to no OS ABI (no notification)
CHK_NO_OS_ABI: 31,
// Invalid url for app.update.url default preference (no notification)
CHK_INVALID_DEFAULT_URL: 32,
// Invalid url for app.update.url user preference (no notification)
CHK_INVALID_USER_OVERRIDE_URL: 33,
// Invalid url for app.update.url.override user preference (no notification)
CHK_INVALID_DEFAULT_OVERRIDE_URL: 34,
/**
* Submit a telemetry ping for the update check result code or a telemetry
* ping for a count type histogram count when no update was found. The no
* update found ping is separate since it is the typical result, is less
* interesting than the other result codes, and it is easier to analyze the
* other codes without including it.
*
* @param aSuffix
* The histogram id suffix for histogram IDs:
* UPDATE_CHECK_CODE_EXTERNAL
* UPDATE_CHECK_CODE_NOTIFY
* UPDATE_CHECK_NO_UPDATE_EXTERNAL
* UPDATE_CHECK_NO_UPDATE_NOTIFY
* @param aCode
* An integer value as defined by the values that start with CHK_ in
* the above section.
*/
pingCheckCode: function UT_pingCheckCode(aSuffix, aCode) {
try {
if (aCode == this.CHK_NO_UPDATE_FOUND) {
let id = "UPDATE_CHECK_NO_UPDATE_" + aSuffix;
// count type histogram
Services.telemetry.getHistogramById(id).add();
} else {
let id = "UPDATE_CHECK_CODE_" + aSuffix;
// enumerated type histogram
Services.telemetry.getHistogramById(id).add(aCode);
}
} catch (e) {
Cu.reportError(e);
}
},
/**
* Submit a telemetry ping for a failed update check's unhandled error code
* when the pingCheckCode is CHK_GENERAL_ERROR_SILENT. The histogram is a
* keyed count type with key names that are prefixed with 'AUS_CHECK_EX_ERR_'.
*
* @param aSuffix
* The histogram id suffix for histogram IDs:
* UPDATE_CHK_EXTENDED_ERROR_EXTERNAL
* UPDATE_CHK_EXTENDED_ERROR_NOTIFY
* @param aCode
* The extended error value return by a failed update check.
*/
pingCheckExError: function UT_pingCheckExError(aSuffix, aCode) {
try {
let id = "UPDATE_CHECK_EXTENDED_ERROR_" + aSuffix;
let val = "AUS_CHECK_EX_ERR_" + aCode;
// keyed count type histogram
Services.telemetry.getKeyedHistogramById(id).add(val);
} catch (e) {
Cu.reportError(e);
}
},
// The state code and if present the status error code were read on startup.
STARTUP: "STARTUP",
// The state code and status error code if present were read after staging.
STAGE: "STAGE",
// Patch type Complete
PATCH_COMPLETE: "COMPLETE",
// Patch type partial
PATCH_PARTIAL: "PARTIAL",
// Patch type unknown
PATCH_UNKNOWN: "UNKNOWN",
/**
* Values for the UPDATE_DOWNLOAD_CODE_COMPLETE and
* UPDATE_DOWNLOAD_CODE_PARTIAL Telemetry histograms.
*/
DWNLD_SUCCESS: 0,
DWNLD_RETRY_OFFLINE: 1,
DWNLD_RETRY_NET_TIMEOUT: 2,
DWNLD_RETRY_CONNECTION_REFUSED: 3,
DWNLD_RETRY_NET_RESET: 4,
DWNLD_ERR_NO_UPDATE: 5,
DWNLD_ERR_NO_UPDATE_PATCH: 6,
DWNLD_ERR_NO_PATCH_FILE: 7,
DWNLD_ERR_PATCH_SIZE_LARGER: 8,
DWNLD_ERR_PATCH_SIZE_NOT_EQUAL: 9,
DWNLD_ERR_BINDING_ABORTED: 10,
DWNLD_ERR_ABORT: 11,
DWNLD_ERR_DOCUMENT_NOT_CACHED: 12,
DWNLD_ERR_VERIFY_NO_REQUEST: 13,
DWNLD_ERR_VERIFY_PATCH_SIZE_NOT_EQUAL: 14,
DWNLD_ERR_VERIFY_NO_HASH_MATCH: 15,
/**
* Submit a telemetry ping for the update download result code.
*
* @param aIsComplete
* If true the histogram is for a patch type complete, if false the
* histogram is for a patch type partial, and when undefined the
* histogram is for an unknown patch type. This is used to determine
* the histogram ID out of the following histogram IDs:
* UPDATE_DOWNLOAD_CODE_COMPLETE
* UPDATE_DOWNLOAD_CODE_PARTIAL
* @param aCode
* An integer value as defined by the values that start with DWNLD_ in
* the above section.
*/
pingDownloadCode: function UT_pingDownloadCode(aIsComplete, aCode) {
let patchType = this.PATCH_UNKNOWN;
if (aIsComplete === true) {
patchType = this.PATCH_COMPLETE;
} else if (aIsComplete === false) {
patchType = this.PATCH_PARTIAL;
}
try {
let id = "UPDATE_DOWNLOAD_CODE_" + patchType;
// enumerated type histogram
Services.telemetry.getHistogramById(id).add(aCode);
} catch (e) {
Cu.reportError(e);
}
},
/**
* Submit a telemetry ping for the update status state code.
*
* @param aSuffix
* The histogram id suffix for histogram IDs:
* UPDATE_STATE_CODE_COMPLETE_STARTUP
* UPDATE_STATE_CODE_PARTIAL_STARTUP
* UPDATE_STATE_CODE_UNKNOWN_STARTUP
* UPDATE_STATE_CODE_COMPLETE_STAGE
* UPDATE_STATE_CODE_PARTIAL_STAGE
* UPDATE_STATE_CODE_UNKNOWN_STAGE
* @param aCode
* An integer value as defined by the values that start with STATE_ in
* the above section for the update state from the update.status file.
*/
pingStateCode: function UT_pingStateCode(aSuffix, aCode) {
try {
let id = "UPDATE_STATE_CODE_" + aSuffix;
// enumerated type histogram
Services.telemetry.getHistogramById(id).add(aCode);
} catch(e) {
Cu.reportError(e);
}
},
/**
* Submit a telemetry ping for the update status error code. This does not
* submit a success value which can be determined from the state code.
*
* @param aSuffix
* The histogram id suffix for histogram IDs:
* UPDATE_STATUS_ERROR_CODE_COMPLETE_STARTUP
* UPDATE_STATUS_ERROR_CODE_PARTIAL_STARTUP
* UPDATE_STATUS_ERROR_CODE_UNKNOWN_STARTUP
* UPDATE_STATUS_ERROR_CODE_COMPLETE_STAGE
* UPDATE_STATUS_ERROR_CODE_PARTIAL_STAGE
* UPDATE_STATUS_ERROR_CODE_UNKNOWN_STAGE
* @param aCode
* An integer value for the error code from the update.status file.
*/
pingStatusErrorCode: function UT_pingStatusErrorCode(aSuffix, aCode) {
try {
let id = "UPDATE_STATUS_ERROR_CODE_" + aSuffix;
// enumerated type histogram
Services.telemetry.getHistogramById(id).add(aCode);
} catch(e) {
Cu.reportError(e);
}
},
/**
* Submit the interval in days since the last notification for this background
* update check or a boolean if the last notification is in the future.
*
* @param aSuffix
* The histogram id suffix for histogram IDs:
* UPDATE_INVALID_LASTUPDATETIME_EXTERNAL
* UPDATE_INVALID_LASTUPDATETIME_NOTIFY
* UPDATE_LAST_NOTIFY_INTERVAL_DAYS_EXTERNAL
* UPDATE_LAST_NOTIFY_INTERVAL_DAYS_NOTIFY
*/
pingLastUpdateTime: function UT_pingLastUpdateTime(aSuffix) {
const PREF_APP_UPDATE_LASTUPDATETIME = "app.update.lastUpdateTime.background-update-timer";
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_LASTUPDATETIME)) {
let lastUpdateTimeSeconds = Services.prefs.getIntPref(PREF_APP_UPDATE_LASTUPDATETIME);
if (lastUpdateTimeSeconds) {
let currentTimeSeconds = Math.round(Date.now() / 1000);
if (lastUpdateTimeSeconds > currentTimeSeconds) {
try {
let id = "UPDATE_INVALID_LASTUPDATETIME_" + aSuffix;
// count type histogram
Services.telemetry.getHistogramById().add();
} catch(e) {
Cu.reportError(e);
}
} else {
let intervalDays = (currentTimeSeconds - lastUpdateTimeSeconds) /
(60 * 60 * 24);
try {
let id = "UPDATE_LAST_NOTIFY_INTERVAL_DAYS_" + aSuffix;
// exponential type histogram
Services.telemetry.getHistogramById(id).add(intervalDays);
} catch(e) {
Cu.reportError(e);
}
}
}
}
},
/**
* Submit a telemetry ping for the last page displayed by the update wizard.
*
* @param aPageID
* The page id for the last page displayed.
*/
pingWizLastPageCode: function UT_pingWizLastPageCode(aPageID) {
let pageMap = { invalid: 0,
dummy: 1,
checking: 2,
pluginupdatesfound: 3,
noupdatesfound: 4,
manualUpdate: 5,
unsupported: 6,
incompatibleCheck: 7,
updatesfoundbasic: 8,
updatesfoundbillboard: 9,
license: 10,
incompatibleList: 11,
downloading: 12,
errors: 13,
errorextra: 14,
errorpatching: 15,
finished: 16,
finishedBackground: 17,
installed: 18 };
try {
let id = "UPDATE_WIZ_LAST_PAGE_CODE";
// enumerated type histogram
Services.telemetry.getHistogramById(id).add(pageMap[aPageID] ||
pageMap.invalid);
} catch (e) {
Cu.reportError(e);
}
},
/**
* Submit a telemetry ping for a boolean type histogram that indicates if the
* service is installed and a telemetry ping for a boolean type histogram that
* indicates if the service was at some point installed and is now
* uninstalled.
* Note: the total for the following histogram IDs can be used to determine
* the total number of telemetry timer and externally initiated
* submissions for systems that build with MOZ_MAINTENANCE_SERVICE
* defined:
* UPDATE_SERVICE_INSTALLED_EXTERNAL
* UPDATE_SERVICE_INSTALLED_NOTIFY
*
* @param aSuffix
* The histogram id suffix for histogram IDs:
* UPDATE_SERVICE_INSTALLED_EXTERNAL
* UPDATE_SERVICE_INSTALLED_NOTIFY
* UPDATE_SERVICE_MANUALLY_UNINSTALLED_EXTERNAL
* UPDATE_SERVICE_MANUALLY_UNINSTALLED_NOTIFY
* @param aInstalled
* Whether the service is installed.
*/
pingServiceInstallStatus: function UT_PSIS(aSuffix, aInstalled) {
// Report the error but don't throw since it is more important to
// successfully update than to throw.
if (!("@mozilla.org/windows-registry-key;1" in Cc)) {
Cu.reportError(Cr.NS_ERROR_NOT_AVAILABLE);
return;
}
try {
let id = "UPDATE_SERVICE_INSTALLED_" + aSuffix;
// boolean type histogram
Services.telemetry.getHistogramById(id).add(aInstalled);
} catch(e) {
Cu.reportError(e);
}
let attempted = 0;
try {
let wrk = Cc["@mozilla.org/windows-registry-key;1"].
createInstance(Ci.nsIWindowsRegKey);
wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE,
"SOFTWARE\\Mozilla\\MaintenanceService",
wrk.ACCESS_READ | wrk.WOW64_64);
// Was the service at some point installed, but is now uninstalled?
attempted = wrk.readIntValue("Attempted");
wrk.close();
} catch(e) {
// Since this will throw if the registry key doesn't exist (e.g. the
// service has never been installed) don't report an error.
}
try {
let id = "UPDATE_SERVICE_MANUALLY_UNINSTALLED_" + aSuffix;
if (!aInstalled && attempted) {
// count type histogram
Services.telemetry.getHistogramById(id).add();
}
} catch(e) {
Cu.reportError(e);
}
},
/**
* Submit a telemetry ping for a count type histogram when the expected value
* does not equal the boolean value of a pref or if the pref isn't present
* when the expected value does not equal default value. This lessens the
* amount of data submitted to telemetry.
*
* @param aID
* The histogram ID to report to.
* @param aPref
* The preference to check.
* @param aDefault
* The default value when the preference isn't present.
* @param aExpected (optional)
* If specified and the value is the same as the value that will be
* added the value won't be added to telemetry.
*/
pingBoolPref: function UT_pingBoolPref(aID, aPref, aDefault, aExpected) {
try {
let val = aDefault;
if (Services.prefs.getPrefType(aPref) != Ci.nsIPrefBranch.PREF_INVALID) {
val = Services.prefs.getBoolPref(aPref);
}
if (val != aExpected) {
// count type histogram
Services.telemetry.getHistogramById(aID).add();
}
} catch(e) {
Cu.reportError(e);
}
},
/**
* Submit a telemetry ping for a histogram with the integer value of a
* preference when it is not the expected value or the default value when it
* is not the expected value. This lessens the amount of data submitted to
* telemetry.
*
* @param aID
* The histogram ID to report to.
* @param aPref
* The preference to check.
* @param aDefault
* The default value when the pref is not set.
* @param aExpected (optional)
* If specified and the value is the same as the value that will be
* added the value won't be added to telemetry.
*/
pingIntPref: function UT_pingIntPref(aID, aPref, aDefault, aExpected) {
try {
let val = aDefault;
if (Services.prefs.getPrefType(aPref) != Ci.nsIPrefBranch.PREF_INVALID) {
val = Services.prefs.getIntPref(aPref);
}
if (aExpected === undefined || val != aExpected) {
// enumerated or exponential type histogram
Services.telemetry.getHistogramById(aID).add(val);
}
} catch(e) {
Cu.reportError(e);
}
},
/**
* Submit a telemetry ping for all histogram types that take a single
* parameter to the telemetry add function and the count type histogram when
* the aExpected parameter is specified. If the aExpected parameter is
* specified and it equals the value specified by the aValue
* parameter the telemetry submission will be skipped.
* Note: the total for the following histogram IDs can be used to determine
* the total number of telemetry timer and externally initiated
* submissions:
* UPDATE_CANNOT_APPLY_EXTERNAL
* UPDATE_CANNOT_APPLY_NOTIFY
*
* @param aID
* The histogram ID to report to.
* @param aValue
* The value to add when aExpected is not defined or the value to
* check if it is equal to when aExpected is defined.
* @param aExpected (optional)
* If specified and the value is the same as the value specified by
* aValue parameter the submission will be skipped.
*/
pingGeneric: function UT_pingGeneric(aID, aValue, aExpected) {
try {
if (aExpected === undefined) {
Services.telemetry.getHistogramById(aID).add(aValue);
} else if (aValue != aExpected) {
// count type histogram
Services.telemetry.getHistogramById(aID).add();
}
} catch(e) {
Cu.reportError(e);
}
}
};
Object.freeze(AUSTLMY);
@@ -1,69 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
this.EXPORTED_SYMBOLS = [
"UpdateProvider",
];
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/Metrics.jsm", this);
Cu.import("resource://gre/modules/Task.jsm", this);
const DAILY_COUNTER_FIELD = {type: Metrics.Storage.FIELD_DAILY_COUNTER};
const DAILY_DISCRETE_NUMERIC_FIELD = {type: Metrics.Storage.FIELD_DAILY_DISCRETE_NUMERIC};
function UpdateMeasurement1() {
Metrics.Measurement.call(this);
}
UpdateMeasurement1.prototype = Object.freeze({
__proto__: Metrics.Measurement.prototype,
name: "update",
version: 1,
fields: {
updateCheckStartCount: DAILY_COUNTER_FIELD,
updateCheckSuccessCount: DAILY_COUNTER_FIELD,
updateCheckFailedCount: DAILY_COUNTER_FIELD,
updateCheckFailedStatuses: DAILY_DISCRETE_NUMERIC_FIELD,
completeUpdateStartCount: DAILY_COUNTER_FIELD,
partialUpdateStartCount: DAILY_COUNTER_FIELD,
completeUpdateSuccessCount: DAILY_COUNTER_FIELD,
partialUpdateSuccessCount: DAILY_COUNTER_FIELD,
updateFailedCount: DAILY_COUNTER_FIELD,
updateFailedStatuses: DAILY_DISCRETE_NUMERIC_FIELD,
},
});
this.UpdateProvider = function () {
Metrics.Provider.call(this);
};
UpdateProvider.prototype = Object.freeze({
__proto__: Metrics.Provider.prototype,
name: "org.mozilla.update",
measurementTypes: [
UpdateMeasurement1,
],
recordUpdate: function (field, status) {
let m = this.getMeasurement(UpdateMeasurement1.prototype.name,
UpdateMeasurement1.prototype.version);
return this.enqueueStorageOperation(function recordUpdateFields() {
return Task.spawn(function recordUpdateFieldsTask() {
yield m.incrementDailyCounter(field + "Count");
if ((field == "updateFailed" || field == "updateCheckFailed") && status) {
yield m.addDailyDiscreteNumeric(field + "Statuses", status);
}
}.bind(this));
}.bind(this));
},
});
+7 -5
View File
@@ -9,9 +9,12 @@
#define OK 0
// Old unused error codes:
// #define MEM_ERROR 1 // Replaced with errors 10-16 (inclusive)
// #define IO_ERROR 2 // Use READ_ERROR or WRITE_ERROR instead
// Error codes that are no longer used should not be used again unless they
// aren't used in client code (e.g. nsUpdateService.js, updates.js,
// UpdatePrompt.js, etc.).
#define MAR_ERROR_EMPTY_ACTION_LIST 1
#define LOADSOURCE_ERROR_WRONG_SIZE 2
// Error codes 3-16 are for general update problems.
#define USAGE_ERROR 3
@@ -39,8 +42,7 @@
#define MAR_CHANNEL_MISMATCH_ERROR 22
#define VERSION_DOWNGRADE_ERROR 23
// Error codes 24-34 are related to the maintenance service
// and so are Windows only
// Error codes 24-33 and 49 are for the Windows maintenance service.
#define SERVICE_UPDATER_COULD_NOT_BE_STARTED 24
#define SERVICE_NOT_ENOUGH_COMMAND_LINE_ARGS 25
#define SERVICE_UPDATER_SIGN_ERROR 26
+33 -57
View File
@@ -5,15 +5,14 @@
'use strict';
Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
Components.utils.import("resource://gre/modules/AddonManager.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
// Firefox's macBrowserOverlay.xul includes scripts that define Cc, Ci, and Cr
// so we have to use different names.
const CoC = Components.classes;
const CoI = Components.interfaces;
const CoR = Components.results;
const {classes: CoC, interfaces: CoI, results: CoR, utils: CoU} = Components;
CoU.import("resource://gre/modules/DownloadUtils.jsm", this);
CoU.import("resource://gre/modules/AddonManager.jsm", this);
CoU.import("resource://gre/modules/Services.jsm", this);
CoU.import("resource://gre/modules/UpdateTelemetry.jsm", this);
const XMLNS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
@@ -22,13 +21,16 @@ const PREF_APP_UPDATE_BILLBOARD_TEST_URL = "app.update.billboard.test_url";
const PREF_APP_UPDATE_CERT_ERRORS = "app.update.cert.errors";
const PREF_APP_UPDATE_ENABLED = "app.update.enabled";
const PREF_APP_UPDATE_LOG = "app.update.log";
const PREF_APP_UPDATE_MANUAL_URL = "app.update.url.manual";
const PREF_APP_UPDATE_NEVER_BRANCH = "app.update.never.";
const PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED = "app.update.notifiedUnsupported";
const PREF_APP_UPDATE_TEST_LOOP = "app.update.test.loop";
const PREF_PLUGINS_UPDATEURL = "plugins.update.url";
const PREF_APP_UPDATE_URL_MANUAL = "app.update.url.manual";
const UPDATE_TEST_LOOP_INTERVAL = 2000;
const PREFBRANCH_APP_UPDATE_NEVER = "app.update.never.";
const PREF_EM_HOTFIX_ID = "extensions.hotfix.id";
const PREF_PLUGINS_UPDATE_URL = "plugins.update.url";
const UPDATE_TEST_LOOP_INTERVAL = 2000;
const URI_UPDATES_PROPERTIES = "chrome://mozapps/locale/update/updates.properties";
@@ -143,38 +145,12 @@ var gUpdates = {
_runUnload: true,
/**
* Submit the last page code when the wizard exited. The pageid is used to map
* to an integer instead of using the pageindex since pages can be added and
* removed which would change the page's pageindex.
* @param pageID
* Submit on close telemtry values for the update wizard.
* @param pageID
* The page id for the last page displayed.
*/
_sendLastPageCodePing: function(pageID) {
var pageMap = { invalid: 0,
dummy: 1,
checking: 2,
pluginupdatesfound: 3,
noupdatesfound: 4,
manualUpdate: 5,
unsupported: 6,
incompatibleCheck: 7,
updatesfoundbasic: 8,
updatesfoundbillboard: 9,
license: 10,
incompatibleList: 11,
downloading: 12,
errors: 13,
errorextra: 14,
errorpatching: 15,
finished: 16,
finishedBackground: 17,
installed: 18 };
try {
Services.telemetry.getHistogramById("UPDATER_WIZ_LAST_PAGE_CODE").
add(pageMap[pageID] || pageMap.invalid);
}
catch (e) {
Components.utils.reportError(e);
}
_submitTelemetry: function(aPageID) {
AUSTLMY.pingWizLastPageCode(aPageID);
},
/**
@@ -267,7 +243,7 @@ var gUpdates = {
// If the user clicks "No Thanks", we should not prompt them to update to
// this version again unless they manually select "Check for Updates..."
// which will clear all of the "never" prefs.
var neverPrefName = PREF_APP_UPDATE_NEVER_BRANCH + this.update.appVersion;
var neverPrefName = PREFBRANCH_APP_UPDATE_NEVER + this.update.appVersion;
Services.prefs.setBoolPref(neverPrefName, true);
},
@@ -286,7 +262,7 @@ var gUpdates = {
var pageid = document.documentElement.currentPage.pageid;
if ("onWizardFinish" in this._pages[pageid])
this._pages[pageid].onWizardFinish();
this._sendLastPageCodePing(pageid);
this._submitTelemetry(pageid);
},
/**
@@ -298,7 +274,7 @@ var gUpdates = {
var pageid = document.documentElement.currentPage.pageid;
if ("onWizardCancel" in this._pages[pageid])
this._pages[pageid].onWizardCancel();
this._sendLastPageCodePing(pageid);
this._submitTelemetry(pageid);
},
/**
@@ -551,7 +527,7 @@ var gUpdates = {
"or the findUpdates method!";
if (addon.id)
errMsg += " Add-on ID: " + addon.id;
Components.utils.reportError(errMsg);
CoU.reportError(errMsg);
return;
}
@@ -573,7 +549,7 @@ var gUpdates = {
self.addons.push(addon);
}
catch (e) {
Components.utils.reportError(e);
CoU.reportError(e);
}
});
@@ -626,7 +602,7 @@ var gCheckingPage = {
// clicked "never" for an update, selected "Check for Updates...", and
// then canceled. If we don't clear the "never" prefs future
// notifications will never happen.
Services.prefs.deleteBranch(PREF_APP_UPDATE_NEVER_BRANCH);
Services.prefs.deleteBranch(PREFBRANCH_APP_UPDATE_NEVER);
// The user will be notified if there is an error so clear the background
// check error count.
@@ -737,18 +713,18 @@ var gPluginsPage = {
* URL of the plugin updates page
*/
_url: null,
/**
* Initialize
*/
onPageShow: function() {
var prefs = Services.prefs;
if (prefs.getPrefType(PREF_PLUGINS_UPDATEURL) == prefs.PREF_INVALID) {
if (prefs.getPrefType(PREF_PLUGINS_UPDATE_URL) == prefs.PREF_INVALID) {
gUpdates.wiz.goTo("noupdatesfound");
return;
}
this._url = Services.urlFormatter.formatURLPref(PREF_PLUGINS_UPDATEURL);
this._url = Services.urlFormatter.formatURLPref(PREF_PLUGINS_UPDATE_URL);
var link = document.getElementById("pluginupdateslink");
link.setAttribute("href", this._url);
@@ -775,7 +751,7 @@ var gPluginsPage = {
gUpdates.setButtons(null, null, "okButton", true);
gUpdates.wiz.getButton("finish").focus();
},
/**
* Finish button clicked.
*/
@@ -907,7 +883,7 @@ var gIncompatibleCheckPage = {
*/
var gManualUpdatePage = {
onPageShow: function() {
var manualURL = Services.urlFormatter.formatURLPref(PREF_APP_UPDATE_MANUAL_URL);
var manualURL = Services.urlFormatter.formatURLPref(PREF_APP_UPDATE_URL_MANUAL);
var manualUpdateLinkLabel = document.getElementById("manualUpdateLinkLabel");
manualUpdateLinkLabel.value = manualURL;
manualUpdateLinkLabel.setAttribute("url", manualURL);
@@ -1710,7 +1686,7 @@ var gErrorsPage = {
var errorReason = document.getElementById("errorReason");
errorReason.value = statusText;
var manualURL = Services.urlFormatter.formatURLPref(PREF_APP_UPDATE_MANUAL_URL);
var manualURL = Services.urlFormatter.formatURLPref(PREF_APP_UPDATE_URL_MANUAL);
var errorLinkLabel = document.getElementById("errorLinkLabel");
errorLinkLabel.value = manualURL;
errorLinkLabel.setAttribute("url", manualURL);
@@ -1749,7 +1725,7 @@ var gErrorExtraPage = {
}
else
document.getElementById("genericBackgroundErrorLabel").hidden = false;
var manualURL = Services.urlFormatter.formatURLPref(PREF_APP_UPDATE_MANUAL_URL);
var manualURL = Services.urlFormatter.formatURLPref(PREF_APP_UPDATE_URL_MANUAL);
var errorLinkLabel = document.getElementById("errorExtraLinkLabel");
errorLinkLabel.value = manualURL;
errorLinkLabel.setAttribute("url", manualURL);
@@ -1772,7 +1748,7 @@ var gErrorPatchingPage = {
onWizardNext: function() {
switch (gUpdates.update.selectedPatch.state) {
case STATE_PENDING:
case STATE_PENDING_SVC:
case STATE_PENDING_SVC:
gUpdates.wiz.goTo("finished");
break;
case STATE_DOWNLOADING:
+2 -5
View File
@@ -31,16 +31,13 @@ if CONFIG['MOZ_UPDATER']:
]
EXTRA_COMPONENTS += [
'nsUpdateService.manifest',
]
EXTRA_PP_COMPONENTS += [
'nsUpdateService.js',
'nsUpdateService.manifest',
'nsUpdateServiceStub.js',
]
EXTRA_JS_MODULES += [
'UpdaterHealthProvider.jsm'
'UpdateTelemetry.jsm',
]
JAR_MANIFESTS += ['jar.mn']
+2 -2
View File
@@ -476,7 +476,7 @@ interface nsIUpdateProcessor : nsISupports
* An interface describing a global application service that maintains a list
* of updates previously performed as well as the current active update.
*/
[scriptable, uuid(c5df56de-919d-406b-aaf9-106dfa9b685b)]
[scriptable, uuid(f8371237-10a6-46a5-b23f-f6f7684e9d71)]
interface nsIUpdateManager : nsISupports
{
/**
@@ -505,7 +505,7 @@ interface nsIUpdateManager : nsISupports
/**
* Refresh the update status based on the information in update.status.
*/
void refreshUpdateStatus(in nsIUpdate update);
void refreshUpdateStatus();
};
/**
File diff suppressed because it is too large Load Diff
+4 -142
View File
@@ -3,137 +3,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const Ci = Components.interfaces;
const Cc = Components.classes;
const Cu = Components.utils;
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
Cu.import("resource://gre/modules/FileUtils.jsm", this);
const DIR_UPDATES = "updates";
const FILE_UPDATES_DB = "updates.xml";
const FILE_UPDATE_ACTIVE = "active-update.xml";
const FILE_LAST_LOG = "last-update.log";
const FILE_BACKUP_LOG = "backup-update.log";
const FILE_UPDATE_STATUS = "update.status";
const KEY_UPDROOT = "UpdRootD";
#ifdef XP_WIN
const PREF_APP_UPDATE_MIGRATE_APP_DIR = "app.update.migrated.updateDir";
function getTaskbarIDHash(rootKey, exePath, appInfoName) {
let registry = Cc["@mozilla.org/windows-registry-key;1"].
createInstance(Ci.nsIWindowsRegKey);
try {
registry.open(rootKey, "Software\\Mozilla\\" + appInfoName + "\\TaskBarIDs",
Ci.nsIWindowsRegKey.ACCESS_READ);
if (registry.hasValue(exePath)) {
return registry.readStringValue(exePath);
}
} catch (ex) {
} finally {
registry.close();
}
return undefined;
};
/*
* Migrates old update directory files to the new update directory
* which is based on a hash of the installation.
*/
function migrateOldUpdateDir() {
// Get the old udpate root leaf dir. It is based on the sub directory of
// program files, or if the exe path is not inside program files, the appname.
var appinfo = Components.classes["@mozilla.org/xre/app-info;1"].
getService(Components.interfaces.nsIXULAppInfo).
QueryInterface(Components.interfaces.nsIXULRuntime);
var updateLeafName;
var programFiles = FileUtils.getFile("ProgF", []);
var exeFile = FileUtils.getFile("XREExeF", []);
if (exeFile.path.substring(0, programFiles.path.length).toLowerCase() ==
programFiles.path.toLowerCase()) {
updateLeafName = exeFile.parent.leafName;
} else {
updateLeafName = appinfo.name;
}
// Get the old update root dir
var oldUpdateRoot;
if (appinfo.vendor) {
oldUpdateRoot = FileUtils.getDir("LocalAppData", [appinfo.vendor,
appinfo.name,
updateLeafName], false);
} else {
oldUpdateRoot = FileUtils.getDir("LocalAppData", [appinfo.name,
updateLeafName], false);
}
// Obtain the new update root
var newUpdateRoot = FileUtils.getDir("UpdRootD", [], true);
// If there is no taskbar ID then we want to retry this migration
// at a later time if the application gets a taskbar ID.
var taskbarID = getTaskbarIDHash(Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
exeFile.parent.path, appinfo.name);
if (!taskbarID) {
taskbarID = getTaskbarIDHash(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
exeFile.parent.path, appinfo.name);
if (!taskbarID) {
return;
}
}
Services.prefs.setBoolPref(PREF_APP_UPDATE_MIGRATE_APP_DIR, true);
// Sanity checks only to ensure we don't delete something we don't mean to.
if (oldUpdateRoot.path.toLowerCase() == newUpdateRoot.path.toLowerCase() ||
updateLeafName.length == 0) {
return;
}
// If the old update root doesn't exist then we have already migrated
// or else there is no work to do.
if (!oldUpdateRoot.exists()) {
return;
}
// Get an array of all of the files we want to migrate.
// We do this so we don't copy anything extra.
var filesToMigrate = [FILE_UPDATES_DB, FILE_UPDATE_ACTIVE,
["updates", FILE_LAST_LOG], ["updates", FILE_BACKUP_LOG],
["updates", "0", FILE_UPDATE_STATUS]];
// Move each of those files to the new directory
filesToMigrate.forEach(relPath => {
let oldFile = oldUpdateRoot.clone();
let newFile = newUpdateRoot.clone();
if (relPath instanceof Array) {
relPath.forEach(relPathPart => {
oldFile.append(relPathPart);
newFile.append(relPathPart);
});
} else {
oldFile.append(relPath);
newFile.append(relPath);
}
try {
if (!newFile.exists()) {
oldFile.moveTo(newFile.parent, newFile.leafName);
}
} catch (e) {
Components.utils.reportError(e);
}
});
oldUpdateRoot.remove(true);
}
#endif
/**
* Gets the specified directory at the specified hierarchy under the update root
* directory without creating it if it doesn't exist.
@@ -147,28 +26,11 @@ function getUpdateDirNoCreate(pathArray) {
}
function UpdateServiceStub() {
#ifdef XP_WIN
// Don't attempt this migration more than once for perf reasons
var migrated = 0;
try {
migrated = Services.prefs.getBoolPref(PREF_APP_UPDATE_MIGRATE_APP_DIR);
} catch (e) {
}
if (!migrated) {
try {
migrateOldUpdateDir();
} catch (e) {
Components.utils.reportError(e);
}
}
#endif
let statusFile = getUpdateDirNoCreate([DIR_UPDATES, "0"]);
statusFile.append(FILE_UPDATE_STATUS);
// If the update.status file exists then initiate post update processing.
if (statusFile.exists()) {
let aus = Components.classes["@mozilla.org/updates/update-service;1"].
let aus = Cc["@mozilla.org/updates/update-service;1"].
getService(Ci.nsIApplicationUpdateService).
QueryInterface(Ci.nsIObserver);
aus.observe(null, "post-update-processing", "");
@@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm", this);
Components.utils.import("resource://gre/modules/Services.jsm", this);
const Cc = Components.classes;
const Ci = Components.interfaces;
+21 -30
View File
@@ -5,49 +5,40 @@
XPCSHELLTESTROOT = $(abspath $(DEPTH))/_tests/xpcshell/$(relativesrcdir)
CHROMETESTROOT = $(abspath $(DEPTH))/_tests/testing/mochitest/chrome/$(relativesrcdir)
PP_TARGETS += aus-update-head
aus-update-head_FLAGS := -Fsubstitution $(DEFINES) $(ACDEFINES)
aus-update-head := $(srcdir)/unit_aus_update/head_update.js
aus-update-head_PATH := $(XPCSHELLTESTROOT)/unit_aus_update
aus-update-head_TARGET := misc
pp_const_file = $(srcdir)/data/xpcshellConstantsPP.js
INSTALL_TARGETS += xpcshell-data
xpcshell-data_TARGET := misc
xpcshell-data_DEST := $(XPCSHELLTESTROOT)/data
xpcshell-data_FILES := $(wildcard $(srcdir)/data/*)
PP_TARGETS += aus-test-const
aus-test-const := $(pp_const_file)
aus-test-const_PATH := $(XPCSHELLTESTROOT)/data
aus-test-const_FLAGS := -Fsubstitution $(DEFINES) $(ACDEFINES)
aus-test-const_TARGET := misc
INSTALL_TARGETS += xpcshell-data
xpcshell-data_FILES := $(filter-out $(pp_const_file),$(wildcard $(srcdir)/data/*))
xpcshell-data_DEST := $(XPCSHELLTESTROOT)/data
xpcshell-data_TARGET := misc
# Android doesn't use the Mozilla updater or the toolkit update UI
ifneq (android,$(MOZ_WIDGET_TOOLKIT))
INSTALL_TARGETS += base-updater-head
base-updater-head_TARGET := misc
base-updater-head_DEST := $(XPCSHELLTESTROOT)/unit_base_updater
base-updater-head_FILES := $(XPCSHELLTESTROOT)/unit_aus_update/head_update.js
ifndef MOZ_PROFILE_GENERATE
ifdef COMPILE_ENVIRONMENT
INSTALL_TARGETS += xpcshell-test-helper
xpcshell-test-helper_TARGET := misc
xpcshell-test-helper_DEST := $(XPCSHELLTESTROOT)/data
xpcshell-test-helper_FILES := $(DIST)/bin/TestAUSHelper$(BIN_SUFFIX)
INSTALL_TARGETS += xpcshell-helper
xpcshell-helper_FILES := $(DIST)/bin/TestAUSHelper$(BIN_SUFFIX)
xpcshell-helper_DEST := $(XPCSHELLTESTROOT)/data
xpcshell-helper_TARGET := misc
endif
endif # Not MOZ_PROFILE_GENERATE
_CHROME_SHARED := \
update.sjs \
utils.js \
$(NULL)
PP_TARGETS += chrome-shared
chrome-shared := $(addprefix $(srcdir)/chrome/,$(_CHROME_SHARED))
chrome-shared_PATH := $(CHROMETESTROOT)/chrome
chrome-shared_TARGET := misc
_CHROME_DATA := \
shared.js \
sharedUpdateXML.js \
simple.mar \
$(NULL)
INSTALL_TARGETS += chrome-data
chrome-data_TARGET := misc
chrome-data_DEST := $(CHROMETESTROOT)/data
chrome-data_FILES := $(addprefix $(srcdir)/data/,$(_CHROME_DATA))
INSTALL_TARGETS += chrome-data
chrome-data_FILES := $(addprefix $(srcdir)/data/,$(_CHROME_DATA))
chrome-data_DEST := $(CHROMETESTROOT)/data
chrome-data_TARGET := misc
INI_TEST_FILES = \
TestAUSReadStrings1.ini \
@@ -77,8 +77,9 @@ static void
WriteMsg(const NS_tchar *path, const char *status)
{
FILE* outFP = NS_tfopen(path, NS_T("wb"));
if (!outFP)
if (!outFP) {
return;
}
fprintf(outFP, "%s\n", status);
fclose(outFP);
@@ -207,7 +208,7 @@ int NS_main(int argc, NS_tchar **argv)
} else {
return 1;
}
#else
#else
// Not implemented on non-Windows platforms
return 1;
#endif
@@ -285,7 +286,7 @@ int NS_main(int argc, NS_tchar **argv)
} else {
return serviceState;
}
#else
#else
// Not implemented on non-Windows platforms
return 1;
#endif
@@ -303,7 +304,7 @@ int NS_main(int argc, NS_tchar **argv)
} else {
return 2;
}
#else
#else
// Not implemented on non-Windows platforms
return 1;
#endif
@@ -372,4 +373,4 @@ int NS_main(int argc, NS_tchar **argv)
}
return 0;
}
}
@@ -117,8 +117,7 @@ int NS_main(int argc, NS_tchar **argv)
rv = 22;
fail("%s | Info ini value incorrect (check 4)", TEST_NAME);
}
}
else {
} else {
fail("%s | ReadStrings returned %i (check 2)", TEST_NAME, retval);
rv = 23;
}
@@ -157,8 +156,7 @@ int NS_main(int argc, NS_tchar **argv)
rv = 27;
fail("%s | Title ini value incorrect (check 9)", TEST_NAME);
}
}
else {
} else {
fail("%s | ReadStrings returned %i (check 8)", TEST_NAME, retval);
rv = 28;
}
@@ -7,9 +7,6 @@ skip-if = buildapp == 'mulet'
support-files =
utils.js
update.sjs
generated-files =
utils.js
update.sjs
; mochitest-chrome tests must start with "test_" and are executed in sorted
; order and not in the order specified in the manifest.
@@ -70,6 +67,8 @@ reason = Bug 918029 - timeout caused by copying too many files.
[test_0103_background_restartNotification_stagingService.xul]
skip-if = os != 'win'
reason = only Windows has the maintenance service.
[test_0104_background_restartNotification_NoIncompatAddons.xul]
[test_0105_background_restartNotification_VersionCompatAddons.xul]
[test_0111_neverButton_basic.xul]
[test_0112_neverButton_billboard.xul]
[test_0113_showNeverForVersionRemovedWithPref.xul]
@@ -49,7 +49,7 @@ function runTest() {
"update's promptWaitTime attribute value was set from the " +
PREF_APP_UPDATE_PROMPTWAITTIME + " preference");
gUpdateManager.refreshUpdateStatus(gUpdateManager.activeUpdate);
gUpdateManager.refreshUpdateStatus();
}
]]>
@@ -49,7 +49,7 @@ function runTest() {
"update's promptWaitTime attribute value was set from the " +
PREF_APP_UPDATE_PROMPTWAITTIME + " preference");
gUpdateManager.refreshUpdateStatus(gUpdateManager.activeUpdate);
gUpdateManager.refreshUpdateStatus();
}
]]>
@@ -0,0 +1,51 @@
<?xml version="1.0"?>
<!--
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-->
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<window title="Update Wizard pages: background finish with a background download"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="runTestDefault();">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="utils.js"/>
<script type="application/javascript">
<![CDATA[
const TESTS = [ {
pageid: PAGEID_FINISHED_BKGRD,
buttonClick: "extra1"
} ];
gDisableNoUpdateAddon = true;
gDisableUpdateCompatibilityAddon = true;
gDisableUpdateVersionAddon = true;
function runTest() {
debugDump("entering");
Services.prefs.setIntPref(PREF_APP_UPDATE_PROMPTWAITTIME, 1);
let url = URL_HTTP_UPDATE_XML + "?showDetails=1" +
getVersionParams(getNewerAppVersion(), getNewerPlatformVersion());
setUpdateURLOverride(url);
gAUS.notify(null);
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
</body>
</window>
@@ -0,0 +1,50 @@
<?xml version="1.0"?>
<!--
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-->
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<window title="Update Wizard pages: background finish with a background download"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="runTestDefault();">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="utils.js"/>
<script type="application/javascript">
<![CDATA[
const TESTS = [ {
pageid: PAGEID_FINISHED_BKGRD,
buttonClick: "extra1"
} ];
gDisableNoUpdateAddon = true;
gDisableUpdateCompatibilityAddon = true;
function runTest() {
debugDump("entering");
Services.prefs.setIntPref(PREF_APP_UPDATE_PROMPTWAITTIME, 1);
let url = URL_HTTP_UPDATE_XML + "?showDetails=1" +
getVersionParams(getNewerAppVersion(), getNewerPlatformVersion());
setUpdateURLOverride(url);
gAUS.notify(null);
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
</body>
</window>
@@ -26,7 +26,7 @@ const TESTS = [ {
buttonClick: "finish"
} ];
Components.utils.import("resource://gre/modules/CertUtils.jsm");
Cu.import("resource://gre/modules/CertUtils.jsm");
const CERT_ATTRS = ["nickname", "emailAddress", "subjectName", "commonName",
"organization", "organizationalUnit", "sha1Fingerprint",
@@ -39,8 +39,8 @@ var gRequest;
function runTest() {
debugDump("entering");
gRequest = AUS_Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
createInstance(AUS_Ci.nsIXMLHttpRequest);
gRequest = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
createInstance(Ci.nsIXMLHttpRequest);
gRequest.open("GET", "https://example.com/", true);
gRequest.channel.notificationCallbacks = new BadCertHandler(true);
gRequest.onload = function(event) { testXHRLoad(event); };
@@ -53,16 +53,17 @@ function testXHRError(aEvent) {
ok(true, "Entering testXHRError - something went wrong");
var request = aEvent.target;
var status = 0;
let request = aEvent.target;
let status = 0;
try {
status = request.status;
}
catch (e) {
}
if (status == 0)
status = request.channel.QueryInterface(AUS_Ci.nsIRequest).status;
if (status == 0) {
status = request.channel.QueryInterface(Ci.nsIRequest).status;
}
ok(false, "XHR onerror called: " + status);
@@ -73,9 +74,9 @@ function testXHRError(aEvent) {
function testXHRLoad(aEvent) {
debugDump("entering");
var channel = aEvent.target.channel;
var cert = channel.securityInfo.QueryInterface(AUS_Ci.nsISSLStatusProvider).
SSLStatus.QueryInterface(AUS_Ci.nsISSLStatus).serverCert;
let channel = aEvent.target.channel;
let cert = channel.securityInfo.QueryInterface(Ci.nsISSLStatusProvider).
SSLStatus.QueryInterface(Ci.nsISSLStatus).serverCert;
CERT_ATTRS.forEach(function(aCertAttrName) {
Services.prefs.setCharPref(PREF_APP_UPDATE_CERTS_BRANCH + "1." +
aCertAttrName, cert[aCertAttrName]);
@@ -26,7 +26,7 @@ const TESTS = [ {
buttonClick: "extra1"
} ];
Components.utils.import("resource://gre/modules/CertUtils.jsm");
Cu.import("resource://gre/modules/CertUtils.jsm");
const CERT_ATTRS = ["nickname", "emailAddress", "subjectName", "commonName",
"organization", "organizationalUnit", "sha1Fingerprint",
@@ -39,8 +39,8 @@ var gRequest;
function runTest() {
debugDump("entering");
gRequest = AUS_Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
createInstance(AUS_Ci.nsIXMLHttpRequest);
gRequest = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
createInstance(Ci.nsIXMLHttpRequest);
gRequest.open("GET", "https://example.com/", true);
gRequest.channel.notificationCallbacks = new BadCertHandler(true);
gRequest.onload = function(event) { testXHRLoad(event); };
@@ -53,16 +53,17 @@ function testXHRError(aEvent) {
ok(true, "Entering testXHRError - something went wrong");
var request = aEvent.target;
var status = 0;
let request = aEvent.target;
let status = 0;
try {
status = request.status;
}
catch (e) {
}
if (status == 0)
status = request.channel.QueryInterface(AUS_Ci.nsIRequest).status;
if (status == 0) {
status = request.channel.QueryInterface(Ci.nsIRequest).status;
}
ok(false, "XHR onerror called: " + status);
@@ -73,9 +74,9 @@ function testXHRError(aEvent) {
function testXHRLoad(aEvent) {
debugDump("entering");
var channel = aEvent.target.channel;
var cert = channel.securityInfo.QueryInterface(AUS_Ci.nsISSLStatusProvider).
SSLStatus.QueryInterface(AUS_Ci.nsISSLStatus).serverCert;
let channel = aEvent.target.channel;
let cert = channel.securityInfo.QueryInterface(Ci.nsISSLStatusProvider).
SSLStatus.QueryInterface(Ci.nsISSLStatus).serverCert;
CERT_ATTRS.forEach(function(aCertAttrName) {
Services.prefs.setCharPref(PREF_APP_UPDATE_CERTS_BRANCH + "1." +
aCertAttrName, cert[aCertAttrName]);
@@ -26,7 +26,7 @@ const TESTS = [ {
buttonClick: "extra1"
} ];
Components.utils.import("resource://gre/modules/CertUtils.jsm");
Cu.import("resource://gre/modules/CertUtils.jsm");
function runTest() {
debugDump("entering");
@@ -68,7 +68,7 @@ function runTest() {
ok(!file.exists(), file.path + " should not exist");
let addonPrepDir = Services.dirsvc.get(NS_APP_USER_PROFILE_50_DIR,
AUS_Ci.nsILocalFile);
Ci.nsILocalFile);
addonPrepDir.append(ADDON_PREP_DIR);
// Not being able to remove the directory used to create the test add-ons
// will not adversely affect subsequent tests so wrap it in a try block and
+88 -77
View File
@@ -4,32 +4,51 @@
/**
* Server side http server script for application update tests.
*
* !IMPORTANT - Since xpcshell used by the http server is launched with -v 170
* this file must not use features greater than JavaScript 1.7.
*/
const AUS_Cc = Components.classes;
const AUS_Ci = Components.interfaces;
const { classes: Cc, interfaces: Ci } = Components;
#include ../sharedUpdateXML.js
const REL_PATH_DATA = "chrome/toolkit/mozapps/update/tests/data/";
function getTestDataFile(aFilename) {
let file = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).get("CurWorkD", Ci.nsILocalFile);
let pathParts = REL_PATH_DATA.split("/");
for (let i = 0; i < pathParts.length; ++i) {
file.append(pathParts[i]);
}
if (aFilename) {
file.append(aFilename);
}
return file;
}
function loadHelperScript() {
let scriptFile = getTestDataFile("sharedUpdateXML.js");
let io = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService2);
let scriptSpec = io.newFileURI(scriptFile).spec;
let scriptloader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
scriptloader.loadSubScript(scriptSpec, this);
}
loadHelperScript();
const URL_HOST = "http://example.com";
const URL_PATH_UPDATE_XML = "/chrome/toolkit/mozapps/update/tests/chrome/update.sjs";
const URL_HTTP_UPDATE_SJS = URL_HOST + URL_PATH_UPDATE_XML;
const REL_PATH_DATA = "chrome/toolkit/mozapps/update/tests/data/";
const SERVICE_URL = URL_HOST + "/" + REL_PATH_DATA + FILE_SIMPLE_MAR;
const SLOW_MAR_DOWNLOAD_INTERVAL = 100;
var gTimer;
function handleRequest(aRequest, aResponse) {
var params = { };
if (aRequest.queryString)
let params = { };
if (aRequest.queryString) {
params = parseQueryString(aRequest.queryString);
}
var statusCode = params.statusCode ? parseInt(params.statusCode) : 200;
var statusReason = params.statusReason ? params.statusReason : "OK";
let statusCode = params.statusCode ? parseInt(params.statusCode) : 200;
let statusReason = params.statusReason ? params.statusReason : "OK";
aResponse.setStatusLine(aRequest.httpVersion, statusCode, statusReason);
aResponse.setHeader("Cache-Control", "no-cache", false);
@@ -44,42 +63,25 @@ function handleRequest(aRequest, aResponse) {
// mar will be downloaded asynchronously which will allow the ui to load
// before the download completes.
if (params.slowDownloadMar) {
var i;
aResponse.processAsync();
aResponse.setHeader("Content-Type", "binary/octet-stream");
aResponse.setHeader("Content-Length", SIZE_SIMPLE_MAR);
var continueFile = AUS_Cc["@mozilla.org/file/directory_service;1"].
getService(AUS_Ci.nsIProperties).
get("CurWorkD", AUS_Ci.nsILocalFile);
var continuePath = REL_PATH_DATA + "continue";
var continuePathParts = continuePath.split("/");
for (i = 0; i < continuePathParts.length; ++i) {
continueFile.append(continuePathParts[i]);
}
var marFile = AUS_Cc["@mozilla.org/file/directory_service;1"].
getService(AUS_Ci.nsIProperties).
get("CurWorkD", AUS_Ci.nsILocalFile);
var path = REL_PATH_DATA + FILE_SIMPLE_MAR;
var pathParts = path.split("/");
for (i = 0; i < pathParts.length; ++i) {
marFile.append(pathParts[i]);
}
var contents = readFileBytes(marFile);
gTimer = AUS_Cc["@mozilla.org/timer;1"].
createInstance(AUS_Ci.nsITimer);
var continueFile = getTestDataFile("continue");
var contents = readFileBytes(getTestDataFile(FILE_SIMPLE_MAR));
gTimer = Cc["@mozilla.org/timer;1"].
createInstance(Ci.nsITimer);
gTimer.initWithCallback(function(aTimer) {
if (continueFile.exists()) {
gTimer.cancel();
aResponse.write(contents);
aResponse.finish();
}
}, SLOW_MAR_DOWNLOAD_INTERVAL, AUS_Ci.nsITimer.TYPE_REPEATING_SLACK);
}, SLOW_MAR_DOWNLOAD_INTERVAL, Ci.nsITimer.TYPE_REPEATING_SLACK);
return;
}
if (params.uiURL) {
var remoteType = "";
let remoteType = "";
if (!params.remoteNoTypeAttr &&
(params.uiURL == "BILLBOARD" || params.uiURL == "LICENSE")) {
remoteType = " " + params.uiURL.toLowerCase() + "=\"1\"";
@@ -110,8 +112,8 @@ function handleRequest(aRequest, aResponse) {
return;
}
var hash;
var patches = "";
let hash;
let patches = "";
if (!params.partialPatchOnly) {
hash = SHA512_HASH_SIMPLE_MAR + (params.invalidCompleteHash ? "e" : "");
patches += getRemotePatchString("complete", SERVICE_URL, "SHA512",
@@ -124,31 +126,37 @@ function handleRequest(aRequest, aResponse) {
hash, SIZE_SIMPLE_MAR);
}
var type = params.type ? params.type : "major";
var name = params.name ? params.name : "App Update Test";
var appVersion = params.appVersion ? params.appVersion : "99.9";
var displayVersion = params.displayVersion ? params.displayVersion
let type = params.type ? params.type : "major";
let name = params.name ? params.name : "App Update Test";
let appVersion = params.appVersion ? params.appVersion : "99.9";
let displayVersion = params.displayVersion ? params.displayVersion
: "version " + appVersion;
var platformVersion = params.platformVersion ? params.platformVersion : "99.8";
var buildID = params.buildID ? params.buildID : "01234567890123";
let platformVersion = params.platformVersion ? params.platformVersion : "99.8";
let buildID = params.buildID ? params.buildID : "01234567890123";
// XXXrstrong - not specifying a detailsURL will cause a leak due to bug 470244
// var detailsURL = params.showDetails ? URL_HTTP_UPDATE_SJS + "?uiURL=DETAILS" : null;
var detailsURL = URL_HTTP_UPDATE_SJS + "?uiURL=DETAILS";
var billboardURL = params.showBillboard ? URL_HTTP_UPDATE_SJS + "?uiURL=BILLBOARD" : null;
if (billboardURL && params.remoteNoTypeAttr)
// let detailsURL = params.showDetails ? URL_HTTP_UPDATE_SJS + "?uiURL=DETAILS" : null;
let detailsURL = URL_HTTP_UPDATE_SJS + "?uiURL=DETAILS";
let billboardURL = params.showBillboard ? URL_HTTP_UPDATE_SJS + "?uiURL=BILLBOARD" : null;
if (billboardURL && params.remoteNoTypeAttr) {
billboardURL += "&amp;remoteNoTypeAttr=1";
if (params.billboard404)
}
if (params.billboard404) {
billboardURL = URL_HOST + "/missing.html";
var licenseURL = params.showLicense ? URL_HTTP_UPDATE_SJS + "?uiURL=LICENSE" : null;
if (licenseURL && params.remoteNoTypeAttr)
}
let licenseURL = params.showLicense ? URL_HTTP_UPDATE_SJS + "?uiURL=LICENSE" : null;
if (licenseURL && params.remoteNoTypeAttr) {
licenseURL += "&amp;remoteNoTypeAttr=1";
if (params.license404)
}
if (params.license404) {
licenseURL = URL_HOST + "/missing.html";
var showPrompt = params.showPrompt ? "true" : null;
var showNever = params.showNever ? "true" : null;
var promptWaitTime = params.promptWaitTime ? params.promptWaitTime : null;
var showSurvey = params.showSurvey ? "true" : null;
}
let showPrompt = params.showPrompt ? "true" : null;
let showNever = params.showNever ? "true" : null;
let promptWaitTime = params.promptWaitTime ? params.promptWaitTime : null;
let showSurvey = params.showSurvey ? "true" : null;
let extensionVersion;
let version;
// For testing the deprecated update xml format
if (params.oldFormat) {
appVersion = null;
@@ -158,14 +166,15 @@ function handleRequest(aRequest, aResponse) {
showNever = null;
showSurvey = null;
detailsURL = URL_HTTP_UPDATE_SJS + "?uiURL=BILLBOARD";
if (params.remoteNoTypeAttr)
if (params.remoteNoTypeAttr) {
detailsURL += "&amp;remoteNoTypeAttr=1";
var extensionVersion = params.appVersion ? params.appVersion : "99.9";
var version = params.displayVersion ? params.displayVersion
: "version " + extensionVersion;
}
extensionVersion = params.appVersion ? params.appVersion : "99.9";
version = params.displayVersion ? params.displayVersion
: "version " + extensionVersion;
}
var updates = getRemoteUpdateString(patches, type, "App Update Test",
let updates = getRemoteUpdateString(patches, type, "App Update Test",
displayVersion, appVersion,
platformVersion, buildID, detailsURL,
billboardURL, licenseURL, showPrompt,
@@ -185,13 +194,14 @@ function handleRequest(aRequest, aResponse) {
* queryString.
*/
function parseQueryString(aQueryString) {
var paramArray = aQueryString.split("&");
var regex = /^([^=]+)=(.*)$/;
var params = {};
for (var i = 0, sz = paramArray.length; i < sz; i++) {
var match = regex.exec(paramArray[i]);
if (!match)
let paramArray = aQueryString.split("&");
let regex = /^([^=]+)=(.*)$/;
let params = {};
for (let i = 0, sz = paramArray.length; i < sz; i++) {
let match = regex.exec(paramArray[i]);
if (!match) {
throw "Bad parameter in queryString! '" + paramArray[i] + "'";
}
params[decodeURIComponent(match[1])] = decodeURIComponent(match[2]);
}
@@ -209,10 +219,10 @@ function parseQueryString(aQueryString) {
* manifest file.
*/
function getUpdateRDF(aParams) {
var addonVersion;
var addonID = aParams.addonID;
var addonUpdateType = addonID.split("_")[0];
var maxVersion = aParams.platformVersion;
let addonVersion;
let addonID = aParams.addonID;
let addonUpdateType = addonID.split("_")[0];
let maxVersion = aParams.platformVersion;
switch (addonUpdateType) {
case "updatecompatibility":
@@ -265,20 +275,21 @@ function getUpdateRDF(aParams) {
* @return The contents of the file as a string.
*/
function readFileBytes(aFile) {
var fis = AUS_Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(AUS_Ci.nsIFileInputStream);
let fis = Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(Ci.nsIFileInputStream);
fis.init(aFile, -1, -1, false);
var bis = AUS_Cc["@mozilla.org/binaryinputstream;1"].
createInstance(AUS_Ci.nsIBinaryInputStream);
let bis = Cc["@mozilla.org/binaryinputstream;1"].
createInstance(Ci.nsIBinaryInputStream);
bis.setInputStream(fis);
var data = [];
var count = fis.available();
let data = [];
let count = fis.available();
while (count > 0) {
var bytes = bis.readByteArray(Math.min(65535, count));
let bytes = bis.readByteArray(Math.min(65535, count));
data.push(String.fromCharCode.apply(null, bytes));
count -= bytes.length;
if (bytes.length == 0)
if (bytes.length == 0) {
throw "Nothing read from input stream!";
}
}
data.join('');
fis.close();
+70 -50
View File
@@ -102,11 +102,17 @@
* updatecompatibility
* the add-on is compatible with the current toolkit version and has a
* compatibility update to make it compatible with the update's toolkit
* version.
* version. Tests that need to have add-ons compatible for the application
* update without updating the add-on's compatibility information can disable
* this add-on by setting the gDisableUpdateCompatibilityAddon variable to
* true.
*
* updateversion
* the add-on is compatible with the current toolkit version and has a version
* update to make it compatible with the update's toolkit version.
* update to make it compatible with the update's toolkit version. Tests that
* need to have add-ons compatible for the application update without updating
* the add-on's to a new version that is compatible can disable this add-on by
* setting the gDisableUpdateVersionAddon variable to true.
*
* userdisabled
* disabled by the user and compatible with the current toolkit version but
@@ -116,7 +122,13 @@
'use strict';
Components.utils.import("resource://gre/modules/AddonManager.jsm");
const { classes: Cc, interfaces: Ci, manager: Cm, results: Cr,
utils: Cu } = Components;
Cu.import("resource://gre/modules/AddonManager.jsm", this);
Cu.import("resource://gre/modules/Services.jsm", this);
const IS_MACOSX = ("nsILocalFileMac" in Ci);
// The tests have to use the pageid instead of the pageIndex due to the
// app update wizard's access method being random.
@@ -145,6 +157,8 @@ const URL_HOST = "http://example.com";
const URL_PATH_UPDATE_XML = "/chrome/toolkit/mozapps/update/tests/chrome/update.sjs";
const REL_PATH_DATA = "chrome/toolkit/mozapps/update/tests/data";
// These two URLs must not contain parameters since tests add their own
// test specific parameters.
const URL_HTTP_UPDATE_XML = URL_HOST + URL_PATH_UPDATE_XML;
const URL_HTTPS_UPDATE_XML = "https://example.com" + URL_PATH_UPDATE_XML;
@@ -194,13 +208,16 @@ var gWin;
var gDocElem;
var gPrefToCheck;
var gDisableNoUpdateAddon = false;
var gDisableUpdateCompatibilityAddon = false;
var gDisableUpdateVersionAddon = false;
// Set to true to log additional information for debugging. To log additional
// information for an individual test set DEBUG_AUS_TEST to true in the test's
// onload function.
var DEBUG_AUS_TEST = true;
#include ../shared.js
const DATA_URI_SPEC = "chrome://mochitests/content/chrome/toolkit/mozapps/update/tests/data/";
Services.scriptloader.loadSubScript(DATA_URI_SPEC + "shared.js", this);
/**
* The current test in TESTS array.
@@ -267,7 +284,7 @@ this.__defineGetter__("gIncompatibleListbox", function() {
function runTestDefault() {
debugDump("entering");
if (!("@mozilla.org/zipwriter;1" in AUS_Cc)) {
if (!("@mozilla.org/zipwriter;1" in Cc)) {
ok(false, "nsIZipWriter is required to run these tests");
return;
}
@@ -300,8 +317,7 @@ function runTestDefaultWaitForWindowClosed() {
// |closeUpdateWindow| will close it and cause the test to fail.
if (closeUpdateWindow()) {
SimpleTest.executeSoon(runTestDefaultWaitForWindowClosed);
}
else {
} else {
Services.ww.registerNotification(gWindowObserver);
gCloseWindowTimeoutCounter = 0;
@@ -386,8 +402,7 @@ function finishTestDefaultWaitForWindowClosed() {
// |closeUpdateWindow| will close it and cause the test to fail.
if (closeUpdateWindow()) {
SimpleTest.executeSoon(finishTestDefaultWaitForWindowClosed);
}
else {
} else {
SimpleTest.finish();
}
}
@@ -493,8 +508,7 @@ function delayedDefaultCallback() {
throw("Tests cannot have a buttonClick and an extraDelayedFinishFunction property");
}
gDocElem.getButton(gTest.buttonClick).click();
}
else if (gTest.extraDelayedFinishFunction) {
} else if (gTest.extraDelayedFinishFunction) {
debugDump("calling extraDelayedFinishFunction " +
gTest.extraDelayedFinishFunction.name);
gTest.extraDelayedFinishFunction();
@@ -508,9 +522,9 @@ function delayedDefaultCallback() {
* @return nsILocalFile for the continue file.
*/
function getContinueFile() {
let continueFile = AUS_Cc["@mozilla.org/file/directory_service;1"].
getService(AUS_Ci.nsIProperties).
get("CurWorkD", AUS_Ci.nsILocalFile);
let continueFile = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).
get("CurWorkD", Ci.nsILocalFile);
let continuePath = REL_PATH_DATA + "/continue";
let continuePathParts = continuePath.split("/");
for (let i = 0; i < continuePathParts.length; ++i) {
@@ -938,12 +952,13 @@ function resetFiles() {
// Not being able to remove the "updated" directory will not adversely affect
// subsequent tests so wrap it in a try block and don't test whether its
// removal was successful.
#ifdef XP_MACOSX
let updatedDir = getUpdatesDir();
updatedDir.append(DIR_PATCH);
#else
let updatedDir = getAppBaseDir();
#endif
let updatedDir;
if (IS_MACOSX) {
updatedDir = getUpdatesDir();
updatedDir.append(DIR_PATCH);
} else {
updatedDir = getAppBaseDir();
}
updatedDir.append(DIR_UPDATED);
if (updatedDir.exists()) {
try {
@@ -962,8 +977,7 @@ function resetFiles() {
function resetPrefs() {
if (gAppUpdateURL !== undefined) {
Services.prefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, gAppUpdateURL);
}
else if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_URL_OVERRIDE)) {
} else if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_URL_OVERRIDE)) {
Services.prefs.clearUserPref(PREF_APP_UPDATE_URL_OVERRIDE);
}
@@ -973,29 +987,25 @@ function resetPrefs() {
if (gAppUpdateEnabled !== undefined) {
Services.prefs.setBoolPref(PREF_APP_UPDATE_ENABLED, gAppUpdateEnabled);
}
else if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_ENABLED)) {
} else if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_ENABLED)) {
Services.prefs.clearUserPref(PREF_APP_UPDATE_ENABLED);
}
if (gAppUpdateServiceEnabled !== undefined) {
Services.prefs.setBoolPref(PREF_APP_UPDATE_SERVICE_ENABLED, gAppUpdateServiceEnabled);
}
else if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_SERVICE_ENABLED)) {
} else if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_SERVICE_ENABLED)) {
Services.prefs.clearUserPref(PREF_APP_UPDATE_SERVICE_ENABLED);
}
if (gAppUpdateStagingEnabled !== undefined) {
Services.prefs.setBoolPref(PREF_APP_UPDATE_STAGING_ENABLED, gAppUpdateStagingEnabled);
}
else if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_STAGING_ENABLED)) {
} else if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_STAGING_ENABLED)) {
Services.prefs.clearUserPref(PREF_APP_UPDATE_STAGING_ENABLED);
}
if (gExtUpdateURL !== undefined) {
Services.prefs.setCharPref(PREF_EXTENSIONS_UPDATE_URL, gExtUpdateURL);
}
else if (Services.prefs.prefHasUserValue(PREF_EXTENSIONS_UPDATE_URL)) {
} else if (Services.prefs.prefHasUserValue(PREF_EXTENSIONS_UPDATE_URL)) {
Services.prefs.clearUserPref(PREF_EXTENSIONS_UPDATE_URL);
}
@@ -1081,10 +1091,10 @@ function setupTimer(aTestTimeout) {
gTimeoutTimer.cancel();
gTimeoutTimer = null;
}
gTimeoutTimer = AUS_Cc["@mozilla.org/timer;1"].
createInstance(AUS_Ci.nsITimer);
gTimeoutTimer = Cc["@mozilla.org/timer;1"].
createInstance(Ci.nsITimer);
gTimeoutTimer.initWithCallback(finishTestTimeout, gTestTimeout,
AUS_Ci.nsITimer.TYPE_ONE_SHOT);
Ci.nsITimer.TYPE_ONE_SHOT);
}
/**
@@ -1106,17 +1116,26 @@ function setupAddons(aCallback) {
function setNoUpdateAddonsDisabledState() {
AddonManager.getAllAddons(function(aAddons) {
aAddons.forEach(function(aAddon) {
if (aAddon.name.indexOf("noupdate") != 0)
return;
if (gDisableNoUpdateAddon) {
if (!aAddon.userDisabled) {
aAddon.userDisabled = true;
}
}
else {
if (aAddon.userDisabled) {
aAddon.userDisabled = false;
if (aAddon.name.startsWith("noupdate")) {
if (aAddon.userDisabled != gDisableNoUpdateAddon) {
aAddon.userDisabled = gDisableNoUpdateAddon;
}
}
if (aAddon.name.startsWith("updatecompatibility")) {
if (aAddon.userDisabled != gDisableUpdateCompatibilityAddon) {
aAddon.userDisabled = gDisableUpdateCompatibilityAddon;
}
}
if (aAddon.name.startsWith("updateversion")) {
if (aAddon.userDisabled != gDisableUpdateVersionAddon) {
aAddon.userDisabled = gDisableUpdateVersionAddon;
}
}
});
@@ -1273,7 +1292,7 @@ function getAddonTestType(aName) {
*/
function getTestAddonXPIFiles() {
let addonPrepDir = Services.dirsvc.get(NS_APP_USER_PROFILE_50_DIR,
AUS_Ci.nsILocalFile);
Ci.nsILocalFile);
addonPrepDir.append(ADDON_PREP_DIR);
let bootstrap = addonPrepDir.clone();
@@ -1295,15 +1314,16 @@ function getTestAddonXPIFiles() {
let xpiFile = addonPrepDir.clone();
xpiFile.append(aName + ".xpi");
if (installRDF.exists())
if (installRDF.exists()) {
installRDF.remove(false);
}
writeFile(installRDF, getInstallRDFString(aName));
gZipW.open(xpiFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
gZipW.addEntryFile(installRDF.leafName,
AUS_Ci.nsIZipWriter.COMPRESSION_DEFAULT, installRDF,
Ci.nsIZipWriter.COMPRESSION_DEFAULT, installRDF,
false);
gZipW.addEntryFile(bootstrap.leafName,
AUS_Ci.nsIZipWriter.COMPRESSION_DEFAULT, bootstrap,
Ci.nsIZipWriter.COMPRESSION_DEFAULT, bootstrap,
false);
gZipW.close();
xpiFiles.push(xpiFile);
@@ -1361,8 +1381,9 @@ function getInstallRDFString(aName) {
*/
function closeUpdateWindow() {
let updateWindow = getUpdateWindow();
if (!updateWindow)
if (!updateWindow) {
return false;
}
ok(false, "Found an existing Update Window from the current or a previous " +
"test... attempting to close it.");
@@ -1383,7 +1404,7 @@ function getUpdateWindow() {
/**
* Helper for background check errors.
*/
var errorsPrefObserver = {
const errorsPrefObserver = {
observedPref: null,
maxErrorPref: null,
@@ -1417,8 +1438,7 @@ var errorsPrefObserver = {
if (errCount >= errMax) {
debugDump("removing pref observer");
Services.prefs.removeObserver(this.observedPref, this);
}
else {
} else {
debugDump("notifying AUS");
SimpleTest.executeSoon(function() {
gAUS.notify(null);
@@ -1431,9 +1451,9 @@ var errorsPrefObserver = {
/**
* nsIObserver for receiving window open and close notifications.
*/
var gWindowObserver = {
const gWindowObserver = {
observe: function WO_observe(aSubject, aTopic, aData) {
let win = aSubject.QueryInterface(AUS_Ci.nsIDOMEventTarget);
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
if (aTopic == "domwindowclosed") {
if (win.location != URI_UPDATE_PROMPT_DIALOG) {
@@ -182,5 +182,5 @@ FINISH REMOVEFILE 3/3text1
backup_restore: backup file doesn't exist: 3/3text1.moz-backup
FINISH REMOVEFILE 3/3text0
backup_restore: backup file doesn't exist: 3/3text0.moz-backup
failed: 42
failed: 2
calling QuitProgressUI
@@ -182,5 +182,5 @@ FINISH REMOVEFILE Contents/Resources/3/3text1
backup_restore: backup file doesn't exist: Contents/Resources/3/3text1.moz-backup
FINISH REMOVEFILE Contents/Resources/3/3text0
backup_restore: backup file doesn't exist: Contents/Resources/3/3text0.moz-backup
failed: 42
failed: 2
calling QuitProgressUI
@@ -4,13 +4,8 @@
/* Shared code for xpcshell and mochitests-chrome */
// const Cc, Ci, and Cr are defined in netwerk/test/httpserver/httpd.js so we
// need to define unique ones.
const AUS_Cc = Components.classes;
const AUS_Ci = Components.interfaces;
const AUS_Cr = Components.results;
const AUS_Cu = Components.utils;
const AUS_Cm = Components.manager;
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const PREF_APP_UPDATE_AUTO = "app.update.auto";
const PREF_APP_UPDATE_BACKGROUNDERRORS = "app.update.backgroundErrors";
@@ -61,11 +56,7 @@ const WRITE_ERROR = 7;
const DIR_PATCH = "0";
const DIR_TOBEDELETED = "tobedeleted";
const DIR_UPDATES = "updates";
#ifdef XP_MACOSX
const DIR_UPDATED = "Updated.app";
#else
const DIR_UPDATED = "updated";
#endif
const DIR_UPDATED = IS_MACOSX ? "Updated.app" : "updated";
const FILE_APPLICATION_INI = "application.ini";
const FILE_BACKUP_LOG = "backup-update.log";
@@ -95,11 +86,7 @@ const DEFAULT_UPDATE_VERSION = "999999.0";
var gChannel;
#include sharedUpdateXML.js
AUS_Cu.import("resource://gre/modules/FileUtils.jsm");
AUS_Cu.import("resource://gre/modules/Services.jsm");
AUS_Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Services.scriptloader.loadSubScript(DATA_URI_SPEC + "sharedUpdateXML.js", this);
const PERMS_FILE = FileUtils.PERMS_FILE;
const PERMS_DIRECTORY = FileUtils.PERMS_DIRECTORY;
@@ -115,11 +102,11 @@ const URI_UPDATES_PROPERTIES = "chrome://mozapps/locale/update/updates.propertie
const gUpdateBundle = Services.strings.createBundle(URI_UPDATES_PROPERTIES);
XPCOMUtils.defineLazyGetter(this, "gAUS", function test_gAUS() {
return AUS_Cc["@mozilla.org/updates/update-service;1"].
getService(AUS_Ci.nsIApplicationUpdateService).
QueryInterface(AUS_Ci.nsITimerCallback).
QueryInterface(AUS_Ci.nsIObserver).
QueryInterface(AUS_Ci.nsIUpdateCheckListener);
return Cc["@mozilla.org/updates/update-service;1"].
getService(Ci.nsIApplicationUpdateService).
QueryInterface(Ci.nsITimerCallback).
QueryInterface(Ci.nsIObserver).
QueryInterface(Ci.nsIUpdateCheckListener);
});
XPCOMUtils.defineLazyServiceGetter(this, "gUpdateManager",
@@ -127,13 +114,13 @@ XPCOMUtils.defineLazyServiceGetter(this, "gUpdateManager",
"nsIUpdateManager");
XPCOMUtils.defineLazyGetter(this, "gUpdateChecker", function test_gUC() {
return AUS_Cc["@mozilla.org/updates/update-checker;1"].
createInstance(AUS_Ci.nsIUpdateChecker);
return Cc["@mozilla.org/updates/update-checker;1"].
createInstance(Ci.nsIUpdateChecker);
});
XPCOMUtils.defineLazyGetter(this, "gUP", function test_gUP() {
return AUS_Cc["@mozilla.org/updates/update-prompt;1"].
createInstance(AUS_Ci.nsIUpdatePrompt);
return Cc["@mozilla.org/updates/update-prompt;1"].
createInstance(Ci.nsIUpdatePrompt);
});
XPCOMUtils.defineLazyGetter(this, "gDefaultPrefBranch", function test_gDPB() {
@@ -145,19 +132,19 @@ XPCOMUtils.defineLazyGetter(this, "gPrefRoot", function test_gPR() {
});
XPCOMUtils.defineLazyGetter(this, "gZipW", function test_gZipW() {
return AUS_Cc["@mozilla.org/zipwriter;1"].
createInstance(AUS_Ci.nsIZipWriter);
return Cc["@mozilla.org/zipwriter;1"].
createInstance(Ci.nsIZipWriter);
});
/* Initializes the update service stub */
function initUpdateServiceStub() {
AUS_Cc["@mozilla.org/updates/update-service-stub;1"].
createInstance(AUS_Ci.nsISupports);
Cc["@mozilla.org/updates/update-service-stub;1"].
createInstance(Ci.nsISupports);
}
/* Reloads the update metadata from disk */
function reloadUpdateManagerData() {
gUpdateManager.QueryInterface(AUS_Ci.nsIObserver).
gUpdateManager.QueryInterface(Ci.nsIObserver).
observe(null, "um-reload-update-data", "");
}
@@ -174,17 +161,17 @@ function setUpdateChannel(aChannel) {
gPrefRoot.addObserver(PREF_APP_UPDATE_CHANNEL, observer, false);
}
var observer = {
const observer = {
observe: function(aSubject, aTopic, aData) {
if (aTopic == "nsPref:changed" && aData == PREF_APP_UPDATE_CHANNEL) {
var channel = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_CHANNEL);
let channel = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_CHANNEL);
if (channel != gChannel) {
debugDump("Changing channel from " + channel + " to " + gChannel);
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_CHANNEL, gChannel);
}
}
},
QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsIObserver])
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
};
/**
@@ -208,7 +195,7 @@ function setUpdateURLOverride(aURL) {
* return the updates.xml file.
*/
function getUpdatesXMLFile(aIsActiveUpdate) {
var file = getUpdatesRootDir();
let file = getUpdatesRootDir();
file.append(aIsActiveUpdate ? FILE_UPDATE_ACTIVE : FILE_UPDATES_DB);
return file;
}
@@ -260,7 +247,7 @@ function writeVersionFile(aVersion) {
* @return nsIFile for the updates root directory.
*/
function getUpdatesRootDir() {
return Services.dirsvc.get(XRE_UPDATE_ROOT_DIR, AUS_Ci.nsIFile);
return Services.dirsvc.get(XRE_UPDATE_ROOT_DIR, Ci.nsIFile);
}
/**
@@ -269,7 +256,7 @@ function getUpdatesRootDir() {
* @return nsIFile for the updates directory.
*/
function getUpdatesDir() {
var dir = getUpdatesRootDir();
let dir = getUpdatesRootDir();
dir.append(DIR_UPDATES);
return dir;
}
@@ -296,10 +283,11 @@ function getUpdatesPatchDir() {
* replaced.
*/
function writeFile(aFile, aText) {
var fos = AUS_Cc["@mozilla.org/network/file-output-stream;1"].
createInstance(AUS_Ci.nsIFileOutputStream);
if (!aFile.exists())
aFile.create(AUS_Ci.nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE);
let fos = Cc["@mozilla.org/network/file-output-stream;1"].
createInstance(Ci.nsIFileOutputStream);
if (!aFile.exists()) {
aFile.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE);
}
fos.init(aFile, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, PERMS_FILE, 0);
fos.write(aText, aText.length);
fos.close();
@@ -351,15 +339,16 @@ function readStatusFailedCode() {
* @return The string of text read from the file.
*/
function readFile(aFile) {
var fis = AUS_Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(AUS_Ci.nsIFileInputStream);
if (!aFile.exists())
let fis = Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(Ci.nsIFileInputStream);
if (!aFile.exists()) {
return null;
}
fis.init(aFile, MODE_RDONLY, PERMS_FILE, 0);
var sis = AUS_Cc["@mozilla.org/scriptableinputstream;1"].
createInstance(AUS_Ci.nsIScriptableInputStream);
let sis = Cc["@mozilla.org/scriptableinputstream;1"].
createInstance(Ci.nsIScriptableInputStream);
sis.init(fis);
var text = sis.read(sis.available());
let text = sis.read(sis.available());
sis.close();
return text;
}
@@ -372,20 +361,21 @@ function readFile(aFile) {
* @return The contents of the file as a string.
*/
function readFileBytes(aFile) {
var fis = AUS_Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(AUS_Ci.nsIFileInputStream);
let fis = Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(Ci.nsIFileInputStream);
fis.init(aFile, -1, -1, false);
var bis = AUS_Cc["@mozilla.org/binaryinputstream;1"].
createInstance(AUS_Ci.nsIBinaryInputStream);
let bis = Cc["@mozilla.org/binaryinputstream;1"].
createInstance(Ci.nsIBinaryInputStream);
bis.setInputStream(fis);
var data = [];
var count = fis.available();
let data = [];
let count = fis.available();
while (count > 0) {
var bytes = bis.readByteArray(Math.min(65535, count));
let bytes = bis.readByteArray(Math.min(65535, count));
data.push(String.fromCharCode.apply(null, bytes));
count -= bytes.length;
if (bytes.length == 0)
if (bytes.length == 0) {
throw "Nothing read from input stream!";
}
}
data.join('');
fis.close();
@@ -414,7 +404,7 @@ function getString(aName) {
* @return The file extension.
*/
function getFileExtension(aFile) {
return Services.io.newFileURI(aFile).QueryInterface(AUS_Ci.nsIURL).
return Services.io.newFileURI(aFile).QueryInterface(Ci.nsIURL).
fileExtension;
}
@@ -425,10 +415,11 @@ function getFileExtension(aFile) {
* tests are interrupted.
*/
function removeUpdateDirsAndFiles() {
var file = getUpdatesXMLFile(true);
let file = getUpdatesXMLFile(true);
try {
if (file.exists())
if (file.exists()) {
file.remove(false);
}
} catch (e) {
logTestInfo("Unable to remove file. Path: " + file.path +
", Exception: " + e);
@@ -436,15 +427,16 @@ function removeUpdateDirsAndFiles() {
file = getUpdatesXMLFile(false);
try {
if (file.exists())
if (file.exists()) {
file.remove(false);
}
} catch (e) {
logTestInfo("Unable to remove file. Path: " + file.path +
", Exception: " + e);
}
// This fails sporadically on Mac OS X so wrap it in a try catch
var updatesDir = getUpdatesDir();
let updatesDir = getUpdatesDir();
try {
cleanUpdatesDir(updatesDir);
} catch (e) {
@@ -461,12 +453,13 @@ function removeUpdateDirsAndFiles() {
* nsIFile for the directory to be deleted.
*/
function cleanUpdatesDir(aDir) {
if (!aDir.exists())
if (!aDir.exists()) {
return;
}
var dirEntries = aDir.directoryEntries;
let dirEntries = aDir.directoryEntries;
while (dirEntries.hasMoreElements()) {
var entry = dirEntries.getNext().QueryInterface(AUS_Ci.nsIFile);
let entry = dirEntries.getNext().QueryInterface(Ci.nsIFile);
if (entry.isDirectory()) {
if (entry.leafName == DIR_PATCH && entry.parent.leafName == DIR_UPDATES) {
@@ -522,9 +515,9 @@ function removeDirRecursive(aDir) {
logTestInfo("non-fatal error removing directory. Exception: " + e);
}
var dirEntries = aDir.directoryEntries;
let dirEntries = aDir.directoryEntries;
while (dirEntries.hasMoreElements()) {
var entry = dirEntries.getNext().QueryInterface(AUS_Ci.nsIFile);
let entry = dirEntries.getNext().QueryInterface(Ci.nsIFile);
if (entry.isDirectory()) {
removeDirRecursive(entry);
@@ -558,7 +551,7 @@ function removeDirRecursive(aDir) {
* @return nsIFile for the current process directory.
*/
function getCurrentProcessDir() {
return Services.dirsvc.get(NS_XPCOM_CURRENT_PROCESS_DIR, AUS_Ci.nsIFile);
return Services.dirsvc.get(NS_XPCOM_CURRENT_PROCESS_DIR, Ci.nsIFile);
}
/**
@@ -567,7 +560,7 @@ function getCurrentProcessDir() {
* @return nsIFile object for the application base directory.
*/
function getAppBaseDir() {
return Services.dirsvc.get(XRE_EXECUTABLE_FILE, AUS_Ci.nsIFile).parent;
return Services.dirsvc.get(XRE_EXECUTABLE_FILE, Ci.nsIFile).parent;
}
/**
@@ -578,7 +571,7 @@ function getAppBaseDir() {
* @return nsIFile for the Goanna Runtime Engine directory.
*/
function getGREDir() {
return Services.dirsvc.get(NS_GRE_DIR, AUS_Ci.nsIFile);
return Services.dirsvc.get(NS_GRE_DIR, Ci.nsIFile);
}
/**
@@ -591,7 +584,7 @@ function getGREDir() {
* @return nsIFile for the Goanna Runtime Engine Binary directory.
*/
function getGREBinDir() {
return Services.dirsvc.get(NS_GRE_BIN_DIR, AUS_Ci.nsIFile);
return Services.dirsvc.get(NS_GRE_BIN_DIR, Ci.nsIFile);
}
/**
@@ -35,11 +35,12 @@ const STATE_SUCCEEDED = "succeeded";
const STATE_DOWNLOAD_FAILED = "download-failed";
const STATE_FAILED = "failed";
const STATE_FAILED_READ_ERROR = STATE_FAILED + ": 6";
const STATE_FAILED_WRITE_ERROR = STATE_FAILED + ": 7";
const STATE_FAILED_CHANNEL_MISMATCH_ERROR = STATE_FAILED + ": 22";
const STATE_FAILED_VERSION_DOWNGRADE_ERROR = STATE_FAILED + ": 23";
const STATE_FAILED_UNEXPECTED_FILE_OPERATION_ERROR = STATE_FAILED + ": 42";
const STATE_FAILED_LOADSOURCE_ERROR_WRONG_SIZE = STATE_FAILED + ": 2";
const STATE_FAILED_READ_ERROR = STATE_FAILED + ": 6";
const STATE_FAILED_WRITE_ERROR = STATE_FAILED + ": 7";
const STATE_FAILED_CHANNEL_MISMATCH_ERROR = STATE_FAILED + ": 22";
const STATE_FAILED_VERSION_DOWNGRADE_ERROR = STATE_FAILED + ": 23";
const STATE_FAILED_WRITE_ERROR_FILE_COPY = STATE_FAILED + ": 61";
/**
* Constructs a string representing a remote update xml file.
@@ -97,8 +98,9 @@ function getRemotePatchString(aType, aURL, aHashFunction, aHashValue, aSize) {
* @return The string representing a local update xml file.
*/
function getLocalUpdatesXMLString(aUpdates) {
if (!aUpdates || aUpdates == "")
if (!aUpdates || aUpdates == "") {
return "<updates xmlns=\"http://www.mozilla.org/2005/app-update\"/>"
}
return ("<updates xmlns=\"http://www.mozilla.org/2005/app-update\">" +
aUpdates +
"</updates>").replace(/>\s+\n*</g,'><');
@@ -0,0 +1,65 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Preprocessed constants used by xpcshell tests */
const INSTALL_LOCALE = "@AB_CD@";
const MOZ_APP_NAME = "@MOZ_APP_NAME@";
const BIN_SUFFIX = "@BIN_SUFFIX@";
// MOZ_APP_VENDOR is optional.
#ifdef MOZ_APP_VENDOR
const MOZ_APP_VENDOR = "@MOZ_APP_VENDOR@";
#else
const MOZ_APP_VENDOR = "";
#endif
// MOZ_APP_BASENAME is not optional for tests.
const MOZ_APP_BASENAME = "@MOZ_APP_BASENAME@";
const APP_BIN_SUFFIX = "@BIN_SUFFIX@";
const APP_INFO_NAME = "XPCShell";
const APP_INFO_VENDOR = "Mozilla";
#ifdef XP_WIN
const IS_WIN = true;
#else
const IS_WIN = false;
#endif
#ifdef XP_MACOSX
const IS_MACOSX = true;
#else
const IS_MACOSX = false;
#endif
#ifdef XP_UNIX
const IS_UNIX = true;
#else
const IS_UNIX = false;
#endif
#ifdef ANDROID
const IS_ANDROID = true;
#else
const IS_ANDROID = false;
#endif
#ifdef MOZ_WIDGET_GONK
const IS_TOOLKIT_GONK = true;
#else
const IS_TOOLKIT_GONK = false;
#endif
#ifdef MOZ_VERIFY_MAR_SIGNATURE
const IS_MAR_CHECKS_ENABLED = true;
#else
const IS_MAR_CHECKS_ENABLED = false;
#endif
#ifdef DISABLE_UPDATER_AUTHENTICODE_CHECK
const IS_AUTHENTICODE_CHECK_ENABLED = false;
#else
const IS_AUTHENTICODE_CHECK_ENABLED = true;
#endif
File diff suppressed because it is too large Load Diff
@@ -10,7 +10,7 @@ function run_test() {
logTestInfo("testing write access to the application directory");
let testFile = getCurrentProcessDir();
testFile.append("update_write_access_test");
testFile.create(AUS_Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
testFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
do_check_true(testFile.exists());
testFile.remove(false);
do_check_false(testFile.exists());
@@ -22,8 +22,8 @@ function run_test() {
logTestInfo("attempting to create mutex");
let handle = createMutex(getPerInstallationMutexName());
logTestInfo("testing that the mutex was successfully created");
do_check_neq(handle, null);
debugDump("testing that the mutex was successfully created");
do_check_true(!!handle);
// Check if available updates cannot be checked for when there is a mutex
// for this installation.
@@ -71,14 +71,14 @@ function getPerInstallationMutexName() {
do_throw("Windows only function called by a different platform!");
}
let hasher = AUS_Cc["@mozilla.org/security/hash;1"].
createInstance(AUS_Ci.nsICryptoHash);
let hasher = Cc["@mozilla.org/security/hash;1"].
createInstance(Ci.nsICryptoHash);
hasher.init(hasher.SHA1);
let exeFile = Services.dirsvc.get(XRE_EXECUTABLE_FILE, AUS_Ci.nsILocalFile);
let exeFile = Services.dirsvc.get(XRE_EXECUTABLE_FILE, Ci.nsILocalFile);
let converter = AUS_Cc["@mozilla.org/intl/scriptableunicodeconverter"].
createInstance(AUS_Ci.nsIScriptableUnicodeConverter);
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
createInstance(Ci.nsIScriptableUnicodeConverter);
converter.charset = "UTF-8";
let data = converter.convertToByteArray(exeFile.path.toLowerCase());
@@ -11,10 +11,9 @@ function run_test() {
logTestInfo("testing removal of an active update for a channel that is not" +
"valid due to switching channels (Bug 486275).");
var patches, updates, update;
patches = getLocalPatchString(null, null, null, null, null, null,
STATE_DOWNLOADING);
updates = getLocalUpdateString(patches, null, null, "version 1.0", "1.0");
let patches = getLocalPatchString(null, null, null, null, null, null,
STATE_DOWNLOADING);
let updates = getLocalUpdateString(patches, null, null, "version 1.0", "1.0");
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeStatusFile(STATE_DOWNLOADING);
@@ -30,7 +29,7 @@ function run_test() {
standardInit();
do_check_eq(gUpdateManager.updateCount, 1);
update = gUpdateManager.getUpdateAt(0);
let update = gUpdateManager.getUpdateAt(0);
do_check_eq(update.name, "Existing");
do_check_eq(gUpdateManager.activeUpdate, null);
@@ -10,11 +10,9 @@ function run_test() {
logTestInfo("testing cleanup of an update download in progress for an " +
"older version of the application on startup (Bug 485624)");
var patches, updates;
patches = getLocalPatchString(null, null, null, null, null, null,
STATE_DOWNLOADING);
updates = getLocalUpdateString(patches, null, null, "version 0.9", "0.9");
let patches = getLocalPatchString(null, null, null, null, null, null,
STATE_DOWNLOADING);
let updates = getLocalUpdateString(patches, null, null, "version 0.9", "0.9");
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeStatusFile(STATE_DOWNLOADING);
@@ -10,12 +10,10 @@ function run_test() {
"same version of the application with the same application " +
"build id on startup (Bug 536547)");
var patches, updates;
patches = getLocalPatchString(null, null, null, null, null, null,
STATE_DOWNLOADING);
updates = getLocalUpdateString(patches, null, null, "version 1.0", "1.0", null,
"2007010101");
let patches = getLocalPatchString(null, null, null, null, null, null,
STATE_DOWNLOADING);
let updates = getLocalUpdateString(patches, null, null, "version 1.0", "1.0",
null, "2007010101");
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeStatusFile(STATE_DOWNLOADING);
@@ -10,20 +10,20 @@ function run_test() {
"STATE_DOWNLOADING (Bug 539717).");
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
var patches = getLocalPatchString(null, null, null, null, null, null,
let patches = getLocalPatchString(null, null, null, null, null, null,
STATE_DOWNLOADING);
var updates = getLocalUpdateString(patches);
let updates = getLocalUpdateString(patches);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeStatusFile(STATE_NONE);
standardInit();
var dir = getUpdatesDir();
let dir = getUpdatesDir();
dir.append("0");
logTestInfo("testing " + dir.path + " should exist");
do_check_true(dir.exists());
var statusFile = dir.clone();
let statusFile = dir.clone();
statusFile.append(FILE_UPDATE_STATUS);
logTestInfo("testing " + statusFile.path + " should not exist");
do_check_false(statusFile.exists());
@@ -10,9 +10,9 @@ function run_test() {
"update xml has an update with STATE_PENDING (Bug 601701).");
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
var patches = getLocalPatchString(null, null, null, null, null, null,
let patches = getLocalPatchString(null, null, null, null, null, null,
STATE_PENDING);
var updates = getLocalUpdateString(patches);
let updates = getLocalUpdateString(patches);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeVersionFile("99.9");
@@ -25,12 +25,12 @@ function run_test() {
logTestInfo("testing updateCount == 0");
do_check_eq(gUpdateManager.updateCount, 0);
var dir = getUpdatesDir();
let dir = getUpdatesDir();
dir.append("0");
logTestInfo("testing " + dir.path + " should exist");
do_check_true(dir.exists());
var versionFile = dir.clone();
let versionFile = dir.clone();
versionFile.append(FILE_UPDATE_VERSION);
logTestInfo("testing " + versionFile.path + " should not exist");
do_check_false(versionFile.exists());
@@ -9,14 +9,14 @@ function run_test() {
logTestInfo("testing that the update.log is moved after a successful update");
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
var patches = getLocalPatchString(null, null, null, null, null, null,
let patches = getLocalPatchString(null, null, null, null, null, null,
STATE_PENDING);
var updates = getLocalUpdateString(patches);
let updates = getLocalUpdateString(patches);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeStatusFile(STATE_SUCCEEDED);
var dir = getUpdatesDir();
var log = dir.clone();
let dir = getUpdatesDir();
let log = dir.clone();
log.append("0");
log.append(FILE_UPDATE_LOG);
writeFile(log, "Last Update Log");
@@ -9,14 +9,14 @@ function run_test() {
logTestInfo("testing update logs are first in first out deleted");
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
var patches = getLocalPatchString(null, null, null, null, null, null,
let patches = getLocalPatchString(null, null, null, null, null, null,
STATE_PENDING);
var updates = getLocalUpdateString(patches);
let updates = getLocalUpdateString(patches);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeStatusFile(STATE_SUCCEEDED);
var dir = getUpdatesDir();
var log = dir.clone();
let dir = getUpdatesDir();
let log = dir.clone();
log.append(FILE_LAST_LOG);
writeFile(log, "Backup Update Log");
@@ -32,12 +32,12 @@ function callHandleEvent() {
gXHR.status = 400;
gXHR.responseText = gResponseBody;
try {
var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(AUS_Ci.nsIDOMParser);
let parser = Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(Ci.nsIDOMParser);
gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
} catch(e) {
}
var e = { target: gXHR };
let e = { target: gXHR };
gXHR.onload(e);
}
@@ -57,10 +57,11 @@ function run_test_helper_pt1(aMsg, aExpectedStatusResult, aNextRunFunc) {
function check_test_helper_pt1_1() {
do_check_eq(gUpdateCount, 1);
gCheckFunc = check_test_helper_pt1_2;
var bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
var state = gAUS.downloadUpdate(bestUpdate, false);
if (state == STATE_NONE || state == STATE_FAILED)
let bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
let state = gAUS.downloadUpdate(bestUpdate, false);
if (state == STATE_NONE || state == STATE_FAILED) {
do_throw("nsIApplicationUpdateService:downloadUpdate returned " + state);
}
gAUS.addDownloadListener(downloadListener);
}
@@ -87,16 +88,17 @@ function run_test_helper_bug828858_pt1(aMsg, aExpectedStatusResult, aNextRunFunc
function check_test_helper_bug828858_pt1_1() {
do_check_eq(gUpdateCount, 1);
gCheckFunc = check_test_helper_bug828858_pt1_2;
var bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
var state = gAUS.downloadUpdate(bestUpdate, false);
if (state == STATE_NONE || state == STATE_FAILED)
let bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
let state = gAUS.downloadUpdate(bestUpdate, false);
if (state == STATE_NONE || state == STATE_FAILED) {
do_throw("nsIApplicationUpdateService:downloadUpdate returned " + state);
}
gAUS.addDownloadListener(downloadListener);
}
function check_test_helper_bug828858_pt1_2() {
if (gStatusResult == AUS_Cr.NS_ERROR_CONTENT_CORRUPTED) {
do_check_eq(gStatusResult, AUS_Cr.NS_ERROR_CONTENT_CORRUPTED);
if (gStatusResult == Cr.NS_ERROR_CONTENT_CORRUPTED) {
do_check_eq(gStatusResult, Cr.NS_ERROR_CONTENT_CORRUPTED);
} else {
do_check_eq(gStatusResult, gExpectedStatusResult);
}
@@ -105,9 +107,9 @@ function check_test_helper_bug828858_pt1_2() {
}
function setResponseBody(aHashFunction, aHashValue, aSize) {
var patches = getRemotePatchString(null, null,
let patches = getRemotePatchString(null, null,
aHashFunction, aHashValue, aSize);
var updates = getRemoteUpdateString(patches);
let updates = getRemoteUpdateString(patches);
gResponseBody = getRemoteUpdatesXMLString(updates);
}
@@ -115,79 +117,79 @@ function setResponseBody(aHashFunction, aHashValue, aSize) {
function run_test_pt1() {
setResponseBody("MD5", MD5_HASH_SIMPLE_MAR);
run_test_helper_pt1("mar download with a valid MD5 hash",
AUS_Cr.NS_OK, run_test_pt2);
Cr.NS_OK, run_test_pt2);
}
// mar download with an invalid MD5 hash
function run_test_pt2() {
setResponseBody("MD5", MD5_HASH_SIMPLE_MAR + "0");
run_test_helper_pt1("mar download with an invalid MD5 hash",
AUS_Cr.NS_ERROR_CORRUPTED_CONTENT, run_test_pt3);
Cr.NS_ERROR_CORRUPTED_CONTENT, run_test_pt3);
}
// mar download with a valid SHA1 hash
function run_test_pt3() {
setResponseBody("SHA1", SHA1_HASH_SIMPLE_MAR);
run_test_helper_pt1("mar download with a valid SHA1 hash",
AUS_Cr.NS_OK, run_test_pt4);
Cr.NS_OK, run_test_pt4);
}
// mar download with an invalid SHA1 hash
function run_test_pt4() {
setResponseBody("SHA1", SHA1_HASH_SIMPLE_MAR + "0");
run_test_helper_pt1("mar download with an invalid SHA1 hash",
AUS_Cr.NS_ERROR_CORRUPTED_CONTENT, run_test_pt5);
Cr.NS_ERROR_CORRUPTED_CONTENT, run_test_pt5);
}
// mar download with a valid SHA256 hash
function run_test_pt5() {
setResponseBody("SHA256", SHA256_HASH_SIMPLE_MAR);
run_test_helper_pt1("mar download with a valid SHA256 hash",
AUS_Cr.NS_OK, run_test_pt6);
Cr.NS_OK, run_test_pt6);
}
// mar download with an invalid SHA256 hash
function run_test_pt6() {
setResponseBody("SHA256", SHA256_HASH_SIMPLE_MAR + "0");
run_test_helper_pt1("mar download with an invalid SHA256 hash",
AUS_Cr.NS_ERROR_CORRUPTED_CONTENT, run_test_pt7);
Cr.NS_ERROR_CORRUPTED_CONTENT, run_test_pt7);
}
// mar download with a valid SHA384 hash
function run_test_pt7() {
setResponseBody("SHA384", SHA384_HASH_SIMPLE_MAR);
run_test_helper_pt1("mar download with a valid SHA384 hash",
AUS_Cr.NS_OK, run_test_pt8);
Cr.NS_OK, run_test_pt8);
}
// mar download with an invalid SHA384 hash
function run_test_pt8() {
setResponseBody("SHA384", SHA384_HASH_SIMPLE_MAR + "0");
run_test_helper_pt1("mar download with an invalid SHA384 hash",
AUS_Cr.NS_ERROR_CORRUPTED_CONTENT, run_test_pt9);
Cr.NS_ERROR_CORRUPTED_CONTENT, run_test_pt9);
}
// mar download with a valid SHA512 hash
function run_test_pt9() {
setResponseBody("SHA512", SHA512_HASH_SIMPLE_MAR);
run_test_helper_pt1("mar download with a valid SHA512 hash",
AUS_Cr.NS_OK, run_test_pt10);
Cr.NS_OK, run_test_pt10);
}
// mar download with an invalid SHA512 hash
function run_test_pt10() {
setResponseBody("SHA512", SHA512_HASH_SIMPLE_MAR + "0");
run_test_helper_pt1("mar download with an invalid SHA512 hash",
AUS_Cr.NS_ERROR_CORRUPTED_CONTENT, run_test_pt11);
Cr.NS_ERROR_CORRUPTED_CONTENT, run_test_pt11);
}
// mar download with the mar not found
function run_test_pt11() {
var patches = getRemotePatchString(null, gURLData + "missing.mar");
var updates = getRemoteUpdateString(patches);
let patches = getRemotePatchString(null, gURLData + "missing.mar");
let updates = getRemoteUpdateString(patches);
gResponseBody = getRemoteUpdatesXMLString(updates);
run_test_helper_pt1("mar download with the mar not found",
AUS_Cr.NS_ERROR_UNEXPECTED, run_test_pt12);
Cr.NS_ERROR_UNEXPECTED, run_test_pt12);
}
// mar download with a valid MD5 hash but invalid file size
@@ -202,9 +204,9 @@ function run_test_pt12() {
// NS_ERROR_CONTENT_CORRUPTED.
// Bug 828858 was filed to follow up on this issue.
run_test_helper_bug828858_pt1("mar download with a valid MD5 hash but invalid file size",
AUS_Cr.NS_ERROR_UNEXPECTED, finish_test);
Cr.NS_ERROR_UNEXPECTED, finish_test);
} else {
run_test_helper_pt1("mar download with a valid MD5 hash but invalid file size",
AUS_Cr.NS_ERROR_UNEXPECTED, finish_test);
Cr.NS_ERROR_UNEXPECTED, finish_test);
}
}
@@ -13,7 +13,7 @@ function run_test() {
Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, false);
let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1",
@@ -34,18 +34,18 @@ function run_test() {
let update = gUpdateManager.activeUpdate;
update.errorCode = WRITE_ERROR;
let prompter = AUS_Cc["@mozilla.org/updates/update-prompt;1"].
createInstance(AUS_Ci.nsIUpdatePrompt);
let prompter = Cc["@mozilla.org/updates/update-prompt;1"].
createInstance(Ci.nsIUpdatePrompt);
prompter.showUpdateError(update);
}
function end_test() {
let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
WindowWatcherFactory);
}
var WindowWatcher = {
const WindowWatcher = {
getNewPrompter: function(aParent) {
do_check_eq(aParent, null);
return {
@@ -62,19 +62,14 @@ var WindowWatcher = {
};
},
QueryInterface: function(iid) {
if (iid.equals(AUS_Ci.nsIWindowWatcher) ||
iid.equals(AUS_Ci.nsISupports))
return this;
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowWatcher])
};
throw AUS_Cr.NS_ERROR_NO_INTERFACE;
}
}
var WindowWatcherFactory = {
createInstance: function createInstance(outer, iid) {
if (outer != null)
throw AUS_Cr.NS_ERROR_NO_AGGREGATION;
return WindowWatcher.QueryInterface(iid);
const WindowWatcherFactory = {
createInstance: function createInstance(aOuter, aIID) {
if (aOuter != null) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return WindowWatcher.QueryInterface(aIID);
}
};
@@ -10,21 +10,6 @@ let gDirService;
let gDirProvider;
let gOldProviders;
function FakeDirProvider() {}
FakeDirProvider.prototype = {
classID: Components.ID("{f30b43a7-2bfa-4e5f-8c4f-abc7dd4ac486}"),
QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsIDirectoryServiceProvider]),
getFile: function(prop, persistent) {
if (prop == KEY_UPDATE_ARCHIVE_DIR) {
if (gActiveUpdate) {
gActiveUpdate.errorCode = AUS_Cr.NS_ERROR_FILE_TOO_BIG;
}
}
return null;
}
};
function run_test() {
setupTestCommon();
@@ -37,19 +22,19 @@ function run_test() {
gDirProvider = new FakeDirProvider();
let cm = AUS_Cc["@mozilla.org/categorymanager;1"].getService(AUS_Ci.nsICategoryManager);
let cm = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
gOldProviders = [];
let enumerator = cm.enumerateCategory("xpcom-directory-providers");
while (enumerator.hasMoreElements()) {
let entry = enumerator.getNext().QueryInterface(AUS_Ci.nsISupportsCString).data;
let entry = enumerator.getNext().QueryInterface(Ci.nsISupportsCString).data;
let contractID = cm.getCategoryEntry("xpcom-directory-providers", entry);
gOldProviders.push(AUS_Cc[contractID].createInstance(AUS_Ci.nsIDirectoryServiceProvider));
gOldProviders.push(Cc[contractID].createInstance(Ci.nsIDirectoryServiceProvider));
}
gDirService = AUS_Cc["@mozilla.org/file/directory_service;1"]
.getService(AUS_Ci.nsIProperties);
gDirService = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
gOldProviders.forEach(function (p) {
gOldProviders.forEach(function(p) {
gDirService.unregisterProvider(p);
});
gDirService.registerProvider(gDirProvider);
@@ -62,13 +47,13 @@ function xhr_pt1() {
gXHR.status = 200;
gXHR.responseText = gResponseBody;
try {
var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(AUS_Ci.nsIDOMParser);
let parser = Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(Ci.nsIDOMParser);
gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
} catch (e) {
gXHR.responseXML = null;
}
var e = { target: gXHR };
let e = { target: gXHR };
gXHR.onload(e);
}
@@ -92,17 +77,31 @@ function check_test_pt1() {
let state = gAUS.downloadUpdate(gActiveUpdate, true);
do_check_eq(state, "null");
do_check_eq(gActiveUpdate.errorCode >>> 0 , AUS_Cr.NS_ERROR_FILE_TOO_BIG);
do_check_eq(gActiveUpdate.errorCode >>> 0 , Cr.NS_ERROR_FILE_TOO_BIG);
doTestFinish();
}
function end_test() {
gDirService.unregisterProvider(gDirProvider);
gOldProviders.forEach(function (p) {
gOldProviders.forEach(function(p) {
gDirService.registerProvider(p);
});
gActiveUpdate = null;
gDirService = null;
gDirProvider = null;
}
function FakeDirProvider() {}
FakeDirProvider.prototype = {
getFile: function(prop, persistent) {
if (prop == KEY_UPDATE_ARCHIVE_DIR) {
if (gActiveUpdate) {
gActiveUpdate.errorCode = Cr.NS_ERROR_FILE_TOO_BIG;
}
}
return null;
},
classID: Components.ID("{f30b43a7-2bfa-4e5f-8c4f-abc7dd4ac486}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDirectoryServiceProvider])
};
@@ -31,12 +31,12 @@ function run_test_pt1() {
}
function xhr_pt1() {
gXHR.status = AUS_Cr.NS_ERROR_OFFLINE;
gXHR.status = Cr.NS_ERROR_OFFLINE;
gXHR.onerror({ target: gXHR });
}
function check_test_pt1(request, update) {
do_check_eq(gStatusCode, AUS_Cr.NS_ERROR_OFFLINE);
do_check_eq(gStatusCode, Cr.NS_ERROR_OFFLINE);
do_check_eq(update.errorCode, NETWORK_ERROR_OFFLINE);
// Forward the error to AUS, which should register the online observer
@@ -47,22 +47,22 @@ function check_test_pt1(request, update) {
Services.obs.notifyObservers(gAUS, "network:offline-status-changed", "online");
}
var updatePrompt = {
const updatePrompt = {
showUpdateAvailable: function(update) {
check_test_pt2(update);
}
};
function xhr_pt2() {
var patches = getLocalPatchString();
var updates = getLocalUpdateString(patches);
var responseBody = getLocalUpdatesXMLString(updates);
let patches = getLocalPatchString();
let updates = getLocalUpdateString(patches);
let responseBody = getLocalUpdatesXMLString(updates);
gXHR.status = 200;
gXHR.responseText = responseBody;
try {
var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(AUS_Ci.nsIDOMParser);
let parser = Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(Ci.nsIDOMParser);
gXHR.responseXML = parser.parseFromString(responseBody, "application/xml");
} catch (e) {
}
@@ -46,12 +46,12 @@ function callHandleEvent() {
gXHR.status = 400;
gXHR.responseText = gResponseBody;
try {
var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(AUS_Ci.nsIDOMParser);
let parser = Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(Ci.nsIDOMParser);
gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
} catch (e) {
}
var e = { target: gXHR };
let e = { target: gXHR };
gXHR.onload(e);
}
@@ -71,10 +71,11 @@ function run_test_helper_pt1(aMsg, aExpectedStatusResult, aNextRunFunc) {
function check_test_helper_pt1_1() {
do_check_eq(gUpdateCount, 1);
gCheckFunc = check_test_helper_pt1_2;
var bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
var state = gAUS.downloadUpdate(bestUpdate, false);
if (state == STATE_NONE || state == STATE_FAILED)
let bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
let state = gAUS.downloadUpdate(bestUpdate, false);
if (state == STATE_NONE || state == STATE_FAILED) {
do_throw("nsIApplicationUpdateService:downloadUpdate returned " + state);
}
gAUS.addDownloadListener(downloadListener);
}
@@ -85,38 +86,38 @@ function check_test_helper_pt1_2() {
}
function setResponseBody(aHashFunction, aHashValue, aSize) {
var patches = getRemotePatchString(null, null,
let patches = getRemotePatchString(null, null,
aHashFunction, aHashValue, aSize);
var updates = getRemoteUpdateString(patches);
let updates = getRemoteUpdateString(patches);
gResponseBody = getRemoteUpdatesXMLString(updates);
}
var newFactory = {
const newFactory = {
createInstance: function(aOuter, aIID) {
if (aOuter)
throw Components.results.NS_ERROR_NO_AGGREGATION;
if (aOuter) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return new IncrementalDownload().QueryInterface(aIID);
},
lockFactory: function(aLock) {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsIFactory])
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory])
};
function initMockIncrementalDownload() {
var registrar = AUS_Cm.QueryInterface(AUS_Ci.nsIComponentRegistrar);
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
gIncrementalDownloadClassID = registrar.contractIDToCID(INC_CONTRACT_ID);
gIncOldFactory = AUS_Cm.getClassObject(AUS_Cc[INC_CONTRACT_ID],
AUS_Ci.nsIFactory);
gIncOldFactory = Cm.getClassObject(Cc[INC_CONTRACT_ID], Ci.nsIFactory);
registrar.unregisterFactory(gIncrementalDownloadClassID, gIncOldFactory);
var components = [IncrementalDownload];
let components = [IncrementalDownload];
registrar.registerFactory(gIncrementalDownloadClassID, "",
INC_CONTRACT_ID, newFactory);
}
function cleanupMockIncrementalDownload() {
if (gIncOldFactory) {
var registrar = AUS_Cm.QueryInterface(AUS_Ci.nsIComponentRegistrar);
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(gIncrementalDownloadClassID, newFactory);
registrar.registerFactory(gIncrementalDownloadClassID, "",
INC_CONTRACT_ID, gIncOldFactory);
@@ -135,8 +136,6 @@ function IncrementalDownload() {
}
IncrementalDownload.prototype = {
QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsIIncrementalDownload]),
/* nsIIncrementalDownload */
init: function(uri, file, chunkSize, intervalInSeconds) {
this._destination = file;
@@ -145,45 +144,45 @@ IncrementalDownload.prototype = {
},
start: function(observer, ctxt) {
var tm = Components.classes["@mozilla.org/thread-manager;1"].
getService(AUS_Ci.nsIThreadManager);
let tm = Cc["@mozilla.org/thread-manager;1"].
getService(Ci.nsIThreadManager);
// Do the actual operation async to give a chance for observers
// to add themselves.
tm.mainThread.dispatch(function() {
this._observer = observer.QueryInterface(AUS_Ci.nsIRequestObserver);
this._observer = observer.QueryInterface(Ci.nsIRequestObserver);
this._ctxt = ctxt;
this._observer.onStartRequest(this, this._ctxt);
let mar = getTestDirFile(FILE_SIMPLE_MAR);
mar.copyTo(this._destination.parent, this._destination.leafName);
var status = AUS_Cr.NS_OK
let status = Cr.NS_OK
switch (gIncrementalDownloadErrorType++) {
case 0:
status = AUS_Cr.NS_ERROR_NET_RESET;
break;
status = Cr.NS_ERROR_NET_RESET;
break;
case 1:
status = AUS_Cr.NS_ERROR_CONNECTION_REFUSED;
break;
status = Cr.NS_ERROR_CONNECTION_REFUSED;
break;
case 2:
status = AUS_Cr.NS_ERROR_NET_RESET;
break;
status = Cr.NS_ERROR_NET_RESET;
break;
case 3:
status = AUS_Cr.NS_OK;
status = Cr.NS_OK;
break;
case 4:
status = AUS_Cr.NS_ERROR_OFFLINE;
status = Cr.NS_ERROR_OFFLINE;
// After we report offline, we want to eventually show offline
// status being changed to online.
var tm = Components.classes["@mozilla.org/thread-manager;1"].
getService(AUS_Ci.nsIThreadManager);
let tm = Cc["@mozilla.org/thread-manager;1"].
getService(Ci.nsIThreadManager);
tm.mainThread.dispatch(function() {
Services.obs.notifyObservers(gAUS,
"network:offline-status-changed",
"online");
}, AUS_Ci.nsIThread.DISPATCH_NORMAL);
break;
}, Ci.nsIThread.DISPATCH_NORMAL);
break;
}
this._observer.onStopRequest(this, this._ctxt, status);
}.bind(this), AUS_Ci.nsIThread.DISPATCH_NORMAL);
}.bind(this), Ci.nsIThread.DISPATCH_NORMAL);
},
get URI() {
@@ -191,7 +190,7 @@ IncrementalDownload.prototype = {
},
get currentSize() {
throw AUS_Cr.NS_ERROR_NOT_IMPLEMENTED;
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
get destination() {
@@ -203,18 +202,18 @@ IncrementalDownload.prototype = {
},
get totalSize() {
throw AUS_Cr.NS_ERROR_NOT_IMPLEMENTED;
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
/* nsIRequest */
cancel: function(aStatus) {
throw AUS_Cr.NS_ERROR_NOT_IMPLEMENTED;
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
suspend: function() {
throw AUS_Cr.NS_ERROR_NOT_IMPLEMENTED;
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
isPending: function() {
throw AUS_Cr.NS_ERROR_NOT_IMPLEMENTED;
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
_loadFlags: 0,
get loadFlags() {
@@ -240,15 +239,16 @@ IncrementalDownload.prototype = {
_status: 0,
get status() {
return this._status;
}
}
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIIncrementalDownload])
};
// Test disconnecting during an update
function run_test_pt1() {
initMockIncrementalDownload();
setResponseBody("MD5", MD5_HASH_SIMPLE_MAR);
run_test_helper_pt1("mar download with connection interruption",
AUS_Cr.NS_OK, run_test_pt2);
Cr.NS_OK, run_test_pt2);
}
// Test disconnecting during an update
@@ -258,15 +258,15 @@ function run_test_pt2() {
Services.prefs.setIntPref(PREF_APP_UPDATE_RETRY_TIMEOUT, 0);
setResponseBody("MD5", MD5_HASH_SIMPLE_MAR);
var expectedResult;
let expectedResult;
if (IS_TOOLKIT_GONK) {
// Gonk treats interrupted downloads differently. For gonk, if the state
// is pending, this means that the download has completed and only the
// staging needs to occur. So gonk will skip the download portion which
// results in an NS_OK return.
expectedResult = AUS_Cr.NS_OK;
expectedResult = Cr.NS_OK;
} else {
expectedResult = AUS_Cr.NS_ERROR_NET_RESET;
expectedResult = Cr.NS_ERROR_NET_RESET;
}
run_test_helper_pt1("mar download with connection interruption without recovery",
expectedResult, run_test_pt3);
@@ -277,5 +277,5 @@ function run_test_pt3() {
gIncrementalDownloadErrorType = 4;
setResponseBody("MD5", MD5_HASH_SIMPLE_MAR);
run_test_helper_pt1("mar download with offline mode",
AUS_Cr.NS_OK, finish_test);
Cr.NS_OK, finish_test);
}
@@ -9,11 +9,9 @@ function run_test() {
logTestInfo("testing resuming an update download in progress for the same " +
"version of the application on startup (Bug 485624)");
var patches, updates;
patches = getLocalPatchString(null, null, null, null, null, null,
STATE_DOWNLOADING);
updates = getLocalUpdateString(patches, null, null, "1.0", "1.0");
let patches = getLocalPatchString(null, null, null, null, null, null,
STATE_DOWNLOADING);
let updates = getLocalUpdateString(patches, null, null, "1.0", "1.0");
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeStatusFile(STATE_DOWNLOADING);
@@ -38,5 +36,5 @@ function run_test() {
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
reloadUpdateManagerData();
do_timeout(TEST_CHECK_TIMEOUT, doTestFinish);
do_execute_soon(doTestFinish);
}
File diff suppressed because it is too large Load Diff
@@ -41,13 +41,13 @@ function callHandleEvent() {
gXHR.status = 400;
gXHR.responseText = gResponseBody;
try {
var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(AUS_Ci.nsIDOMParser);
let parser = Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(Ci.nsIDOMParser);
gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
} catch (e) {
gXHR.responseXML = null;
}
var e = { target: gXHR };
let e = { target: gXHR };
gXHR.onload(e);
}
@@ -63,13 +63,13 @@ function run_test_pt02() {
gUpdates = null;
gUpdateCount = null;
gCheckFunc = check_test_pt02;
var patches = getRemotePatchString("complete", "http://complete/", "SHA1",
let patches = getRemotePatchString("complete", "http://complete/", "SHA1",
"98db9dad8e1d80eda7e1170d0187d6f53e477059",
"9856459");
patches += getRemotePatchString("partial", "http://partial/", "SHA1",
"e6678ca40ae7582316acdeddf3c133c9c8577de4",
"1316138");
var updates = getRemoteUpdateString(patches, "minor", "Minor Test",
let updates = getRemoteUpdateString(patches, "minor", "Minor Test",
"version 2.1a1pre", "2.1a1pre",
"3.1a1pre", "20080811053724",
"http://details/",
@@ -87,19 +87,19 @@ function check_test_pt02() {
// XXXrstrong - not specifying a detailsURL will cause a leak due to bug 470244
// and until this is fixed this will not test the value for detailsURL when it
// isn't specified in the update xml.
// var defaultDetailsURL;
// let defaultDetailsURL;
// try {
// Try using a default details URL supplied by the distribution
// if the update XML does not supply one.
// var formatter = AUS_Cc["@mozilla.org/toolkit/URLFormatterService;1"].
// getService(AUS_Ci.nsIURLFormatter);
// let formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].
// getService(Ci.nsIURLFormatter);
// defaultDetailsURL = formatter.formatURLPref(PREF_APP_UPDATE_URL_DETAILS);
// } catch (e) {
// defaultDetailsURL = "";
// }
do_check_eq(gUpdateCount, 1);
var bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount).QueryInterface(AUS_Ci.nsIPropertyBag);
let bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount).QueryInterface(Ci.nsIPropertyBag);
do_check_eq(bestUpdate.type, "minor");
do_check_eq(bestUpdate.name, "Minor Test");
do_check_eq(bestUpdate.displayVersion, "version 2.1a1pre");
@@ -129,7 +129,7 @@ function check_test_pt02() {
do_check_eq(bestUpdate.getProperty("custom1_attr"), "custom1 value");
do_check_eq(bestUpdate.getProperty("custom2_attr"), "custom2 value");
var patch = bestUpdate.getPatchAt(0);
let patch = bestUpdate.getPatchAt(0);
do_check_eq(patch.type, "complete");
do_check_eq(patch.URL, "http://complete/");
do_check_eq(patch.hashFunction, "SHA1");
@@ -164,10 +164,10 @@ function run_test_pt03() {
gUpdates = null;
gUpdateCount = null;
gCheckFunc = check_test_pt03;
var patches = getRemotePatchString("complete", "http://complete/", "SHA1",
let patches = getRemotePatchString("complete", "http://complete/", "SHA1",
"98db9dad8e1d80eda7e1170d0187d6f53e477059",
"9856459");
var updates = getRemoteUpdateString(patches, "major", "Major Test",
let updates = getRemoteUpdateString(patches, "major", "Major Test",
null, null,
"5.1a1pre", "20080811053724",
"http://details/",
@@ -179,7 +179,7 @@ function run_test_pt03() {
function check_test_pt03() {
do_check_eq(gUpdateCount, 1);
var bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
let bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
do_check_eq(bestUpdate.type, "major");
do_check_eq(bestUpdate.name, "Major Test");
do_check_eq(bestUpdate.displayVersion, "version 4.1a1pre");
@@ -206,7 +206,7 @@ function check_test_pt03() {
do_check_eq(bestUpdate.patchCount, 1);
//XXX TODO - test nsIUpdate:serialize
var patch = bestUpdate.getPatchAt(0);
let patch = bestUpdate.getPatchAt(0);
do_check_eq(patch.type, "complete");
do_check_eq(patch.URL, "http://complete/");
do_check_eq(patch.hashFunction, "SHA1");
@@ -240,9 +240,9 @@ function run_test_pt05() {
// one update available with two patches
function run_test_pt06() {
var patches = getRemotePatchString("complete");
let patches = getRemotePatchString("complete");
patches += getRemotePatchString("partial");
var updates = getRemoteUpdateString(patches);
let updates = getRemoteUpdateString(patches);
gResponseBody = getRemoteUpdatesXMLString(updates);
run_test_helper_pt1("testing one update available",
1, run_test_pt07);
@@ -250,9 +250,9 @@ function run_test_pt06() {
// three updates available each with two patches
function run_test_pt07() {
var patches = getRemotePatchString("complete");
let patches = getRemotePatchString("complete");
patches += getRemotePatchString("partial");
var updates = getRemoteUpdateString(patches);
let updates = getRemoteUpdateString(patches);
updates += getRemoteUpdateString(patches);
updates += getRemoteUpdateString(patches);
gResponseBody = getRemoteUpdatesXMLString(updates);
@@ -263,9 +263,9 @@ function run_test_pt07() {
// one update with complete and partial patches with size 0 specified in the
// update xml
function run_test_pt08() {
var patches = getRemotePatchString("complete", null, null, null, "0");
let patches = getRemotePatchString("complete", null, null, null, "0");
patches += getRemotePatchString("partial", null, null, null, "0");
var updates = getRemoteUpdateString(patches);
let updates = getRemoteUpdateString(patches);
gResponseBody = getRemoteUpdatesXMLString(updates);
run_test_helper_pt1("testing one update with complete and partial " +
"patches with size 0", 0, run_test_pt09);
@@ -273,8 +273,8 @@ function run_test_pt08() {
// one update with complete patch with size 0 specified in the update xml
function run_test_pt09() {
var patches = getRemotePatchString("complete", null, null, null, "0");
var updates = getRemoteUpdateString(patches);
let patches = getRemotePatchString("complete", null, null, null, "0");
let updates = getRemoteUpdateString(patches);
gResponseBody = getRemoteUpdatesXMLString(updates);
run_test_helper_pt1("testing one update with complete patch with size 0",
0, run_test_pt10);
@@ -282,8 +282,8 @@ function run_test_pt09() {
// one update with partial patch with size 0 specified in the update xml
function run_test_pt10() {
var patches = getRemotePatchString("partial", null, null, null, "0");
var updates = getRemoteUpdateString(patches);
let patches = getRemotePatchString("partial", null, null, null, "0");
let updates = getRemoteUpdateString(patches);
gResponseBody = getRemoteUpdatesXMLString(updates);
run_test_helper_pt1("testing one update with partial patch with size 0",
0, run_test_pt11);
@@ -291,9 +291,9 @@ function run_test_pt10() {
// check that updates for older versions of the application aren't selected
function run_test_pt11() {
var patches = getRemotePatchString("complete");
let patches = getRemotePatchString("complete");
patches += getRemotePatchString("partial");
var updates = getRemoteUpdateString(patches, "minor", null, null, "1.0pre");
let updates = getRemoteUpdateString(patches, "minor", null, null, "1.0pre");
updates += getRemoteUpdateString(patches, "minor", null, null, "1.0a");
gResponseBody = getRemoteUpdatesXMLString(updates);
run_test_helper_pt1("testing two updates older than the current version",
@@ -301,23 +301,23 @@ function run_test_pt11() {
}
function check_test_pt11() {
var bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
let bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
do_check_eq(bestUpdate, null);
run_test_pt12();
}
// check that updates for the current version of the application are selected
function run_test_pt12() {
var patches = getRemotePatchString("complete");
let patches = getRemotePatchString("complete");
patches += getRemotePatchString("partial");
var updates = getRemoteUpdateString(patches, "minor", null, "version 1.0");
let updates = getRemoteUpdateString(patches, "minor", null, "version 1.0");
gResponseBody = getRemoteUpdatesXMLString(updates);
run_test_helper_pt1("testing one update equal to the current version",
1, check_test_pt12);
}
function check_test_pt12() {
var bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
let bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
do_check_neq(bestUpdate, null);
do_check_eq(bestUpdate.displayVersion, "version 1.0");
@@ -15,7 +15,7 @@ function run_test() {
Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, false);
let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1",
@@ -52,7 +52,7 @@ function run_test() {
// didn't throw and otherwise it would report no tests run.
do_check_true(true);
registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
WindowWatcherFactory);
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af56}"),
@@ -69,46 +69,36 @@ function check_showUpdateAvailable() {
do_throw("showUpdateAvailable should not have called openWindow!");
}
var WindowWatcher = {
const WindowWatcher = {
openWindow: function(aParent, aUrl, aName, aFeatures, aArgs) {
gCheckFunc();
},
QueryInterface: function(aIID) {
if (aIID.equals(AUS_Ci.nsIWindowWatcher) ||
aIID.equals(AUS_Ci.nsISupports))
return this;
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowWatcher])
};
throw AUS_Cr.NS_ERROR_NO_INTERFACE;
}
}
var WindowWatcherFactory = {
const WindowWatcherFactory = {
createInstance: function createInstance(aOuter, aIID) {
if (aOuter != null)
throw AUS_Cr.NS_ERROR_NO_AGGREGATION;
if (aOuter != null) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return WindowWatcher.QueryInterface(aIID);
}
};
var WindowMediator = {
const WindowMediator = {
getMostRecentWindow: function(aWindowType) {
return { getInterface: XPCOMUtils.generateQI([AUS_Ci.nsIDOMWindow]) };
return { getInterface: XPCOMUtils.generateQI([Ci.nsIDOMWindow]) };
},
QueryInterface: function(aIID) {
if (aIID.equals(AUS_Ci.nsIWindowMediator) ||
aIID.equals(AUS_Ci.nsISupports))
return this;
throw AUS_Cr.NS_ERROR_NO_INTERFACE;
}
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowMediator])
}
var WindowMediatorFactory = {
const WindowMediatorFactory = {
createInstance: function createInstance(aOuter, aIID) {
if (aOuter != null)
throw AUS_Cr.NS_ERROR_NO_AGGREGATION;
if (aOuter != null) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return WindowMediator.QueryInterface(aIID);
}
};
@@ -16,7 +16,7 @@ function run_test() {
Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, true);
let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1",
@@ -57,7 +57,7 @@ function run_test() {
// didn't throw and otherwise it would report no tests run.
do_check_true(true);
registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
WindowWatcherFactory);
@@ -76,7 +76,7 @@ function check_showUpdateError() {
do_throw("showUpdateError should not have seen getNewPrompter!");
}
var WindowWatcher = {
const WindowWatcher = {
openWindow: function(aParent, aUrl, aName, aFeatures, aArgs) {
gCheckFunc();
},
@@ -85,19 +85,14 @@ var WindowWatcher = {
gCheckFunc();
},
QueryInterface: function(aIID) {
if (aIID.equals(AUS_Ci.nsIWindowWatcher) ||
aIID.equals(AUS_Ci.nsISupports))
return this;
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowWatcher])
};
throw AUS_Cr.NS_ERROR_NO_INTERFACE;
}
}
var WindowWatcherFactory = {
const WindowWatcherFactory = {
createInstance: function createInstance(aOuter, aIID) {
if (aOuter != null)
throw AUS_Cr.NS_ERROR_NO_AGGREGATION;
if (aOuter != null) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return WindowWatcher.QueryInterface(aIID);
}
};
@@ -15,7 +15,7 @@ function run_test() {
overrideXHR(callHandleEvent);
standardInit();
let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1",
@@ -51,7 +51,7 @@ function check_test() {
}
function end_test() {
let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
WindowWatcherFactory);
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af56}"),
@@ -64,12 +64,12 @@ function callHandleEvent() {
gXHR.status = 400;
gXHR.responseText = gResponseBody;
try {
var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(AUS_Ci.nsIDOMParser);
let parser = Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(Ci.nsIDOMParser);
gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
} catch (e) {
}
var e = { target: gXHR };
let e = { target: gXHR };
gXHR.onload(e);
}
@@ -77,46 +77,36 @@ function check_showUpdateAvailable() {
do_throw("showUpdateAvailable should not have called openWindow!");
}
var WindowWatcher = {
const WindowWatcher = {
openWindow: function(aParent, aUrl, aName, aFeatures, aArgs) {
check_showUpdateAvailable();
},
QueryInterface: function(aIID) {
if (aIID.equals(AUS_Ci.nsIWindowWatcher) ||
aIID.equals(AUS_Ci.nsISupports))
return this;
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowWatcher])
};
throw AUS_Cr.NS_ERROR_NO_INTERFACE;
}
}
var WindowWatcherFactory = {
const WindowWatcherFactory = {
createInstance: function createInstance(aOuter, aIID) {
if (aOuter != null)
throw AUS_Cr.NS_ERROR_NO_AGGREGATION;
if (aOuter != null) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return WindowWatcher.QueryInterface(aIID);
}
};
var WindowMediator = {
const WindowMediator = {
getMostRecentWindow: function(aWindowType) {
return null;
},
QueryInterface: function(aIID) {
if (aIID.equals(AUS_Ci.nsIWindowMediator) ||
aIID.equals(AUS_Ci.nsISupports))
return this;
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowMediator])
};
throw AUS_Cr.NS_ERROR_NO_INTERFACE;
}
}
var WindowMediatorFactory = {
const WindowMediatorFactory = {
createInstance: function createInstance(aOuter, aIID) {
if (aOuter != null)
throw AUS_Cr.NS_ERROR_NO_AGGREGATION;
if (aOuter != null) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return WindowMediator.QueryInterface(aIID);
}
};
@@ -29,7 +29,7 @@ function run_test() {
// call the nsIDOMEventListener's handleEvent method for onload.
function callHandleEvent() {
gXHR.status = gExpectedStatusCode;
var e = { target: gXHR };
let e = { target: gXHR };
gXHR.onload(e);
}
@@ -46,7 +46,7 @@ function run_test_helper(aNextRunFunc, aExpectedStatusCode, aMsg) {
function check_test_helper() {
do_check_eq(gStatusCode, gExpectedStatusCode);
var expectedStatusText = getStatusText(gExpectedStatusCode);
let expectedStatusText = getStatusText(gExpectedStatusCode);
do_check_eq(gStatusText, expectedStatusText);
gNextRunFunc();
}
@@ -67,7 +67,7 @@ function run_test_pt1() {
function check_test_pt1() {
do_check_eq(gStatusCode, gExpectedStatusCode);
var expectedStatusText = getStatusText(404);
let expectedStatusText = getStatusText(404);
do_check_eq(gStatusText, expectedStatusText);
run_test_pt2();
}
@@ -98,55 +98,55 @@ function run_test_pt5() {
// failed (unknown reason) - NS_BINDING_FAILED (2152398849)
function run_test_pt6() {
run_test_helper(run_test_pt7, AUS_Cr.NS_BINDING_FAILED,
run_test_helper(run_test_pt7, Cr.NS_BINDING_FAILED,
"testing failed (unknown reason)");
}
// connection timed out - NS_ERROR_NET_TIMEOUT (2152398862)
function run_test_pt7() {
run_test_helper(run_test_pt8, AUS_Cr.NS_ERROR_NET_TIMEOUT,
run_test_helper(run_test_pt8, Cr.NS_ERROR_NET_TIMEOUT,
"testing connection timed out");
}
// network offline - NS_ERROR_OFFLINE (2152398864)
function run_test_pt8() {
run_test_helper(run_test_pt9, AUS_Cr.NS_ERROR_OFFLINE,
run_test_helper(run_test_pt9, Cr.NS_ERROR_OFFLINE,
"testing network offline");
}
// port not allowed - NS_ERROR_PORT_ACCESS_NOT_ALLOWED (2152398867)
function run_test_pt9() {
run_test_helper(run_test_pt10, AUS_Cr.NS_ERROR_PORT_ACCESS_NOT_ALLOWED,
run_test_helper(run_test_pt10, Cr.NS_ERROR_PORT_ACCESS_NOT_ALLOWED,
"testing port not allowed");
}
// no data was received - NS_ERROR_NET_RESET (2152398868)
function run_test_pt10() {
run_test_helper(run_test_pt11, AUS_Cr.NS_ERROR_NET_RESET,
run_test_helper(run_test_pt11, Cr.NS_ERROR_NET_RESET,
"testing no data was received");
}
// update server not found - NS_ERROR_UNKNOWN_HOST (2152398878)
function run_test_pt11() {
run_test_helper(run_test_pt12, AUS_Cr.NS_ERROR_UNKNOWN_HOST,
run_test_helper(run_test_pt12, Cr.NS_ERROR_UNKNOWN_HOST,
"testing update server not found");
}
// proxy server not found - NS_ERROR_UNKNOWN_PROXY_HOST (2152398890)
function run_test_pt12() {
run_test_helper(run_test_pt13, AUS_Cr.NS_ERROR_UNKNOWN_PROXY_HOST,
run_test_helper(run_test_pt13, Cr.NS_ERROR_UNKNOWN_PROXY_HOST,
"testing proxy server not found");
}
// data transfer interrupted - NS_ERROR_NET_INTERRUPT (2152398919)
function run_test_pt13() {
run_test_helper(run_test_pt14, AUS_Cr.NS_ERROR_NET_INTERRUPT,
run_test_helper(run_test_pt14, Cr.NS_ERROR_NET_INTERRUPT,
"testing data transfer interrupted");
}
// proxy server connection refused - NS_ERROR_PROXY_CONNECTION_REFUSED (2152398920)
function run_test_pt14() {
run_test_helper(run_test_pt15, AUS_Cr.NS_ERROR_PROXY_CONNECTION_REFUSED,
run_test_helper(run_test_pt15, Cr.NS_ERROR_PROXY_CONNECTION_REFUSED,
"testing proxy server connection refused");
}
@@ -158,12 +158,12 @@ function run_test_pt15() {
// network is offline - NS_ERROR_DOCUMENT_NOT_CACHED (2152398918)
function run_test_pt16() {
run_test_helper(run_test_pt17, AUS_Cr.NS_ERROR_DOCUMENT_NOT_CACHED,
run_test_helper(run_test_pt17, Cr.NS_ERROR_DOCUMENT_NOT_CACHED,
"testing network is offline");
}
// connection refused - NS_ERROR_CONNECTION_REFUSED (2152398861)
function run_test_pt17() {
run_test_helper(doTestFinish, AUS_Cr.NS_ERROR_CONNECTION_REFUSED,
run_test_helper(doTestFinish, Cr.NS_ERROR_CONNECTION_REFUSED,
"testing connection refused");
}
@@ -3,9 +3,6 @@
"use strict";
const {utils: Cu, classes: Cc, interfaces: Ci} = Components;
Cu.import("resource://gre/modules/Metrics.jsm");
Cu.import("resource://gre/modules/UpdaterHealthProvider.jsm");
@@ -12,21 +12,21 @@ function run_test() {
setUpdateChannel("test_channel");
var patch, patches, update, updates;
// XXXrstrong - not specifying a detailsURL will cause a leak due to bug 470244
// and until bug 470244 is fixed this will not test the value for detailsURL
// when it isn't specified in the update xml.
patches = getLocalPatchString("partial", "http://partial/", "SHA256", "cd43",
"86", "true", STATE_PENDING);
updates = getLocalUpdateString(patches, "major", "New", "version 4", "4.0",
"4.0", "20070811053724", "http://details1/",
"http://billboard1/", "http://license1/",
"http://service1/", "1238441300314",
"test status text", "false", "test_channel",
"true", "true", "true", "345600", "true",
"test version", "3.0", "3.0",
"custom1_attr=\"custom1 value\"",
"custom2_attr=\"custom2 value\"");
let patches = getLocalPatchString("partial", "http://partial/", "SHA256",
"cd43", "86", "true", STATE_PENDING);
let updates = getLocalUpdateString(patches, "major", "New", "version 4",
"4.0", "4.0", "20070811053724",
"http://details1/", "http://billboard1/",
"http://license1/", "http://service1/",
"1238441300314", "test status text",
"false", "test_channel", "true", "true",
"true", "345600", "true", "test version",
"3.0", "3.0",
"custom1_attr=\"custom1 value\"",
"custom2_attr=\"custom2 value\"");
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeStatusFile(STATE_SUCCEEDED);
@@ -48,7 +48,7 @@ function run_test() {
do_check_eq(gUpdateManager.activeUpdate, null);
do_check_eq(gUpdateManager.updateCount, 2);
update = gUpdateManager.getUpdateAt(0).QueryInterface(AUS_Ci.nsIPropertyBag);
let update = gUpdateManager.getUpdateAt(0).QueryInterface(Ci.nsIPropertyBag);
do_check_eq(update.state, STATE_SUCCEEDED);
do_check_eq(update.type, "major");
do_check_eq(update.name, "New");
@@ -73,7 +73,7 @@ function run_test() {
do_check_eq(update.getProperty("custom1_attr"), "custom1 value");
do_check_eq(update.getProperty("custom2_attr"), "custom2 value");
patch = update.selectedPatch;
let patch = update.selectedPatch;
do_check_eq(patch.type, "partial");
do_check_eq(patch.URL, "http://partial/");
do_check_eq(patch.hashFunction, "SHA256");
@@ -82,7 +82,7 @@ function run_test() {
do_check_true(patch.selected);
do_check_eq(patch.state, STATE_SUCCEEDED);
update = gUpdateManager.getUpdateAt(1).QueryInterface(AUS_Ci.nsIPropertyBag);
update = gUpdateManager.getUpdateAt(1).QueryInterface(Ci.nsIPropertyBag);
do_check_eq(update.state, STATE_FAILED);
do_check_eq(update.name, "Existing");
do_check_eq(update.type, "major");
@@ -6,12 +6,12 @@
const PREF_APP_UPDATE_MIGRATE_APP_DIR = "app.update.migrated.updateDir";
function clearTaskbarIDHash(exePath, appInfoName) {
let registry = AUS_Cc["@mozilla.org/windows-registry-key;1"].
createInstance(AUS_Ci.nsIWindowsRegKey);
let registry = Cc["@mozilla.org/windows-registry-key;1"].
createInstance(Ci.nsIWindowsRegKey);
try {
registry.open(AUS_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
registry.open(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
"Software\\Mozilla\\" + appInfoName + "\\TaskBarIDs",
AUS_Ci.nsIWindowsRegKey.ACCESS_ALL);
Ci.nsIWindowsRegKey.ACCESS_ALL);
registry.removeValue(exePath);
} catch (e) {
}
@@ -21,12 +21,12 @@ function clearTaskbarIDHash(exePath, appInfoName) {
}
function setTaskbarIDHash(exePath, hash, appInfoName) {
let registry = AUS_Cc["@mozilla.org/windows-registry-key;1"].
createInstance(AUS_Ci.nsIWindowsRegKey);
let registry = Cc["@mozilla.org/windows-registry-key;1"].
createInstance(Ci.nsIWindowsRegKey);
try {
registry.create(AUS_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
registry.create(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
"Software\\Mozilla\\" + appInfoName + "\\TaskBarIDs",
AUS_Ci.nsIWindowsRegKey.ACCESS_WRITE);
Ci.nsIWindowsRegKey.ACCESS_WRITE);
registry.writeStringValue(exePath, hash);
} catch (e) {
}
@@ -36,7 +36,7 @@ function setTaskbarIDHash(exePath, hash, appInfoName) {
};
function getMigrated() {
var migrated = 0;
let migrated = 0;
try {
migrated = Services.prefs.getBoolPref(PREF_APP_UPDATE_MIGRATE_APP_DIR);
} catch (e) {
@@ -51,14 +51,14 @@ function run_test() {
standardInit();
var appinfo = AUS_Cc["@mozilla.org/xre/app-info;1"].
getService(AUS_Ci.nsIXULAppInfo).
QueryInterface(AUS_Ci.nsIXULRuntime);
let appinfo = Cc["@mozilla.org/xre/app-info;1"].
getService(Ci.nsIXULAppInfo).
QueryInterface(Ci.nsIXULRuntime);
// Obtain the old update root leaf
var updateLeafName;
var exeFile = FileUtils.getFile(XRE_EXECUTABLE_FILE, []);
var programFiles = FileUtils.getFile("ProgF", []);
let updateLeafName;
let exeFile = FileUtils.getFile(XRE_EXECUTABLE_FILE, []);
let programFiles = FileUtils.getFile("ProgF", []);
if (exeFile.path.substring(0, programFiles.path.length).toLowerCase() ==
programFiles.path.toLowerCase()) {
updateLeafName = exeFile.parent.leafName;
@@ -67,7 +67,7 @@ function run_test() {
}
// Obtain the old update root
var oldUpdateRoot;
let oldUpdateRoot;
if (appinfo.vendor) {
oldUpdateRoot = FileUtils.getDir("LocalAppData", [appinfo.vendor,
appinfo.name,
@@ -77,7 +77,7 @@ function run_test() {
updateLeafName], false);
}
// Obtain the new update root
var newUpdateRoot = FileUtils.getDir("UpdRootD", [], false);
let newUpdateRoot = FileUtils.getDir("UpdRootD", [], false);
///////////////////////////////////////////////////////////
// Setting a taskbar ID without the old update dir existing should set the
@@ -112,14 +112,14 @@ function run_test() {
Services.prefs.setBoolPref(PREF_APP_UPDATE_MIGRATE_APP_DIR, false);
setTaskbarIDHash(exeFile.parent.path, "AAAAAAAA", appinfo.name);
var oldUpdateDirs = oldUpdateRoot.clone();
let oldUpdateDirs = oldUpdateRoot.clone();
oldUpdateDirs.append("updates");
oldUpdateDirs.append("0");
oldUpdateDirs.create(AUS_Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
oldUpdateDirs.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
// Get an array of all of the files we want to migrate.
// We do this to create them in the old update directory.
var filesToMigrate = [FILE_UPDATES_DB, FILE_UPDATE_ACTIVE,
let filesToMigrate = [FILE_UPDATES_DB, FILE_UPDATE_ACTIVE,
["updates", FILE_LAST_LOG], ["updates", FILE_BACKUP_LOG],
["updates", "0", FILE_UPDATE_STATUS]];
// Move each of those files to the new directory
@@ -132,7 +132,7 @@ function run_test() {
} else {
oldFile.append(relPath);
}
oldFile.create(AUS_Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
oldFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
});
// Do the migration
initUpdateServiceStub();
@@ -163,9 +163,9 @@ function run_test() {
}
function end_test() {
var appinfo = AUS_Cc["@mozilla.org/xre/app-info;1"].
getService(AUS_Ci.nsIXULAppInfo).
QueryInterface(AUS_Ci.nsIXULRuntime);
var exeFile = FileUtils.getFile(XRE_EXECUTABLE_FILE, []);
let appinfo = Cc["@mozilla.org/xre/app-info;1"].
getService(Ci.nsIXULAppInfo).
QueryInterface(Ci.nsIXULRuntime);
let exeFile = FileUtils.getFile(XRE_EXECUTABLE_FILE, []);
clearTaskbarIDHash(exeFile.parent.path, appinfo.name);
}
@@ -5,7 +5,7 @@
/* General URL Construction Tests */
Components.utils.import("resource://gre/modules/ctypes.jsm")
Cu.import("resource://gre/modules/ctypes.jsm")
const URL_PREFIX = URL_HOST + "/";
@@ -20,16 +20,16 @@ function run_test() {
// The mock XMLHttpRequest is MUCH faster
overrideXHR(callHandleEvent);
standardInit();
gAppInfo = AUS_Cc["@mozilla.org/xre/app-info;1"].
getService(AUS_Ci.nsIXULAppInfo).
QueryInterface(AUS_Ci.nsIXULRuntime);
gAppInfo = Cc["@mozilla.org/xre/app-info;1"].
getService(Ci.nsIXULAppInfo).
QueryInterface(Ci.nsIXULRuntime);
do_execute_soon(run_test_pt1);
}
// Callback function used by the custom XMLHttpRequest implementation to
// call the nsIDOMEventListener's handleEvent method for onload.
function callHandleEvent() {
var e = { target: gXHR };
let e = { target: gXHR };
gXHR.onload(e);
}
@@ -41,7 +41,7 @@ function getResult(url) {
// url constructed with %PRODUCT%
function run_test_pt1() {
gCheckFunc = check_test_pt1;
var url = URL_PREFIX + "%PRODUCT%/";
let url = URL_PREFIX + "%PRODUCT%/";
logTestInfo("testing url constructed with %PRODUCT% - " + url);
setUpdateURLOverride(url);
gUpdateChecker.checkForUpdates(updateCheckListener, true);
@@ -55,7 +55,7 @@ function check_test_pt1() {
// url constructed with %VERSION%
function run_test_pt2() {
gCheckFunc = check_test_pt2;
var url = URL_PREFIX + "%VERSION%/";
let url = URL_PREFIX + "%VERSION%/";
logTestInfo("testing url constructed with %VERSION% - " + url);
setUpdateURLOverride(url);
gUpdateChecker.checkForUpdates(updateCheckListener, true);
@@ -69,7 +69,7 @@ function check_test_pt2() {
// url constructed with %BUILD_ID%
function run_test_pt3() {
gCheckFunc = check_test_pt3;
var url = URL_PREFIX + "%BUILD_ID%/";
let url = URL_PREFIX + "%BUILD_ID%/";
logTestInfo("testing url constructed with %BUILD_ID% - " + url);
setUpdateURLOverride(url);
gUpdateChecker.checkForUpdates(updateCheckListener, true);
@@ -84,14 +84,14 @@ function check_test_pt3() {
// XXX TODO - it might be nice if we tested the actual ABI
function run_test_pt4() {
gCheckFunc = check_test_pt4;
var url = URL_PREFIX + "%BUILD_TARGET%/";
let url = URL_PREFIX + "%BUILD_TARGET%/";
logTestInfo("testing url constructed with %BUILD_TARGET% - " + url);
setUpdateURLOverride(url);
gUpdateChecker.checkForUpdates(updateCheckListener, true);
}
function check_test_pt4() {
var abi;
let abi;
try {
abi = gAppInfo.XPCOMABI;
} catch (e) {
@@ -102,16 +102,12 @@ function check_test_pt4() {
// Mac universal build should report a different ABI than either macppc
// or mactel. This is necessary since nsUpdateService.js will set the ABI to
// Universal-gcc3 for Mac universal builds.
var macutils = AUS_Cc["@mozilla.org/xpcom/mac-utils;1"].
getService(AUS_Ci.nsIMacUtils);
let macutils = Cc["@mozilla.org/xpcom/mac-utils;1"].
getService(Ci.nsIMacUtils);
if (macutils.isUniversalBinary)
if (macutils.isUniversalBinary) {
abi += "-u-" + macutils.architecturesInBinary;
if (IS_SHARK) {
// Disambiguate optimised and shark nightlies
abi += "-shark"
}
}
do_check_eq(getResult(gRequestURL), gAppInfo.OS + "_" + abi);
@@ -122,7 +118,7 @@ function check_test_pt4() {
// Bug 488936 added the update.locale file that stores the update locale
function run_test_pt5() {
gCheckFunc = check_test_pt5;
var url = URL_PREFIX + "%LOCALE%/";
let url = URL_PREFIX + "%LOCALE%/";
logTestInfo("testing url constructed with %LOCALE% - " + url);
setUpdateURLOverride(url);
try {
@@ -142,7 +138,7 @@ function check_test_pt5() {
// url constructed with %CHANNEL%
function run_test_pt6() {
gCheckFunc = check_test_pt6;
var url = URL_PREFIX + "%CHANNEL%/";
let url = URL_PREFIX + "%CHANNEL%/";
logTestInfo("testing url constructed with %CHANNEL% - " + url);
setUpdateURLOverride(url);
setUpdateChannel("test_channel");
@@ -157,7 +153,7 @@ function check_test_pt6() {
// url constructed with %CHANNEL% with distribution partners
function run_test_pt7() {
gCheckFunc = check_test_pt7;
var url = URL_PREFIX + "%CHANNEL%/";
let url = URL_PREFIX + "%CHANNEL%/";
logTestInfo("testing url constructed with %CHANNEL% - " + url);
setUpdateURLOverride(url);
gDefaultPrefBranch.setCharPref(PREF_APP_PARTNER_BRANCH + "test_partner1", "test_partner1");
@@ -173,7 +169,7 @@ function check_test_pt7() {
// url constructed with %PLATFORM_VERSION%
function run_test_pt8() {
gCheckFunc = check_test_pt8;
var url = URL_PREFIX + "%PLATFORM_VERSION%/";
let url = URL_PREFIX + "%PLATFORM_VERSION%/";
logTestInfo("testing url constructed with %PLATFORM_VERSION% - " + url);
setUpdateURLOverride(url);
gUpdateChecker.checkForUpdates(updateCheckListener, true);
@@ -187,7 +183,7 @@ function check_test_pt8() {
// url constructed with %OS_VERSION%
function run_test_pt9() {
gCheckFunc = check_test_pt9;
var url = URL_PREFIX + "%OS_VERSION%/";
let url = URL_PREFIX + "%OS_VERSION%/";
logTestInfo("testing url constructed with %OS_VERSION% - " + url);
setUpdateURLOverride(url);
gUpdateChecker.checkForUpdates(updateCheckListener, true);
@@ -231,7 +227,7 @@ function getServicePack() {
let winVer = OSVERSIONINFOEXW();
winVer.dwOSVersionInfoSize = OSVERSIONINFOEXW.size;
if(0 === GetVersionEx(winVer.address())) {
if (0 === GetVersionEx(winVer.address())) {
// Using "throw" instead of "do_throw" (see NOTE above)
throw("Failure in GetVersionEx (returned 0)");
}
@@ -295,12 +291,11 @@ function getProcArchitecture() {
}
function check_test_pt9() {
var osVersion;
var sysInfo = AUS_Cc["@mozilla.org/system-info;1"].
getService(AUS_Ci.nsIPropertyBag2);
let osVersion;
let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
osVersion = sysInfo.getProperty("name") + " " + sysInfo.getProperty("version");
if(IS_WIN) {
if (IS_WIN) {
try {
let servicePack = getServicePack();
osVersion += "." + servicePack;
@@ -308,7 +303,7 @@ function check_test_pt9() {
do_throw("Failure obtaining service pack: " + e);
}
if("5.0" === sysInfo.getProperty("version")) { // Win2K
if ("5.0" === sysInfo.getProperty("version")) { // Win2K
osVersion += " (unknown)";
} else {
try {
@@ -336,7 +331,7 @@ function check_test_pt9() {
// url constructed with %DISTRIBUTION%
function run_test_pt10() {
gCheckFunc = check_test_pt10;
var url = URL_PREFIX + "%DISTRIBUTION%/";
let url = URL_PREFIX + "%DISTRIBUTION%/";
logTestInfo("testing url constructed with %DISTRIBUTION% - " + url);
setUpdateURLOverride(url);
gDefaultPrefBranch.setCharPref(PREF_DISTRIBUTION_ID, "test_distro");
@@ -351,7 +346,7 @@ function check_test_pt10() {
// url constructed with %DISTRIBUTION_VERSION%
function run_test_pt11() {
gCheckFunc = check_test_pt11;
var url = URL_PREFIX + "%DISTRIBUTION_VERSION%/";
let url = URL_PREFIX + "%DISTRIBUTION_VERSION%/";
logTestInfo("testing url constructed with %DISTRIBUTION_VERSION% - " + url);
setUpdateURLOverride(url);
gDefaultPrefBranch.setCharPref(PREF_DISTRIBUTION_VERSION, "test_distro_version");
@@ -366,7 +361,7 @@ function check_test_pt11() {
// url with force param that doesn't already have a param - bug 454357
function run_test_pt12() {
gCheckFunc = check_test_pt12;
var url = URL_PREFIX;
let url = URL_PREFIX;
logTestInfo("testing url with force param that doesn't already have a " +
"param - " + url);
setUpdateURLOverride(url);
@@ -381,7 +376,7 @@ function check_test_pt12() {
// url with force param that already has a param - bug 454357
function run_test_pt13() {
gCheckFunc = check_test_pt13;
var url = URL_PREFIX + "?extra=param";
let url = URL_PREFIX + "?extra=param";
logTestInfo("testing url with force param that already has a param - " + url);
logTestInfo("testing url constructed that has a parameter - " + url);
setUpdateURLOverride(url);
@@ -396,7 +391,7 @@ function check_test_pt13() {
function run_test_pt14() {
Services.prefs.setCharPref("app.update.custom", "custom");
gCheckFunc = check_test_pt14;
var url = URL_PREFIX + "?custom=%CUSTOM%";
let url = URL_PREFIX + "?custom=%CUSTOM%";
logTestInfo("testing url constructed with %CUSTOM% - " + url);
setUpdateURLOverride(url);
gUpdateChecker.checkForUpdates(updateCheckListener, true);
@@ -6,7 +6,6 @@
head = head_update.js
tail =
skip-if = toolkit == 'android'
generated-files = head_update.js
[canCheckForAndCanApplyUpdates.js]
[urlConstruction.js]
@@ -38,7 +37,3 @@ reason = custom nsIUpdatePrompt
[uiUnsupportedAlreadyNotified.js]
skip-if = toolkit == 'gonk'
reason = custom nsIUpdatePrompt
[updateRootDirMigration_win.js]
skip-if = os != 'win'
[updateHealthReport.js]
skip-if = ! healthreport
@@ -0,0 +1,5 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
load("../data/xpcshellUtilsAUS.js");
@@ -89,5 +89,6 @@ function finishTest() {
do_check_eq(readStatusState(), STATE_PENDING);
checkFilesAfterUpdateFailure(getApplyDirFile, false, false);
unlockDirectory(getAppBaseDir());
standardInit();
waitForFilesInUse();
}
@@ -7,7 +7,7 @@
* apply it.
*/
Components.utils.import("resource://gre/modules/ctypes.jsm");
Cu.import("resource://gre/modules/ctypes.jsm");
function run_test() {
if (MOZ_APP_NAME == "xulrunner") {
@@ -16,8 +16,8 @@ function run_test() {
let callbackApp = getApplyDirFile(DIR_RESOURCES + gCallbackBinFile);
let args = [getApplyDirPath() + DIR_RESOURCES, "input", "output", "-s",
HELPER_SLEEP_TIMEOUT];
let callbackAppProcess = AUS_Cc["@mozilla.org/process/util;1"].
createInstance(AUS_Ci.nsIProcess);
let callbackAppProcess = Cc["@mozilla.org/process/util;1"].
createInstance(Ci.nsIProcess);
callbackAppProcess.init(callbackApp);
callbackAppProcess.run(false, args, args.length);
@@ -40,5 +40,6 @@ function checkUpdateApplied() {
function checkUpdate() {
checkFilesAfterUpdateFailure(getApplyDirFile, false, false);
checkUpdateLogContains(ERR_RENAME_FILE);
standardInit();
checkCallbackAppLog();
}
@@ -16,8 +16,8 @@ function run_test() {
let callbackApp = getApplyDirFile(DIR_RESOURCES + gCallbackBinFile);
let args = [getApplyDirPath() + DIR_RESOURCES, "input", "output", "-s",
HELPER_SLEEP_TIMEOUT];
let callbackAppProcess = AUS_Cc["@mozilla.org/process/util;1"].
createInstance(AUS_Ci.nsIProcess);
let callbackAppProcess = Cc["@mozilla.org/process/util;1"].
createInstance(Ci.nsIProcess);
callbackAppProcess.init(callbackApp);
callbackAppProcess.run(false, args, args.length);
@@ -41,5 +41,6 @@ function checkUpdateApplied() {
function checkUpdate() {
checkFilesAfterUpdateFailure(getApplyDirFile, true, false);
checkUpdateLogContains(ERR_RENAME_FILE);
standardInit();
checkCallbackAppLog();
}
@@ -49,8 +49,8 @@ function run_test() {
callbackApp.permissions = PERMS_DIRECTORY;
let args = [getApplyDirPath() + DIR_RESOURCES, "input", "output", "-s",
HELPER_SLEEP_TIMEOUT];
let callbackAppProcess = AUS_Cc["@mozilla.org/process/util;1"].
createInstance(AUS_Ci.nsIProcess);
let callbackAppProcess = Cc["@mozilla.org/process/util;1"].
createInstance(Ci.nsIProcess);
callbackAppProcess.init(callbackApp);
callbackAppProcess.run(false, args, args.length);
@@ -113,13 +113,14 @@ function checkUpdate() {
checkSymlink();
}
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
standardInit();
checkCallbackAppLog();
}
function runHelperProcess(args) {
let helperBin = getTestDirFile(FILE_HELPER_BIN);
let process = AUS_Cc["@mozilla.org/process/util;1"].
createInstance(AUS_Ci.nsIProcess);
let process = Cc["@mozilla.org/process/util;1"].
createInstance(Ci.nsIProcess);
process.init(helperBin);
logTestInfo("Running " + helperBin.path + " " + args.join(" "));
process.run(true, args, args.length);
@@ -15,8 +15,8 @@ function run_test() {
callbackApp.permissions = PERMS_DIRECTORY;
let args = [getApplyDirPath() + DIR_RESOURCES, "input", "output", "-s",
HELPER_SLEEP_TIMEOUT];
let callbackAppProcess = AUS_Cc["@mozilla.org/process/util;1"].
createInstance(AUS_Ci.nsIProcess);
let callbackAppProcess = Cc["@mozilla.org/process/util;1"].
createInstance(Ci.nsIProcess);
callbackAppProcess.init(callbackApp);
callbackAppProcess.run(false, args, args.length);
@@ -53,5 +53,6 @@ function checkUpdate() {
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
standardInit();
checkCallbackAppLog();
}
@@ -23,5 +23,6 @@ function run_test() {
function checkUpdateApplied() {
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
standardInit();
checkCallbackAppLog();
}
@@ -23,5 +23,6 @@ function run_test() {
function checkUpdateApplied() {
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
standardInit();
checkCallbackAppLog();
}
@@ -17,5 +17,6 @@ function run_test() {
function checkUpdateApplied() {
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
standardInit();
checkCallbackAppLog();
}
@@ -17,5 +17,6 @@ function run_test() {
function checkUpdateApplied() {
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
standardInit();
checkCallbackAppLog();
}
@@ -26,7 +26,7 @@ function run_test() {
}
// Note that on platforms where we use execv, we cannot trust the return code.
runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_UNEXPECTED_FILE_OPERATION_ERROR);
runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_LOADSOURCE_ERROR_WRONG_SIZE);
}
/**
@@ -50,5 +50,6 @@ function checkUpdateApplied() {
checkFilesAfterUpdateFailure(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_PARTIAL_FAILURE);
standardInit();
checkCallbackAppLog();
}

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