Merge backout. CLOSED TREE

This commit is contained in:
Chris Jones 2009-11-16 23:50:52 -06:00
commit f0661e7597
21 changed files with 237 additions and 42 deletions

View File

@ -48,6 +48,7 @@
# Paul OShannessy <paul@oshannessy.com>
# Nils Maier <maierman@web.de>
# Rob Arnold <robarnold@cmu.edu>
# Dietrich Ayala <dietrich@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@ -152,6 +153,12 @@ XPCOMUtils.defineLazyGetter(this, "Win7Features", function () {
return null;
});
#ifdef MOZ_CRASHREPORTER
XPCOMUtils.defineLazyServiceGetter(this, "gCrashReporter",
"@mozilla.org/xre/app-info;1",
"nsICrashReporter");
#endif
/**
* We can avoid adding multiple load event listeners and save some time by adding
* one listener that calls all real handlers.
@ -4318,6 +4325,12 @@ var TabsProgressListener = {
},
onStateChange: function (aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) {
if (!aRequest.URI)
aRequest.QueryInterface(Ci.nsIChannel);
if (aStateFlags & Ci.nsIWebProgressListener.STATE_START &&
aStateFlags & Ci.nsIWebProgressListener.STATE_IS_DOCUMENT) {
gCrashReporter.annotateCrashReport("URL", aRequest.URI.spec);
}
},
onLocationChange: function (aBrowser, aWebProgress, aRequest, aLocationURI) {

View File

@ -35,8 +35,21 @@
*
* ***** END LICENSE BLOCK ***** */
function browserWindowsCount() {
let count = 0;
let e = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator)
.getEnumerator("navigator:browser");
while (e.hasMoreElements()) {
if (!e.getNext().closed)
++count;
}
return count;
}
function test() {
/** Test for Bug 490040 **/
is(browserWindowsCount(), 1, "Only one browser window should be open initially");
let ss = Cc["@mozilla.org/browser/sessionstore;1"].
getService(Ci.nsISessionStore);
@ -154,6 +167,7 @@ function test() {
else {
if (gPrefService.prefHasUserValue("browser.sessionstore.max_windows_undo"))
gPrefService.clearUserPref("browser.sessionstore.max_windows_undo");
is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
finish();
}
}

View File

@ -34,8 +34,21 @@
*
* ***** END LICENSE BLOCK ***** */
function browserWindowsCount() {
let count = 0;
let e = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator)
.getEnumerator("navigator:browser");
while (e.hasMoreElements()) {
if (!e.getNext().closed)
++count;
}
return count;
}
function test() {
/** Test for Bug 491168 **/
is(browserWindowsCount(), 1, "Only one browser window should be open initially");
// test setup
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
@ -72,6 +85,7 @@ function test() {
is(window.content.document.referrer, REFERRER2, "document.referrer is still correct after closing and reopening the tab.");
gBrowser.removeTab(newTab);
is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
finish();
}, true);
}, true);

View File

@ -35,8 +35,21 @@
*
* ***** END LICENSE BLOCK ***** */
function browserWindowsCount() {
let count = 0;
let e = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator)
.getEnumerator("navigator:browser");
while (e.hasMoreElements()) {
if (!e.getNext().closed)
++count;
}
return count;
}
function test() {
/** Test for Bug 491577 **/
is(browserWindowsCount(), 1, "Only one browser window should be open initially");
// test setup
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
@ -149,6 +162,7 @@ function test() {
// clean up
newWin.close();
is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
if (gPrefService.prefHasUserValue("browser.sessionstore.max_windows_undo"))
gPrefService.clearUserPref("browser.sessionstore.max_windows_undo");
finish();

View File

@ -34,8 +34,21 @@
*
* ***** END LICENSE BLOCK ***** */
function browserWindowsCount() {
let count = 0;
let e = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator)
.getEnumerator("navigator:browser");
while (e.hasMoreElements()) {
if (!e.getNext().closed)
++count;
}
return count;
}
function test() {
/** Test for Bug 493467 **/
is(browserWindowsCount(), 1, "Only one browser window should be open initially");
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
@ -66,4 +79,5 @@ function test() {
// leading "allow") to nsSessionStore.js's CAPABILITIES array. Thanks.
gBrowser.removeTab(tab);
is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
}

View File

@ -34,8 +34,21 @@
*
* ***** END LICENSE BLOCK ***** */
function browserWindowsCount() {
let count = 0;
let e = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator)
.getEnumerator("navigator:browser");
while (e.hasMoreElements()) {
if (!e.getNext().closed)
++count;
}
return count;
}
function test() {
/** Test for Bug 495495 **/
is(browserWindowsCount(), 1, "Only one browser window should be open initially");
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
waitForExplicitFinish();
@ -79,7 +92,10 @@ function test() {
testState(state1, {readOnly: false, enablehistory: "true"}, function() {
testState(state2, {readOnly: true, enablehistory: "false"}, function() {
executeSoon(finish);
executeSoon(function () {
is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
finish();
});
});
});
});

View File

@ -1510,6 +1510,25 @@ if test "$GNU_CXX"; then
if test "$ac_has_wno_invalid_offsetof" = "yes"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-Wno-invalid-offsetof"
fi
AC_CACHE_CHECK(whether the compiler supports -Wno-variadic-macros,
ac_has_wno_variadic_macros,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS ${_COMPILER_PREFIX}-Wno-variadic-macros"
AC_TRY_COMPILE([],
[return(0);],
ac_has_wno_variadic_macros="yes",
ac_has_wno_variadic_macros="no")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_has_wno_variadic_macros" = "yes"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-Wno-variadic-macros"
fi
else
_DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
fi

View File

@ -48,7 +48,7 @@ interface nsIDOMFile : nsISupports
readonly attribute DOMString name;
readonly attribute unsigned long long size;
readonly attribute DOMString mediaType;
readonly attribute DOMString type;
DOMString getAsText(in DOMString encoding); // raises(FileException) on retrieval
DOMString getAsDataURL(); // raises(FileException) on retrieval

View File

@ -50,7 +50,7 @@ interface nsIDOMFileReader : nsISupports
void abort();
const unsigned short INITIAL = 0;
const unsigned short EMPTY = 0;
const unsigned short LOADING = 1;
const unsigned short DONE = 2;
readonly attribute unsigned short readyState;

View File

@ -125,7 +125,7 @@ nsDOMFile::GetSize(PRUint64 *aFileSize)
}
NS_IMETHODIMP
nsDOMFile::GetMediaType(nsAString &aMediaType)
nsDOMFile::GetType(nsAString &aType)
{
if (!mContentType.Length()) {
nsresult rv;
@ -133,17 +133,17 @@ nsDOMFile::GetMediaType(nsAString &aMediaType)
do_GetService(NS_MIMESERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString mediaType;
rv = mimeService->GetTypeFromFile(mFile, mediaType);
nsCAutoString mimeType;
rv = mimeService->GetTypeFromFile(mFile, mimeType);
if (NS_FAILED(rv)) {
SetDOMStringToNull(aMediaType);
aType.Truncate();
return NS_OK;
}
AppendUTF8toUTF16(mediaType, mContentType);
AppendUTF8toUTF16(mimeType, mContentType);
}
aMediaType = mContentType;
aType = mContentType;
return NS_OK;
}

View File

@ -154,7 +154,7 @@ nsDOMFileReader::Notify(const char *aCharset, nsDetectionConfident aConf)
nsDOMFileReader::nsDOMFileReader()
: mFileData(nsnull), mReadCount(0),
mDataLen(0), mDataFormat(0),
mReadyState(nsIDOMFileReader::INITIAL),
mReadyState(nsIDOMFileReader::EMPTY),
mProgressEventWasDelayed(PR_FALSE),
mTimerIsActive(PR_FALSE),
mReadTotal(0), mReadTransferred(0),
@ -319,7 +319,7 @@ nsDOMFileReader::Abort()
DispatchProgressEvent(NS_LITERAL_STRING(ABORT_STR));
DispatchProgressEvent(NS_LITERAL_STRING(LOADEND_STR));
mReadyState = nsIDOMFileReader::INITIAL;
mReadyState = nsIDOMFileReader::EMPTY;
return NS_OK;
}

View File

@ -509,6 +509,15 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
!aElement->GetScriptAsync();
mPreloads.RemoveElementAt(i);
if (nsContentUtils::GetBoolPref("content.scriptloader.logloads")) {
nsCString spec;
request->mURI->GetSpec(spec);
printf("Grabbing existing speculative load for %s (%p). async:%d defer:%d\n",
spec.get(), request.get(), aElement->GetScriptAsync(),
request->mDefer);
}
rv = CheckContentPolicy(mDocument, aElement, request->mURI, type);
if (NS_FAILED(rv)) {
// Note, we're dropping our last ref to request here.
@ -558,6 +567,14 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
request->mIsInline = PR_FALSE;
request->mLoading = PR_TRUE;
if (nsContentUtils::GetBoolPref("content.scriptloader.logloads")) {
nsCString spec;
request->mURI->GetSpec(spec);
printf("Starting normal load for %s (%p). async:%d defer:%d\n",
spec.get(), request.get(), aElement->GetScriptAsync(),
request->mDefer);
}
rv = StartLoad(request, type);
if (NS_FAILED(rv)) {
return rv;
@ -570,6 +587,10 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
request->mLineNo = aElement->GetScriptLineNumber();
if (nsContentUtils::GetBoolPref("content.scriptloader.logloads")) {
printf("Creating inline request (%p).\n", request.get());
}
// If we've got existing pending requests, add ourselves
// to this list.
if (!hadPendingRequests && ReadyToExecuteScripts() &&
@ -609,6 +630,10 @@ nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest)
nsAFlatString* script;
nsAutoString textData;
if (nsContentUtils::GetBoolPref("content.scriptloader.logloads")) {
printf("Running request (%p).\n", aRequest);
}
// If there's no script text, we try to get it from the element
if (aRequest->mIsInline) {
// XXX This is inefficient - GetText makes multiple
@ -957,6 +982,13 @@ nsScriptLoader::OnStreamComplete(nsIStreamLoader* aLoader,
NS_ASSERTION(request, "null request in stream complete handler");
NS_ENSURE_TRUE(request, NS_ERROR_FAILURE);
if (nsContentUtils::GetBoolPref("content.scriptloader.logloads")) {
nsCString spec;
request->mURI->GetSpec(spec);
printf("Finished loading %s (%p). status:%d\n", spec.get(), request,
aStatus);
}
nsresult rv = PrepareLoadedRequest(request, aLoader, aStatus, aStringLen,
aString);
if (NS_FAILED(rv)) {
@ -1110,6 +1142,14 @@ nsScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset,
request->mLoading = PR_TRUE;
request->mDefer = PR_FALSE; // This is computed later when we go to execute the
// script.
if (nsContentUtils::GetBoolPref("content.scriptloader.logloads")) {
nsCString spec;
request->mURI->GetSpec(spec);
printf("Starting speculative load for %s (%p).\n", spec.get(),
request.get());
}
nsresult rv = StartLoad(request, aType);
if (NS_FAILED(rv)) {
return;

View File

@ -4,6 +4,13 @@
<!-- Async script that isn't preloaded -->
<script async src="file_bug503481.sjs?blockOn=R&body=runFirst();"></script>
<script>
function enableLogs(b) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
prefs.setBoolPref("content.scriptloader.logloads", b);
}
enableLogs(true);
firstRan = false;
secondRan = false;
thirdRan = false;
@ -37,6 +44,7 @@ function done() {
parent.is(forthRan, true, "forth should have run by onload");
parent.is(fifthRan, true, "fifth should have run by onload");
parent.is(sixthRan, true, "sixth should have run by onload");
enableLogs(false);
parent.SimpleTest.finish();
}

View File

@ -27,6 +27,10 @@ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
// Write a test file > 8192 characters
is(FileReader.EMPTY, 0, "correct EMPTY value");
is(FileReader.LOADING, 1, "correct LOADING value");
is(FileReader.DONE, 2, "correct DONE value");
var testData = "asdfblahqwer";
for (var i = 0; i < 10; i++) {
testData = testData + testData;
@ -62,8 +66,10 @@ var domFileBinary2 = utf16File.getAsBinary();
var domFileBinary3 = utf32File.getAsBinary();
var request1 = new FileReader();
is(request1.readyState, FileReader.EMPTY, "correct initial readyState");
request1.onload = handleTextISO1;
request1.readAsText(file, "iso-8859-1");
is(request1.readyState, FileReader.LOADING, "correct loading readyState");
var request2 = new FileReader();
request2.onload = handleTextUTF8;
@ -89,8 +95,10 @@ request6.readAsText(utf32File, "UTF-32");
//Test binary data accessor
var request7 = new FileReader();
is(request7.readyState, FileReader.EMPTY, "correct initial readyState");
request7.onload = handleDataBinary;
request7.readAsBinaryString(file);
is(request7.readyState, FileReader.LOADING, "correct loading readyState");
var request71 = new FileReader();
request71.onload = handleDataBinary16;
@ -172,6 +180,7 @@ function handleCancel(event) {
}
function handleTextISO1(event) {
is(event.target.readyState, FileReader.DONE, "correct final readyState");
var fileAsText = event.target.result;
var error = event.target.error;
is(error, null, "error code set to null for successful data accesses");
@ -232,6 +241,7 @@ function handleDataURI2(event) {
}
function handleDataBinary(event) {
is(event.target.readyState, FileReader.DONE, "correct final readyState");
var fileAsBinary = event.target.result;
is(domFileBinary.length, fileAsBinary.length, "binary data async length should match dom file binary");
is(domFileBinary, fileAsBinary, "binary data async string result should match dom file binary");

View File

@ -86,11 +86,11 @@ is(singleFileInput.value, input1File.name, "single-file input .value");
is(multiFileInput.value, input2Files[0].name, "multi-file input .value");
is(singleFileInput.files[0].name, input1File.name, "single-file input .files[n].name");
is(singleFileInput.files[0].size, input1File.body.length, "single-file input .files[n].size");
is(singleFileInput.files[0].mediaType, input1File.type, "single-file input .files[n].mediaType");
is(singleFileInput.files[0].type, input1File.type, "single-file input .files[n].type");
for(i = 0; i < input2Files.length; ++i) {
is(multiFileInput.files[i].name, input2Files[i].name, "multi-file input .files[n].name");
is(multiFileInput.files[i].size, input2Files[i].body.length, "multi-file input .files[n].size");
is(multiFileInput.files[i].mediaType, input2Files[i].type, "multi-file input .files[n].mediaType");
is(multiFileInput.files[i].type, input2Files[i].type, "multi-file input .files[n].type");
}
document.getElementById('form').submit();

View File

@ -941,26 +941,48 @@ nsJSContext::DOMOperationCallback(JSContext *cx)
JS_ClearPendingException(cx);
return JS_FALSE;
}
nsCOMPtr<nsIPrompt> prompt = GetPromptFromContext(ctx);
nsXPIDLString title, msg;
rv = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
"LowMemoryTitle",
title);
rv |= nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
"LowMemoryMessage",
msg);
//GetStringFromName can return NS_OK and still give NULL string
if (NS_FAILED(rv) || !title || !msg) {
NS_ERROR("Failed to get localized strings.");
JS_ClearPendingException(cx);
return JS_FALSE;
nsCOMPtr<nsIScriptError> errorObject =
do_CreateInstance("@mozilla.org/scripterror;1");
if (errorObject) {
nsXPIDLString msg;
nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
"LowMemoryMessage",
msg);
JSStackFrame *fp, *iterator = nsnull;
fp = ::JS_FrameIterator(cx, &iterator);
PRUint32 lineno = 0;
nsAutoString sourcefile;
if (fp) {
JSScript* script = ::JS_GetFrameScript(cx, fp);
if (script) {
const char* filename = ::JS_GetScriptFilename(cx, script);
if (filename) {
CopyUTF8toUTF16(nsDependentCString(filename), sourcefile);
}
jsbytecode* pc = ::JS_GetFramePC(cx, fp);
if (pc) {
lineno = ::JS_PCToLineNumber(cx, script, pc);
}
}
}
rv = errorObject->Init(msg.get(),
sourcefile.get(),
EmptyString().get(),
lineno, 0, nsIScriptError::errorFlag,
"content javascript");
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIConsoleService> consoleService =
do_GetService(NS_CONSOLESERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
consoleService->LogMessage(errorObject);
}
}
}
prompt->Alert(title, msg);
JS_ClearPendingException(cx);
return JS_FALSE;
}

View File

@ -20,10 +20,10 @@ RemoteCanvas.prototype.load = function(callback) {
var me = this;
iframe.addEventListener("load", function() {
var m = iframe.contentDocument.getElementById("av");
m.addEventListener("progress", function(aEvent) {
m.addEventListener("suspend", function(aEvent) {
if (m.readyState == m.HAVE_ENOUGH_DATA &&
aEvent.loaded == aEvent.total) {
m.removeEventListener("progress", arguments.callee, false);
m.removeEventListener("suspend", arguments.callee, false);
setTimeout(function() {
me.remotePageLoaded(callback);
}, 0);

View File

@ -106,7 +106,8 @@ const STATE_DOWNLOAD_FAILED = "download-failed";
const STATE_FAILED = "failed";
// From updater/errors.h:
const WRITE_ERROR = 7;
const WRITE_ERROR = 7;
const ELEVATION_CANCELED = 9;
const DOWNLOAD_CHUNK_SIZE = 300000; // bytes
const DOWNLOAD_BACKGROUND_INTERVAL = 600; // seconds
@ -1160,6 +1161,11 @@ UpdateService.prototype = {
writeVersionFile(getUpdatesDir(), update.extensionVersion);
return;
}
else if (update.errorCode == ELEVATION_CANCELED) {
writeStatusFile(getUpdatesDir(), update.state = STATE_PENDING);
writeVersionFile(getUpdatesDir(), update.extensionVersion);
return;
}
}
// Something went wrong with the patch application process.

View File

@ -48,5 +48,6 @@
#define READ_ERROR 6
#define WRITE_ERROR 7
#define UNEXPECTED_ERROR 8
#define ELEVATION_CANCELED 9
#endif // Errors_h__

View File

@ -1445,6 +1445,8 @@ int NS_main(int argc, NS_tchar **argv)
// argument prior to argOffset is the working directory.
const int argOffset = 4;
gSourcePath = argv[1];
#if defined(XP_WIN) && !defined(WINCE)
// Launch a second instance of the updater with the runas verb on Windows
// when write access is denied to the installation directory.
@ -1520,6 +1522,8 @@ int NS_main(int argc, NS_tchar **argv)
if (result) {
WaitForSingleObject(sinfo.hProcess, INFINITE);
CloseHandle(sinfo.hProcess);
} else {
WriteStatusFile(ELEVATION_CANCELED);
}
if (argc > argOffset) {
@ -1532,8 +1536,6 @@ int NS_main(int argc, NS_tchar **argv)
}
#endif
gSourcePath = argv[1];
LogInit();
LOG(("SOURCE DIRECTORY " LOG_S "\n", gSourcePath));

View File

@ -99,19 +99,21 @@ nsObserverList::FillObserverArray(nsCOMArray<nsIObserver> &aArray)
{
aArray.SetCapacity(mObservers.Length());
for (PRInt32 i = mObservers.Length() - 1; i >= 0; --i) {
if (mObservers[i].isWeakRef) {
nsCOMPtr<nsIObserver> o(do_QueryReferent(mObservers[i].asWeak()));
nsTArray<ObserverRef> observers(mObservers);
for (PRInt32 i = observers.Length() - 1; i >= 0; --i) {
if (observers[i].isWeakRef) {
nsCOMPtr<nsIObserver> o(do_QueryReferent(observers[i].asWeak()));
if (o) {
aArray.AppendObject(o);
}
else {
// the object has gone away, remove the weakref
mObservers.RemoveElementAt(i);
mObservers.RemoveElement(observers[i].asWeak());
}
}
else {
aArray.AppendObject(mObservers[i].asObserver());
aArray.AppendObject(observers[i].asObserver());
}
}
}