diff --git a/.hgtags b/.hgtags index 614c3e6a4db..df5f7eade5b 100644 --- a/.hgtags +++ b/.hgtags @@ -63,3 +63,4 @@ a71bd564ebf5bf4f93d13e84114f759c263130b0 MOBILE_MERGE_DONE a71bd564ebf5bf4f93d13e84114f759c263130b0 MOBILE_MERGE_DONE_20110406 a95d426422816513477e5863add1b00ac7041dcb AURORA_BASE_20110412 138f593553b66c9f815e8f57870c19d6347f7702 UPDATE_PACKAGING_R14 +9eae975b3d6fb7748fe5a3c0113d449b1c7cc0b2 AURORA_BASE_20110524 diff --git a/accessible/src/base/nsARIAMap.cpp b/accessible/src/base/nsARIAMap.cpp index 5b86248a1d2..390b78aa5d4 100644 --- a/accessible/src/base/nsARIAMap.cpp +++ b/accessible/src/base/nsARIAMap.cpp @@ -477,7 +477,8 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] = eNoValue, eSwitchAction, eNoLiveAttr, - kNoReqStates + kNoReqStates, + eARIASelectable }, { "tablist", diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index d2dfad66003..f2ef90761b2 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -1533,15 +1533,20 @@ nsAccessible::State() return states::DEFUNCT; PRUint64 state = NativeState(); - // Apply ARIA states to be sure accessible states will be overriden. + // Apply ARIA states to be sure accessible states will be overridden. ApplyARIAState(&state); - if (mRoleMapEntry && mRoleMapEntry->role == nsIAccessibleRole::ROLE_PAGETAB) { + if (mRoleMapEntry && mRoleMapEntry->role == nsIAccessibleRole::ROLE_PAGETAB && + !(state & states::SELECTED) && + !mContent->AttrValueIs(kNameSpaceID_None, + nsAccessibilityAtoms::aria_selected, + nsAccessibilityAtoms::_false, eCaseMatters)) { + // Special case: for tabs, focused implies selected, unless explicitly + // false, i.e. aria-selected="false". if (state & states::FOCUSED) { state |= states::SELECTED; } else { - // Expose 'selected' state on ARIA tab if the focus is on internal element - // of related tabpanel. + // If focus is in a child of the tab panel surely the tab is selected! nsCOMPtr tabPanel = nsRelUtils:: GetRelatedAccessible(this, nsIAccessibleRelation::RELATION_LABEL_FOR); diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp index 4b288395d18..262d63b1d7a 100644 --- a/accessible/src/base/nsDocAccessible.cpp +++ b/accessible/src/base/nsDocAccessible.cpp @@ -1037,6 +1037,14 @@ nsDocAccessible::AttributeChangedImpl(nsIContent* aContent, PRInt32 aNameSpaceID return; } + if (aAttribute == nsAccessibilityAtoms::aria_busy) { + PRBool isOn = !aContent->AttrValueIs(aNameSpaceID, aAttribute, + nsAccessibilityAtoms::_true, eCaseMatters); + nsRefPtr event = new AccStateChangeEvent(aContent, states::BUSY, isOn); + FireDelayedAccessibleEvent(event); + return; + } + if (aAttribute == nsAccessibilityAtoms::selected || aAttribute == nsAccessibilityAtoms::aria_selected) { // ARIA or XUL selection diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index e5521be0501..902b9c0ff6b 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -35,6 +35,9 @@ * * ***** END LICENSE BLOCK ***** */ +#define CreateEvent CreateEventA +#include "nsIDOMDocument.h" + #include "States.h" #include "nsAccessibilityService.h" #include "nsApplicationAccessibleWrap.h" @@ -48,7 +51,6 @@ #include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeNode.h" #include "nsIDocShellTreeOwner.h" -#include "nsIDOMDocument.h" #include "nsIDOMElement.h" #include "nsIDOMEventListener.h" #include "nsIDOMEventTarget.h" @@ -76,11 +78,8 @@ #include "nsReadableUtils.h" #include "nsRootAccessible.h" #include "nsIDOMNSEventTarget.h" -#include "nsIDOMDocumentEvent.h" #include "nsIPrivateDOMEvent.h" #include "nsFocusManager.h" -#include "mozilla/dom/Element.h" - #ifdef MOZ_XUL #include "nsXULTreeAccessible.h" @@ -415,11 +414,11 @@ nsRootAccessible::FireCurrentFocusEvent() return; // No current focus } - nsCOMPtr docEvent = do_QueryInterface(mDocument); - if (docEvent) { + nsCOMPtr domDoc = do_QueryInterface(mDocument); + if (domDoc) { nsCOMPtr event; - if (NS_SUCCEEDED(docEvent->CreateEvent(NS_LITERAL_STRING("Events"), - getter_AddRefs(event))) && + if (NS_SUCCEEDED(domDoc->CreateEvent(NS_LITERAL_STRING("Events"), + getter_AddRefs(event))) && NS_SUCCEEDED(event->InitEvent(NS_LITERAL_STRING("focus"), PR_TRUE, PR_TRUE))) { nsCOMPtr privateEvent(do_QueryInterface(event)); diff --git a/accessible/tests/mochitest/events/test_aria_statechange.html b/accessible/tests/mochitest/events/test_aria_statechange.html index 00402fd0223..cdb5e5a00d1 100644 --- a/accessible/tests/mochitest/events/test_aria_statechange.html +++ b/accessible/tests/mochitest/events/test_aria_statechange.html @@ -26,35 +26,60 @@ */ var gQueue = null; + // Debug stuff. + //gA11yEventDumpID = "eventdump"; + // gA11yEventDumpToConsole = true; + function expandNode(aNodeOrID, bExpand) { this.DOMNode = getNode(aNodeOrID); - this.invoke = function expand_invoke() { + this.invoke = function expandNode_invoke() { // Note: this should fire an EVENT_STATE_CHANGE this.DOMNode.setAttribute("aria-expanded", bExpand); }; - this.check = function expand_check() { + this.check = function expandNode_check() { testStates(aNodeOrID, bExpand ? STATE_EXPANDED : STATE_COLLAPSED, EXT_STATE_EXPANDABLE); }; - this.getID = function changeValue_getID() { + this.getID = function expandNode_getID() { return prettyName(aNodeOrID) + " aria-expanded changed"; }; } + function busyify(aNodeOrID, aBusy) + { + this.DOMNode = getNode(aNodeOrID); + + this.invoke = function busyify_invoke() { + this.DOMNode.setAttribute("aria-busy", aBusy); + }; + + this.check = function busyify_check(event) { + testStates(aNodeOrID, + (aBusy ? STATE_BUSY : 0), 0, + (aBusy ? 0 : STATE_BUSY), 0); + }; + + this.getID = function busyify_getID() { + return prettyName(aNodeOrID) + " aria-busy changed to " + aBusy; + }; + } + function doTests() { - gQueue = new eventQueue(nsIAccessibleEvent.EVENT_STATE_CHANGE); + gQueue = new eventQueue(EVENT_STATE_CHANGE); gQueue.push(new expandNode("section", true)); gQueue.push(new expandNode("section", false)); gQueue.push(new expandNode("div", true)); gQueue.push(new expandNode("div", false)); + gQueue.push(new busyify("aria_doc", true)); + gQueue.push(new busyify("aria_doc", false)); gQueue.invoke(); // Will call SimpleTest.finish(); } @@ -71,6 +96,11 @@ Mozilla Bug 551684 +

@@ -81,5 +111,7 @@
   
   
 
+  
+  
A document
diff --git a/accessible/tests/mochitest/states/Makefile.in b/accessible/tests/mochitest/states/Makefile.in index 9b3cbb2711a..3905fb981e2 100644 --- a/accessible/tests/mochitest/states/Makefile.in +++ b/accessible/tests/mochitest/states/Makefile.in @@ -48,6 +48,7 @@ include $(topsrcdir)/config/rules.mk _TEST_FILES =\ test_aria.html \ test_aria_imgmap.html \ + test_aria_tabs.html \ test_doc.html \ test_docarticle.html \ test_editablebody.html \ diff --git a/accessible/tests/mochitest/states/test_aria_tabs.html b/accessible/tests/mochitest/states/test_aria_tabs.html new file mode 100644 index 00000000000..50dd95f1f5f --- /dev/null +++ b/accessible/tests/mochitest/states/test_aria_tabs.html @@ -0,0 +1,137 @@ + + + + + Test ARIA tab accessible selected state + + + + + + + + + + + + + + +
+ Mozilla Bug 653601 + +

+ +
+  
+ + +
+ + + +
+ + +
+ + + +
+ + diff --git a/browser/app/Makefile.in b/browser/app/Makefile.in index dd3a89ffa6e..0f9f7a18ebd 100644 --- a/browser/app/Makefile.in +++ b/browser/app/Makefile.in @@ -102,51 +102,20 @@ CPPSRCS = nsBrowserApp.cpp LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/base -ifdef BUILD_STATIC_LIBS -ifdef _MSC_VER -STATIC_COMPONENTS_LINKER_PATH = -LIBPATH:$(DEPTH)/staticlib -else -STATIC_COMPONENTS_LINKER_PATH = -L$(DEPTH)/staticlib -endif -LIBS += $(DEPTH)/toolkit/xre/$(LIB_PREFIX)xulapp_s.$(LIB_SUFFIX) -else ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) LIBS += $(DIST)/bin/XUL +TK_LIBS := $(TK_LIBS) else EXTRA_DSO_LIBS += xul endif -endif - -ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) -TK_LIBS := $(TK_LIBS) -endif - -ifdef MOZ_ENABLE_LIBXUL -APP_XPCOM_LIBS = $(XPCOM_GLUE_LDOPTS) -else -MOZILLA_INTERNAL_API = 1 -APP_XPCOM_LIBS = $(XPCOM_LIBS) -endif LIBS += \ $(STATIC_COMPONENTS_LINKER_PATH) \ $(EXTRA_DSO_LIBS) \ - $(APP_XPCOM_LIBS) \ + $(XPCOM_GLUE_LDOPTS) \ $(NSPR_LIBS) \ $(NULL) -ifdef BUILD_STATIC_LIBS -LIBS += \ - $(MOZ_JS_LIBS) \ - $(TK_LIBS) \ - $(NULL) - -# Add explicit X11 dependency when building against X11 toolkits -ifneq (,$(filter gtk2,$(MOZ_WIDGET_TOOLKIT))) -LIBS += $(XLDFLAGS) $(XLIBS) $(ZLIB_LIBS) -endif -endif - ifdef MOZ_JPROF LIBS += -ljprof endif @@ -171,18 +140,6 @@ ifdef _MSC_VER WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup endif -ifdef BUILD_STATIC_LIBS -include $(topsrcdir)/config/static-config.mk - -EXTRA_DEPS += \ - $(STATIC_EXTRA_DEPS) \ - $(NULL) -DEFINES += $(STATIC_DEFINES) -CPPSRCS += $(STATIC_CPPSRCS) -EXTRA_DSO_LIBS += $(STATIC_EXTRA_DSO_LIBS) -EXTRA_LIBS += $(STATIC_EXTRA_LIBS) -endif - ifeq ($(OS_ARCH),WINNT) OS_LIBS += $(call EXPAND_LIBNAME,comctl32 comdlg32 uuid shell32 ole32 oleaut32 version winspool) OS_LIBS += $(call EXPAND_LIBNAME,usp10 msimg32) @@ -195,9 +152,6 @@ RCFLAGS += -DMOZ_PHOENIX -I$(srcdir) else RCFLAGS += -DMOZ_PHOENIX --include-dir $(srcdir) endif -ifdef BUILD_STATIC_LIBS -RCFLAGS += -DMOZ_STATIC_BUILD -endif ifdef DEBUG RCFLAGS += -DDEBUG endif @@ -206,9 +160,6 @@ endif ifeq ($(OS_ARCH),OS2) RESFILE=splashos2.res RCFLAGS += -DMOZ_PHOENIX -ifdef BUILD_STATIC_LIBS -RCFLAGS += -DMOZ_STATIC_BUILD -i $(DIST)/include -endif ifdef DEBUG RCFLAGS += -DDEBUG endif @@ -217,12 +168,6 @@ endif include $(topsrcdir)/config/rules.mk -ifdef BUILD_STATIC_LIBS -include $(topsrcdir)/config/static-rules.mk - -DEFINES += -DIMPL_XREAPI -endif - ifeq ($(MOZ_WIDGET_TOOLKIT),photon) LIBS += -lphexlib endif diff --git a/browser/app/profile/extensions/testpilot@labs.mozilla.com/content/survey-generator.js b/browser/app/profile/extensions/testpilot@labs.mozilla.com/content/survey-generator.js index 6dfb15c2de1..2e6a991f640 100644 --- a/browser/app/profile/extensions/testpilot@labs.mozilla.com/content/survey-generator.js +++ b/browser/app/profile/extensions/testpilot@labs.mozilla.com/content/survey-generator.js @@ -91,6 +91,9 @@ function onBuiltinSurveyLoad() { explanation.innerHTML = ""; } drawSurveyForm(task, contentDiv); + // Allow surveys to define arbitrary page load handlers - call them + // after creating the rest of the page: + task.onPageLoad(task, document); } } @@ -114,7 +117,7 @@ function drawSurveyForm(task, contentDiv) { for (let i = 0; i < surveyQuestions.length; i++) { let question = surveyQuestions[i].question; let explanation = surveyQuestions[i].explanation; - let elem; + let elem, j; elem = document.createElement("h3"); elem.innerHTML = (i+1) + ". " + question; @@ -129,7 +132,7 @@ function drawSurveyForm(task, contentDiv) { let choices = surveyQuestions[i].choices; switch (surveyQuestions[i].type) { case MULTIPLE_CHOICE: - for (let j = 0; j < choices.length; j++) { + for (j = 0; j < choices.length; j++) { let newRadio = document.createElement("input"); newRadio.setAttribute("type", "radio"); newRadio.setAttribute("name", "answer_to_" + i); @@ -148,7 +151,7 @@ function drawSurveyForm(task, contentDiv) { case CHECK_BOXES_WITH_FREE_ENTRY: let checkboxName = "answer_to_" + i; // Check boxes: - for (let j = 0; j < choices.length; j++) { + for (j = 0; j < choices.length; j++) { let newCheck = document.createElement("input"); newCheck.setAttribute("type", "checkbox"); newCheck.setAttribute("name", checkboxName); @@ -188,7 +191,7 @@ function drawSurveyForm(task, contentDiv) { inputBox.addEventListener( "keypress", function() { let elements = document.getElementsByName(checkboxName); - for (let j = (elements.length - 1); j >= 0; j--) { + for (j = (elements.length - 1); j >= 0; j--) { if (elements[j].value == freeformId) { elements[j].checked = true; break; @@ -213,7 +216,7 @@ function drawSurveyForm(task, contentDiv) { let label = document.createElement("span"); label.innerHTML = surveyQuestions[i].min_label; contentDiv.appendChild(label); - for (let j = surveyQuestions[i].scale_minimum; + for (j = surveyQuestions[i].scale_minimum; j <= surveyQuestions[i].scale_maximum; j++) { let newRadio = document.createElement("input"); @@ -243,7 +246,7 @@ function drawSurveyForm(task, contentDiv) { let freeformId = "freeform_" + i; let radioName = "answer_to_" + i; - for (let j = 0; j < choices.length; j++) { + for (j = 0; j < choices.length; j++) { let newRadio = document.createElement("input"); newRadio.setAttribute("type", "radio"); newRadio.setAttribute("name", radioName); diff --git a/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/remote-experiment-loader.js b/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/remote-experiment-loader.js index 6a4a086ac1b..b736dad1ebf 100644 --- a/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/remote-experiment-loader.js +++ b/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/remote-experiment-loader.js @@ -512,15 +512,15 @@ exports.RemoteExperimentLoader.prototype = { remoteExperiments[filename] = this._loader.require(filename); this._logger.info("Loaded " + filename + " OK."); } catch(e) { - /* Turn the load-time errors into strings and store them, so we can display - * them on a debug page or include them with a data upload! (Don't store - * exception objects directly as that causes garbage collector problems- - * aka bug 646122) */ - let errStr = e.name + " on line " + e.lineNumber + " of file " + - e.fileName + ": " + e.message; + /* Turn the load-time errors into strings and store them, so we can display + * them on a debug page or include them with a data upload! (Don't store + * exception objects directly as that causes garbage collector problems- + * aka bug 646122) */ + let errStr = e.name + " on line " + e.lineNumber + " of file " + + e.fileName + ": " + e.message; this._loadErrors.push(errStr); this._logger.warn("Error loading " + filename); - this._logger.warn(e); + this._logger.warn(errStr); } } return remoteExperiments; diff --git a/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js b/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js index 31db0d2a17e..cb6775ac388 100644 --- a/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js +++ b/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js @@ -597,7 +597,7 @@ TestPilotExperiment.prototype = { } } } catch(e) { - this._logger.warn("Error in getStudyMetadata: " + e); + this._dataStore.logException("getStudyMetadata: " + e); } return null; }, @@ -660,6 +660,7 @@ TestPilotExperiment.prototype = { // This method handles all date-related status changes and should be // called periodically. let currentDate = this._now(); + let self = this; // Reset automatically recurring tests: if (this._recursAutomatically && @@ -703,7 +704,6 @@ TestPilotExperiment.prototype = { currentDate <= this._endDate) { this._logger.info("Study now starting."); // clear the data before starting. - let self = this; this._dataStore.wipeAllData(function() { // Experiment is now in progress. self.changeStatus(TaskConstants.STATUS_IN_PROGRESS, true); @@ -714,7 +714,6 @@ TestPilotExperiment.prototype = { // What happens when a test finishes: if (this._status < TaskConstants.STATUS_FINISHED && currentDate > this._endDate) { - let self = this; let setDataDeletionDate = true; this._logger.info("Passed End Date - Switched Task Status to Finished"); this.changeStatus(TaskConstants.STATUS_FINISHED); @@ -896,7 +895,6 @@ TestPilotExperiment.prototype = { optOut: function TestPilotExperiment_optOut(reason, callback) { // Regardless of study ID, post the opt-out message to a special // database table of just opt-out messages; include study ID in metadata. - let url = Application.prefs.getValue(DATA_UPLOAD_PREF, "") + "opt-out"; let logger = this._logger; this.onExperimentShutdown(); @@ -909,6 +907,7 @@ TestPilotExperiment.prototype = { if (reason) { // Send us the reason... // (TODO: include metadata?) + let url = Application.prefs.getValue(DATA_UPLOAD_PREF, "") + "opt-out"; let answer = {id: this._id, reason: reason}; let dataString = JSON.stringify(answer); @@ -924,17 +923,23 @@ TestPilotExperiment.prototype = { if (req.readyState == 4) { if (req.status == 200 || req.status == 201 || req.status == 202) { logger.info("Quit reason posted successfully " + req.responseText); - callback(true); + if (callback) { + callback(true); + } } else { logger.warn(req.status + " posting error " + req.responseText); - callback(false); + if (callback) { + callback(false); + } } } }; logger.trace("Sending quit reason."); req.send(dataString); } else { - callback(false); + if (callback) { + callback(false); + } } }, @@ -961,6 +966,7 @@ TestPilotBuiltinSurvey.prototype = { this._versionNumber = surveyInfo.versionNumber; this._questions = surveyInfo.surveyQuestions; this._explanation = surveyInfo.surveyExplanation; + this._onPageLoad = surveyInfo.onPageLoad; }, get taskType() { @@ -988,6 +994,12 @@ TestPilotBuiltinSurvey.prototype = { return this._studyId; }, + onPageLoad: function(task, document) { + if (this._onPageLoad) { + this._onPageLoad(task, document); + } + }, + onDetailPageOpened: function TPS_onDetailPageOpened() { if (this._status < TaskConstants.STATUS_IN_PROGRESS) { this.changeStatus( TaskConstants.STATUS_IN_PROGRESS, true ); @@ -1204,4 +1216,4 @@ TestPilotLegacyStudy.prototype = { // TODO test that they don't say "thanks for contributing" if the // user didn't actually complete them... }; -TestPilotLegacyStudy.prototype.__proto__ = TestPilotTask; \ No newline at end of file +TestPilotLegacyStudy.prototype.__proto__ = TestPilotTask; diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 612107707bc..d503274b88e 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -264,7 +264,7 @@ pref("browser.urlbar.doubleClickSelectsAll", true); #else pref("browser.urlbar.doubleClickSelectsAll", false); #endif -pref("browser.urlbar.autoFill", false); +pref("browser.urlbar.autoFill", true); // 0: Match anywhere (e.g., middle of words) // 1: Match on word boundaries and then try matching anywhere // 2: Match only on word boundaries (e.g., after / or .) @@ -901,6 +901,17 @@ pref("dom.ipc.plugins.enabled.x86_64", true); pref("dom.ipc.plugins.enabled", true); #endif +// This pref governs whether we attempt to work around problems caused by +// plugins using OS calls to manipulate the cursor while running out-of- +// process. These workarounds all involve intercepting (hooking) certain +// OS calls in the plugin process, then arranging to make certain OS calls +// in the browser process. Eventually plugins will be required to use the +// NPAPI to manipulate the cursor, and these workarounds will be removed. +// See bug 621117. +#ifdef XP_MACOSX +pref("dom.ipc.plugins.nativeCursorSupport", true); +#endif + #ifdef XP_WIN pref("browser.taskbar.previews.enable", false); pref("browser.taskbar.previews.max", 20); diff --git a/browser/base/content/browser-appmenu.inc b/browser/base/content/browser-appmenu.inc index 21507665913..72f320b228b 100644 --- a/browser/base/content/browser-appmenu.inc +++ b/browser/base/content/browser-appmenu.inc @@ -201,6 +201,10 @@ label="&errorConsoleCmd.label;" key="key_errorConsole" oncommand="toJavaScriptConsole();"/> + + #define ID_PREFIX appmenu_developer_ #define OMIT_ACCESSKEYS diff --git a/browser/base/content/browser-menubar.inc b/browser/base/content/browser-menubar.inc index 3ce44822be6..d66bccf733c 100644 --- a/browser/base/content/browser-menubar.inc +++ b/browser/base/content/browser-menubar.inc @@ -567,6 +567,11 @@ accesskey="&errorConsoleCmd.accesskey;" key="key_errorConsole" oncommand="toJavaScriptConsole();"/> + + = buttonRect.left && + aEvent.clientX <= buttonRect.right && + aEvent.clientY >= buttonRect.bottom) + openMenu(aEvent.currentTarget); + else + cancelHold(aEvent.currentTarget); + } + + function mouseupHandler(aEvent) { + cancelHold(aEvent.currentTarget); + } + + function cancelHold(aButton) { + clearTimeout(timer); + aButton.removeEventListener("mouseout", mouseoutHandler, false); + aButton.removeEventListener("mouseup", mouseupHandler, false); } function clickHandler(aEvent) { @@ -292,17 +314,8 @@ function SetClickAndHoldHandlers() { } } - function stopTimer(aEvent) { - if (timer) { - clearTimeout(timer); - timer = null; - } - } - function _addClickAndHoldListenersOnElement(aElm) { aElm.addEventListener("mousedown", mousedownHandler, true); - aElm.addEventListener("mouseup", stopTimer, false); - aElm.addEventListener("mouseout", stopTimer, false); aElm.addEventListener("click", clickHandler, true); } diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index a7189d0c9bc..33ec72720d8 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -177,6 +177,7 @@
diff --git a/layout/style/test/test_parse_rule.html b/layout/style/test/test_parse_rule.html index 338d6541924..4b95f258b9e 100644 --- a/layout/style/test/test_parse_rule.html +++ b/layout/style/test/test_parse_rule.html @@ -104,13 +104,13 @@ base + "#6ident, #a {color: red }", ".\\--ident, .a { color: green; }", // CSS2.1 section 4.1.5 and 4.2 -"@import 'data:text/css,#a{color:green}';", -"@import \"data:text/css,#a{color:green}\";", -"@import url(data:text/css,#a{color:green});", -"@import 'data:text/css,#a{color:green}' screen;", -base + "@import 'data:text/css,#a{color:red}' blahblahblah;", -"@import 'data:text/css,#a{color:green}'", -"@import 'data:text/css,#a{color:green}", +"@import 'data:text/css,%23a{color:green}';", +"@import \"data:text/css,%23a{color:green}\";", +"@import url(data:text/css,%23a{color:green});", +"@import 'data:text/css,%23a{color:green}' screen;", +base + "@import 'data:text/css,%23a{color:red}' blahblahblah;", +"@import 'data:text/css,%23a{color:green}'", +"@import 'data:text/css,%23a{color:green}", "@foo {}" + base, "@foo bar {}" + base, "@foo; " + base, diff --git a/layout/style/test/test_transitions_per_property.html b/layout/style/test/test_transitions_per_property.html index 8498a70f7dc..b7a05e0466e 100644 --- a/layout/style/test/test_transitions_per_property.html +++ b/layout/style/test/test_transitions_per_property.html @@ -1170,6 +1170,26 @@ function test_background_position_transition(prop) { } function test_background_position_size_common(prop) { + div.style.setProperty("-moz-transition-property", "none", ""); + div.style.setProperty(prop, "40% 0%", ""); + is(cs.getPropertyValue(prop), "40% 0%", + "property " + prop + ": computed value before transition"); + div.style.setProperty("-moz-transition-property", prop, ""); + div.style.setProperty(prop, "0% 0%", ""); + is(cs.getPropertyValue(prop), "30% 0%", + "property " + prop + ": interpolation of percentages"); + check_distance(prop, "40% 0%", "30% 0%", "0% 0%"); + + div.style.setProperty("-moz-transition-property", "none", ""); + div.style.setProperty(prop, "0% 40%", ""); + is(cs.getPropertyValue(prop), "0% 40%", + "property " + prop + ": computed value before transition"); + div.style.setProperty("-moz-transition-property", prop, ""); + div.style.setProperty(prop, "0% 0%", ""); + is(cs.getPropertyValue(prop), "0% 30%", + "property " + prop + ": interpolation of percentages"); + check_distance(prop, "0% 40%", "0% 30%", "0% 0%"); + div.style.setProperty("-moz-transition-property", "none", ""); div.style.setProperty(prop, "10px 40px", ""); is(cs.getPropertyValue(prop), "10px 40px", diff --git a/layout/tools/reftest/reftest.xul b/layout/tools/reftest/reftest.xul index dec48704b78..58201761811 100644 --- a/layout/tools/reftest/reftest.xul +++ b/layout/tools/reftest/reftest.xul @@ -36,7 +36,7 @@ - ***** END LICENSE BLOCK ***** --> domEventDoc = - do_QueryInterface(content->GetOwnerDoc()); - if (!domEventDoc) + nsCOMPtr domDoc = do_QueryInterface(content->GetOwnerDoc()); + if (!domDoc) return; nsCOMPtr event; - domEventDoc->CreateEvent(NS_LITERAL_STRING("datacontainerevents"), - getter_AddRefs(event)); + domDoc->CreateEvent(NS_LITERAL_STRING("datacontainerevents"), + getter_AddRefs(event)); nsCOMPtr treeEvent(do_QueryInterface(event)); if (!treeEvent) @@ -4515,14 +4513,13 @@ nsTreeBodyFrame::FireInvalidateEvent(PRInt32 aStartRowIdx, PRInt32 aEndRowIdx, if (!content) return; - nsCOMPtr domEventDoc = - do_QueryInterface(content->GetOwnerDoc()); - if (!domEventDoc) + nsCOMPtr domDoc = do_QueryInterface(content->GetOwnerDoc()); + if (!domDoc) return; nsCOMPtr event; - domEventDoc->CreateEvent(NS_LITERAL_STRING("datacontainerevents"), - getter_AddRefs(event)); + domDoc->CreateEvent(NS_LITERAL_STRING("datacontainerevents"), + getter_AddRefs(event)); nsCOMPtr treeEvent(do_QueryInterface(event)); if (!treeEvent) diff --git a/mobile/app/Makefile.in b/mobile/app/Makefile.in index 1c062dc4a0a..5b65c1e5943 100644 --- a/mobile/app/Makefile.in +++ b/mobile/app/Makefile.in @@ -62,20 +62,11 @@ OS_LDFLAGS += -Wl,-rpath='$$ORIGIN' NSDISTMODE = copy endif -ifdef MOZ_ENABLE_LIBXUL -APP_XPCOM_LIBS = $(XPCOM_GLUE_LDOPTS) -else -MOZILLA_INTERNAL_API = 1 -APP_XPCOM_LIBS = $(XPCOM_LIBS) -endif +LIBS += \ + $(XPCOM_GLUE_LDOPTS) \ + $(NSPR_LIBS) \ + $(NULL) -LIBS += $(APP_XPCOM_LIBS) \ - $(NSPR_LIBS) \ - $(NULL) - -ifdef BUILD_STATIC_LIBS -LIBS += $(DEPTH)/toolkit/xre/$(LIB_PREFIX)xulapp_s.$(LIB_SUFFIX) -else ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa) LIBS += $(DIST)/bin/XUL else @@ -85,7 +76,6 @@ endif ifeq ($(OS_ARCH),WINNT) OS_LIBS += $(call EXPAND_LIBNAME,version) endif -endif # BUILD_STATIC_LIBS ifdef _MSC_VER # Always enter a Windows program through wmain, whether or not we're diff --git a/mobile/build.mk b/mobile/build.mk index 36712498ccd..30aee7a52be 100644 --- a/mobile/build.mk +++ b/mobile/build.mk @@ -68,7 +68,6 @@ installer: @$(MAKE) -C mobile/installer installer package: - rm -rf dist/fennec* @$(MAKE) -C mobile/installer install:: diff --git a/mobile/confvars.sh b/mobile/confvars.sh index 6ef92163bc2..a8766a29c2f 100644 --- a/mobile/confvars.sh +++ b/mobile/confvars.sh @@ -38,7 +38,7 @@ MOZ_APP_NAME=fennec MOZ_APP_UA_NAME=Fennec -MOZ_APP_VERSION=6.0a1 +MOZ_APP_VERSION=7.0a1 MOZ_BRANDING_DIRECTORY=mobile/branding/unofficial MOZ_OFFICIAL_BRANDING_DIRECTORY=mobile/branding/official @@ -47,7 +47,6 @@ MOZ_OFFICIAL_BRANDING_DIRECTORY=mobile/branding/official MOZ_SAFE_BROWSING= MOZ_SERVICES_SYNC=1 -MOZ_ENABLE_LIBXUL=1 MOZ_DISABLE_DOMCRYPTO=1 if test "$LIBXUL_SDK"; then diff --git a/mobile/installer/Makefile.in b/mobile/installer/Makefile.in index f3a2c12c2d1..cbb8771a141 100644 --- a/mobile/installer/Makefile.in +++ b/mobile/installer/Makefile.in @@ -52,16 +52,7 @@ include $(topsrcdir)/config/rules.mk MOZ_PKG_REMOVALS = $(srcdir)/removed-files.in -ifdef MOZ_ENABLE_LIBXUL MOZ_PKG_MANIFEST_P = $(srcdir)/package-manifest.in -else -define message -You need to build with --enable-libxul (the default, unless you specify ---disable-libxul or --enable-shared or --enable-debug) to package a build. -endef -default libs installer:: - $(error $(message)) -endif MOZ_NONLOCALIZED_PKG_LIST = \ xpcom \ diff --git a/mobile/themes/core/forms.css b/mobile/themes/core/forms.css index 157ac8fa298..cff12d50ebb 100644 --- a/mobile/themes/core/forms.css +++ b/mobile/themes/core/forms.css @@ -53,6 +53,8 @@ #content-navigator > .previous-button, #content-navigator > .next-button { + min-width: @touch_button_small@ !important; /* button size */ + min-height: @touch_button_small@ !important; /* button size */ border: @border_width_tiny@ solid rgba(0,0,0,0.2) !important; border-bottom: @border_width_large@ solid #53565a !important; background-color: #5e6166; @@ -117,10 +119,8 @@ margin: @margin_normal@; -moz-margin-end: 0; padding: @padding_xnormal@; - border-radius: @border_radius_normal@; border-top-right-radius: 0; border-bottom-right-radius: 0; - border: @border_width_tiny@ solid rgba(0,0,0,0.2) !important; width: 10em; } diff --git a/mobile/themes/core/gingerbread/browser.css b/mobile/themes/core/gingerbread/browser.css new file mode 100644 index 00000000000..e5f3d4d2157 --- /dev/null +++ b/mobile/themes/core/gingerbread/browser.css @@ -0,0 +1,1417 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Mobile Browser. + * + * The Initial Developer of the Original Code is + * Mozilla Corporation. + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Mark Finkle + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +%filter substitution +%include defines.inc + +/* main toolbar (URL bar) -------------------------------------------------- */ +#toolbar-main { + -moz-appearance: none; + -moz-box-align: center; + padding: 0; + border: none; + background: @color_background_default@; +} + +#toolbar-moveable-container[mode="discovery"], +#toolbar-moveable-container[top="0"] { + position: fixed; + left: 0; + z-index: 1000; +} + +/* main toolbar buttons */ +toolbarbutton.urlbar-button { + /* space out the buttons a bit horizontally */ + -moz-margin-start: @margin_normal@; /* core spacing */ +} + +%ifndef ANDROID +/* MAEMO (and desktop) only */ +#tool-app-switch { + margin-top: -@margin_normal@; /* force the button to go to the edge */ + -moz-margin-start: 0; /* force the button to go to the edge */ + min-width: @touch_button_xlarge@ !important; /* 72, not 64 to make up for the negative margin */ + min-height: @touch_button_xlarge@ !important; /* 72, not 64 to make up for the negative margin */ + visibility: collapse; + -moz-margin-end: @margin_normal@; /* core spacing */ + list-style-image: url("chrome://browser/skin/images/task-switch-hdpi.png"); + background-color: transparent !important; + border: none !important; +} + +#tool-app-switch:hover:active { + background-color: #8db8d8 !important; + -moz-border-radius-bottomright: @border_radius_small@; +} + +#toolbar-main[fullscreen="true"] #tool-app-switch:not(:-moz-system-metric(maemo-classic)) { + visibility: visible; +} + +/* MAEMO (and desktop) only */ +#tool-app-close { + margin-top: -@margin_normal@; /* force the button to go to the edge */ + -moz-margin-end: 0 !important; /* force the button to go to the edge */ + min-width: @touch_button_xlarge@ !important; /* 72, not 64 to make up for the negative margin */ + min-height: @touch_button_xlarge@ !important; /* 72, not 64 to make up for the negative margin */ + visibility: collapse; + list-style-image: url("chrome://browser/skin/images/task-close-hdpi.png"); + background-color: transparent !important; + border: none !important; +} + +#tool-app-close:hover:active { + background-color: #8db8d8 !important; +} + +#tool-app-close:hover:active:-moz-locale-dir(ltr) { + -moz-border-radius-bottomleft: @border_radius_small@; +} + +#tool-app-close:hover:active:-moz-locale-dir(rtl) { + -moz-border-radius-bottomright: @border_radius_small@; +} + +%if MOZ_PLATFORM_MAEMO != 6 +#toolbar-main[fullscreen="true"] #tool-app-close { + visibility: visible; +} +%endif + +#toolbar-main[dialog="true"] #tool-app-close { + visibility: visible; + list-style-image: url("chrome://browser/skin/images/task-back-hdpi.png"); +} + +#toolbar-main[dialog="true"] #tool-app-close:-moz-locale-dir(rtl) { + list-style-image: url("chrome://browser/skin/images/task-back-rtl-hdpi.png"); +} +%endif + +/* URL bar ----------------------------------------------------------------- */ +#urlbar-container { + color: @color_text_inverse@; + margin: @margin_normal@; + background: @color_background_inverse@ url("chrome://browser/skin/images/urlbar-bg.png") bottom left repeat-x; +} + +#urlbar-container[mode="edit"] > #identity-box { + visibility: collapse; +} + +/* URL bar cap buttons */ +.urlbar-cap-button { + margin: 0 !important; + padding: 0 !important; + border: 0 solid transparent; + min-width: @touch_button_large@ !important; + max-width: @touch_button_large@ !important; + -moz-box-flex: 1; + -moz-box-align: center; + -moz-box-pack: center; + background: @color_background_inverse@ url("chrome://browser/skin/images/endcap-default-bg.png") bottom center; +} + +.urlbar-cap-button[open="true"], +.urlbar-cap-button:not([disabled="true"]):hover:active { + background: #a5aab2 url("chrome://browser/skin/images/endcap-active-bg.png") bottom center; +} + +/* left cap button --------------------------------------------------------- */ +#identity-box { + border-right: @border_width_tiny@ solid rgba(118,121,126,0.5) !important; +} + +#identity-box[open="true"], +#identity-box:hover:active { + border-right: @border_width_tiny@ solid rgba(0, 0, 0, 0.2); +} + +/* add special color */ +#identity-box[mode="verifiedIdentity"] { + background-color: #89d715; + background-image: url("chrome://browser/skin/images/endcap-ev-default-bg.png"); +} + +#identity-box[mode="verifiedIdentity"][open="true"], +#identity-box[mode="verifiedIdentity"]:hover:active { + background-image: url("chrome://browser/skin/images/endcap-ev-active-bg.png"); +} + +#identity-box[mode="verifiedDomain"] { + background-color: #6579e3; + background-image: url("chrome://browser/skin/images/endcap-ssl-default-bg.png"); +} + +#identity-box[mode="verifiedDomain"][open="true"], +#identity-box[mode="verifiedDomain"]:hover:active { + background-image: url("chrome://browser/skin/images/endcap-ssl-active-bg.png"); +} + +#urlbar-throbber[loading] { + list-style-image: url("chrome://browser/skin/images/throbber.png"); +} + +#urlbar-favicon { + width: 32px; + height: 32px; +} + +#urlbar-favicon[src=""] { + list-style-image: url("chrome://browser/skin/images/favicon-default-32.png"); +} + +/* Main urlbar textbox */ +#urlbar-title { + padding: @padding_xxxnormal@ @padding_normal@; +} + +#urlbar-title.placeholder { + color: gray; +} + +#urlbar-edit, +#urlbar-title { + margin: 0 !important; + border-left: @border_width_tiny@ solid white; + border-right: @border_width_tiny@ solid white; + min-height: @touch_normal@; +} + +#urlbar-edit, +#urlbar-title:hover:active { + background: #f9f9f9 url("chrome://browser/skin/images/textbox-bg.png") top left repeat-x; +} + +#urlbar-edit { + -moz-appearance: none !important; + border: 0 solid transparent; + border-right: @border_width_tiny@ solid rgba(0,0,0,0.5); + padding: 0 !important; +} + +#urlbar-edit > hbox > .textbox-input-box { + margin: 0; +} + +:invalid { + box-shadow: none; +} + +#urlbar-edit > hbox > hbox > .textbox-input { + min-height: @urlbar_edit_height@; + text-indent: @urlbar_edit_indent@; +} + +/* Right cap button --------------------------------------------------------- */ +#urlbar-icons { + border-left: @border_width_tiny@ solid rgba(118,121,126,0.5) !important; +} + +#urlbar-icons[disabled="true"] { + pointer-events: none; +} + +#urlbar-icons[disabled="true"] > toolbarbutton { + opacity: 0.5; +} + +#urlbar-icons:not([disabled="true"]):hover:active { + border-left: @border_width_tiny@ solid rgba(0, 0, 0, 0.2); +} + +#tool-reload { + list-style-image: url("chrome://browser/skin/images/reload-hdpi.png"); +} + +#tool-stop { + list-style-image: url("chrome://browser/skin/images/stop-hdpi.png"); +} + +#tool-search { + list-style-image: url("chrome://browser/skin/images/navigation-magnifier-30.png"); +} + +#urlbar-icons[mode="loading"] > #tool-search, +#urlbar-icons[mode="loading"] > #tool-reload { + visibility: collapse; +} + +#urlbar-icons[mode="view"] > #tool-search, +#urlbar-icons[mode="view"] > #tool-stop { + visibility: collapse; +} + +#urlbar-icons[mode="edit"] > #tool-reload, +#urlbar-icons[mode="edit"] > #tool-stop { + visibility: collapse; +} + +/* right toolbar (browser controls) ---------------------------------------- */ +#browser-controls { + -moz-box-align: start; + padding: 0; + -moz-border-start: @border_width_large@ solid #262629; + min-width: @sidebar_width_minimum@ !important; + background: @color_background_default@; +} + +toolbarbutton.button-control { + padding: 0 !important; + min-width: @sidebar_width_minimum@ !important; + border-top: @border_width_tiny@ solid @color_divider_border@ !important; + border-bottom: @border_width_tiny@ solid @color_divider_border@ !important; + background-color: transparent !important; + -moz-box-align: center; + -moz-box-pack: center; + height: @sidebar_button_height@; +} + +toolbarbutton.button-control:last-child { + border-bottom: 0 solid @color_divider_border@ !important; +} + +toolbarbutton.button-control[disabled="true"] { + opacity: 0.5; +} + +toolbarbutton.button-control:not([disabled="true"]):hover:active { + background-color: @color_background_active@ !important; + border-top: none; +} + +#tool-star { + list-style-image: url("chrome://browser/skin/images/bookmark-default-hdpi.png"); +} + +#tool-star[starred="true"] { + list-style-image: url("chrome://browser/skin/images/bookmark-starred-hdpi.png"); +} + +#tool-back, +#tool-forward:-moz-locale-dir(rtl) { + list-style-image: url("chrome://browser/skin/images/back-default-hdpi.png"); +} + +#tool-back:-moz-locale-dir(rtl), +#tool-forward { + list-style-image: url("chrome://browser/skin/images/forward-default-hdpi.png"); +} + +#tool-panel-open { + list-style-image: url("chrome://browser/skin/images/settings-default-hdpi.png"); +} + +%ifndef ANDROID +/* MAEMO (and desktop) only */ +.panel-close { + min-width: @touch_button_xlarge@ !important; /* 72, not 64 to make up for the negative margin */ + max-width: @touch_button_xlarge@ !important; /* 72, not 64 to make up for the negative margin */ + min-height: @touch_button_xlarge@ !important; /* 72, not 64 to make up for the negative margin */ + list-style-image: url("chrome://browser/skin/images/task-back-hdpi.png"); + background: transparent !important; + border: none !important; +} + +.panel-close:hover:active { + background-color: #8db8d8 !important; +} + +.panel-close:hover:active:-moz-locale-dir(ltr) { + -moz-border-radius-bottomleft: @border_radius_small@; +} + +.panel-close:-moz-locale-dir(rtl) { + list-style-image: url("chrome://browser/skin/images/task-back-rtl-hdpi.png"); +} + +.panel-close:hover:active:-moz-locale-dir(rtl) { + -moz-border-radius-bottomright: @border_radius_small@; +} +%endif + +/* awesomescreen buttons --------------------------------------------------- */ +toolbarbutton.choice-all { + list-style-image: url(chrome://browser/skin/images/allpages-48.png); +} + +toolbarbutton.choice-bookmarks { + list-style-image: url(chrome://browser/skin/images/bookmarks-48.png); +} + +toolbarbutton.choice-history { + list-style-image: url(chrome://browser/skin/images/history-48.png); +} + +toolbarbutton.choice-remotetabs { + list-style-image: url(chrome://browser/skin/images/remotetabs-48.png); +} + +/* browsers ---------------------------------------------------------------- */ +.input-overlay:-moz-focusring { + outline: 0 !important; +} + +/* + * These rules prevent browser to steal the focus while touching the screen + * to allow panning/zooming of the browser view without closing the VKB + */ +#browsers > notificationbox { + -moz-user-focus: ignore; +} + +/* browser tools panel UI ------------------------------------------------ */ +.panel-header { + margin: 0; + padding: @padding_small@ @padding_normal@ @padding_normal@ @padding_normal@; + font-weight: bold; + color: white !important; + background-color: rgb(101, 121, 227) !important; +} + +#tool-addons { + list-style-image: url("chrome://browser/skin/images/addons-default-hdpi.png"); +} + +#tool-downloads { + list-style-image: url("chrome://browser/skin/images/downloads-default-hdpi.png"); +} + +#tool-preferences { + list-style-image: url("chrome://browser/skin/images/preferences-default-hdpi.png"); +} + +#tool-console { + list-style-image: url("chrome://browser/skin/images/console-default-hdpi.png"); +} + +/* preferences panel UI -----------------------------------------------------*/ +#menulist-container[for="prefs-homepage-options"] .options-command.selected { + pointer-events: none; +} + +/* bug 597296 - The language.properties file is LTR and never translated */ +#prefs-languages .menulist-label { + direction: ltr !important; +} + +/* addons panel UI ------------------------------------------------------- */ +#addons-repo { + -moz-box-orient: horizontal; + -moz-box-align: center; +} + +@media (@orientation@: portrait) { + #addons-repo { + -moz-box-orient: vertical; + -moz-box-pack: center; + } +} + +.addon-image, +.searchplugin-image { + list-style-image: url("chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png"); + width: 32px; + height: 32px; + -moz-margin-start: @margin_normal@; + -moz-margin-end: @margin_normal@; +} + +.addon-rating[rating] { + width: 78px; + height: 18px; + list-style-image: url("chrome://browser/skin/images/ratings-18.png"); +} + +.addon-rating[rating="0"] { + -moz-image-region: rect(0px 78px 18px 0px); +} + +.addon-rating[rating="1"] { + -moz-image-region: rect(18px 78px 36px 0px); +} + +.addon-rating[rating="2"] { + -moz-image-region: rect(36px 78px 54px 0px); +} + +.addon-rating[rating="3"] { + -moz-image-region: rect(54px 78px 72px 0px); +} + +.addon-rating[rating="4"] { + -moz-image-region: rect(72px 78px 90px 0px); +} + +.addon-rating[rating="5"] { + -moz-image-region: rect(90px 78px 108px 0px); +} + +.addon-showmore-image, +.addon-banner-image { + width: 32px; + height: 32px; + list-style-image: url("chrome://browser/skin/images/addons-32.png"); + -moz-margin-start: @margin_normal@; + -moz-margin-end: @margin_normal@; +} + +richlistitem[isDisabled="true"] .title { + color: gray; +} + +richlistitem[isDisabled="true"] .normal { + color: lightgray; +} + +richlistitem[isDisabled="true"] image { + opacity: 0.25; +} + +richlistitem[typeName="banner"], +richlistitem[typeName="showmore"] { + background-color: rgb(255,255,255); + background: url(chrome://browser/skin/images/browseaddons-bg.jpg) repeat-x center top; +} + +/* downloads panel UI ---------------------------------------------------- */ +.download-retry-failed { + color: red !important; + display: none; +} + +.download-retry-failed[state="2"] { + display: -moz-box; +} + +/* special "no downloads" items */ +#dl-empty-message { + margin-top: -moz-calc(2 * @touch_row@); /* 2 times row height */ + font-style: italic; + border-bottom: none; +} + +#dl-empty-message:active { + background-color: white; +} + +#dl-empty-message > label { + text-align: center; + color: grey; +} + +/* console panel UI ------------------------------------------------------ */ +#console-filter-warnings, +#console-filter-messages { + visibility: visible; +} + +@media (max-width: 499px) { + #console-filter-warnings, + #console-filter-messages { + visibility: collapse; + } +} + +.console-error-msg, +.console-msg-text { + white-space: pre-wrap; +} + +/* folders navigation row */ +.place-list-parents placelabel { + visibility: collapse; +} + +.place-list-parents placelabel:last-child:not(:only-child) { + visibility: visible; +} + +/* be consistent with the size of placeitem */ +placelabel { + -moz-box-align: center; + -moz-padding-end: @placelabel_padding@; + background-image: url(images/arrowup-16.png), url("images/row-header-bg.png"); + background-repeat: no-repeat, repeat-x; + background-position: 98% 50%, top left; + background-size: auto auto, auto 100%; + color: #000; + min-height: @touch_row@; /* row size */ +} + +placelabel:-moz-locale-dir(rtl) { + background-position: 2% 50%, top left; +} + +placelabel:hover:active { + background-image: url(images/arrowup-16.png); + background-color: #8db8d8; +} + +/* folder bookmarks row */ +placeitem[type="folder"] { + -moz-box-pack: center; + -moz-padding-end: @placeitem_padding@; + background-image: url(images/arrowright-16.png); + background-repeat: no-repeat; + background-position: 98% 50%; +} + +placeitem[type="folder"]:-moz-locale-dir(rtl) { + background-image: url(images/arrowleft-16.png); + background-position: 2% 50%; +} + +placelist[ui="manage"] placeitem[type="folder"] { + background-image: none; +} + +placeitem[type="folder"] > .bookmark-item-container > image, +placeitem[type="folder"] > .bookmark-manage > image { + list-style-image: url(images/folder-32.png); + margin-top: 0; +} + +placeitem[type="folder"] .bookmark-item-url { + display: none; +} + +/* bookmark manage controls */ +placeitem > .bookmark-manage .bookmark-controls { + padding-top: @padding_normal@; +} + +/* bookmark popup for star button */ +placeitem[ui="manage"] { + border-bottom: 0; +} + +placeitem[ui="manage"] > .bookmark-manage > image { + visibility: collapse; +} + +/* making the url textbox right-aligned for rtl locales */ +placeitem[ui="manage"] > .bookmark-manage textbox[anonid="uri"]:-moz-locale-dir(rtl) { + text-align: right; +} + +/* autocomplete-items */ +.autocomplete-items { + background-color: white; +} + +autocompleteresult, +placeitem { + -moz-user-focus: ignore; + color: black; + background-color: white; + padding: @padding_xsmall@ @padding_small@; + border-bottom: @border_width_tiny@ solid rgb(207,207,207); + min-height: @touch_row@; /* row size */ +} + +#popup_autocomplete autocompleteresult:hover:active, +placelist placeitem:hover:active:not([selected="true"]), +historylist autocompleteresult:hover:active:not([selected="true"]):not([class="history-item-title"]), +remotetabslist autocompleteresult:hover:active:not([selected="true"]):not([class="remotetabs-item-title"]), +.autocompleteresult-selected { + background-color: #8db8d8; +} + +.autocomplete-item-container, +.bookmark-item-container { + margin: 0; + padding: 0; +} + +.autocomplete-item-label, +.bookmark-item-label { + font-size: @font_normal@ !important; + font-weight: normal; + -moz-margin-end: @margin_normal@; +} + +.autocomplete-item-container > image, +.bookmark-item-container > image, +placeitem > .bookmark-manage > image { + width: 32px; + height: 32px; + max-height: 32px; + /* margin-top = (1 - title's line-height) * title's font-size */ + margin-top: @autocomplete_item_container_image_padding@; + margin-bottom: 0; + -moz-margin-end: @margin_xxxnormal@; + -moz-margin-start: @margin_normal@; +} + +.autocomplete-item-container > image[src=""], +placeitem[src=""] .bookmark-item-container > image { + list-style-image: url("chrome://browser/skin/images/favicon-default-32.png"); +} + +.autocomplete-item-container > vbox > label, +.bookmark-item-container > vbox > label { + -moz-margin-start: @margin_xtiny@; +} + +.autocomplete-item-container[favorite="true"], +.autocomplete-item-container[remote="true"], +.autocomplete-item-container[search="true"] { + background-repeat: no-repeat; + background-position: 100% @autocomplete_item_container_position@; + background-size: @autocomplete_item_container_size@ @autocomplete_item_container_size@; +} + +.autocomplete-item-container[favorite="true"] { + background-image: url("chrome://browser/skin/images/autocomplete-bookmarked-hdpi.png"); +} + +.autocomplete-item-container[remote="true"] { + background-image: url("chrome://browser/skin/images/autocomplete-desktop-hdpi.png"); +} + +.autocomplete-item-container[search="true"] { + background-image: url("chrome://browser/skin/images/autocomplete-search-hdpi.png"); +} + +.autocomplete-item-container[favorite="true"][remote="true"] { + background-image: url("chrome://browser/skin/images/autocomplete-bookmarked-hdpi.png"), + url("chrome://browser/skin/images/autocomplete-desktop-hdpi.png"); + background-position: 100% @autocomplete_item_container_position@, + 94% @autocomplete_item_container_position@; + -moz-padding-end: @autocomplete_item_container_padding@; +} + +.autocomplete-item-container[favorite="true"]:-moz-locale-dir(rtl), +.autocomplete-item-container[remote="true"]:-moz-locale-dir(rtl) { + background-position: left @autocomplete_item_container_position@; +} + +.autocomplete-item-container[favorite="true"][remote="true"]:-moz-locale-dir(rtl) { + background-position: left @autocomplete_item_container_position@, + 6% @autocomplete_item_container_position@; +} + +.autocomplete-item-subtitle, +.bookmark-item-url { + color: blue; + font-size: @font_small@ !important; + -moz-margin-end: @autocomplete_item_subtitle_margin@; +} + +.autocomplete-item-container[favorite="true"] .autocomplete-item-label, +.autocomplete-item-container[remote="true"] .autocomplete-item-label, +.autocomplete-item-container[search="true"] .autocomplete-item-label { + -moz-padding-end: @autocomplete_item_label_margin@; +} + +.autocomplete-item-container[search="true"] .autocomplete-item-subtitle { + color: black; + font-size: smaller; +} + +.autocomplete-item-tags, +.bookmark-item-tags { + content: attr(tags); + font-size: @font_small@ !important; + font-weight: lighter; + margin: @margin_tiny@ 0 @margin_small@ 0; + -moz-margin-start: @margin_normal@; + -moz-padding-end: @autocomplete_item_tags_margin@; +} + +.autocomplete-item-tags[value=""] { + visibility: hidden; +} + +.autocomplete-item-badge { + opacity: 1; + -moz-transition: opacity 1s ease; + background-color: #c90707; + border: @border_width_tiny@ solid #951919; + -moz-border-radius: @border_radius_tiny@; + content: attr(badge); + font-size: @font_xtiny@ !important; + font-weight: bolder; + margin: @margin_small@ 0 0 0; + padding: @padding_small@ @padding_snormal@; + color: white; +} + +autocompleteresult:not([badge]) .autocomplete-item-badge, +.autocomplete-item-badge[value=""] { + opacity: 0; + -moz-transition: none; +} + +/* special "no results", "awesome header row" and "title rows" items */ +autocompleteresult[class="history-item-title"], +autocompleteresult[class="remotetabs-item-title"], +.settings-title { + min-height: 0; + color: @color_text_default@; + font-size: smaller; + font-weight: bold; + background-color: transparent; + margin: 0; + padding: @autocompleteresult_padding@ @padding_xnormal@; + background-image: url(images/row-header-bg.png); + background-repeat: repeat-x; + background-size: auto 100%; +} + +autocompleteresult[class="history-item-title"] .autocomplete-item-label, +autocompleteresult[class="remotetabs-item-title"] .autocomplete-item-label { + font-size: @font_small@ !important; + font-weight: bold !important; +} + +autocompleteresult[class="history-item-title"] .autocomplete-item-subtitle, +autocompleteresult[class="history-item-title"] .autocomplete-item-tags, +autocompleteresult[class="history-item-title"] .autocomplete-item-badge, +autocompleteresult[class="remotetabs-item-title"] .autocomplete-item-subtitle, +autocompleteresult[class="remotetabs-item-title"] .autocomplete-item-tags, +autocompleteresult[class="remotetabs-item-title"] .autocomplete-item-badge { + margin: 0; + padding: 0; +} + +autocompleteresult[class="history-item-title"] .bookmark-item-subtitle, +autocompleteresult[class="history-item-title"] .autocomplete-item-tags, +autocompleteresult[class="history-item-title"] .autocomplete-item-badge, +autocompleteresult[class="remotetabs-item-title"] .bookmark-item-subtitle, +autocompleteresult[class="remotetabs-item-title"] .autocomplete-item-tags, +autocompleteresult[class="remotetabs-item-title"] .autocomplete-item-badge { + display: none; +} + +autocompleteresult[class="history-item-title"] .bookmark-item-container, +autocompleteresult[class="remotetabs-item-title"] .bookmark-item-container { + font-size: @font_normal@ !important; +} + +autocompleteresult[class="history-item-title"] image, +autocompleteresult[class="remotetabs-item-title"] image { + display: none; +} + +autocompleteresult.noresults { + font-style: italic; + border-bottom: none; +} + +autocompleteresult.noresults:hover:active { + background-color: white !important; +} + +autocompleteresult.noresults > .autocomplete-item-container { + text-align: center; + color: grey; +} + +/* Left sidebar (tabs) ---------------------------------------------------- */ +#tabs-container { + -moz-border-end: @border_width_large@ solid #262629; + background: @color_background_default@; +} + +#tabs:-moz-locale-dir(rtl) { + -moz-box-align: start; +} + +#tabs > scrollbox { + max-width: 350px; +} + +#tabs .tabs-list { + display: block; + -moz-column-width: 121px; + -moz-column-gap: 0; + -moz-user-focus: ignore; + padding: 0; + background-color: transparent; + margin: 0; + -moz-padding-end: @padding_normal@; /* core spacing */ + -moz-padding-start: @padding_small@; /* allow the thumbnails to get close to the edge */ +} + +#tabs-controls { + margin-top: @margin_normal@; /* core spacing */ + -moz-box-pack: center; +} + +documenttab { + -moz-margin-start: @margin_xnormal@; + margin-bottom: @documenttab_margin_bottom@; + width: 121px; + padding: @padding_normal@; + padding-bottom: @padding_xnormal@; + background: url("chrome://browser/skin/images/tab-inactive-hdpi.png") bottom repeat-x; + background-clip: padding-box; + border: @border_width_tiny@ solid rgba(0,0,0,0.1); + border-bottom-width: @border_width_small@; + line-height: 0; +} + +documenttab[selected="true"] { + border-bottom-color: rgba(0,0,0,0.2); + background: url("chrome://browser/skin/images/tab-active-hdpi.png") bottom repeat-x; +} + +.documenttab-thumbnail { + background-color: white; + opacity: 0.5; + + /* if there is no border, blank thumbnail are invisible */ + border: 1px solid white; + margin: -1px; +} + +documenttab:hover:active > stack > .documenttab-thumbnail, +documenttab[selected="true"] > stack > .documenttab-thumbnail { + opacity: 1.0; +} + +.documenttab-close-container { + position: relative; + left: -16px; + -moz-margin-end: 49px; +} + +.documenttab-close { + width: 40px; + height: 40px; + list-style-image: url("chrome://browser/skin/images/close-inactive-tab-hdpi.png"); +} + +documenttab[selected="true"] > stack > hbox > .documenttab-close { + list-style-image: url("chrome://browser/skin/images/close-default-hdpi.png"); +} + +.documenttab-close-container:hover:active > .documenttab-close { + list-style-image: url("chrome://browser/skin/images/close-active-hdpi.png"); +} + +documenttab:only-child > stack > hbox > .documenttab-close { + display: none; +} + +documenttab[reload="true"] { + background: url("chrome://browser/skin/images/tab-closed-hdpi.png") bottom repeat-x; +} + +.documenttab-reload { + background: url("chrome://browser/skin/images/tab-reopen-hdpi.png"); + display: none; +} + +documenttab[reload="true"] > stack > .documenttab-close-container { + display: none; +} + +documenttab[reload="true"] > stack > .documenttab-reload { + display: -moz-box; +} + +#newtab-button { + -moz-box-flex: 1; + list-style-image: url("images/newtab-default-hdpi.png"); + height: @sidebar_button_height@; +} + +/* bookmark editor ------------------------------------------------------- */ +#bookmark-form .bookmark-controls { + display: none; +} + +/* Identity popup -------------------------------------------------------- */ +#identity-popup-container { + background-color: @color_background_panel@; + padding: @padding_normal@; /* core spacing */ + padding-bottom: @padding_xxxnormal@; +} + +/* Popup Icons */ +#identity-popup-icon { + padding: 0; + list-style-image: url("chrome://browser/skin/images/identity-default-hdpi.png"); +} + +#identity-container[mode="verifiedIdentity"] > hbox > #identity-popup-icon { + list-style-image: url("chrome://browser/skin/images/identity-ev-hdpi.png"); +} + +#identity-container[mode="verifiedDomain"] > hbox > #identity-popup-icon { + list-style-image: url("chrome://browser/skin/images/identity-ssl-hdpi.png"); +} + +/* Popup Body Text */ +#identity-popup-content-box { + -moz-padding-start: @padding_normal@; /* core spacing */ + font-size: @font_small@ !important; + white-space: pre-wrap; +} + +/* let the text flow into a second row, if needed */ +#identity-popup-runBy-box { + display: block; +} + +#identity-popup-content-box.unknownIdentity > hbox > #identity-popup-connectedToLabel, +#identity-popup-content-box.unknownIdentity > hbox > #identity-popup-runByLabel, +#identity-popup-content-box.unknownIdentity > hbox > #identity-popup-content-host, +#identity-popup-content-box.unknownIdentity > hbox > #identity-popup-content-owner, +#identity-popup-content-box.verifiedIdentity > hbox > #identity-popup-connectedToLabel2, +#identity-popup-content-box.verifiedDomain > hbox > #identity-popup-connectedToLabel2 { + display: none; +} + +#identity-popup-encryption-label, +#identity-popup-content-verifier { + font-size: @font_tiny@ !important; +} + +#identity-popup-content-host, +#identity-popup-content-owner { + font-weight: bold; +} + +#identity-popup-encryption-icon { + list-style-image: url("chrome://browser/skin/images/unlocked-hdpi.png"); +} + +#identity-container[mode="verifiedIdentity"] > hbox > vbox > #identity-popup-encryption-icon , +#identity-container[mode="verifiedDomain"] > hbox > vbox > #identity-popup-encryption-icon { + list-style-image: url("chrome://browser/skin/images/locked-hdpi.png"); +} + +/* Page Actions, Prompt, and Context Menu popups --------------------------- */ +.action-buttons, +#context-commands, +#pageactions-container { + background: transparent; + border-top: @border_width_tiny@ solid rgb(205,205,205); + padding: 0; + -moz-user-focus: ignore; + display: inline-block; +} + +.action-button, +.context-command, +pageaction { + -moz-border-top-colors: white; + -moz-border-right-colors: rgb(175,175,175); + -moz-border-bottom-colors: rgb(175,175,175); + -moz-border-left-colors: white; + border-style: solid; + border-width: @border_width_tiny@ !important; + height: @touch_button_large@; + min-height: @touch_button_large@; + width: 100%; + min-width: @touch_action_minwidth@; /* keep the button from being too narrow */ +} + +/* Override richlistbox and richlistitem styles */ +#context-commands > scrollbox { + width: 100%; +} + +.action-button, +.context-command { + -moz-box-align: center; +} + +.action-button[disabled="true"], +.context-command[disabled="true"] { + pointer-events: none; + color: #aaa !important; +} + +.action-button[selected="true"], +.context-command[selected="true"] { + background: transparent; +} + +/* Override button styles */ +.action-button { + margin: 0; + -moz-border-image: none !important; + margin: 0; + background: transparent; +} + +.action-button > .button-box { + padding: 0 @padding_small@ @padding_tiny@ @padding_xsmall@ !important; +} + +.action-button > .button-box > .button-icon { + -moz-margin-end: @margin_normal@; +} + +@media (min-width: 500px) { + .action-button, + pageaction { + width: 50%; + } + + .action-button:last-child:nth-child(odd), + pageaction.odd-last-child { + width: 100%; + } +} + +.action-button:not([disabled]):hover:active, +.context-command:not([disabled]):hover:active, +pageaction:not([disabled]):hover:active { + background: url("chrome://browser/skin/images/popup-selected-item-hdpi.png") repeat-x !important; + background-origin: border-box !important; + background-clip: border-box !important; + -moz-border-top-colors: transparent; + -moz-border-left-colors: transparent; +} + +pageaction > hbox > .pageaction-image { + width: 32px; + height: 32px; + -moz-margin-end: @margin_normal@; +} + +pageaction:not([image]) > hbox >.pageaction-image { + width: 0; +} + +.action-button, +.context-command, +.pageaction-title { + font-size: @font_normal@ !important; + color: #414141 !important; +} + +.pageaction-desc { + font-size: @font_tiny@ !important; + color: #414141; +} + +.pageaction-desc[value=""] { + display: none; +} + +#share-title, +#context-hint { + font-size: @font_small@; + padding: @padding_small@; +} + +#context-hint[value=""] { + visibility: collapse; +} + +#search-engines-list > .action-button > .button-box > .button-text { + text-align: start; + -moz-box-flex: 1; /* Needed for the crop attribute to have an effect */ +} + +#search-engines-list > .action-button > .button-box > .button-icon { + width: 32px; + height: 32px; +} + +#search-engines-list > .action-button[image=""] > .button-box > .button-icon { + list-style-image: url("chrome://browser/skin/images/favicon-default-32.png"); +} + +/* Preferences window ---------------------------------------------------- */ +.setting { + padding-left: @padding_xnormal@; + border-bottom: @border_width_tiny@ solid #cacdd5; +} + +/* XXX should be a richlistitem */ +.prefbox { + padding: @padding_xsmall@; + border-bottom: @border_width_tiny@ solid rgb(207,207,207); + min-height: @touch_row@; /* row size */ + -moz-box-align: center; +} + +.setting-group > .prefbox { + border-bottom: none; +} + +.setting-subgroup > .prefbox { + border-bottom: none; + -moz-margin-start: @margin_xxxnormal@; +} + +.setting-subgroup + :not(.setting-subgroup) > .prefbox { + border-top: @border_width_tiny@ solid rgb(207,207,207); +} + +/* Put setting textboxes on a separate row in portrait */ +@media (@orientation@: portrait) { + .setting-integer, + .setting-string { + -moz-box-align: start; + -moz-box-orient: vertical; + } + + .setting-integer > .setting-input > textbox, + .setting-string > .setting-input > textbox { + width: 499px; /* textboxes seem to need a width in order to flex */ + -moz-box-flex: 1; + } +} + +.options-box { + -moz-margin-start: 28px; /* sized based on the 32px addon image */ +} + +.options-box > setting:last-child > .prefbox { + border-bottom: 0; +} + +/* XXX should be a richlistitem description.title */ +.preftitle { + font-size: @font_normal@ !important; +} + +/* XXX should be a richlistitem description.normal */ +.prefdesc { + font-size: @font_small@ !important; + color: grey; +} + +/* alerts popup ----------------------------------------------------------- */ +#alerts-container { + color: white; + background-color: #5e6166; + border: @border_width_small@ solid #767973; + border-radius: @border_radius_normal@; + box-shadow: black 0 @border_radius_tiny@ @border_radius_tiny@; + padding: @padding_normal@; /* core spacing on top/bottom */ + margin-bottom: @margin_large@; + -moz-transition-property: opacity; + -moz-transition-duration: 0.5s; + opacity: 0; +} + +#alerts-container.showing { + opacity: 1; +} + +#alerts-title { + font-size: @font_small@ !important; +} + +#alerts-text { + font-size: @font_xsmall@ !important; + white-space: pre; +} + +%ifndef ANDROID +#alerts-container { + -moz-margin-end: @margin_large@; +} +%endif + +/* helperapp (save-as) popup ----------------------------------------------- */ +#helperapp-target { + font-size: @font_small@ !important; +} + +/* full-screen video ------------------------------------------------------- */ +.full-screen { + position: absolute; + z-index: 500; +} + +/* Android menu ------------------------------------------------------------ */ +#appmenu { + background: @color_background_default@; + border-style: solid; + border-color: #6d6d6d; + border-width: @border_width_small@ @border_width_small@ 0 @border_width_small@; +} + +#appmenu > .appmenu-button { + -moz-box-flex: 1; + -moz-box-orient: vertical; + color: @color_text_default@; + border-style: solid; + border-color: @color_divider_border@ !important; + border-width: 0 @border_width_tiny@ @border_width_tiny@ 0; + height: @appmenu_button_height@; + width: 0; + display: none; +} + +#appmenu > .appmenu-button[show] { + display: inline-block; +} + +#appmenu > .appmenu-button:hover:active { + background-image: url("chrome://browser/skin/images/appmenu-active-hdpi.png"); + background-size: 100% 100%; +} + +#appmenu > .appmenu-button .toolbarbutton-text { + display: block !important; + font-size: @font_snormal@ !important; +} + +#appmenu > .appmenu-button .toolbarbutton-icon { + margin-top: @margin_normal@ !important; + margin-bottom: @margin_small@ !important; +} + +richlistitem.appmenu-site-button > image, +.appmenu-site-button { + list-style-image: url("chrome://browser/skin/images/appmenu-site-hdpi.png"); +} + +richlistitem.appmenu-addons-button > image, +.appmenu-addons-button { + list-style-image: url("chrome://browser/skin/images/appmenu-addons-hdpi.png"); +} + +richlistitem.appmenu-preferences-button > image, +.appmenu-preferences-button { + list-style-image: url("chrome://browser/skin/images/appmenu-preferences-hdpi.png"); +} + +richlistitem.appmenu-downloads-button > image, +.appmenu-downloads-button { + list-style-image: url("chrome://browser/skin/images/appmenu-downloads-hdpi.png"); +} + +#appmenu-more-button { + list-style-image: url("chrome://browser/skin/images/appmenu-site-hdpi.png"); + display: none; +} + +@media (@orientation@: portrait) { + #appmenu:not([hidden])[count="4"], + #appmenu:not([hidden])[count="5"], + #appmenu:not([hidden])[count="6"] { + height: @appmenu_portrait_height@; + display: inline-block; + } + + #appmenu[count="4"] > .appmenu-button, + #appmenu[count="5"] > .appmenu-button { + width: 50%; + } + + #appmenu[count="5"] > .appmenu-button[show="2"], + #appmenu[count="5"] > .appmenu-button[show="3"], + #appmenu[count="5"] > .appmenu-button[show="4"], + #appmenu[count="6"] > .appmenu-button { + width: 33.33%; + } +} + +/* Sync setup ------------------------------------------------------------- */ +.syncsetup-center { + /* TODO: remove this dummy when we no longer use it in other themes */ +} + +.syncsetup-code { + color: #000; + background-color: #fff; + font-size: @font_xlarge@ !important; + padding: 0.2em 0.4em; + -moz-padding-end: 0.2em; + letter-spacing: 0.2em; + text-align: center; + min-width: 5.5em; +} + +.syncsetup-link { + text-decoration: underline; +} + +.syncsetup-label { + color: #fff; +} + +#syncsetup-customserver { + -moz-margin-start: @margin_xnormal@; +} + +/* content scrollbars */ +.scroller { + opacity: 0; + background-color: rgba(0, 0, 0, 0.4) !important; + -moz-border-top-colors: none !important; + -moz-border-bottom-colors: none !important; + -moz-border-right-colors: none !important; + -moz-border-left-colors: none !important; + border: @border_width_tiny@ solid rgba(255, 255, 255, 0.4) !important; +} + +.scroller[panning="true"] { + opacity: 1; +} + +.scroller[orient="vertical"] { + min-width: @scroller_thickness@; + width: @scroller_thickness@; + min-height: @scroller_minimum@; +} + +.scroller[orient="horizontal"] { + min-height: @scroller_thickness@; + height: @scroller_thickness@; + min-width: @scroller_minimum@; +} + +/* Sidebar peeking */ +.sidebar[mode="discovery"], #browsers[mode="discovery"] { + -moz-animation-delay: 1s; + -moz-animation-duration: 5s; + -moz-animation-name: sidebardiscovery; +} + +@-moz-keyframes sidebardiscovery { + from { -moz-transform: translateX(0); } + 10% { -moz-transform: translateX(-moz-calc(121px + @border_width_large@ + 2*@padding_normal@)); } + 45% { -moz-transform: translateX(-moz-calc(121px + @border_width_large@ + 2*@padding_normal@)); } + 55% { -moz-transform: translateX(-@sidebar_width_minimum@); } + 90% { -moz-transform: translateX(-@sidebar_width_minimum@); } + to { -moz-transform: translateX(0); } +} diff --git a/mobile/themes/core/gingerbread/defines.inc b/mobile/themes/core/gingerbread/defines.inc new file mode 100644 index 00000000000..a03e8482215 --- /dev/null +++ b/mobile/themes/core/gingerbread/defines.inc @@ -0,0 +1,202 @@ +%filter substitution + +%define color_background_active #525252 +%define color_background_default #000 +%define color_text_default #fff +%define color_divider_border #333333 +%define color_button_border #5a5a5a +%define color_dialog_border #5a5a5a +%define color_background_dlgbuttons #9a9a9a +%define color_background_panel #d6d6d6 + +%define color_background_inverse #fff +%define color_text_inverse #000 +%define color_text_gray #808080 + +%ifdef ANDROID +%define font_xlarge 5.08mozmm +%define font_xnormal 2.75mozmm +%define font_normal 2.54mozmm +%define font_snormal 2.33mozmm +%define font_small 1.91mozmm +%define font_xsmall 1.69mozmm +%define font_tiny 1.48mozmm +%define font_xtiny 1.27mozmm + +%define touch_row 7.41mozmm +%define touch_button_xlarge 7.62mozmm +%define touch_button_large 6.77mozmm +%define touch_button_small 5.93mozmm +%define touch_button_minwidth 11.86mozmm +%define touch_action_minwidth 21.17mozmm +%define touch_normal 6.77mozmm + +%define margin_large 2.54mozmm +%define margin_xxxnormal 1.69mozmm +%define margin_xnormal 1.06mozmm +%define margin_normal 0.85mozmm +%define margin_snormal 0.64mozmm +%define margin_small 0.42mozmm +%define margin_tiny 0.21mozmm +%define margin_xtiny 0.11mozmm + +%define padding_xlarge 3.39mozmm +%define padding_large 2.54mozmm +%define padding_xxxnormal 1.69mozmm +%define padding_xxnormal 1.27mozmm +%define padding_xnormal 1.06mozmm +%define padding_normal 0.85mozmm +%define padding_snormal 0.64mozmm +%define padding_small 0.42mozmm +%define padding_xsmall 0.21mozmm +%define padding_tiny 0.11mozmm + +%define border_width_xxlarge 0.64mozmm +%define border_width_xlarge 0.42mozmm +%define border_width_large 0.32mozmm +%define border_width_small 0.21mozmm +%define border_width_tiny 0.11mozmm + +%define border_radius_normal 0.85mozmm +%define border_radius_small 0.64mozmm +%define border_radius_tiny 0.21mozmm + +%define shadow_width_xlarge 1.06mozmm +%define shadow_width_large 0.64mozmm +%define shadow_width_small 0.21mozmm + +%define textbox_height 5.08mozmm + +%define dropmarker_padding 0.53mozmm + +%define progressmeter_height 3.39mozmm + +%define urlbar_edit_height 6.35mozmm +%define urlbar_edit_indent 0.85mozmm + +%define scroller_thickness 0.64mozmm +%define scroller_minimum 1.27mozmm + +%define sidebar_width_minimum 8.47mozmm +%define sidebar_button_height 7.41mozmm +%define documenttab_margin_bottom 0.85mozmm + +%define placelabel_padding 8.47mozmm +%define placeitem_padding 4.23mozmm + +%define autocomplete_item_container_image_padding 0.53mozmm +%define autocomplete_item_container_position 0.21mozmm +%define autocomplete_item_container_size 2.75mozmm +%define autocomplete_item_container_padding 5.08mozmm + +%define autocomplete_item_subtitle_margin 2.75mozmm +%define autocomplete_item_label_margin 3.18mozmm +%define autocomplete_item_tags_margin 3.39mozmm + +%define autocompleteresult_padding 0.53mozmm + +%define dialog_width 76.2mozmm + +%define appmenu_portrait_height 21.17mozmm +%define appmenu_button_height 10.48mozmm + +%define tablet_panel_controls 40mozmm +%define tablet_panel_minwidth 124mozmm +%else +%define font_xlarge 48px +%define font_xnormal 26px +%define font_normal 24px +%define font_snormal 22px +%define font_small 18px +%define font_xsmall 16px +%define font_tiny 14px +%define font_xtiny 12px + +%define touch_row 70px +%define touch_button_xlarge 72px +%define touch_button_large 64px +%define touch_button_small 56px +%define touch_button_minwidth 112px +%define touch_action_minwidth 200px +%define touch_normal 64px + +%define margin_large 24px +%define margin_xxxnormal 16px +%define margin_xnormal 10px +%define margin_normal 8px +%define margin_snormal 6px +%define margin_small 4px +%define margin_tiny 2px +%define margin_xtiny 1px + +%define padding_xlarge 32px +%define padding_large 24px +%define padding_xxxnormal 16px +%define padding_xxnormal 12px +%define padding_xnormal 10px +%define padding_normal 8px +%define padding_snormal 6px +%define padding_small 4px +%define padding_xsmall 2px +%define padding_tiny 1px + +%define border_width_xxlarge 6px +%define border_width_xlarge 4px +%define border_width_large 3px +%define border_width_small 2px +%define border_width_tiny 1px + +%define border_radius_normal 8px +%define border_radius_small 6px +%define border_radius_tiny 2px + +%define shadow_width_xlarge 10px +%define shadow_width_large 6px +%define shadow_width_small 2px + +%define textbox_height 48px + +%define dropmarker_margin 5px + +%define progressmeter_height 32px + +%define urlbar_edit_height 60px +%define urlbar_edit_indent 8px + +%define scroller_thickness 6px +%define scroller_minimum 12px + +%define sidebar_width_minimum 80px +%define sidebar_button_height 70px +%define documenttab_margin_bottom 8px + +%define placelabel_padding 80px +%define placeitem_padding 40px + +%define autocomplete_item_container_image_padding 5px +%define autocomplete_item_container_position 2px +%define autocomplete_item_container_size 26px +%define autocomplete_item_container_padding 48px + +%define autocomplete_item_subtitle_margin 26px +%define autocomplete_item_label_margin 30px +%define autocomplete_item_tags_margin 32px + +%define autocompleteresult_padding 5px + +%define dialog_width 500px + +%define appmenu_portrait_height 200px +%define appmenu_button_height 99px + +%define tablet_panel_controls 270px +%define tablet_panel_minwidth 801px +%endif + +%ifdef MOZ_PLATFORM_MAEMO +%define orientation -moz-device-orientation +%elifdef ANDROID +%define orientation -moz-device-orientation +%else +%define orientation orientation +%endif diff --git a/mobile/themes/core/gingerbread/images/addons-default-hdpi.png b/mobile/themes/core/gingerbread/images/addons-default-hdpi.png index 25f09906e01..e08a1a72739 100644 Binary files a/mobile/themes/core/gingerbread/images/addons-default-hdpi.png and b/mobile/themes/core/gingerbread/images/addons-default-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/alert-addons-30.png b/mobile/themes/core/gingerbread/images/alert-addons-30.png index 18744ad8522..c8c1a8d3a0c 100644 Binary files a/mobile/themes/core/gingerbread/images/alert-addons-30.png and b/mobile/themes/core/gingerbread/images/alert-addons-30.png differ diff --git a/mobile/themes/core/gingerbread/images/alert-downloads-30.png b/mobile/themes/core/gingerbread/images/alert-downloads-30.png index 2546352d28f..8279c3c92c1 100644 Binary files a/mobile/themes/core/gingerbread/images/alert-downloads-30.png and b/mobile/themes/core/gingerbread/images/alert-downloads-30.png differ diff --git a/mobile/themes/core/gingerbread/images/allpages-48.png b/mobile/themes/core/gingerbread/images/allpages-48.png index 9a18988e1fb..5e42b14b443 100644 Binary files a/mobile/themes/core/gingerbread/images/allpages-48.png and b/mobile/themes/core/gingerbread/images/allpages-48.png differ diff --git a/mobile/themes/core/gingerbread/images/appmenu-active-hdpi.png b/mobile/themes/core/gingerbread/images/appmenu-active-hdpi.png index b14d7ffd074..288b4354575 100644 Binary files a/mobile/themes/core/gingerbread/images/appmenu-active-hdpi.png and b/mobile/themes/core/gingerbread/images/appmenu-active-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/appmenu-addons-hdpi-xxx.png b/mobile/themes/core/gingerbread/images/appmenu-addons-hdpi-xxx.png deleted file mode 100644 index 97a8201fcee..00000000000 Binary files a/mobile/themes/core/gingerbread/images/appmenu-addons-hdpi-xxx.png and /dev/null differ diff --git a/mobile/themes/core/gingerbread/images/appmenu-addons-hdpi.png b/mobile/themes/core/gingerbread/images/appmenu-addons-hdpi.png index 904ddbfd7dc..de7c3294df3 100644 Binary files a/mobile/themes/core/gingerbread/images/appmenu-addons-hdpi.png and b/mobile/themes/core/gingerbread/images/appmenu-addons-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/appmenu-downloads-hdpi.png b/mobile/themes/core/gingerbread/images/appmenu-downloads-hdpi.png index 9327b0f8197..7096db9d1ce 100644 Binary files a/mobile/themes/core/gingerbread/images/appmenu-downloads-hdpi.png and b/mobile/themes/core/gingerbread/images/appmenu-downloads-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/appmenu-preferences-hdpi.png b/mobile/themes/core/gingerbread/images/appmenu-preferences-hdpi.png index 190ac8b4edc..5bff07cbb3d 100644 Binary files a/mobile/themes/core/gingerbread/images/appmenu-preferences-hdpi.png and b/mobile/themes/core/gingerbread/images/appmenu-preferences-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/appmenu-site-hdpi.png b/mobile/themes/core/gingerbread/images/appmenu-site-hdpi.png index b01d29cbbca..3ebe83dd7ad 100644 Binary files a/mobile/themes/core/gingerbread/images/appmenu-site-hdpi.png and b/mobile/themes/core/gingerbread/images/appmenu-site-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/arrowbox-horiz.png b/mobile/themes/core/gingerbread/images/arrowbox-horiz.png index dfa44b968be..3c51c2de2aa 100644 Binary files a/mobile/themes/core/gingerbread/images/arrowbox-horiz.png and b/mobile/themes/core/gingerbread/images/arrowbox-horiz.png differ diff --git a/mobile/themes/core/gingerbread/images/autocomplete-bookmarked-hdpi.png b/mobile/themes/core/gingerbread/images/autocomplete-bookmarked-hdpi.png index 3a6ef24c479..c3608bbca07 100644 Binary files a/mobile/themes/core/gingerbread/images/autocomplete-bookmarked-hdpi.png and b/mobile/themes/core/gingerbread/images/autocomplete-bookmarked-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/autocomplete-desktop-hdpi.png b/mobile/themes/core/gingerbread/images/autocomplete-desktop-hdpi.png index 6699255814a..4c25b5dfa82 100644 Binary files a/mobile/themes/core/gingerbread/images/autocomplete-desktop-hdpi.png and b/mobile/themes/core/gingerbread/images/autocomplete-desktop-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/autocomplete-search-hdpi.png b/mobile/themes/core/gingerbread/images/autocomplete-search-hdpi.png index 58a5d25fdf6..ffb7e9b43de 100644 Binary files a/mobile/themes/core/gingerbread/images/autocomplete-search-hdpi.png and b/mobile/themes/core/gingerbread/images/autocomplete-search-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/back-default-hdpi.png b/mobile/themes/core/gingerbread/images/back-default-hdpi.png index 8c2387cfcbe..4bae9afbca0 100644 Binary files a/mobile/themes/core/gingerbread/images/back-default-hdpi.png and b/mobile/themes/core/gingerbread/images/back-default-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/bookmark-default-hdpi.png b/mobile/themes/core/gingerbread/images/bookmark-default-hdpi.png index afd9c89544d..9d1bcb94e5a 100644 Binary files a/mobile/themes/core/gingerbread/images/bookmark-default-hdpi.png and b/mobile/themes/core/gingerbread/images/bookmark-default-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/bookmark-starred-hdpi.png b/mobile/themes/core/gingerbread/images/bookmark-starred-hdpi.png index ee1defd1185..3cfc2f2535d 100644 Binary files a/mobile/themes/core/gingerbread/images/bookmark-starred-hdpi.png and b/mobile/themes/core/gingerbread/images/bookmark-starred-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/bookmarks-48.png b/mobile/themes/core/gingerbread/images/bookmarks-48.png index 550122357b7..143b83f87ef 100644 Binary files a/mobile/themes/core/gingerbread/images/bookmarks-48.png and b/mobile/themes/core/gingerbread/images/bookmarks-48.png differ diff --git a/mobile/themes/core/gingerbread/images/button-bg.png b/mobile/themes/core/gingerbread/images/button-bg.png index 0dbc5329eae..f57261d41a4 100644 Binary files a/mobile/themes/core/gingerbread/images/button-bg.png and b/mobile/themes/core/gingerbread/images/button-bg.png differ diff --git a/mobile/themes/core/gingerbread/images/check-selected-30.png b/mobile/themes/core/gingerbread/images/check-selected-30.png deleted file mode 100644 index a29f65655ef..00000000000 Binary files a/mobile/themes/core/gingerbread/images/check-selected-30.png and /dev/null differ diff --git a/mobile/themes/core/gingerbread/images/check-selected-46.png b/mobile/themes/core/gingerbread/images/check-selected-46.png new file mode 100644 index 00000000000..2fa34331d93 Binary files /dev/null and b/mobile/themes/core/gingerbread/images/check-selected-46.png differ diff --git a/mobile/themes/core/gingerbread/images/check-unselected-30.png b/mobile/themes/core/gingerbread/images/check-unselected-30.png deleted file mode 100644 index 054c7373b40..00000000000 Binary files a/mobile/themes/core/gingerbread/images/check-unselected-30.png and /dev/null differ diff --git a/mobile/themes/core/gingerbread/images/check-unselected-46.png b/mobile/themes/core/gingerbread/images/check-unselected-46.png new file mode 100644 index 00000000000..add20cb42c9 Binary files /dev/null and b/mobile/themes/core/gingerbread/images/check-unselected-46.png differ diff --git a/mobile/themes/core/gingerbread/images/close-active-hdpi.png b/mobile/themes/core/gingerbread/images/close-active-hdpi.png index 935b7555e4d..eb4f3d0bf47 100644 Binary files a/mobile/themes/core/gingerbread/images/close-active-hdpi.png and b/mobile/themes/core/gingerbread/images/close-active-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/close-default-hdpi.png b/mobile/themes/core/gingerbread/images/close-default-hdpi.png index 3961ad1baaa..f2a81238611 100644 Binary files a/mobile/themes/core/gingerbread/images/close-default-hdpi.png and b/mobile/themes/core/gingerbread/images/close-default-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/close-inactive-tab-hdpi.png b/mobile/themes/core/gingerbread/images/close-inactive-tab-hdpi.png index 105d7852edd..77d71107fa1 100644 Binary files a/mobile/themes/core/gingerbread/images/close-inactive-tab-hdpi.png and b/mobile/themes/core/gingerbread/images/close-inactive-tab-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/console-default-hdpi.png b/mobile/themes/core/gingerbread/images/console-default-hdpi.png index b0d26f4237f..2ef59011943 100644 Binary files a/mobile/themes/core/gingerbread/images/console-default-hdpi.png and b/mobile/themes/core/gingerbread/images/console-default-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/downloads-default-hdpi.png b/mobile/themes/core/gingerbread/images/downloads-default-hdpi.png index f9afa2cec9f..6b649d110fe 100644 Binary files a/mobile/themes/core/gingerbread/images/downloads-default-hdpi.png and b/mobile/themes/core/gingerbread/images/downloads-default-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/dropmarker-hdpi.png b/mobile/themes/core/gingerbread/images/dropmarker-hdpi.png index 960fbd6ab24..a41c303c2a2 100644 Binary files a/mobile/themes/core/gingerbread/images/dropmarker-hdpi.png and b/mobile/themes/core/gingerbread/images/dropmarker-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/endcap-active-bg.png b/mobile/themes/core/gingerbread/images/endcap-active-bg.png index 0e645479714..889727a1e02 100644 Binary files a/mobile/themes/core/gingerbread/images/endcap-active-bg.png and b/mobile/themes/core/gingerbread/images/endcap-active-bg.png differ diff --git a/mobile/themes/core/gingerbread/images/endcap-default-bg.png b/mobile/themes/core/gingerbread/images/endcap-default-bg.png index 05e66d73551..666af001dbb 100644 Binary files a/mobile/themes/core/gingerbread/images/endcap-default-bg.png and b/mobile/themes/core/gingerbread/images/endcap-default-bg.png differ diff --git a/mobile/themes/core/gingerbread/images/endcap-ev-active-bg.png b/mobile/themes/core/gingerbread/images/endcap-ev-active-bg.png index daf52a6846c..620af6df9c9 100644 Binary files a/mobile/themes/core/gingerbread/images/endcap-ev-active-bg.png and b/mobile/themes/core/gingerbread/images/endcap-ev-active-bg.png differ diff --git a/mobile/themes/core/gingerbread/images/endcap-ev-default-bg.png b/mobile/themes/core/gingerbread/images/endcap-ev-default-bg.png index 0ef93455d99..90dcc1952cc 100644 Binary files a/mobile/themes/core/gingerbread/images/endcap-ev-default-bg.png and b/mobile/themes/core/gingerbread/images/endcap-ev-default-bg.png differ diff --git a/mobile/themes/core/gingerbread/images/endcap-ssl-active-bg.png b/mobile/themes/core/gingerbread/images/endcap-ssl-active-bg.png index e395ef62088..a88df03a478 100644 Binary files a/mobile/themes/core/gingerbread/images/endcap-ssl-active-bg.png and b/mobile/themes/core/gingerbread/images/endcap-ssl-active-bg.png differ diff --git a/mobile/themes/core/gingerbread/images/endcap-ssl-default-bg.png b/mobile/themes/core/gingerbread/images/endcap-ssl-default-bg.png index 7d510880b48..0ede58ba068 100644 Binary files a/mobile/themes/core/gingerbread/images/endcap-ssl-default-bg.png and b/mobile/themes/core/gingerbread/images/endcap-ssl-default-bg.png differ diff --git a/mobile/themes/core/gingerbread/images/forward-default-hdpi.png b/mobile/themes/core/gingerbread/images/forward-default-hdpi.png index 4bcf5010976..1bfa8012f6d 100644 Binary files a/mobile/themes/core/gingerbread/images/forward-default-hdpi.png and b/mobile/themes/core/gingerbread/images/forward-default-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/history-48.png b/mobile/themes/core/gingerbread/images/history-48.png index 965fca75705..6fb9fc2c5bb 100644 Binary files a/mobile/themes/core/gingerbread/images/history-48.png and b/mobile/themes/core/gingerbread/images/history-48.png differ diff --git a/mobile/themes/core/gingerbread/images/identity-default-hdpi.png b/mobile/themes/core/gingerbread/images/identity-default-hdpi.png index 6f21d92adf4..405bb6ba42c 100644 Binary files a/mobile/themes/core/gingerbread/images/identity-default-hdpi.png and b/mobile/themes/core/gingerbread/images/identity-default-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/identity-ev-hdpi.png b/mobile/themes/core/gingerbread/images/identity-ev-hdpi.png index 761b7d8a259..0a865b17fc3 100644 Binary files a/mobile/themes/core/gingerbread/images/identity-ev-hdpi.png and b/mobile/themes/core/gingerbread/images/identity-ev-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/identity-ssl-hdpi.png b/mobile/themes/core/gingerbread/images/identity-ssl-hdpi.png index 64051751ba5..b1112de257a 100644 Binary files a/mobile/themes/core/gingerbread/images/identity-ssl-hdpi.png and b/mobile/themes/core/gingerbread/images/identity-ssl-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/locked-hdpi.png b/mobile/themes/core/gingerbread/images/locked-hdpi.png index e50bc4f1dd2..16dc8e17626 100644 Binary files a/mobile/themes/core/gingerbread/images/locked-hdpi.png and b/mobile/themes/core/gingerbread/images/locked-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/mute-hdpi.png b/mobile/themes/core/gingerbread/images/mute-hdpi.png index 0bd1e60e6a3..c716ef35cd5 100644 Binary files a/mobile/themes/core/gingerbread/images/mute-hdpi.png and b/mobile/themes/core/gingerbread/images/mute-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/navigation-magnifier-30.png b/mobile/themes/core/gingerbread/images/navigation-magnifier-30.png index 48001657c46..2a36e16d21d 100644 Binary files a/mobile/themes/core/gingerbread/images/navigation-magnifier-30.png and b/mobile/themes/core/gingerbread/images/navigation-magnifier-30.png differ diff --git a/mobile/themes/core/gingerbread/images/newtab-default-hdpi.png b/mobile/themes/core/gingerbread/images/newtab-default-hdpi.png index aacf3b927b0..e71e89cd79b 100644 Binary files a/mobile/themes/core/gingerbread/images/newtab-default-hdpi.png and b/mobile/themes/core/gingerbread/images/newtab-default-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/next-disabled-hdpi.png b/mobile/themes/core/gingerbread/images/next-disabled-hdpi.png index 81e68769e09..69cb6d38d6b 100644 Binary files a/mobile/themes/core/gingerbread/images/next-disabled-hdpi.png and b/mobile/themes/core/gingerbread/images/next-disabled-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/next-hdpi.png b/mobile/themes/core/gingerbread/images/next-hdpi.png index c0115d49148..a370353e828 100644 Binary files a/mobile/themes/core/gingerbread/images/next-hdpi.png and b/mobile/themes/core/gingerbread/images/next-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/panelrow-active-hdpi.png b/mobile/themes/core/gingerbread/images/panelrow-active-hdpi.png deleted file mode 100644 index 23676c11c47..00000000000 Binary files a/mobile/themes/core/gingerbread/images/panelrow-active-hdpi.png and /dev/null differ diff --git a/mobile/themes/core/gingerbread/images/panelrow-default-hdpi.png b/mobile/themes/core/gingerbread/images/panelrow-default-hdpi.png deleted file mode 100644 index d8143e245c9..00000000000 Binary files a/mobile/themes/core/gingerbread/images/panelrow-default-hdpi.png and /dev/null differ diff --git a/mobile/themes/core/gingerbread/images/panelrow-selected-hdpi.png b/mobile/themes/core/gingerbread/images/panelrow-selected-hdpi.png deleted file mode 100644 index 5e8dc6eb3a9..00000000000 Binary files a/mobile/themes/core/gingerbread/images/panelrow-selected-hdpi.png and /dev/null differ diff --git a/mobile/themes/core/gingerbread/images/pause-hdpi.png b/mobile/themes/core/gingerbread/images/pause-hdpi.png index e377d321ce0..42b36576978 100644 Binary files a/mobile/themes/core/gingerbread/images/pause-hdpi.png and b/mobile/themes/core/gingerbread/images/pause-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/play-hdpi.png b/mobile/themes/core/gingerbread/images/play-hdpi.png index a8482eb4dd7..7410c99cd5d 100644 Binary files a/mobile/themes/core/gingerbread/images/play-hdpi.png and b/mobile/themes/core/gingerbread/images/play-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/popup-bg-hdpi.png b/mobile/themes/core/gingerbread/images/popup-bg-hdpi.png deleted file mode 100644 index df8e20c929f..00000000000 Binary files a/mobile/themes/core/gingerbread/images/popup-bg-hdpi.png and /dev/null differ diff --git a/mobile/themes/core/gingerbread/images/preferences-default-hdpi.png b/mobile/themes/core/gingerbread/images/preferences-default-hdpi.png index 49d89c1df27..bcd3c9d3d70 100644 Binary files a/mobile/themes/core/gingerbread/images/preferences-default-hdpi.png and b/mobile/themes/core/gingerbread/images/preferences-default-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/previous-disabled-hdpi.png b/mobile/themes/core/gingerbread/images/previous-disabled-hdpi.png index 459f5ab7de4..fa7b069f597 100644 Binary files a/mobile/themes/core/gingerbread/images/previous-disabled-hdpi.png and b/mobile/themes/core/gingerbread/images/previous-disabled-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/previous-hdpi.png b/mobile/themes/core/gingerbread/images/previous-hdpi.png index 530206d58a5..099ff2d574f 100644 Binary files a/mobile/themes/core/gingerbread/images/previous-hdpi.png and b/mobile/themes/core/gingerbread/images/previous-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/reload-hdpi.png b/mobile/themes/core/gingerbread/images/reload-hdpi.png index 57842bdb914..72d50e50982 100644 Binary files a/mobile/themes/core/gingerbread/images/reload-hdpi.png and b/mobile/themes/core/gingerbread/images/reload-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/remotetabs-48.png b/mobile/themes/core/gingerbread/images/remotetabs-48.png index 011d501a1b2..ce1ebb260de 100644 Binary files a/mobile/themes/core/gingerbread/images/remotetabs-48.png and b/mobile/themes/core/gingerbread/images/remotetabs-48.png differ diff --git a/mobile/themes/core/gingerbread/images/row-header-bg.png b/mobile/themes/core/gingerbread/images/row-header-bg.png index aaefd0f3d98..d0f3caa673c 100644 Binary files a/mobile/themes/core/gingerbread/images/row-header-bg.png and b/mobile/themes/core/gingerbread/images/row-header-bg.png differ diff --git a/mobile/themes/core/gingerbread/images/scrubber-hdpi.png b/mobile/themes/core/gingerbread/images/scrubber-hdpi.png index 49c60505f46..0a2fdd3c7fe 100644 Binary files a/mobile/themes/core/gingerbread/images/scrubber-hdpi.png and b/mobile/themes/core/gingerbread/images/scrubber-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/search-glass-30.png b/mobile/themes/core/gingerbread/images/search-glass-30.png index 71bf1f255ee..f8cb0ef2bc3 100644 Binary files a/mobile/themes/core/gingerbread/images/search-glass-30.png and b/mobile/themes/core/gingerbread/images/search-glass-30.png differ diff --git a/mobile/themes/core/gingerbread/images/settings-default-hdpi.png b/mobile/themes/core/gingerbread/images/settings-default-hdpi.png index 448743a4686..65e30ebb751 100644 Binary files a/mobile/themes/core/gingerbread/images/settings-default-hdpi.png and b/mobile/themes/core/gingerbread/images/settings-default-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/sidebarbutton-active-hdpi.png b/mobile/themes/core/gingerbread/images/sidebarbutton-active-hdpi.png deleted file mode 100644 index 30f1d2017bc..00000000000 Binary files a/mobile/themes/core/gingerbread/images/sidebarbutton-active-hdpi.png and /dev/null differ diff --git a/mobile/themes/core/gingerbread/images/stop-hdpi.png b/mobile/themes/core/gingerbread/images/stop-hdpi.png index 2a2fcdfdddd..064d332f559 100644 Binary files a/mobile/themes/core/gingerbread/images/stop-hdpi.png and b/mobile/themes/core/gingerbread/images/stop-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/tab-closed-hdpi.png b/mobile/themes/core/gingerbread/images/tab-closed-hdpi.png index e8333ed8229..53efaa604b5 100644 Binary files a/mobile/themes/core/gingerbread/images/tab-closed-hdpi.png and b/mobile/themes/core/gingerbread/images/tab-closed-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/tab-inactive-hdpi.png b/mobile/themes/core/gingerbread/images/tab-inactive-hdpi.png index b2360da0b0e..4694892601d 100644 Binary files a/mobile/themes/core/gingerbread/images/tab-inactive-hdpi.png and b/mobile/themes/core/gingerbread/images/tab-inactive-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/task-back-hdpi.png b/mobile/themes/core/gingerbread/images/task-back-hdpi.png index 17ec3017aeb..cee5b67e0e0 100644 Binary files a/mobile/themes/core/gingerbread/images/task-back-hdpi.png and b/mobile/themes/core/gingerbread/images/task-back-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/task-back-rtl-hdpi.png b/mobile/themes/core/gingerbread/images/task-back-rtl-hdpi.png index 492c7b5ac28..c25dac6ab32 100644 Binary files a/mobile/themes/core/gingerbread/images/task-back-rtl-hdpi.png and b/mobile/themes/core/gingerbread/images/task-back-rtl-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/task-close-hdpi.png b/mobile/themes/core/gingerbread/images/task-close-hdpi.png index e053d1f14ac..954275de5db 100644 Binary files a/mobile/themes/core/gingerbread/images/task-close-hdpi.png and b/mobile/themes/core/gingerbread/images/task-close-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/task-switch-hdpi.png b/mobile/themes/core/gingerbread/images/task-switch-hdpi.png index 3e9e1a75db1..f4185d6939b 100644 Binary files a/mobile/themes/core/gingerbread/images/task-switch-hdpi.png and b/mobile/themes/core/gingerbread/images/task-switch-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/textbox-bg.png b/mobile/themes/core/gingerbread/images/textbox-bg.png index 40edca065d6..1f02bd73cbd 100644 Binary files a/mobile/themes/core/gingerbread/images/textbox-bg.png and b/mobile/themes/core/gingerbread/images/textbox-bg.png differ diff --git a/mobile/themes/core/gingerbread/images/toggle-off.png b/mobile/themes/core/gingerbread/images/toggle-off.png index a27900e1fe4..87a660c599e 100644 Binary files a/mobile/themes/core/gingerbread/images/toggle-off.png and b/mobile/themes/core/gingerbread/images/toggle-off.png differ diff --git a/mobile/themes/core/gingerbread/images/toggle-on.png b/mobile/themes/core/gingerbread/images/toggle-on.png index a7dc009d5ea..8d333d5d861 100644 Binary files a/mobile/themes/core/gingerbread/images/toggle-on.png and b/mobile/themes/core/gingerbread/images/toggle-on.png differ diff --git a/mobile/themes/core/gingerbread/images/unlocked-hdpi.png b/mobile/themes/core/gingerbread/images/unlocked-hdpi.png index 359923dc6cc..6ed6ff1bc9e 100644 Binary files a/mobile/themes/core/gingerbread/images/unlocked-hdpi.png and b/mobile/themes/core/gingerbread/images/unlocked-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/unmute-hdpi.png b/mobile/themes/core/gingerbread/images/unmute-hdpi.png index 4dbb94f98f0..cf2fb7bfb66 100644 Binary files a/mobile/themes/core/gingerbread/images/unmute-hdpi.png and b/mobile/themes/core/gingerbread/images/unmute-hdpi.png differ diff --git a/mobile/themes/core/gingerbread/images/urlbar-bg.png b/mobile/themes/core/gingerbread/images/urlbar-bg.png new file mode 100644 index 00000000000..9dddc7e7363 Binary files /dev/null and b/mobile/themes/core/gingerbread/images/urlbar-bg.png differ diff --git a/mobile/themes/core/gingerbread/platform.css b/mobile/themes/core/gingerbread/platform.css new file mode 100644 index 00000000000..41c6aa43175 --- /dev/null +++ b/mobile/themes/core/gingerbread/platform.css @@ -0,0 +1,739 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Mobile Browser. + * + * The Initial Developer of the Original Code is + * Mozilla Corporation. + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Mark Finkle + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* global skin ------------------------------------------------------------- */ +@import url(chrome://global/skin/); + +%filter substitution +%include defines.inc + +/* general stuff ------------------------------------------------------------ */ +:root { + font-family: "Nokia Sans", Tahoma, sans-serif !important; + font-size: @font_normal@ !important; +} + +::-moz-selection { + background-color: #8db8d8; + color: black; +} + +menu, +menuitem { + padding: 0 !important; + margin: 0 !important; +} + +description, +label { + /* force mac to use the same margins as windows and linux */ + -moz-margin-start: @margin_snormal@; + -moz-margin-end: @margin_snormal@; +} + +/* Override any OS inverse themes */ +richlistbox, +textbox { + color: black; + background-color: white; +} + +/* textboxes --------------------------------------------------------------- */ +textbox:not([type="number"]) { + min-height: @textbox_height@; + border: @border_width_small@ solid @color_button_border@; + -moz-border-top-colors: -moz-initial; + -moz-border-right-colors: -moz-initial; + -moz-border-bottom-colors: -moz-initial; + -moz-border-left-colors: -moz-initial; +} + +textbox[isempty="true"] { + color: @color_text_gray@; +} + +textbox.search-bar { + border: @border_width_small@ solid rgba(0,0,0,0.4); + background-color: #f9f9f9; + background: url("chrome://browser/skin/images/textbox-bg.png") top left repeat-x; + background-size: 100% 100%; +} + +textbox[disabled="true"] { + background-color: lightgray; +} + +/* sidebars spacer --------------------------------------------------------- */ +.sidebar-spacer { + background-color: #767973; +} + +/* prompt dialogs ---------------------------------------------------------- */ +.context-block, +.modal-block, +.perm-modal-block { + -moz-box-align: center; + -moz-box-pack: center; + background-color: rgba(0,0,0,.6); +} + +.context-block { + padding: @touch_normal@; +} + +.dialog-dark, +.panel-arrowcontent { + background-color: @color_background_inverse@; + box-shadow: black 0 @border_radius_tiny@ @border_radius_tiny@, black 0 -@border_radius_tiny@ @border_radius_tiny@; + padding: @padding_normal@ 0; /* core spacing */ +} + +@media (max-width: 499px) { + .context-block { + padding: @padding_xlarge@; + } +} + +dialog > .prompt-header > .prompt-message { + white-space: pre-wrap; +} + +dialog > .prompt-header > .button-checkbox { + margin-left: @margin_large@; +} + +/* buttons ----------------------------------------------------------------- */ +.button-text, +.toolbarbutton-text { + font-weight: normal; + font-size: @font_snormal@ !important; +} + +button { + -moz-appearance: none; + min-width: @touch_button_minwidth@ !important; + min-height: @touch_button_small@ !important; /* button size */ + color: #000; + margin: @margin_normal@; + padding: @padding_xnormal@; + background-image: url("chrome://browser/skin/images/button-bg.png"); + background-size: auto 100%; + border: @border_width_tiny@ solid @color_button_border@; +} + +button[disabled="true"] { + color: #aaa !important; + border: @border_width_tiny@ solid @color_button_border@ !important; +} + +button:focus > .button-box { + border: @border_width_tiny@ solid transparent; +} + +button:not([disabled]):hover:active, +button:not([disabled])[checked="true"] { + background-image: url("chrome://browser/skin/images/toggle-off.png"); +} + +/* Override GTK2 system setting */ +.button-icon { + display: -moz-initial !important; +} + +/* spinbuttons ------------------------------------------------------------- */ +spinbuttons { + border: none !important; +} + +.numberbox-input-box { + border: @border_width_small@ solid @color_button_border@; + border-right: 0 solid transparent; + -moz-border-top-colors: -moz-initial; + -moz-border-bottom-colors: -moz-initial; + -moz-border-left-colors: -moz-initial; +} + +.numberbox-input-box:-moz-locale-dir(rtl) { + border-right: @border_width_small@ solid @color_button_border@; + border-left: 0 solid transparent; +} + +.spinbuttons-box { + border: none !important; + -moz-box-orient: horizontal !important; + -moz-box-direction: reverse !important; +} + +.spinbuttons-up .button-icon, +.spinbuttons-down .button-icon { + display: block; +} + +.spinbuttons-up, +.spinbuttons-down { + -moz-appearance: none !important; + min-width: @touch_button_small@ !important; /* button size */ + min-height: @touch_button_small@ !important; /* button size */ + color: #000; + margin: @margin_normal@; + padding: @padding_xnormal@; + background-image: url("chrome://browser/skin/images/button-bg.png"); + background-size: auto 100%; + border: @border_width_tiny@ solid @color_button_border@; + list-style-image: url("chrome://browser/skin/images/arrowdown-16.png"); +} + +.spinbuttons-up:hover:active:not([disabled=true]), +.spinbuttons-down:hover:active:not([disabled=true]) { + background-image: url("chrome://browser/skin/images/toggle-on.png"); +} + +.spinbuttons-up { + list-style-image: url("chrome://browser/skin/images/arrowup-16.png"); +} + +/* toolbar buttons --------------------------------------------------------- */ +toolbarbutton { + min-width: @touch_button_large@ !important; /* primary button size */ + min-height: @touch_button_large@ !important; /* primary button size */ + -moz-appearance: none !important; + margin: 0; + padding: @padding_xsmall@; +} + +toolbarbutton:not(.show-text) .toolbarbutton-text { + display: none; +} + +.toolbarbutton-icon[label]:not([label=""]), +.toolbarbutton-icon[type="menu"] { + -moz-margin-end: @margin_tiny@; +} + +toolbarbutton:not(.show-text) .toolbarbutton-icon, +toolbarbutton:not([image]) .toolbarbutton-icon, +toolbarbutton[image=''] .toolbarbutton-icon { + -moz-margin-end: 0; +} + +toolbarbutton:hover, +toolbarbutton:hover:active, +toolbarbutton[open="true"] { + border-color: transparent; +} + +/* checkbox buttons ----------------------------------------------------------- */ +.button-checkbox { + padding: 0 !important; + background: none !important; + border: none !important; + -moz-border-image: none !important; + color: white; + -moz-box-align: center; + font-size: @font_small@; + -moz-box-align: center; +} + +.prompt-checkbox-label { + text-align: left; +} + +.button-checkbox > .button-image-icon { + -moz-margin-end: @margin_normal@; + list-style-image: url("chrome://browser/skin/images/check-unselected-46.png"); +} + +.button-checkbox[checked="true"] > .button-image-icon { + list-style-image: url("chrome://browser/skin/images/check-selected-46.png"); +} + +.button-checkbox:hover:active > .button-box, +.button-checkbox[checked="true"] > .button-box { + padding-top: @padding_tiny@; + padding-bottom: @padding_xsmall@; + -moz-padding-start: @margin_small@; + -moz-padding-end: @margin_small@; +} + +/* radio buttons ----------------------------------------------------------- */ +radiogroup { + -moz-box-orient: horizontal; +} + +.radio-label { + font-weight: normal; + font-size: @font_snormal@ !important; +} + +radio { + -moz-appearance: none; + min-width: @touch_button_small@ !important; /* button size */ + min-height: @touch_button_small@ !important; /* button size */ + color: #000; + padding: @padding_xnormal@; + margin: 0; + background-image: url("chrome://browser/skin/images/button-bg.png"); + background-size: auto 100%; + border-top: @border_width_tiny@ solid @color_button_border@; + border-bottom: @border_width_tiny@ solid @color_button_border@; +} + +radio .radio-icon, radio .radio-check { + display: none; +} + +radio:not([disabled=true]):hover:active, +radio[selected] { + color: white; + background-image: url("chrome://browser/skin/images/toggle-on.png"); +} + +radio:first-child { + border-left: @border_width_tiny@ solid @color_button_border@; +} + +radio:first-child:-moz-locale-dir(rtl) { + border-left: none; + border-right: @border_width_tiny@ solid @color_button_border@; +} + +radio:last-child { + border-right: @border_width_tiny@ solid @color_button_border@; +} + +radio:last-child:-moz-locale-dir(rtl) { + border-right: none; + border-left: @border_width_tiny@ solid @color_button_border@; +} + +radio[focused="true"] > .radio-label-box { + border: @border_width_tiny@ solid transparent; +} + +/* checkbox radios --------------------------------------------------------- */ +checkbox { + margin: @margin_tiny@ @margin_small@ @margin_tiny@ @margin_small@; /* match platform style for buttons */ +} + +radio.checkbox-radio-on:not([selected]) { + border-right: @border_width_tiny@ solid @color_button_border@; +} + +radio.checkbox-radio-on:not([selected]):-moz-locale-dir(rtl) { + border-left: none; + border-left: @border_width_tiny@ solid @color_button_border@; +} + +radio.checkbox-radio-off[selected], +radio.checkbox-radio-off:hover:active { + background-image: url("chrome://browser/skin/images/toggle-off.png"); + color: black; + background-repeat: repeat-x; +} + +radio.checkbox-radio-on:not([selected]) .radio-label-box, +radio.checkbox-radio-off:not([selected]) .radio-label-box { + visibility: hidden; +} + +/* richlistbox ------------------------------------------------------------- */ +richlistbox { + -moz-user-focus: ignore; + margin: 0; +} + +richlistitem { + -moz-user-focus: ignore; + min-height: @touch_row@; /* row size */ + padding: @padding_small@; + border-bottom: @border_width_tiny@ solid rgb(207,207,207); +} + +richlistitem label.title, +richlistitem description.title { + font-size: @font_normal@ !important; +} + +richlistitem label.normal, +richlistitem description.normal { + color: gray; + font-size: @font_small@ !important; + white-space: pre-wrap; + word-wrap: break-word; +} + +richlistitem label.normal-black, +richlistitem description.normal-black { + font-size: @font_small@ !important; + white-space: pre-wrap; + word-wrap: break-word; +} + +richlistitem label.normal-bold, +richlistitem description.normal-bold { + font-weight: bold; + font-size: @font_small@ !important; + white-space: pre-wrap; + word-wrap: break-word; +} + +richlistitem[selected="true"] { + color: black; + background-color: white; +} + +richlistitem:hover:active:not([selected="true"]):not([nohighlight="true"]) { + background-color: #8db8d8; +} + +richlistitem.section-header, +richlistitem[selected="true"].section-header { + font-weight: bold; + color: #000; + background-color: lightgray; +} + +richlistitem .show-on-select { + visibility: collapse; +} + +richlistitem[selected="true"] .show-on-select { + visibility: visible; +} + +richlistitem .hide-on-select { + visibility: visible; +} + +richlistitem[selected="true"] .hide-on-select { + visibility: collapse; +} + +richlistitem[typeName="message"] { + border-bottom: 0; +} + +/* colorpicker ------------------------------------------------------------- */ +colorpicker > panel { + background-color: #767973; +} + +colorpicker > vbox { + background-color: #767973; +} + +/* textbox ----------------------------------------------------------------- */ +.textbox-search-icon { + list-style-image: url("chrome://browser/skin/images/search-glass-30.png"); + -moz-image-region: auto; +} + +.textbox-search-clear { + list-style-image: url("chrome://browser/skin/images/search-clear-30.png"); + -moz-image-region: auto; +} + +/* menulist ---------------------------------------------------------------- */ +.menulist-label { + font-family: "Nokia Sans", Tahoma, sans-serif !important; + font-weight: normal; + font-size: @font_snormal@ !important; + background-color: transparent !important; +} + +menulist { + -moz-appearance: none !important; + -moz-user-focus: ignore; + min-width: @touch_button_minwidth@ !important; + min-height: @touch_button_small@ !important; /* button size */ + color: #000 !important; + margin: @margin_normal@; + padding: @padding_small@ @padding_xnormal@; + background-image: url("chrome://browser/skin/images/button-bg.png"); + background-size: auto 100%; + border: @border_width_tiny@ solid @color_button_border@; +} + +menulist[disabled="true"] { + color: #aaa !important; + border: @border_width_tiny@ solid @color_button_border@ !important; +} + +menulist:not([disabled="true"]):hover:active { + background-image: url("chrome://browser/skin/images/toggle-off.png"); +} + +menulist > dropmarker { + height: 32px; + width: 32px; + margin-left: @margin_snormal@; + background-color: transparent; /* for windows */ + border: none; /* for windows */ + -moz-box-align: center; + -moz-box-pack: center; + list-style-image: url("chrome://browser/skin/images/dropmarker-hdpi.png"); + -moz-image-region: auto; + display: block; +} + +menulist[disabled="true"] > dropmarker { + opacity: 0.5; +} + +/* progressmeter ----------------------------------------------------------- */ +progressmeter { + background-color: #fff; + padding: @padding_small@; + height: @textbox_height@; + border: @border_width_large@ solid #aaa; + -moz-border-top-colors: -moz-initial; + -moz-border-right-colors: -moz-initial; + -moz-border-bottom-colors: -moz-initial; + -moz-border-left-colors: -moz-initial; +} + +.progress-bar { + background-color: #8db8d8; +} + +/* panels / arrowboxes------------------------------------------------------ */ +arrowbox { + -moz-appearance: none; + background: transparent !important; + border: none; +} + +.arrowbox-dark .panel-arrowcontent { + padding: @padding_normal@; /* core spacing */ +} + +dialog, +.arrowbox-dark .panel-arrowcontent, +.panel-dark { + color: @color_text_default@; + background: @color_background_default@; +} + +dialog, +.arrowbox-dark .panel-arrowcontent { + border: @border_width_small@ solid @color_dialog_border@; + box-shadow: black 0 @shadow_width_small@ @shadow_width_small@; +} + +dialog { + margin: @margin_xxxnormal@ !important; + max-width: @dialog_width@; +} + +.prompt-message { + -moz-box-pack: center; + font-size: @font_snormal@; + margin: @padding_normal@; +} + +.prompt-title { + font-size: @font_xnormal@; + padding-top: @padding_xnormal@; + padding-left: @padding_normal@; +} + +/* Authentication dialogs do not have a title */ +.prompt-title:empty, +.prompt-title:empty + .prompt-line { + display: none; +} + +.prompt-line { + border-bottom: @border_width_tiny@ solid @color_divider_border@; + margin: @margin_small@ 0 0 0; + height: @padding_normal@ !important; +} + +.prompt-buttons { + font-size: @font_snormal@; + background-color: @color_background_dlgbuttons@; + display: inline-block; + text-align: center; +} + +.prompt-edit { + margin: @margin_xnormal@; + font-size: @font_normal@; + text-align: start; +} + +.panel-arrow[side="top"] { + list-style-image: url("chrome://browser/skin/images/arrowbox-up.png"); + margin-bottom: -@margin_normal@; +} + +.panel-arrow[side="bottom"] { + list-style-image: url("chrome://browser/skin/images/arrowbox-down.png"); + margin-top: -@margin_normal@; +} + +.panel-arrow[side="left"] { + list-style-image: url("chrome://browser/skin/images/arrowbox-horiz.png"); + margin-right: -@margin_snormal@; + -moz-transform: scaleX(-1); +} + +.panel-arrow[side="right"] { + list-style-image: url("chrome://browser/skin/images/arrowbox-horiz.png"); + margin-left: -@margin_snormal@; +} + +/*.panel-row-header ------------------------------------------------------------ */ +.panel-row-header { + border-bottom: @border_width_xxlarge@ solid @color_background_active@; + background-color: @color_background_default@ !important; + padding: 0 !important; +} + +.panel-row-button { + -moz-appearance: none; + background: @color_background_default@; + background-size: 100% 100%; + color: white; + border: 0 solid transparent !important; + -moz-border-start: @border_width_tiny@ solid rgba(255,255,255,0.2) !important; + -moz-border-end: @border_width_tiny@ solid rgba(0,0,0,0.2) !important; + padding-top: @padding_xsmall@ !important; + padding-bottom: @padding_xsmall@ !important; + -moz-padding-start: @padding_xsmall@ !important; + -moz-padding-end: @padding_xsmall@ !important; + -moz-box-flex: 1; + -moz-user-focus: ignore; + -moz-user-select: none; +} + +.panel-row-button:hover:active { + background: @color_background_active@; + background-size: 100% 100%; +} + +.panel-row-button:first-child { + -moz-border-start-width: 0 !important; +} + +.panel-row-button:last-child { + -moz-border-end-width: 0 !important; +} + +@media (@orientation@: portrait) { + .panel-row-button { + -moz-box-orient: vertical; + } + + .panel-row-button .toolbarbutton-text { + font-size: @font_xsmall@ !important; + } +} + +.panel-row-button .toolbarbutton-text { + text-align: left; + text-shadow: rgba(0,0,0,0.3) 0 @shadow_width_small@; +} + +.panel-row-button .toolbarbutton-text:-moz-locale-dir(rtl) { + text-align: right; +} + +.panel-row-button[disabled="true"] { + pointer-events: none; +} + +.panel-row-button[disabled="true"] .toolbarbutton-icon { + opacity: 0.5; +} + +.panel-row-button[disabled="true"] .toolbarbutton-text { + color: #aaa; +} + +.panel-row-button[checked="true"] { + color: white !important; + background: @color_background_active@ !important; + background-size: 100% 100% !important; +} + +.panel-row-button[checked="true"], +.panel-row-button[disabled="true"] { + pointer-events: none; +} + +#panel-container-inner { + -moz-box-orient: vertical; +} + +#panel-controls { + -moz-box-orient: horizontal; +} + +@media (min-width: @tablet_panel_minwidth@) { + #panel-container-inner { + -moz-box-orient: horizontal; + -moz-box-pack: center; + } + + #panel-items { + max-width: @tablet_panel_minwidth@; + min-width: 0px !important; + } + + /* This will affect the prefs screen, but not the awesome screen */ + #panel-controls { + -moz-box-orient: vertical !important; + -moz-box-align: start; + } + + .panel-row-button { + -moz-box-orient: horizontal; + -moz-box-flex: 0; + min-width: @tablet_panel_controls@ !important; + } + + #panel-controls .toolbarbutton-text { + display: -moz-box !important; + -moz-box-flex: 1; + } + + #panel-container { + -moz-box-pack: center; + padding: @padding_xlarge@ 0px; + } +} diff --git a/mobile/themes/core/honeycomb/images/appmenu-addons-hdpi-xxx.png b/mobile/themes/core/honeycomb/images/appmenu-addons-hdpi-xxx.png deleted file mode 100644 index 97a8201fcee..00000000000 Binary files a/mobile/themes/core/honeycomb/images/appmenu-addons-hdpi-xxx.png and /dev/null differ diff --git a/mobile/themes/core/jar.mn b/mobile/themes/core/jar.mn index 2745e56fb20..ea8ff717f2d 100644 --- a/mobile/themes/core/jar.mn +++ b/mobile/themes/core/jar.mn @@ -126,13 +126,13 @@ chrome.jar: skin/gingerbread/aboutPage.css (aboutPage.css) skin/gingerbread/about.css (about.css) skin/gingerbread/aboutHome.css (aboutHome.css) -* skin/gingerbread/browser.css (browser.css) +* skin/gingerbread/browser.css (gingerbread/browser.css) skin/gingerbread/config.css (config.css) skin/gingerbread/firstRun.css (firstRun.css) * skin/gingerbread/forms.css (forms.css) skin/gingerbread/header.css (header.css) * skin/gingerbread/notification.css (notification.css) -* skin/gingerbread/platform.css (platform.css) +* skin/gingerbread/platform.css (gingerbread/platform.css) skin/gingerbread/touchcontrols.css (touchcontrols.css) % override chrome://global/skin/about.css chrome://browser/skin/about.css % override chrome://global/skin/media/videocontrols.css chrome://browser/skin/touchcontrols.css @@ -146,6 +146,7 @@ chrome.jar: skin/gingerbread/images/aboutBackground.jpg (gingerbread/images/aboutBackground.jpg) skin/gingerbread/images/button-bg.png (gingerbread/images/button-bg.png) skin/gingerbread/images/textbox-bg.png (gingerbread/images/textbox-bg.png) + skin/gingerbread/images/urlbar-bg.png (gingerbread/images/urlbar-bg.png) skin/gingerbread/images/browseaddons-bg.jpg (gingerbread/images/browseaddons-bg.jpg) skin/gingerbread/images/addons-32.png (images/addons-32.png) skin/gingerbread/images/arrowleft-16.png (gingerbread/images/arrowleft-16.png) @@ -156,13 +157,12 @@ chrome.jar: skin/gingerbread/images/arrowrightdark-16.png (gingerbread/images/arrowrightdark-16.png) skin/gingerbread/images/arrowupdark-16.png (gingerbread/images/arrowupdark-16.png) skin/gingerbread/images/arrowdowndark-16.png (gingerbread/images/arrowdowndark-16.png) - skin/gingerbread/images/popup-bg-hdpi.png (gingerbread/images/popup-bg-hdpi.png) skin/gingerbread/images/popup-selected-item-hdpi.png (gingerbread/images/popup-selected-item-hdpi.png) skin/gingerbread/images/arrowbox-up.png (gingerbread/images/arrowbox-up.png) skin/gingerbread/images/arrowbox-down.png (gingerbread/images/arrowbox-down.png) skin/gingerbread/images/arrowbox-horiz.png (gingerbread/images/arrowbox-horiz.png) - skin/gingerbread/images/check-selected-30.png (gingerbread/images/check-selected-30.png) - skin/gingerbread/images/check-unselected-30.png (gingerbread/images/check-unselected-30.png) + skin/gingerbread/images/check-selected-46.png (gingerbread/images/check-selected-46.png) + skin/gingerbread/images/check-unselected-46.png (gingerbread/images/check-unselected-46.png) skin/gingerbread/images/dropmarker-hdpi.png (gingerbread/images/dropmarker-hdpi.png) skin/gingerbread/images/ratings-18.png (images/ratings-18.png) skin/gingerbread/images/favicon-default-32.png (gingerbread/images/favicon-default-32.png) @@ -186,9 +186,6 @@ chrome.jar: skin/gingerbread/images/bookmark-default-hdpi.png (gingerbread/images/bookmark-default-hdpi.png) skin/gingerbread/images/bookmarks-48.png (gingerbread/images/bookmarks-48.png) skin/gingerbread/images/bookmark-starred-hdpi.png (gingerbread/images/bookmark-starred-hdpi.png) - skin/gingerbread/images/panelrow-active-hdpi.png (gingerbread/images/panelrow-active-hdpi.png) - skin/gingerbread/images/panelrow-default-hdpi.png (gingerbread/images/panelrow-default-hdpi.png) - skin/gingerbread/images/panelrow-selected-hdpi.png (gingerbread/images/panelrow-selected-hdpi.png) skin/gingerbread/images/forward-default-hdpi.png (gingerbread/images/forward-default-hdpi.png) skin/gingerbread/images/downloads-default-hdpi.png (gingerbread/images/downloads-default-hdpi.png) skin/gingerbread/images/settings-default-hdpi.png (gingerbread/images/settings-default-hdpi.png) @@ -205,7 +202,6 @@ chrome.jar: skin/gingerbread/images/mozilla-32.png (images/mozilla-32.png) skin/gingerbread/images/toggle-on.png (gingerbread/images/toggle-on.png) skin/gingerbread/images/toggle-off.png (gingerbread/images/toggle-off.png) - skin/gingerbread/images/sidebarbutton-active-hdpi.png (gingerbread/images/sidebarbutton-active-hdpi.png) skin/gingerbread/images/previous-hdpi.png (gingerbread/images/previous-hdpi.png) skin/gingerbread/images/previous-disabled-hdpi.png (gingerbread/images/previous-disabled-hdpi.png) skin/gingerbread/images/next-hdpi.png (gingerbread/images/next-hdpi.png) diff --git a/modules/libpr0n/src/SVGDocumentWrapper.cpp b/modules/libpr0n/src/SVGDocumentWrapper.cpp index 39b9ad94f69..2c5f6fb04aa 100644 --- a/modules/libpr0n/src/SVGDocumentWrapper.cpp +++ b/modules/libpr0n/src/SVGDocumentWrapper.cpp @@ -326,14 +326,7 @@ SVGDocumentWrapper::Observe(nsISupports* aSubject, // Sever ties from rendering observers to helper-doc's root SVG node nsSVGSVGElement* svgElem = GetRootSVGElem(); if (svgElem) { -#ifdef MOZ_ENABLE_LIBXUL nsSVGEffects::RemoveAllRenderingObservers(svgElem); -#else - // XXXdholbert Can't call static nsSVGEffects functions from imagelib in - // non-libxul builds -- so, this is a hack using a virtual function to - // have the SVG element call the method on our behalf. - svgElem->RemoveAllRenderingObservers(); -#endif // MOZ_ENABLE_LIBXUL } // Clean up at XPCOM shutdown time. diff --git a/modules/libpref/public/Makefile.in b/modules/libpref/public/Makefile.in index 78d87752719..924a2afc237 100644 --- a/modules/libpref/public/Makefile.in +++ b/modules/libpref/public/Makefile.in @@ -45,6 +45,8 @@ include $(DEPTH)/config/autoconf.mk MODULE = pref GRE_MODULE = 1 +EXPORTS_NAMESPACES = mozilla + SDK_XPIDLSRCS = \ nsIPrefService.idl \ nsIPrefBranch.idl \ @@ -59,7 +61,11 @@ XPIDLSRCS = \ EXPORTS = \ PPrefTuple.h \ - PrefTuple.h + PrefTuple.h \ + $(NULL) + +EXPORTS_mozilla = \ + Preferences.h \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/modules/libpref/public/Preferences.h b/modules/libpref/public/Preferences.h new file mode 100644 index 00000000000..cfada7ff482 --- /dev/null +++ b/modules/libpref/public/Preferences.h @@ -0,0 +1,193 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Brian Nesse + * Mats Palmgren + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef mozilla_Preferences_h +#define mozilla_Preferences_h + +#ifndef MOZILLA_INTERNAL_API +#error "This header is only usable from within libxul (MOZILLA_INTERNAL_API)." +#endif + +#include "nsIPrefService.h" +#include "nsIPrefBranch.h" +#include "nsIPrefBranchInternal.h" +#include "nsIObserver.h" +#include "nsCOMPtr.h" +#include "nsWeakReference.h" + +class nsIFile; +class nsCString; +class nsString; + +namespace mozilla { + +class Preferences : public nsIPrefService, + public nsIPrefServiceInternal, + public nsIObserver, + public nsIPrefBranchInternal, + public nsSupportsWeakReference +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIPREFSERVICE + NS_DECL_NSIPREFSERVICEINTERNAL + NS_FORWARD_NSIPREFBRANCH(mRootBranch->) + NS_FORWARD_NSIPREFBRANCH2(mRootBranch->) + NS_DECL_NSIOBSERVER + + Preferences(); + virtual ~Preferences(); + + nsresult Init(); + + /** + * Returns the singleton instance which is addreffed. + */ + static Preferences* GetInstance(); + + /** + * Finallizes global members. + */ + static void Shutdown(); + + /** + * Returns shared pref service instance + * NOTE: not addreffed. + */ + static nsIPrefService* GetService() { return sPreferences; } + + /** + * Returns shared pref branch instance. + * NOTE: not addreffed. + */ + static nsIPrefBranch2* GetRootBranch() + { + return sPreferences ? sPreferences->mRootBranch.get() : nsnull; + } + + /** + * Gets int or bool type pref value with default value if failed to get + * the pref. + */ + static PRBool GetBool(const char* aPref, PRBool aDefault = PR_FALSE) + { + PRBool result = aDefault; + GetBool(aPref, &result); + return result; + } + + static PRInt32 GetInt(const char* aPref, PRInt32 aDefault = 0) + { + PRInt32 result = aDefault; + GetInt(aPref, &result); + return result; + } + + /** + * Gets int or bool type pref value with raw return value of nsIPrefBranch. + * + * @param aPref A pref name. + * @param aResult Must not be NULL. The value is never modified when + * these methods fail. + */ + static nsresult GetBool(const char* aPref, PRBool* aResult); + static nsresult GetInt(const char* aPref, PRInt32* aResult); + + /** + * Gets string type pref value with raw return value of nsIPrefBranch. + * + * @param aPref A pref name. + * @param aResult Must not be NULL. The value is never modified when + * these methods fail. + */ + static nsresult GetChar(const char* aPref, nsCString* aResult); + static nsresult GetChar(const char* aPref, nsString* aResult); + static nsresult GetLocalizedString(const char* aPref, nsString* aResult); + + /** + * Sets various type pref values. + */ + static nsresult SetBool(const char* aPref, PRBool aValue); + static nsresult SetInt(const char* aPref, PRInt32 aValue); + static nsresult SetChar(const char* aPref, const char* aValue); + static nsresult SetChar(const char* aPref, const nsCString &aValue); + static nsresult SetChar(const char* aPref, const PRUnichar* aValue); + static nsresult SetChar(const char* aPref, const nsString &aValue); + + /** + * Clears user set pref. + */ + static nsresult ClearUser(const char* aPref); + + /** + * Adds/Removes the observer for the root pref branch. + * The observer is referenced strongly if AddStrongObserver is used. On the + * other hand, it is referenced weakly, if AddWeakObserver is used. + * See nsIPrefBran2.idl for the detail. + */ + static nsresult AddStrongObserver(nsIObserver* aObserver, const char* aPref); + static nsresult AddWeakObserver(nsIObserver* aObserver, const char* aPref); + static nsresult RemoveObserver(nsIObserver* aObserver, const char* aPref); + +protected: + nsresult NotifyServiceObservers(const char *aSubject); + nsresult UseDefaultPrefFile(); + nsresult UseUserPrefFile(); + nsresult ReadAndOwnUserPrefFile(nsIFile *aFile); + nsresult ReadAndOwnSharedUserPrefFile(nsIFile *aFile); + nsresult SavePrefFileInternal(nsIFile* aFile); + nsresult WritePrefFile(nsIFile* aFile); + nsresult MakeBackupPrefFile(nsIFile *aFile); + +private: + nsCOMPtr mRootBranch; + nsCOMPtr mCurrentFile; + + static Preferences* sPreferences; + static PRBool sShutdown; + + /** + * Init static members. TRUE if it succeeded. Otherwise, FALSE. + */ + static PRBool InitStaticMembers(); +}; + +} // namespace mozilla + +#endif // mozilla_Preferences_h diff --git a/modules/libpref/src/Makefile.in b/modules/libpref/src/Makefile.in index 1e0419b71f3..b4080082a1d 100644 --- a/modules/libpref/src/Makefile.in +++ b/modules/libpref/src/Makefile.in @@ -47,18 +47,15 @@ LIBRARY_NAME = pref EXPORT_LIBRARY = 1 IS_COMPONENT = 1 MODULE_NAME = nsPrefModule -ifeq ($(OS_ARCH)$(MOZ_ENABLE_LIBXUL),WINNT) -LIBRARY_NAME = xppref32 -endif GRE_MODULE = 1 LIBXUL_LIBRARY = 1 CPPSRCS = \ nsPrefBranch.cpp \ - nsPrefService.cpp \ nsPrefsFactory.cpp \ prefapi.cpp \ prefread.cpp \ + Preferences.cpp \ $(NULL) DEFINES += -DOS_ARCH=$(OS_ARCH) \ diff --git a/modules/libpref/src/nsPrefService.cpp b/modules/libpref/src/Preferences.cpp similarity index 79% rename from modules/libpref/src/nsPrefService.cpp rename to modules/libpref/src/Preferences.cpp index 953ddbd625e..10167fdd099 100644 --- a/modules/libpref/src/nsPrefService.cpp +++ b/modules/libpref/src/Preferences.cpp @@ -40,7 +40,7 @@ #include "mozilla/dom/ContentChild.h" #include "nsXULAppAPI.h" -#include "nsPrefService.h" +#include "mozilla/Preferences.h" #include "nsAppDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h" #include "nsICategoryManager.h" @@ -73,6 +73,8 @@ #include "mozilla/Omnijar.h" #include "nsZipArchive.h" +namespace mozilla { + // Definitions #define INITIAL_PREF_FILES 10 static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID); @@ -82,17 +84,60 @@ static nsresult openPrefFile(nsIFile* aFile); static nsresult pref_InitInitialObjects(void); static nsresult pref_LoadPrefsInDirList(const char *listId); +Preferences* Preferences::sPreferences = nsnull; +PRBool Preferences::sShutdown = PR_FALSE; + +// static +Preferences* +Preferences::GetInstance() +{ + NS_ENSURE_TRUE(!sShutdown, nsnull); + + if (sPreferences) { + NS_ADDREF(sPreferences); + return sPreferences; + } + + InitStaticMembers(); + NS_IF_ADDREF(sPreferences); + return sPreferences; +} + +// static +PRBool +Preferences::InitStaticMembers() +{ + if (sShutdown || sPreferences) { + return sPreferences != nsnull; + } + + sPreferences = new Preferences(); + NS_ADDREF(sPreferences); + if (NS_FAILED(sPreferences->Init()) || !sPreferences->mRootBranch) { + NS_RELEASE(sPreferences); + } + return sPreferences != nsnull; +} + +// static +void +Preferences::Shutdown() +{ + sShutdown = PR_TRUE; // Don't create the singleton instance after here. + NS_IF_RELEASE(sPreferences); +} + //----------------------------------------------------------------------------- /* * Constructor/Destructor */ -nsPrefService::nsPrefService() +Preferences::Preferences() { } -nsPrefService::~nsPrefService() +Preferences::~Preferences() { PREF_Cleanup(); } @@ -102,10 +147,10 @@ nsPrefService::~nsPrefService() * nsISupports Implementation */ -NS_IMPL_THREADSAFE_ADDREF(nsPrefService) -NS_IMPL_THREADSAFE_RELEASE(nsPrefService) +NS_IMPL_THREADSAFE_ADDREF(Preferences) +NS_IMPL_THREADSAFE_RELEASE(Preferences) -NS_INTERFACE_MAP_BEGIN(nsPrefService) +NS_INTERFACE_MAP_BEGIN(Preferences) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIPrefService) NS_INTERFACE_MAP_ENTRY(nsIPrefService) NS_INTERFACE_MAP_ENTRY(nsIPrefServiceInternal) @@ -121,7 +166,8 @@ NS_INTERFACE_MAP_END * nsIPrefService Implementation */ -nsresult nsPrefService::Init() +nsresult +Preferences::Init() { nsPrefBranch *rootBranch = new nsPrefBranch("", PR_FALSE); if (!rootBranch) @@ -180,7 +226,9 @@ nsresult nsPrefService::Init() return(rv); } -NS_IMETHODIMP nsPrefService::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) +NS_IMETHODIMP +Preferences::Observe(nsISupports *aSubject, const char *aTopic, + const PRUnichar *someData) { if (XRE_GetProcessType() == GeckoProcessType_Content) return NS_ERROR_NOT_AVAILABLE; @@ -209,7 +257,8 @@ NS_IMETHODIMP nsPrefService::Observe(nsISupports *aSubject, const char *aTopic, } -NS_IMETHODIMP nsPrefService::ReadUserPrefs(nsIFile *aFile) +NS_IMETHODIMP +Preferences::ReadUserPrefs(nsIFile *aFile) { if (XRE_GetProcessType() == GeckoProcessType_Content) { NS_ERROR("cannot load prefs from content process"); @@ -230,7 +279,8 @@ NS_IMETHODIMP nsPrefService::ReadUserPrefs(nsIFile *aFile) return rv; } -NS_IMETHODIMP nsPrefService::ResetPrefs() +NS_IMETHODIMP +Preferences::ResetPrefs() { if (XRE_GetProcessType() == GeckoProcessType_Content) { NS_ERROR("cannot set prefs from content process"); @@ -246,7 +296,8 @@ NS_IMETHODIMP nsPrefService::ResetPrefs() return pref_InitInitialObjects(); } -NS_IMETHODIMP nsPrefService::ResetUserPrefs() +NS_IMETHODIMP +Preferences::ResetUserPrefs() { if (XRE_GetProcessType() == GeckoProcessType_Content) { NS_ERROR("cannot set prefs from content process"); @@ -257,7 +308,8 @@ NS_IMETHODIMP nsPrefService::ResetUserPrefs() return NS_OK; } -NS_IMETHODIMP nsPrefService::SavePrefFile(nsIFile *aFile) +NS_IMETHODIMP +Preferences::SavePrefFile(nsIFile *aFile) { if (XRE_GetProcessType() == GeckoProcessType_Content) { NS_ERROR("cannot save prefs from content process"); @@ -268,7 +320,8 @@ NS_IMETHODIMP nsPrefService::SavePrefFile(nsIFile *aFile) } /* part of nsIPrefServiceInternal */ -NS_IMETHODIMP nsPrefService::ReadExtensionPrefs(nsILocalFile *aFile) +NS_IMETHODIMP +Preferences::ReadExtensionPrefs(nsILocalFile *aFile) { nsresult rv; nsCOMPtr reader = do_CreateInstance(kZipReaderCID, &rv); @@ -316,25 +369,27 @@ NS_IMETHODIMP nsPrefService::ReadExtensionPrefs(nsILocalFile *aFile) return rv; } -NS_IMETHODIMP nsPrefService::PrefHasUserValue(const nsACString& aPrefName, - PRBool* aHasValue) +NS_IMETHODIMP +Preferences::PrefHasUserValue(const nsACString& aPrefName, PRBool* aHasValue) { *aHasValue = PREF_HasUserPref(aPrefName.BeginReading()); return NS_OK; } -NS_IMETHODIMP nsPrefService::SetPreference(const PrefTuple *aPref) +NS_IMETHODIMP +Preferences::SetPreference(const PrefTuple *aPref) { return pref_SetPrefTuple(*aPref, PR_TRUE); } -NS_IMETHODIMP nsPrefService::ClearContentPref(const nsACString& aPrefName) +NS_IMETHODIMP +Preferences::ClearContentPref(const nsACString& aPrefName) { return PREF_ClearUserPref(aPrefName.BeginReading()); } -NS_IMETHODIMP nsPrefService::MirrorPreference(const nsACString& aPrefName, - PrefTuple *aPref) +NS_IMETHODIMP +Preferences::MirrorPreference(const nsACString& aPrefName, PrefTuple *aPref) { PrefHashEntry *pref = pref_HashTableLookup(PromiseFlatCString(aPrefName).get()); @@ -346,7 +401,9 @@ NS_IMETHODIMP nsPrefService::MirrorPreference(const nsACString& aPrefName, return NS_OK; } -NS_IMETHODIMP nsPrefService::MirrorPreferences(nsTArray *aArray) +NS_IMETHODIMP +Preferences::MirrorPreferences(nsTArray *aArray) { aArray->SetCapacity(PL_DHASH_TABLE_SIZE(&gHashTable)); @@ -355,7 +412,8 @@ NS_IMETHODIMP nsPrefService::MirrorPreferences(nsTArray observerService = mozilla::services::GetObserverService(); @@ -400,7 +460,8 @@ nsresult nsPrefService::NotifyServiceObservers(const char *aTopic) return NS_OK; } -nsresult nsPrefService::UseDefaultPrefFile() +nsresult +Preferences::UseDefaultPrefFile() { nsresult rv, rv2; nsCOMPtr aFile; @@ -420,7 +481,8 @@ nsresult nsPrefService::UseDefaultPrefFile() return rv; } -nsresult nsPrefService::UseUserPrefFile() +nsresult +Preferences::UseUserPrefFile() { nsresult rv = NS_OK; nsCOMPtr aFile; @@ -442,7 +504,8 @@ nsresult nsPrefService::UseUserPrefFile() return rv; } -nsresult nsPrefService::MakeBackupPrefFile(nsIFile *aFile) +nsresult +Preferences::MakeBackupPrefFile(nsIFile *aFile) { // Example: this copies "prefs.js" to "Invalidprefs.js" in the same directory. // "Invalidprefs.js" is removed if it exists, prior to making the copy. @@ -466,7 +529,8 @@ nsresult nsPrefService::MakeBackupPrefFile(nsIFile *aFile) return rv; } -nsresult nsPrefService::ReadAndOwnUserPrefFile(nsIFile *aFile) +nsresult +Preferences::ReadAndOwnUserPrefFile(nsIFile *aFile) { NS_ENSURE_ARG(aFile); @@ -492,7 +556,8 @@ nsresult nsPrefService::ReadAndOwnUserPrefFile(nsIFile *aFile) return rv; } -nsresult nsPrefService::SavePrefFileInternal(nsIFile *aFile) +nsresult +Preferences::SavePrefFileInternal(nsIFile *aFile) { if (nsnull == aFile) { // the gDirty flag tells us if we should write to mCurrentFile @@ -511,7 +576,8 @@ nsresult nsPrefService::SavePrefFileInternal(nsIFile *aFile) } } -nsresult nsPrefService::WritePrefFile(nsIFile* aFile) +nsresult +Preferences::WritePrefFile(nsIFile* aFile) { const char outHeader[] = "# Mozilla User Preferences" @@ -927,3 +993,162 @@ static nsresult pref_InitInitialObjects() return pref_LoadPrefsInDirList(NS_EXT_PREFS_DEFAULTS_DIR_LIST); } + + +/****************************************************************************** + * + * static utilities + * + ******************************************************************************/ + +// static +nsresult +Preferences::GetBool(const char* aPref, PRBool* aResult) +{ + NS_PRECONDITION(aResult, "aResult must not be NULL"); + NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE); + return sPreferences->mRootBranch->GetBoolPref(aPref, aResult); +} + +// static +nsresult +Preferences::GetInt(const char* aPref, PRInt32* aResult) +{ + NS_PRECONDITION(aResult, "aResult must not be NULL"); + NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE); + return sPreferences->mRootBranch->GetIntPref(aPref, aResult); +} + +// static +nsresult +Preferences::GetChar(const char* aPref, nsCString* aResult) +{ + NS_PRECONDITION(aResult, "aResult must not be NULL"); + NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE); + nsAdoptingCString result; + nsresult rv = + sPreferences->mRootBranch->GetCharPref(aPref, getter_Copies(result)); + if (NS_SUCCEEDED(rv)) { + *aResult = result; + } + return rv; +} + +// static +nsresult +Preferences::GetChar(const char* aPref, nsString* aResult) +{ + NS_PRECONDITION(aResult, "aResult must not be NULL"); + NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE); + nsAdoptingCString result; + nsresult rv = + sPreferences->mRootBranch->GetCharPref(aPref, getter_Copies(result)); + if (NS_SUCCEEDED(rv)) { + CopyUTF8toUTF16(result, *aResult); + } + return rv; +} + +// static +nsresult +Preferences::GetLocalizedString(const char* aPref, nsString* aResult) +{ + NS_PRECONDITION(aResult, "aResult must not be NULL"); + NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE); + nsCOMPtr prefLocalString; + nsresult rv = sPreferences->mRootBranch->GetComplexValue(aPref, + NS_GET_IID(nsIPrefLocalizedString), + getter_AddRefs(prefLocalString)); + if (NS_SUCCEEDED(rv)) { + if (prefLocalString) { + prefLocalString->GetData(getter_Copies(*aResult)); + } else { + aResult->Truncate(); + } + } + return rv; +} + +// static +nsresult +Preferences::SetChar(const char* aPref, const char* aValue) +{ + NS_ENSURE_TRUE(InitStaticMembers(), PR_FALSE); + return sPreferences->mRootBranch->SetCharPref(aPref, aValue); +} + +// static +nsresult +Preferences::SetChar(const char* aPref, const nsCString &aValue) +{ + return SetChar(aPref, nsPromiseFlatCString(aValue).get()); +} + +// static +nsresult +Preferences::SetChar(const char* aPref, const PRUnichar* aValue) +{ + NS_ConvertUTF16toUTF8 utf8(aValue); + return SetChar(aPref, utf8.get()); +} + +// static +nsresult +Preferences::SetChar(const char* aPref, const nsString &aValue) +{ + NS_ConvertUTF16toUTF8 utf8(aValue); + return SetChar(aPref, utf8.get()); +} + +// static +nsresult +Preferences::SetBool(const char* aPref, PRBool aValue) +{ + NS_ENSURE_TRUE(InitStaticMembers(), PR_FALSE); + return sPreferences->mRootBranch->SetBoolPref(aPref, aValue); +} + +// static +nsresult +Preferences::SetInt(const char* aPref, PRInt32 aValue) +{ + NS_ENSURE_TRUE(InitStaticMembers(), PR_FALSE); + return sPreferences->mRootBranch->SetIntPref(aPref, aValue); +} + +// static +nsresult +Preferences::ClearUser(const char* aPref) +{ + NS_ENSURE_TRUE(InitStaticMembers(), PR_FALSE); + return sPreferences->mRootBranch->ClearUserPref(aPref); +} + +// static +nsresult +Preferences::AddStrongObserver(nsIObserver* aObserver, + const char* aPref) +{ + NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE); + return sPreferences->mRootBranch->AddObserver(aPref, aObserver, PR_FALSE); +} + +// static +nsresult +Preferences::AddWeakObserver(nsIObserver* aObserver, + const char* aPref) +{ + NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE); + return sPreferences->mRootBranch->AddObserver(aPref, aObserver, PR_TRUE); +} + +// static +nsresult +Preferences::RemoveObserver(nsIObserver* aObserver, + const char* aPref) +{ + NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE); + return sPreferences->mRootBranch->RemoveObserver(aPref, aObserver); +} + +} // namespace mozilla diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 97459928bf9..13496d79944 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -861,6 +861,7 @@ pref("network.IDN.whitelist.kr", true); pref("network.IDN.whitelist.li", true); pref("network.IDN.whitelist.lt", true); pref("network.IDN.whitelist.lu", true); +pref("network.IDN.whitelist.lv", true); pref("network.IDN.whitelist.no", true); pref("network.IDN.whitelist.nu", true); pref("network.IDN.whitelist.nz", true); @@ -889,6 +890,9 @@ pref("network.IDN.whitelist.xn--mgba3a4f16a", true); pref("network.IDN.whitelist.xn--mgba3a4fra", true); // jo, Jordan, . pref("network.IDN.whitelist.xn--mgbayh7gpa", true); +// lk, Sri Lanka, . and . +pref("network.IDN.whitelist.xn--fzc2c9e2c", true); +pref("network.IDN.whitelist.xn--xkc2al3hye2a", true); // qa, Qatar, . pref("network.IDN.whitelist.xn--wgbl6a", true); // ru, Russian Federation, . @@ -898,11 +902,14 @@ pref("network.IDN.whitelist.xn--mgberp4a5d4ar", true); pref("network.IDN.whitelist.xn--mgberp4a5d4a87g", true); pref("network.IDN.whitelist.xn--mgbqly7c0a67fbc", true); pref("network.IDN.whitelist.xn--mgbqly7cvafr", true); +// sy, Syria, . +pref("network.IDN.whitelist.xn--ogbpf8fl", true); // tw, Taiwan, <.Taiwan> with variants pref("network.IDN.whitelist.xn--kpry57d", true); // Traditional pref("network.IDN.whitelist.xn--kprw13d", true); // Simplified // gTLDs +pref("network.IDN.whitelist.asia", true); pref("network.IDN.whitelist.biz", true); pref("network.IDN.whitelist.cat", true); pref("network.IDN.whitelist.info", true); @@ -1878,7 +1885,7 @@ pref("ui.panel.default_level_parent", false); pref("mousewheel.system_scroll_override_on_root_content.enabled", true); // High resolution scrolling with supported mouse drivers on Vista or later. -pref("mousewheel.enable_pixel_scrolling", false); +pref("mousewheel.enable_pixel_scrolling", true); // If your mouse drive sends WM_*SCROLL messages when you turn your mouse wheel, // set this to true. Then, gecko processes them as mouse wheel messages. diff --git a/modules/libpref/src/nsPrefService.h b/modules/libpref/src/nsPrefService.h deleted file mode 100644 index 9cab286bfac..00000000000 --- a/modules/libpref/src/nsPrefService.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Brian Nesse - * Mats Palmgren - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsPrefService_h__ -#define nsPrefService_h__ - -#include "nsIPrefService.h" -#include "nsIPrefBranch.h" -#include "nsIPrefBranchInternal.h" -#include "nsIObserver.h" -#include "nsCOMPtr.h" -#include "nsWeakReference.h" - -class nsIFile; - -class nsPrefService : public nsIPrefService, - public nsIPrefServiceInternal, - public nsIObserver, - public nsIPrefBranchInternal, - public nsSupportsWeakReference -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIPREFSERVICE - NS_DECL_NSIPREFSERVICEINTERNAL - NS_FORWARD_NSIPREFBRANCH(mRootBranch->) - NS_FORWARD_NSIPREFBRANCH2(mRootBranch->) - NS_DECL_NSIOBSERVER - - nsPrefService(); - virtual ~nsPrefService(); - - nsresult Init(); - -protected: - nsresult NotifyServiceObservers(const char *aSubject); - nsresult UseDefaultPrefFile(); - nsresult UseUserPrefFile(); - nsresult ReadAndOwnUserPrefFile(nsIFile *aFile); - nsresult ReadAndOwnSharedUserPrefFile(nsIFile *aFile); - nsresult SavePrefFileInternal(nsIFile* aFile); - nsresult WritePrefFile(nsIFile* aFile); - nsresult MakeBackupPrefFile(nsIFile *aFile); - -private: - nsCOMPtr mRootBranch; - nsCOMPtr mCurrentFile; -}; - -#endif // nsPrefService_h__ diff --git a/modules/libpref/src/nsPrefsFactory.cpp b/modules/libpref/src/nsPrefsFactory.cpp index aefd8a44e67..0f29fbb5232 100644 --- a/modules/libpref/src/nsPrefsFactory.cpp +++ b/modules/libpref/src/nsPrefsFactory.cpp @@ -37,12 +37,13 @@ * ***** END LICENSE BLOCK ***** */ #include "mozilla/ModuleUtils.h" -#include "nsPrefService.h" +#include "mozilla/Preferences.h" #include "nsPrefBranch.h" #include "prefapi.h" +using namespace mozilla; -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefService, Init) +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(Preferences, Preferences::GetInstance) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefLocalizedString, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(nsRelativeFilePref) @@ -51,7 +52,7 @@ static NS_DEFINE_CID(kPrefLocalizedStringCID, NS_PREFLOCALIZEDSTRING_CID); static NS_DEFINE_CID(kRelativeFilePrefCID, NS_RELATIVEFILEPREF_CID); static mozilla::Module::CIDEntry kPrefCIDs[] = { - { &kPrefServiceCID, true, NULL, nsPrefServiceConstructor }, + { &kPrefServiceCID, true, NULL, PreferencesConstructor }, { &kPrefLocalizedStringCID, false, NULL, nsPrefLocalizedStringConstructor }, { &kRelativeFilePrefCID, false, NULL, nsRelativeFilePrefConstructor }, { NULL } @@ -69,6 +70,7 @@ static mozilla::Module::ContractIDEntry kPrefContracts[] = { static void UnloadPrefsModule() { + Preferences::Shutdown(); PREF_Cleanup(); } diff --git a/modules/zlib/src/Makefile.in b/modules/zlib/src/Makefile.in index 9179a3aa40c..79003fa5dcf 100644 --- a/modules/zlib/src/Makefile.in +++ b/modules/zlib/src/Makefile.in @@ -49,15 +49,6 @@ GRE_MODULE = 1 LIBXUL_LIBRARY = 1 DIST_INSTALL = 1 -ifndef MOZ_ENABLE_LIBXUL -ifeq ($(OS_ARCH),WINNT) -ifndef GNU_CC -MAPFILE = $(LIBRARY_NAME).map -DEFFILE = $(win_srcdir)/zlib.def -endif -endif -endif - ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) DEFINES += -DZLIB_DLL=1 endif diff --git a/modules/zlib/src/mozzconf.h b/modules/zlib/src/mozzconf.h index 1f0c98da47b..08f25a3c6d4 100644 --- a/modules/zlib/src/mozzconf.h +++ b/modules/zlib/src/mozzconf.h @@ -39,10 +39,6 @@ #if defined(XP_WIN) && defined(ZLIB_DLL) #undef ZLIB_DLL -#elif defined(HAVE_VISIBILITY_ATTRIBUTE) && !defined(MOZ_ENABLE_LIBXUL) -#define ZEXTERN __attribute__((visibility ("default"))) extern -#elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC)) && !defined(MOZ_ENABLE_LIBXUL) -#define ZEXTERN __global extern #endif /* Exported Symbols */ diff --git a/netwerk/base/src/nsDNSPrefetch.cpp b/netwerk/base/src/nsDNSPrefetch.cpp index 472557167c1..e47579a78c6 100644 --- a/netwerk/base/src/nsDNSPrefetch.cpp +++ b/netwerk/base/src/nsDNSPrefetch.cpp @@ -66,7 +66,8 @@ nsDNSPrefetch::Shutdown() return NS_OK; } -nsDNSPrefetch::nsDNSPrefetch(nsIURI *aURI) +nsDNSPrefetch::nsDNSPrefetch(nsIURI *aURI, PRBool storeTiming) + : mStoreTiming(storeTiming) { aURI->GetAsciiHost(mHostname); } @@ -82,6 +83,12 @@ nsDNSPrefetch::Prefetch(PRUint16 flags) nsCOMPtr tmpOutstanding; + if (mStoreTiming) + mStartTimestamp = mozilla::TimeStamp::Now(); + // If AsyncResolve fails, for example because prefetching is disabled, + // then our timing will be useless. However, in such a case, + // mEndTimestamp will be a null timestamp and callers should check + // TimingsValid() before using the timing. return sDNSService->AsyncResolve(mHostname, flags | nsIDNSService::RESOLVE_SPECULATE, this, nsnull, getter_AddRefs(tmpOutstanding)); } @@ -112,5 +119,7 @@ nsDNSPrefetch::OnLookupComplete(nsICancelable *request, nsIDNSRecord *rec, nsresult status) { + if (mStoreTiming) + mEndTimestamp = mozilla::TimeStamp::Now(); return NS_OK; } diff --git a/netwerk/base/src/nsDNSPrefetch.h b/netwerk/base/src/nsDNSPrefetch.h index 9c4535cb1f0..0c2c849acd2 100644 --- a/netwerk/base/src/nsDNSPrefetch.h +++ b/netwerk/base/src/nsDNSPrefetch.h @@ -41,6 +41,7 @@ #include "nsCOMPtr.h" #include "nsString.h" +#include "mozilla/TimeStamp.h" #include "nsIDNSListener.h" @@ -53,7 +54,13 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSIDNSLISTENER - nsDNSPrefetch(nsIURI *aURI); + nsDNSPrefetch(nsIURI *aURI, PRBool storeTiming); + bool TimingsValid() const { + return !mStartTimestamp.IsNull() && !mEndTimestamp.IsNull(); + } + // Only use the two timings if TimingsValid() returns true + const mozilla::TimeStamp& StartTimestamp() const { return mStartTimestamp; } + const mozilla::TimeStamp& EndTimestamp() const { return mEndTimestamp; } static nsresult Initialize(nsIDNSService *aDNSService); static nsresult Shutdown(); @@ -64,8 +71,11 @@ public: nsresult PrefetchLow(); private: - nsCString mHostname; - + nsCString mHostname; + PRBool mStoreTiming; + mozilla::TimeStamp mStartTimestamp; + mozilla::TimeStamp mEndTimestamp; + nsresult Prefetch(PRUint16 flags); }; diff --git a/netwerk/base/src/nsSimpleNestedURI.cpp b/netwerk/base/src/nsSimpleNestedURI.cpp index 2a56726a3c5..327cf0836a2 100644 --- a/netwerk/base/src/nsSimpleNestedURI.cpp +++ b/netwerk/base/src/nsSimpleNestedURI.cpp @@ -176,9 +176,7 @@ nsSimpleNestedURI::StartClone(nsSimpleURI::RefHandlingEnum refHandlingMode) } nsSimpleNestedURI* url = new nsSimpleNestedURI(innerClone); - if (url) { - url->SetMutable(PR_FALSE); - } + url->SetMutable(PR_FALSE); return url; } diff --git a/netwerk/base/src/nsSimpleURI.cpp b/netwerk/base/src/nsSimpleURI.cpp index 1a7eb0a3b94..e291a6ff0c2 100644 --- a/netwerk/base/src/nsSimpleURI.cpp +++ b/netwerk/base/src/nsSimpleURI.cpp @@ -115,8 +115,10 @@ nsSimpleURI::Read(nsIObjectInputStream* aStream) mIsRefValid = isRefValid; if (isRefValid) { - rv = aStream->ReadCString(mRef); - if (NS_FAILED(rv)) return rv; + rv = aStream->ReadCString(mRef); + if (NS_FAILED(rv)) return rv; + } else { + mRef.Truncate(); // invariant: mRef should be empty when it's not valid } return NS_OK; @@ -166,6 +168,7 @@ nsSimpleURI::Read(const IPC::Message *aMsg, void **aIter) if (mIsRefValid) { return ReadParam(aMsg, aIter, &mRef); } + mRef.Truncate(); // invariant: mRef should be empty when it's not valid return PR_TRUE; } @@ -191,6 +194,8 @@ nsSimpleURI::GetSpec(nsACString &result) result = mScheme + NS_LITERAL_CSTRING(":") + mPath; if (mIsRefValid) { result += NS_LITERAL_CSTRING("#") + mRef; + } else { + NS_ABORT_IF_FALSE(mRef.IsEmpty(), "mIsRefValid/mRef invariant broken"); } return NS_OK; } @@ -368,6 +373,7 @@ nsSimpleURI::SetPath(const nsACString &path) PRInt32 hashPos = path.FindChar('#'); if (hashPos < 0) { mIsRefValid = PR_FALSE; + mRef.Truncate(); // invariant: mRef should be empty when it's not valid mPath = path; return NS_OK; } @@ -380,6 +386,7 @@ NS_IMETHODIMP nsSimpleURI::GetRef(nsACString &result) { if (!mIsRefValid) { + NS_ABORT_IF_FALSE(mRef.IsEmpty(), "mIsRefValid/mRef invariant broken"); result.Truncate(); } else { result = mRef; @@ -398,7 +405,7 @@ nsSimpleURI::SetRef(const nsACString &aRef) if (aRef.IsEmpty()) { // Empty string means to remove ref completely. mIsRefValid = PR_FALSE; - mRef.Truncate(); + mRef.Truncate(); // invariant: mRef should be empty when it's not valid return NS_OK; } @@ -503,6 +510,7 @@ nsSimpleURI::CloneInternal(nsSimpleURI::RefHandlingEnum refHandlingMode, url->mPath = mPath; if (refHandlingMode == eHonorRef) { url->mRef = mRef; + url->mIsRefValid = mIsRefValid; } url.forget(result); diff --git a/netwerk/cache/nsDiskCacheDevice.cpp b/netwerk/cache/nsDiskCacheDevice.cpp index f1077873833..af94d5ad4af 100644 --- a/netwerk/cache/nsDiskCacheDevice.cpp +++ b/netwerk/cache/nsDiskCacheDevice.cpp @@ -863,8 +863,10 @@ nsDiskCacheDevice::OnDataSizeChange(nsCacheEntry * entry, PRInt32 deltaSize) PRUint32 sizeK = ((entry->DataSize() + 0x03FF) >> 10); // round up to next 1k - NS_ASSERTION(sizeK <= USHRT_MAX, "data size out of range"); - NS_ASSERTION(newSizeK <= USHRT_MAX, "data size out of range"); + // In total count we ignore anything over kMaxDataSizeK (bug #651100), so + // the target capacity should be calculated the same way. + if (sizeK > kMaxDataSizeK) sizeK = kMaxDataSizeK; + if (newSizeK > kMaxDataSizeK) newSizeK = kMaxDataSizeK; // pre-evict entries to make space for new data PRUint32 targetCapacity = mCacheCapacity > (newSizeK - sizeK) diff --git a/netwerk/cache/nsDiskCacheMap.cpp b/netwerk/cache/nsDiskCacheMap.cpp index 3a89378e3cc..296b0bd0d28 100644 --- a/netwerk/cache/nsDiskCacheMap.cpp +++ b/netwerk/cache/nsDiskCacheMap.cpp @@ -580,8 +580,10 @@ nsDiskCacheMap::EvictRecords( nsDiskCacheRecordVisitor * visitor) tempRank[bucketIndex] = mHeader.mEvictionRank[bucketIndex]; // Maximum number of iterations determined by number of records - // as a safety limiter for the loop - for (int n = 0; n < mHeader.mEntryCount; ++n) { + // as a safety limiter for the loop. Use a copy of mHeader.mEntryCount since + // the value could decrease if some entry is evicted. + PRInt32 entryCount = mHeader.mEntryCount; + for (int n = 0; n < entryCount; ++n) { // find bucket with highest eviction rank PRUint32 rank = 0; @@ -829,7 +831,6 @@ nsDiskCacheMap::WriteDiskCacheEntry(nsDiskCacheBinding * binding) if ((binding->mRecord.MetaFile() == 0) && (fileIndex == 0)) { // keeping the separate file // just decrement total - // XXX if bindRecord.MetaFileSize == USHRT_MAX, stat the file to see how big it is DecrementTotalSize(binding->mRecord.MetaFileSize()); NS_ASSERTION(binding->mRecord.MetaFileGeneration() == binding->mGeneration, "generations out of sync"); @@ -877,14 +878,15 @@ nsDiskCacheMap::WriteDiskCacheEntry(nsDiskCacheBinding * binding) if (fileIndex == 0) { // Write entry data to separate file PRUint32 metaFileSizeK = ((size + 0x03FF) >> 10); // round up to nearest 1k - nsCOMPtr localFile; - - // XXX handle metaFileSizeK > USHRT_MAX + if (metaFileSizeK > kMaxDataSizeK) + metaFileSizeK = kMaxDataSizeK; + binding->mRecord.SetMetaFileGeneration(binding->mGeneration); binding->mRecord.SetMetaFileSize(metaFileSizeK); rv = UpdateRecord(&binding->mRecord); NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr localFile; rv = GetLocalFileForDiskCacheRecord(&binding->mRecord, nsDiskCache::kMetaData, PR_TRUE, @@ -904,7 +906,7 @@ nsDiskCacheMap::WriteDiskCacheEntry(nsDiskCacheBinding * binding) if ((bytesWritten != (PRInt32)size) || (err != PR_SUCCESS)) { return NS_ERROR_UNEXPECTED; } - // XXX handle metaFileSizeK == USHRT_MAX + IncrementTotalSize(metaFileSizeK); } diff --git a/netwerk/cache/nsDiskCacheMap.h b/netwerk/cache/nsDiskCacheMap.h index 281390b2ef2..15511afb6a1 100644 --- a/netwerk/cache/nsDiskCacheMap.h +++ b/netwerk/cache/nsDiskCacheMap.h @@ -78,9 +78,9 @@ struct nsDiskCacheEntry; * 2 = 1k block file * 3 = 4k block file * - * eFileSizeMask note: Files larger than 64 MiB have zero size stored in the - * location. The file itself must be examined to determine - * its actual size. (XXX This is broken in places -darin) + * eFileSizeMask note: Files larger than 65535 KiB have this limit stored in + * the location. The file itself must be examined to + * determine its actual size if necessary. * *****************************************************************************/ @@ -99,10 +99,18 @@ struct nsDiskCacheEntry; #define kMinRecordCount 512 #define kSeparateFile 0 -// #define must always be <= 65535KB, or overflow. See bug 443067 Comment 8 #define kMaxDataFileSize 5 * 1024 * 1024 // 5 MB (in bytes) #define kBuckets (1 << 5) // must be a power of 2! +// Maximum size in K which can be stored in the location (see eFileSizeMask). +// Both data and metadata can be larger, but only up to kMaxDataSizeK can be +// counted into total cache size. I.e. if there are entries where either data or +// metadata is larger than kMaxDataSizeK, the total cache size will be +// inaccurate (smaller) than the actual cache size. The alternative is to stat +// the files to find the real size, which was decided against for performance +// reasons. See bug #651100 comment #21. +#define kMaxDataSizeK 0xFFFF + // preallocate up to 1MB of separate cache file #define kPreallocateLimit 1 * 1024 * 1024 diff --git a/netwerk/cache/nsDiskCacheStreams.cpp b/netwerk/cache/nsDiskCacheStreams.cpp index 36cd1eaea42..ef1b24fea2a 100644 --- a/netwerk/cache/nsDiskCacheStreams.cpp +++ b/netwerk/cache/nsDiskCacheStreams.cpp @@ -650,8 +650,12 @@ nsDiskCacheStreamIO::UpdateFileSize() nsDiskCacheRecord * record = &mBinding->mRecord; const PRUint32 oldSizeK = record->DataFileSize(); - const PRUint32 newSizeK = (mStreamEnd + 0x03FF) >> 10; - + PRUint32 newSizeK = (mStreamEnd + 0x03FF) >> 10; + + // make sure the size won't overflow (bug #651100) + if (newSizeK > kMaxDataSizeK) + newSizeK = kMaxDataSizeK; + if (newSizeK == oldSizeK) return; record->SetDataFileSize(newSizeK); diff --git a/netwerk/dns/effective_tld_names.dat b/netwerk/dns/effective_tld_names.dat index 697a9f95008..87b2f33b7ad 100644 --- a/netwerk/dns/effective_tld_names.dat +++ b/netwerk/dns/effective_tld_names.dat @@ -2680,6 +2680,9 @@ nl // BV.nl will be a registry for dutch BV's (besloten vennootschap) bv.nl +// the co.nl domain is managed by CoDNS B.V. Added 2010-05-23. +co.nl + // no : http://www.norid.no/regelverk/index.en.html // The Norwegian registry has declined to notify us of updates. The web pages // referenced below are the official source of the data. There is also an @@ -3447,6 +3450,9 @@ våler.østfold.no valer.hedmark.no våler.hedmark.no +// the co.no domain is managed by CoDNS B.V. Added 2010-05-23. +co.no + // np : http://www.mos.com.np/register.html *.np @@ -4271,7 +4277,6 @@ mil.to // tr : http://en.wikipedia.org/wiki/.tr *.tr !nic.tr -!tsk.tr // Used by government in the TRNC // http://en.wikipedia.org/wiki/.nc.tr gov.nc.tr @@ -4402,9 +4407,12 @@ or.ug !bl.uk !british-library.uk !icnet.uk +!gov.uk !jet.uk +!mod.uk !nel.uk !nhs.uk +!nic.uk !nls.uk !national-library-scotland.uk !parliament.uk diff --git a/netwerk/protocol/about/nsAboutProtocolHandler.cpp b/netwerk/protocol/about/nsAboutProtocolHandler.cpp index 158104da280..9836483d5eb 100644 --- a/netwerk/protocol/about/nsAboutProtocolHandler.cpp +++ b/netwerk/protocol/about/nsAboutProtocolHandler.cpp @@ -352,21 +352,24 @@ nsNestedAboutURI::Write(IPC::Message *aMsg) // nsSimpleURI /* virtual */ nsSimpleURI* -nsNestedAboutURI::StartClone() +nsNestedAboutURI::StartClone(nsSimpleURI::RefHandlingEnum aRefHandlingMode) { // Sadly, we can't make use of nsSimpleNestedURI::StartClone here. + // However, this function is expected to exactly match that function, + // aside from the "new ns***URI()" call. NS_ENSURE_TRUE(mInnerURI, nsnull); nsCOMPtr innerClone; - nsresult rv = mInnerURI->Clone(getter_AddRefs(innerClone)); + nsresult rv = aRefHandlingMode == eHonorRef ? + mInnerURI->Clone(getter_AddRefs(innerClone)) : + mInnerURI->CloneIgnoringRef(getter_AddRefs(innerClone)); + if (NS_FAILED(rv)) { return nsnull; } nsNestedAboutURI* url = new nsNestedAboutURI(innerClone, mBaseURI); - if (url) { - url->SetMutable(PR_FALSE); - } + url->SetMutable(PR_FALSE); return url; } diff --git a/netwerk/protocol/about/nsAboutProtocolHandler.h b/netwerk/protocol/about/nsAboutProtocolHandler.h index afc13811da6..f64fef1ffc6 100644 --- a/netwerk/protocol/about/nsAboutProtocolHandler.h +++ b/netwerk/protocol/about/nsAboutProtocolHandler.h @@ -94,7 +94,7 @@ public: // Override StartClone(), the nsISerializable methods, and // GetClassIDNoAlloc; this last is needed to make our nsISerializable impl // work right. - virtual nsSimpleURI* StartClone(); + virtual nsSimpleURI* StartClone(RefHandlingEnum aRefHandlingMode); NS_IMETHOD Read(nsIObjectInputStream* aStream); NS_IMETHOD Write(nsIObjectOutputStream* aStream); NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc); diff --git a/netwerk/protocol/data/nsDataChannel.cpp b/netwerk/protocol/data/nsDataChannel.cpp index 555e82a6fd8..8c6a90a81d8 100644 --- a/netwerk/protocol/data/nsDataChannel.cpp +++ b/netwerk/protocol/data/nsDataChannel.cpp @@ -62,10 +62,10 @@ nsDataChannel::OpenContentStream(PRBool async, nsIInputStream **result, rv = URI()->GetAsciiSpec(spec); if (NS_FAILED(rv)) return rv; - nsCString contentType, contentCharset, dataBuffer; + nsCString contentType, contentCharset, dataBuffer, hashRef; PRBool lBase64; rv = nsDataHandler::ParseURI(spec, contentType, contentCharset, - lBase64, dataBuffer); + lBase64, dataBuffer, hashRef); NS_UnescapeURL(dataBuffer); diff --git a/netwerk/protocol/data/nsDataHandler.cpp b/netwerk/protocol/data/nsDataHandler.cpp index 688969472e3..7e37e9792fc 100644 --- a/netwerk/protocol/data/nsDataHandler.cpp +++ b/netwerk/protocol/data/nsDataHandler.cpp @@ -114,9 +114,9 @@ nsDataHandler::NewURI(const nsACString &aSpec, rv = uri->SetRef(spec); } else { // Otherwise, we'll assume |spec| is a fully-specified data URI - nsCAutoString contentType, contentCharset, dataBuffer; + nsCAutoString contentType, contentCharset, dataBuffer, hashRef; PRBool base64; - rv = ParseURI(spec, contentType, contentCharset, base64, dataBuffer); + rv = ParseURI(spec, contentType, contentCharset, base64, dataBuffer, hashRef); if (NS_FAILED(rv)) return rv; @@ -171,7 +171,8 @@ nsDataHandler::ParseURI(nsCString& spec, nsCString& contentType, nsCString& contentCharset, PRBool& isBase64, - nsCString& dataBuffer) { + nsCString& dataBuffer, + nsCString& hashRef) { isBase64 = PR_FALSE; // move past "data:" @@ -230,7 +231,16 @@ nsDataHandler::ParseURI(nsCString& spec, contentType.StripWhitespace(); contentCharset.StripWhitespace(); - dataBuffer.Assign(comma + 1); + // Split encoded data from terminal "#ref" (if present) + char *data = comma + 1; + char *hash = strchr(data, '#'); + if (!hash) { + dataBuffer.Assign(data); + hashRef.Truncate(); + } else { + dataBuffer.Assign(data, hash - data); + hashRef.Assign(hash); + } return NS_OK; } diff --git a/netwerk/protocol/data/nsDataHandler.h b/netwerk/protocol/data/nsDataHandler.h index 0b701a609f0..07322981216 100644 --- a/netwerk/protocol/data/nsDataHandler.h +++ b/netwerk/protocol/data/nsDataHandler.h @@ -63,7 +63,8 @@ public: nsCString& contentType, nsCString& contentCharset, PRBool& isBase64, - nsCString& dataBuffer); + nsCString& dataBuffer, + nsCString& hashRef); }; #endif /* nsDataHandler_h___ */ diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index 6af98544f92..d6802e5fc05 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -79,6 +79,7 @@ HttpBaseChannel::HttpBaseChannel() , mChooseApplicationCache(PR_FALSE) , mLoadedFromApplicationCache(PR_FALSE) , mChannelIsForDownload(PR_FALSE) + , mTracingEnabled(PR_TRUE) , mTimingEnabled(PR_FALSE) , mRedirectedCachekeys(nsnull) { @@ -167,7 +168,7 @@ HttpBaseChannel::Init(nsIURI *aURI, // HttpBaseChannel::nsISupports //----------------------------------------------------------------------------- -NS_IMPL_ISUPPORTS_INHERITED8(HttpBaseChannel, +NS_IMPL_ISUPPORTS_INHERITED9(HttpBaseChannel, nsHashPropertyBag, nsIRequest, nsIChannel, @@ -176,7 +177,8 @@ NS_IMPL_ISUPPORTS_INHERITED8(HttpBaseChannel, nsIHttpChannelInternal, nsIUploadChannel, nsIUploadChannel2, - nsISupportsPriority) + nsISupportsPriority, + nsITraceableChannel) //----------------------------------------------------------------------------- // HttpBaseChannel::nsIRequest @@ -1316,7 +1318,54 @@ HttpBaseChannel::GetEntityID(nsACString& aEntityID) return NS_OK; } -//------------------------------------------------------------------------------ +//----------------------------------------------------------------------------- +// nsStreamListenerWrapper +//----------------------------------------------------------------------------- + +// Wrapper class to make replacement of nsHttpChannel's listener +// from JavaScript possible. It is workaround for bug 433711. +class nsStreamListenerWrapper : public nsIStreamListener +{ +public: + nsStreamListenerWrapper(nsIStreamListener *listener); + + NS_DECL_ISUPPORTS + NS_FORWARD_NSIREQUESTOBSERVER(mListener->) + NS_FORWARD_NSISTREAMLISTENER(mListener->) + +private: + ~nsStreamListenerWrapper() {} + nsCOMPtr mListener; +}; + +nsStreamListenerWrapper::nsStreamListenerWrapper(nsIStreamListener *listener) + : mListener(listener) +{ + NS_ASSERTION(mListener, "no stream listener specified"); +} + +NS_IMPL_ISUPPORTS2(nsStreamListenerWrapper, + nsIStreamListener, + nsIRequestObserver) + +//----------------------------------------------------------------------------- +// nsHttpChannel::nsITraceableChannel +//----------------------------------------------------------------------------- + +NS_IMETHODIMP +HttpBaseChannel::SetNewListener(nsIStreamListener *aListener, nsIStreamListener **_retval) +{ + if (!mTracingEnabled) + return NS_ERROR_FAILURE; + + NS_ENSURE_ARG_POINTER(aListener); + + nsCOMPtr wrapper = new nsStreamListenerWrapper(mListener); + + wrapper.forget(_retval); + mListener = aListener; + return NS_OK; +} //----------------------------------------------------------------------------- // HttpBaseChannel helpers diff --git a/netwerk/protocol/http/HttpBaseChannel.h b/netwerk/protocol/http/HttpBaseChannel.h index 932561fffc5..9b47160272f 100644 --- a/netwerk/protocol/http/HttpBaseChannel.h +++ b/netwerk/protocol/http/HttpBaseChannel.h @@ -23,6 +23,7 @@ * * Contributor(s): * Daniel Witte + * Jason Duell * * 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 @@ -59,6 +60,7 @@ #include "nsISupportsPriority.h" #include "nsIApplicationCache.h" #include "nsIResumableChannel.h" +#include "nsITraceableChannel.h" #include "mozilla/net/NeckoCommon.h" namespace mozilla { @@ -79,11 +81,13 @@ class HttpBaseChannel : public nsHashPropertyBag , public nsIUploadChannel2 , public nsISupportsPriority , public nsIResumableChannel + , public nsITraceableChannel { public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIUPLOADCHANNEL NS_DECL_NSIUPLOADCHANNEL2 + NS_DECL_NSITRACEABLECHANNEL HttpBaseChannel(); virtual ~HttpBaseChannel(); @@ -274,8 +278,9 @@ protected: PRUint32 mChooseApplicationCache : 1; PRUint32 mLoadedFromApplicationCache : 1; PRUint32 mChannelIsForDownload : 1; + PRUint32 mTracingEnabled : 1; // True if timing collection is enabled - PRUint32 mTimingEnabled : 1; + PRUint32 mTimingEnabled : 1; nsTArray *mRedirectedCachekeys; }; diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index b90746e5fad..b7dffb4611b 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -270,6 +270,10 @@ HttpChannelChild::OnStartRequest(const nsHttpResponseHead& responseHead, requestHeaders[i].mValue); } + // notify "http-on-examine-response" observers + gHttpHandler->OnExamineResponse(this); + mTracingEnabled = PR_FALSE; + nsresult rv = mListener->OnStartRequest(this, mListenerContext); if (NS_FAILED(rv)) { Cancel(rv); @@ -1188,17 +1192,6 @@ HttpChannelChild::GetProxyInfo(nsIProxyInfo **aProxyInfo) DROP_DEAD(); } -//----------------------------------------------------------------------------- -// HttpChannelChild::nsITraceableChannel -//----------------------------------------------------------------------------- - -NS_IMETHODIMP -HttpChannelChild::SetNewListener(nsIStreamListener *listener, - nsIStreamListener **oldListener) -{ - DROP_DEAD(); -} - //----------------------------------------------------------------------------- // HttpChannelChild::nsIApplicationCacheContainer //----------------------------------------------------------------------------- diff --git a/netwerk/protocol/http/HttpChannelChild.h b/netwerk/protocol/http/HttpChannelChild.h index 2155f83ffbd..dbf14e7bfb9 100644 --- a/netwerk/protocol/http/HttpChannelChild.h +++ b/netwerk/protocol/http/HttpChannelChild.h @@ -58,7 +58,6 @@ #include "nsIUploadChannel2.h" #include "nsIResumableChannel.h" #include "nsIProxiedChannel.h" -#include "nsITraceableChannel.h" #include "nsIAsyncVerifyRedirectCallback.h" #include "nsIAssociatedContentSecurity.h" #include "nsIChildChannel.h" @@ -71,7 +70,6 @@ class HttpChannelChild : public PHttpChannelChild , public HttpBaseChannel , public nsICacheInfoChannel , public nsIProxiedChannel - , public nsITraceableChannel , public nsIApplicationCacheChannel , public nsIAsyncVerifyRedirectCallback , public nsIAssociatedContentSecurity @@ -83,7 +81,6 @@ public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSICACHEINFOCHANNEL NS_DECL_NSIPROXIEDCHANNEL - NS_DECL_NSITRACEABLECHANNEL NS_DECL_NSIAPPLICATIONCACHECONTAINER NS_DECL_NSIAPPLICATIONCACHECHANNEL NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK diff --git a/netwerk/protocol/http/TimingStruct.h b/netwerk/protocol/http/TimingStruct.h index 634359b68c6..c5d2f0a9c80 100644 --- a/netwerk/protocol/http/TimingStruct.h +++ b/netwerk/protocol/http/TimingStruct.h @@ -42,9 +42,6 @@ #include "mozilla/TimeStamp.h" struct TimingStruct { - mozilla::TimeStamp channelCreation; - mozilla::TimeStamp asyncOpen; - mozilla::TimeStamp domainLookupStart; mozilla::TimeStamp domainLookupEnd; mozilla::TimeStamp connectStart; diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 378b7b682c1..4245146cb36 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -130,7 +130,6 @@ nsHttpChannel::nsHttpChannel() , mCacheForOfflineUse(PR_FALSE) , mCachingOpportunistically(PR_FALSE) , mFallbackChannel(PR_FALSE) - , mTracingEnabled(PR_TRUE) , mCustomConditionalRequest(PR_FALSE) , mFallingBack(PR_FALSE) , mWaitingForRedirectCallback(PR_FALSE) @@ -3549,7 +3548,6 @@ NS_INTERFACE_MAP_BEGIN(nsHttpChannel) NS_INTERFACE_MAP_ENTRY(nsIProtocolProxyCallback) NS_INTERFACE_MAP_ENTRY(nsIProxiedChannel) NS_INTERFACE_MAP_ENTRY(nsIHttpAuthenticableChannel) - NS_INTERFACE_MAP_ENTRY(nsITraceableChannel) NS_INTERFACE_MAP_ENTRY(nsIApplicationCacheContainer) NS_INTERFACE_MAP_ENTRY(nsIApplicationCacheChannel) NS_INTERFACE_MAP_ENTRY(nsIAsyncVerifyRedirectCallback) @@ -3651,9 +3649,6 @@ nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context) if (mCanceled) return mStatus; - if (mTimingEnabled) - mAsyncOpenTime = mozilla::TimeStamp::Now(); - rv = NS_CheckPortSafety(mURI); if (NS_FAILED(rv)) return rv; @@ -3662,10 +3657,16 @@ nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context) // Start a DNS lookup very early in case the real open is queued the DNS can // happen in parallel. Do not do so in the presence of an HTTP proxy as // all lookups other than for the proxy itself are done by the proxy. - nsRefPtr prefetch = new nsDNSPrefetch(mURI); - if (prefetch) { - prefetch->PrefetchHigh(); - } + // + // We keep the DNS prefetch object around so that we can retrieve + // timing information from it. There is no guarantee that we actually + // use the DNS prefetch data for the real connection, but as we keep + // this data around for 3 minutes by default, this should almost always + // be correct, and even when it isn't, the timing still represents _a_ + // valid DNS lookup timing for the site, even if it is not _the_ + // timing we used. + mDNSPrefetch = new nsDNSPrefetch(mURI, mTimingEnabled); + mDNSPrefetch->PrefetchHigh(); } // Remember the cookie header that was set, if any @@ -3700,6 +3701,12 @@ nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context) if (mLoadGroup) mLoadGroup->AddRequest(this, nsnull); + // Collect mAsyncOpenTime after we have called all obsrevers like + // "http-on-modify-request" and load group observers that may set + // mTimingEnabled flag. + if (mTimingEnabled) + mAsyncOpenTime = mozilla::TimeStamp::Now(); + // We may have been cancelled already, either by on-modify-request // listeners or by load group observers; in that case, we should // not send the request to the server @@ -3827,7 +3834,9 @@ nsHttpChannel::GetAsyncOpen(mozilla::TimeStamp* _retval) { NS_IMETHODIMP nsHttpChannel::GetDomainLookupStart(mozilla::TimeStamp* _retval) { - if (mTransaction) + if (mDNSPrefetch && mDNSPrefetch->TimingsValid()) + *_retval = mDNSPrefetch->StartTimestamp(); + else if (mTransaction) *_retval = mTransaction->Timings().domainLookupStart; else *_retval = mTransactionTimings.domainLookupStart; @@ -3836,7 +3845,9 @@ nsHttpChannel::GetDomainLookupStart(mozilla::TimeStamp* _retval) { NS_IMETHODIMP nsHttpChannel::GetDomainLookupEnd(mozilla::TimeStamp* _retval) { - if (mTransaction) + if (mDNSPrefetch && mDNSPrefetch->TimingsValid()) + *_retval = mDNSPrefetch->EndTimestamp(); + else if (mTransaction) *_retval = mTransaction->Timings().domainLookupEnd; else *_retval = mTransactionTimings.domainLookupEnd; @@ -4188,6 +4199,15 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st mTransaction = nsnull; mTransactionPump = 0; + // We no longer need the dns prefetch object + if (mDNSPrefetch && mDNSPrefetch->TimingsValid()) { + mTransactionTimings.domainLookupStart = + mDNSPrefetch->StartTimestamp(); + mTransactionTimings.domainLookupEnd = + mDNSPrefetch->EndTimestamp(); + } + mDNSPrefetch = nsnull; + // handle auth retry... if (authRetry) { mAuthRetryPending = PR_FALSE; @@ -4946,59 +4966,11 @@ nsHttpChannel::PopRedirectAsyncFunc(nsContinueRedirectionFunc func) mRedirectFuncStack.TruncateLength(mRedirectFuncStack.Length() - 1); } -//----------------------------------------------------------------------------- -// nsStreamListenerWrapper -//----------------------------------------------------------------------------- - -// Wrapper class to make replacement of nsHttpChannel's listener -// from JavaScript possible. It is workaround for bug 433711. -class nsStreamListenerWrapper : public nsIStreamListener -{ -public: - nsStreamListenerWrapper(nsIStreamListener *listener); - - NS_DECL_ISUPPORTS - NS_FORWARD_NSIREQUESTOBSERVER(mListener->) - NS_FORWARD_NSISTREAMLISTENER(mListener->) - -private: - ~nsStreamListenerWrapper() {} - nsCOMPtr mListener; -}; - -nsStreamListenerWrapper::nsStreamListenerWrapper(nsIStreamListener *listener) - : mListener(listener) -{ - NS_ASSERTION(mListener, "no stream listener specified"); -} - -NS_IMPL_ISUPPORTS2(nsStreamListenerWrapper, - nsIStreamListener, - nsIRequestObserver) //----------------------------------------------------------------------------- -// nsHttpChannel::nsITraceableChannel +// nsHttpChannel internal functions //----------------------------------------------------------------------------- -NS_IMETHODIMP -nsHttpChannel::SetNewListener(nsIStreamListener *aListener, nsIStreamListener **_retval) -{ - if (!mTracingEnabled) - return NS_ERROR_FAILURE; - - NS_ENSURE_ARG_POINTER(aListener); - - nsCOMPtr wrapper = - new nsStreamListenerWrapper(mListener); - - if (!wrapper) - return NS_ERROR_OUT_OF_MEMORY; - - wrapper.forget(_retval); - mListener = aListener; - return NS_OK; -} - void nsHttpChannel::MaybeInvalidateCacheEntryForSubsequentGet() { diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h index c9a03a8b70f..7918f2dc707 100644 --- a/netwerk/protocol/http/nsHttpChannel.h +++ b/netwerk/protocol/http/nsHttpChannel.h @@ -60,11 +60,11 @@ #include "nsIProtocolProxyCallback.h" #include "nsICancelable.h" #include "nsIHttpAuthenticableChannel.h" -#include "nsITraceableChannel.h" #include "nsIHttpChannelAuthProvider.h" #include "nsIAsyncVerifyRedirectCallback.h" #include "nsICryptoHash.h" #include "nsITimedChannel.h" +#include "nsDNSPrefetch.h" #include "TimingStruct.h" class nsAHttpConnection; @@ -83,7 +83,6 @@ class nsHttpChannel : public HttpBaseChannel , public nsITransportEventSink , public nsIProtocolProxyCallback , public nsIHttpAuthenticableChannel - , public nsITraceableChannel , public nsIApplicationCacheChannel , public nsIAsyncVerifyRedirectCallback , public nsITimedChannel @@ -98,7 +97,6 @@ public: NS_DECL_NSITRANSPORTEVENTSINK NS_DECL_NSIPROTOCOLPROXYCALLBACK NS_DECL_NSIPROXIEDCHANNEL - NS_DECL_NSITRACEABLECHANNEL NS_DECL_NSIAPPLICATIONCACHECONTAINER NS_DECL_NSIAPPLICATIONCACHECHANNEL NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK @@ -340,7 +338,6 @@ private: // True if we are loading a fallback cache entry from the // application cache. PRUint32 mFallbackChannel : 1; - PRUint32 mTracingEnabled : 1; // True if consumer added its own If-None-Match or If-Modified-Since // headers. In such a case we must not override them in the cache code // and also we want to pass possible 304 code response through. @@ -363,6 +360,8 @@ private: // copied from the transaction before we null out mTransaction // so that the timing can still be queried from OnStopRequest TimingStruct mTransactionTimings; + // Needed for accurate DNS timing + nsRefPtr mDNSPrefetch; nsresult WaitForRedirectCallback(); void PushRedirectAsyncFunc(nsContinueRedirectionFunc func); diff --git a/netwerk/test/Makefile.in b/netwerk/test/Makefile.in index 15b468dee54..7db55055a23 100644 --- a/netwerk/test/Makefile.in +++ b/netwerk/test/Makefile.in @@ -71,18 +71,17 @@ SIMPLE_PROGRAMS = \ TestProtocols$(BIN_SUFFIX) \ $(NULL) -ifndef MOZ_ENABLE_LIBXUL -SIMPLE_PROGRAMS += \ - TestPerf$(BIN_SUFFIX) \ - TestIDN$(BIN_SUFFIX) \ - TestSocketTransport$(BIN_SUFFIX) \ - TestStreamTransport$(BIN_SUFFIX) \ - TestStreamChannel$(BIN_SUFFIX) \ - TestStreamPump$(BIN_SUFFIX) \ - TestIOThreads$(BIN_SUFFIX) \ - TestUDPSocketProvider$(BIN_SUFFIX) \ - $(NULL) -endif +# XXX Make this work in libxul builds. +#SIMPLE_PROGRAMS += \ +# TestPerf$(BIN_SUFFIX) \ +# TestIDN$(BIN_SUFFIX) \ +# TestSocketTransport$(BIN_SUFFIX) \ +# TestStreamTransport$(BIN_SUFFIX) \ +# TestStreamChannel$(BIN_SUFFIX) \ +# TestStreamPump$(BIN_SUFFIX) \ +# TestIOThreads$(BIN_SUFFIX) \ +# TestUDPSocketProvider$(BIN_SUFFIX) \ +# $(NULL) CPP_UNIT_TESTS = \ TestSTSParser.cpp \ diff --git a/netwerk/test/reftest/658949-1-ref.html b/netwerk/test/reftest/658949-1-ref.html new file mode 100644 index 00000000000..6e6d7e25f67 --- /dev/null +++ b/netwerk/test/reftest/658949-1-ref.html @@ -0,0 +1 @@ + diff --git a/netwerk/test/reftest/658949-1.html b/netwerk/test/reftest/658949-1.html new file mode 100644 index 00000000000..f61c03a5254 --- /dev/null +++ b/netwerk/test/reftest/658949-1.html @@ -0,0 +1 @@ + diff --git a/netwerk/test/reftest/reftest.list b/netwerk/test/reftest/reftest.list index e2cc396d37b..98b5d4fb9a5 100644 --- a/netwerk/test/reftest/reftest.list +++ b/netwerk/test/reftest/reftest.list @@ -1,2 +1,2 @@ == bug565432-1.html bug565432-1-ref.html - +== 658949-1.html 658949-1-ref.html diff --git a/netwerk/test/unit/test_URIs.js b/netwerk/test/unit/test_URIs.js index 3db4031fb30..911b09f079d 100644 --- a/netwerk/test/unit/test_URIs.js +++ b/netwerk/test/unit/test_URIs.js @@ -5,6 +5,12 @@ const Ci = Components.interfaces; // TEST DATA // --------- var gTests = [ + { spec: "about:blank", + scheme: "about", + prePath: "about:", + path: "blank", + ref: "", + nsIURL: false, nsINestedURI: true, immutable: true }, { spec: "about:foobar", scheme: "about", prePath: "about:", @@ -77,6 +83,12 @@ var gTests = [ path: "resource://gre/chrome.toolkit.jar!/", ref: "", nsIURL: true, nsINestedURI: true }, + { spec: "place:redirectsMode=2&sort=8&maxResults=10", + scheme: "place", + prePath: "place:", + path: "redirectsMode=2&sort=8&maxResults=10", + ref: "", + nsIURL: false, nsINestedURI: false }, { spec: "resource://gre/", scheme: "resource", prePath: "resource://gre", @@ -218,6 +230,10 @@ function do_test_uri_with_hash_suffix(aTest, aSuffix) { var testURI = NetUtil.newURI(aTest.spec + aSuffix); var origURI = NetUtil.newURI(aTest.spec); + do_info("testing " + aTest.spec + " with '" + aSuffix + "' appended " + + "equals a clone of itself"); + do_check_uri_eq(testURI, testURI.clone()); + do_info("testing " + aTest.spec + " doesn't equal self with '" + aSuffix + "' appended"); if (aTest.spec == "file://") { diff --git a/netwerk/test/unit/test_bug651100.js b/netwerk/test/unit/test_bug651100.js new file mode 100644 index 00000000000..6ba34343182 --- /dev/null +++ b/netwerk/test/unit/test_bug651100.js @@ -0,0 +1,166 @@ +const Cc = Components.classes; +const Ci = Components.interfaces; +const Cr = Components.results; + +var _CSvc; +function get_cache_service() { + if (_CSvc) + return _CSvc; + + return _CSvc = Cc["@mozilla.org/network/cache-service;1"]. + getService(Ci.nsICacheService); +} + +function get_ostream_for_entry(key, asFile, entryRef) +{ + var cache = get_cache_service(); + var session = cache.createSession( + "HTTP", + asFile ? Ci.nsICache.STORE_ON_DISK_AS_FILE + : Ci.nsICache.STORE_ON_DISK, + Ci.nsICache.STREAM_BASED); + var cacheEntry = session.openCacheEntry(key, Ci.nsICache.ACCESS_WRITE, true); + var oStream = cacheEntry.openOutputStream(0); + entryRef.value = cacheEntry; + return oStream; +} + +function gen_1MiB() +{ + var i; + var data="x"; + for (i=0 ; i < 20 ; i++) + data+=data; + return data; +} + +function write_and_check(str, data, len) +{ + var written = str.write(data, len); + if (written != len) { + do_throw("str.write has not written all data!\n" + + " Expected: " + len + "\n" + + " Actual: " + written + "\n"); + } +} + +function write_big_datafile() +{ + var entry = {}; + var oStr = get_ostream_for_entry("bigdata", true, entry); + var data = gen_1MiB(); + + // >64MiB + var i; + for (i=0 ; i<65 ; i++) + write_and_check(oStr, data, data.length); + + oStr.close(); + entry.value.close(); +} + +function write_and_doom_big_metafile() +{ + var entry = {}; + var oStr = get_ostream_for_entry("bigmetadata", true, entry); + var data = gen_1MiB(); + + // >64MiB + var i; + for (i=0 ; i<65 ; i++) + entry.value.setMetaDataElement("metadata_"+i, data); + + write_and_check(oStr, data, data.length); + + oStr.close(); + entry.value.doom(); + entry.value.close(); +} + +function check_cache_size() { + var diskDeviceVisited; + var visitor = { + visitDevice: function (deviceID, deviceInfo) { + if (deviceID == "disk") { + diskDeviceVisited = true; + do_check_eq(deviceInfo.totalSize, 0) + } + return false; + }, + visitEntry: function (deviceID, entryInfo) { + do_throw("unexpected call to visitEntry"); + } + }; + + var cs = get_cache_service(); + diskDeviceVisited = false; + cs.visitEntries(visitor); + do_check_true(diskDeviceVisited); +} + +var _continue_with = null; +function sync_with_cache_IO_thread(aFunc) +{ + do_check_eq(sync_with_cache_IO_thread_cb.listener, null); + sync_with_cache_IO_thread_cb.listener = aFunc; + var cache = get_cache_service(); + var session = cache.createSession( + "HTTP", + Ci.nsICache.STORE_ON_DISK, + Ci.nsICache.STREAM_BASED); + var cacheEntry = session.asyncOpenCacheEntry( + "nonexistententry", + Ci.nsICache.ACCESS_READ, + sync_with_cache_IO_thread_cb); +} + +var sync_with_cache_IO_thread_cb = { + listener: null, + + onCacheEntryAvailable: function oCEA(descriptor, accessGranted, status) { + do_check_eq(status, Cr.NS_ERROR_CACHE_KEY_NOT_FOUND); + cb = this.listener; + this.listener = null; + do_timeout(0, cb); + } +}; + + +function run_test() { + var prefBranch = Cc["@mozilla.org/preferences-service;1"]. + getService(Ci.nsIPrefBranch); + prefBranch.setIntPref("browser.cache.disk.capacity", 50000); + + do_get_profile(); + + // clear the cache + get_cache_service().evictEntries(Ci.nsICache.STORE_ANYWHERE); + + // write an entry with data > 64MiB + write_big_datafile(); + + // DoomEntry() is called when the cache is full, but the data is really + // deleted (and the cache size updated) on the background thread when the + // entry is deactivated. We need to sync with the cache IO thread before we + // continue with the test. + sync_with_cache_IO_thread(run_test_2); + + do_test_pending(); +} + +function run_test_2() +{ + check_cache_size(); + + // write an entry with metadata > 64MiB + write_and_doom_big_metafile(); + + sync_with_cache_IO_thread(run_test_3); +} + +function run_test_3() +{ + check_cache_size(); + + do_test_finished(); +} diff --git a/netwerk/test/unit/test_traceable_channel.js b/netwerk/test/unit/test_traceable_channel.js index 726ebdd4401..a62b8a2c92b 100644 --- a/netwerk/test/unit/test_traceable_channel.js +++ b/netwerk/test/unit/test_traceable_channel.js @@ -21,11 +21,15 @@ TracingListener.prototype = { gotOnStartRequest = true; request.QueryInterface(Components.interfaces.nsIHttpChannelInternal); + +// local/remote addresses broken in e10s: disable for now +/* do_check_eq(request.localAddress, "127.0.0.1"); do_check_eq(request.localPort > 0, true); do_check_neq(request.localPort, 4444); do_check_eq(request.remoteAddress, "127.0.0.1"); do_check_eq(request.remotePort, 4444); +*/ // Make sure listener can't be replaced after OnStartRequest was called. request.QueryInterface(Components.interfaces.nsITraceableChannel); @@ -131,6 +135,7 @@ function make_channel(url) { // Check if received body is correctly modified. function channel_finished(request, input, ctx) { + httpserver.stop(do_test_finished); } function run_test() { diff --git a/netwerk/test/unit/xpcshell.ini b/netwerk/test/unit/xpcshell.ini index dbd6835a7c2..94c054264d2 100644 --- a/netwerk/test/unit/xpcshell.ini +++ b/netwerk/test/unit/xpcshell.ini @@ -58,6 +58,7 @@ tail = [test_bug596443.js] [test_bug633743.js] [test_bug652761.js] +[test_bug651100.js] [test_cacheflags.js] [test_channel_close.js] [test_compareURIs.js] diff --git a/netwerk/test/unit_ipc/test_traceable_channel_wrap.js b/netwerk/test/unit_ipc/test_traceable_channel_wrap.js new file mode 100644 index 00000000000..5855bc23a18 --- /dev/null +++ b/netwerk/test/unit_ipc/test_traceable_channel_wrap.js @@ -0,0 +1,7 @@ +// +// Run test script in content process instead of chrome (xpcshell's default) +// + +function run_test() { + run_test_in_child("../unit/test_traceable_channel.js"); +} diff --git a/netwerk/test/unit_ipc/xpcshell.ini b/netwerk/test/unit_ipc/xpcshell.ini index 6bc9f90000c..91c3608aab5 100644 --- a/netwerk/test/unit_ipc/xpcshell.ini +++ b/netwerk/test/unit_ipc/xpcshell.ini @@ -19,4 +19,5 @@ tail = [test_reentrancy_wrap.js] [test_resumable_channel_wrap.js] [test_simple_wrap.js] +[test_traceable_channel_wrap.js] [test_xmlhttprequest_wrap.js] diff --git a/parser/htmlparser/tests/Makefile.in b/parser/htmlparser/tests/Makefile.in index 2294a11300e..67c60fc593b 100644 --- a/parser/htmlparser/tests/Makefile.in +++ b/parser/htmlparser/tests/Makefile.in @@ -48,10 +48,9 @@ DIRS = \ mochitest \ $(NULL) -ifndef MOZ_ENABLE_LIBXUL -DIRS += \ - outsinks \ - $(NULL) -endif +# XXX This doesn't work in libxul builds. +#DIRS += \ +# outsinks \ +# $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/rdf/build/Makefile.in b/rdf/build/Makefile.in index 2458968a25b..7a961a1814a 100644 --- a/rdf/build/Makefile.in +++ b/rdf/build/Makefile.in @@ -64,12 +64,6 @@ SHARED_LIBRARY_LIBS = \ ../datasource/src/$(LIB_PREFIX)rdfdatasource_s.$(LIB_SUFFIX) \ $(NULL) -ifndef MOZ_ENABLE_LIBXUL -SHARED_LIBRARY_LIBS += \ - ../util/src/internal/$(LIB_PREFIX)rdfutil_s.$(LIB_SUFFIX) \ - $(NULL) -endif - EXTRA_DSO_LDOPTS = \ $(LIBS_DIR) \ $(EXTRA_DSO_LIBS) \ diff --git a/security/manager/ssl/src/nsNSSComponent.cpp b/security/manager/ssl/src/nsNSSComponent.cpp index 99af07f45b0..8f162b3eeda 100644 --- a/security/manager/ssl/src/nsNSSComponent.cpp +++ b/security/manager/ssl/src/nsNSSComponent.cpp @@ -74,7 +74,6 @@ #include "nsDateTimeFormatCID.h" #include "nsIDOMEvent.h" #include "nsIDOMDocument.h" -#include "nsIDOMDocumentEvent.h" #include "nsIDOMWindow.h" #include "nsIDOMWindowCollection.h" #include "nsIDOMWindowInternal.h" @@ -550,14 +549,9 @@ nsNSSComponent::DispatchEventToWindow(nsIDOMWindow *domWin, } // create the event - nsCOMPtr docEvent = do_QueryInterface(doc, &rv); - if (NS_FAILED(rv)) { - return rv; - } - nsCOMPtr event; - rv = docEvent->CreateEvent(NS_LITERAL_STRING("Events"), - getter_AddRefs(event)); + rv = doc->CreateEvent(NS_LITERAL_STRING("Events"), + getter_AddRefs(event)); if (NS_FAILED(rv)) { return rv; } diff --git a/services/sync/modules/engines.js b/services/sync/modules/engines.js index d1e632d318a..dcbd037152e 100644 --- a/services/sync/modules/engines.js +++ b/services/sync/modules/engines.js @@ -193,7 +193,7 @@ function Store(name) { let level = Svc.Prefs.get("log.logger.engine." + this.name, "Debug"); this._log.level = Log4Moz.Level[level]; - Utils.lazy2(this, "_timer", function() { + XPCOMUtils.defineLazyGetter(this, "_timer", function() { return Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); }); } @@ -267,7 +267,9 @@ Store.prototype = { // Singleton service, holds registered engines -Utils.lazy(this, 'Engines', EngineManagerSvc); +XPCOMUtils.defineLazyGetter(this, "Engines", function() { + return new EngineManagerSvc(); +}); function EngineManagerSvc() { this._engines = {}; diff --git a/services/sync/modules/engines/bookmarks.js b/services/sync/modules/engines/bookmarks.js index 9483df38990..d0f2f7e783c 100644 --- a/services/sync/modules/engines/bookmarks.js +++ b/services/sync/modules/engines/bookmarks.js @@ -57,6 +57,7 @@ const MOBILE_ANNO = "MobileBookmarks"; const EXCLUDEBACKUP_ANNO = "places/excludeFromBackup"; const SMART_BOOKMARKS_ANNO = "Places/SmartBookmark"; const PARENT_ANNO = "sync/parent"; +const ORGANIZERQUERY_ANNO = "PlacesOrganizer/OrganizerQuery"; const ANNOS_TO_TRACK = [DESCRIPTION_ANNO, SIDEBAR_ANNO, FEEDURI_ANNO, SITEURI_ANNO]; @@ -184,16 +185,18 @@ let kSpecialIds = { // Create the special mobile folder to store mobile bookmarks. createMobileRoot: function createMobileRoot() { - let root = Svc.Bookmark.placesRoot; - let mRoot = Svc.Bookmark.createFolder(root, "mobile", -1); - Svc.Annos.setItemAnnotation(mRoot, MOBILEROOT_ANNO, 1, 0, - Svc.Annos.EXPIRE_NEVER); + let root = PlacesUtils.placesRootId; + let mRoot = PlacesUtils.bookmarks.createFolder(root, "mobile", -1); + PlacesUtils.annotations.setItemAnnotation( + mRoot, MOBILEROOT_ANNO, 1, 0, PlacesUtils.annotations.EXPIRE_NEVER); + PlacesUtils.annotations.setItemAnnotation( + mRoot, EXCLUDEBACKUP_ANNO, 1, 0, PlacesUtils.annotations.EXPIRE_NEVER); return mRoot; }, findMobileRoot: function findMobileRoot(create) { // Use the (one) mobile root if it already exists. - let root = Svc.Annos.getItemsWithAnnotation(MOBILEROOT_ANNO, {}); + let root = PlacesUtils.annotations.getItemsWithAnnotation(MOBILEROOT_ANNO, {}); if (root.length != 0) return root[0]; @@ -223,11 +226,11 @@ let kSpecialIds = { return null; }, - get menu() Svc.Bookmark.bookmarksMenuFolder, - get places() Svc.Bookmark.placesRoot, - get tags() Svc.Bookmark.tagsFolder, - get toolbar() Svc.Bookmark.toolbarFolder, - get unfiled() Svc.Bookmark.unfiledBookmarksFolder, + get menu() PlacesUtils.bookmarksMenuFolderId, + get places() PlacesUtils.placesRootId, + get tags() PlacesUtils.tagsFolderId, + get toolbar() PlacesUtils.toolbarFolderId, + get unfiled() PlacesUtils.unfiledBookmarksFolderId, get mobile() this.findMobileRoot(true), }; @@ -241,7 +244,27 @@ BookmarksEngine.prototype = { _trackerObj: BookmarksTracker, version: 2, - _sync: Utils.batchSync("Bookmark", SyncEngine), + _sync: function _sync() { + let engine = this; + let batchEx = null; + + // Try running sync in batch mode + PlacesUtils.bookmarks.runInBatchMode({ + runBatched: function wrappedSync() { + try { + SyncEngine.prototype._sync.call(engine); + } + catch(ex) { + batchEx = ex; + } + } + }, null); + + // Expose the exception if something inside the batch failed + if (batchEx!= null) { + throw batchEx; + } + }, _syncStartup: function _syncStart() { SyncEngine.prototype._syncStartup.call(this); @@ -259,37 +282,38 @@ BookmarksEngine.prototype = { // Figure out what key to store the mapping let key; let id = this._store.idForGUID(guid); - switch (Svc.Bookmark.getItemType(id)) { - case Svc.Bookmark.TYPE_BOOKMARK: + switch (PlacesUtils.bookmarks.getItemType(id)) { + case PlacesUtils.bookmarks.TYPE_BOOKMARK: // Smart bookmarks map to their annotation value. let queryId; try { - queryId = Svc.Annos.getItemAnnotation(id, SMART_BOOKMARKS_ANNO); + queryId = PlacesUtils.annotations.getItemAnnotation( + id, SMART_BOOKMARKS_ANNO); } catch(ex) {} if (queryId) key = "q" + queryId; else - key = "b" + Svc.Bookmark.getBookmarkURI(id).spec + ":" + - Svc.Bookmark.getItemTitle(id); + key = "b" + PlacesUtils.bookmarks.getBookmarkURI(id).spec + ":" + + PlacesUtils.bookmarks.getItemTitle(id); break; - case Svc.Bookmark.TYPE_FOLDER: - key = "f" + Svc.Bookmark.getItemTitle(id); + case PlacesUtils.bookmarks.TYPE_FOLDER: + key = "f" + PlacesUtils.bookmarks.getItemTitle(id); break; - case Svc.Bookmark.TYPE_SEPARATOR: - key = "s" + Svc.Bookmark.getItemIndex(id); + case PlacesUtils.bookmarks.TYPE_SEPARATOR: + key = "s" + PlacesUtils.bookmarks.getItemIndex(id); break; default: continue; } // The mapping is on a per parent-folder-name basis - let parent = Svc.Bookmark.getFolderIdForItem(id); + let parent = PlacesUtils.bookmarks.getFolderIdForItem(id); if (parent <= 0) continue; - let parentName = Svc.Bookmark.getItemTitle(parent); + let parentName = PlacesUtils.bookmarks.getItemTitle(parent); if (lazyMap[parentName] == null) lazyMap[parentName] = {}; @@ -415,10 +439,6 @@ function BookmarksStore(name) { // Explicitly nullify our references to our cached services so we don't leak Svc.Obs.add("places-shutdown", function() { - this.__bms = null; - this.__hsvc = null; - this.__ls = null; - this.__ts = null; for each ([query, stmt] in Iterator(this._stmts)) stmt.finalize(); }, this); @@ -426,40 +446,6 @@ function BookmarksStore(name) { BookmarksStore.prototype = { __proto__: Store.prototype, - __bms: null, - get _bms() { - if (!this.__bms) - this.__bms = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. - getService(Ci.nsINavBookmarksService); - return this.__bms; - }, - - __hsvc: null, - get _hsvc() { - if (!this.__hsvc) - this.__hsvc = Cc["@mozilla.org/browser/nav-history-service;1"]. - getService(Ci.nsINavHistoryService). - QueryInterface(Ci.nsPIPlacesDatabase); - return this.__hsvc; - }, - - __ls: null, - get _ls() { - if (!this.__ls) - this.__ls = Cc["@mozilla.org/browser/livemark-service;2"]. - getService(Ci.nsILivemarkService); - return this.__ls; - }, - - __ts: null, - get _ts() { - if (!this.__ts) - this.__ts = Cc["@mozilla.org/browser/tagging-service;1"]. - getService(Ci.nsITaggingService); - return this.__ts; - }, - - itemExists: function BStore_itemExists(id) { return this.idForGUID(id, true) > 0; }, @@ -480,7 +466,8 @@ BookmarksStore.prototype = { let queriesRef = {}; let queryCountRef = {}; let optionsRef = {}; - Svc.History.queryStringToQueries(uri, queriesRef, queryCountRef, optionsRef); + PlacesUtils.history.queryStringToQueries(uri, queriesRef, queryCountRef, + optionsRef); // We only process tag URIs. if (optionsRef.value.resultType != optionsRef.value.RESULTS_AS_TAG_CONTENTS) @@ -489,10 +476,10 @@ BookmarksStore.prototype = { // Tag something to ensure that the tag exists. let tag = record.folderName; let dummyURI = Utils.makeURI("about:weave#BStore_preprocess"); - this._ts.tagURI(dummyURI, [tag]); + PlacesUtils.tagging.tagURI(dummyURI, [tag]); // Look for the id of the tag, which might just have been added. - let tags = this._getNode(this._bms.tagsFolder); + let tags = this._getNode(PlacesUtils.tagsFolderId); if (!(tags instanceof Ci.nsINavHistoryQueryResultNode)) { this._log.debug("tags isn't an nsINavHistoryQueryResultNode; aborting."); return; @@ -510,9 +497,8 @@ BookmarksStore.prototype = { for each (let q in queriesRef.value) q.setFolders([child.itemId], 1); - record.bmkUri = Svc.History.queriesToQueryString(queriesRef.value, - queryCountRef.value, - optionsRef.value); + record.bmkUri = PlacesUtils.history.queriesToQueryString( + queriesRef.value, queryCountRef.value, optionsRef.value); return; } } @@ -573,8 +559,9 @@ BookmarksStore.prototype = { // Create an annotation to remember that it needs reparenting. if (record._orphan) { - Svc.Annos.setItemAnnotation(itemId, PARENT_ANNO, parentGUID, 0, - Svc.Annos.EXPIRE_NEVER); + PlacesUtils.annotations.setItemAnnotation( + itemId, PARENT_ANNO, parentGUID, 0, + PlacesUtils.annotations.EXPIRE_NEVER); } } }, @@ -583,8 +570,10 @@ BookmarksStore.prototype = { * Find all ids of items that have a given value for an annotation */ _findAnnoItems: function BStore__findAnnoItems(anno, val) { - return Svc.Annos.getItemsWithAnnotation(anno, {}).filter(function(id) - Svc.Annos.getItemAnnotation(id, anno) == val); + return PlacesUtils.annotations.getItemsWithAnnotation(anno, {}) + .filter(function(id) { + return PlacesUtils.annotations.getItemAnnotation(id, anno) == val; + }); }, /** @@ -599,7 +588,7 @@ BookmarksStore.prototype = { orphans.forEach(function(orphan) { // Move the orphan to the parent and drop the missing parent annotation if (this._reparentItem(orphan, parentId)) { - Svc.Annos.removeItemAnnotation(orphan, PARENT_ANNO); + PlacesUtils.annotations.removeItemAnnotation(orphan, PARENT_ANNO); } }, this); }, @@ -609,7 +598,8 @@ BookmarksStore.prototype = { parentId); try { if (parentId > 0) { - Svc.Bookmark.moveItem(itemId, parentId, Svc.Bookmark.DEFAULT_INDEX); + PlacesUtils.bookmarks.moveItem(itemId, parentId, + PlacesUtils.bookmarks.DEFAULT_INDEX); return true; } } catch(ex) { @@ -621,12 +611,12 @@ BookmarksStore.prototype = { // Turn a record's nsINavBookmarksService constant and other attributes into // a granular type for comparison. _recordType: function _recordType(itemId) { - let bms = this._bms; + let bms = PlacesUtils.bookmarks; let type = bms.getItemType(itemId); switch (type) { case bms.TYPE_FOLDER: - if (this._ls.isLivemark(itemId)) + if (PlacesUtils.itemIsLivemark(itemId)) return "livemark"; return "folder"; @@ -662,42 +652,45 @@ BookmarksStore.prototype = { case "query": case "microsummary": { let uri = Utils.makeURI(record.bmkUri); - newId = this._bms.insertBookmark(record._parent, uri, - Svc.Bookmark.DEFAULT_INDEX, record.title); + newId = PlacesUtils.bookmarks.insertBookmark( + record._parent, uri, PlacesUtils.bookmarks.DEFAULT_INDEX, record.title); this._log.debug("created bookmark " + newId + " under " + record._parent + " as " + record.title + " " + record.bmkUri); // Smart bookmark annotations are strings. if (record.queryId) { - Svc.Annos.setItemAnnotation(newId, SMART_BOOKMARKS_ANNO, record.queryId, - 0, Svc.Annos.EXPIRE_NEVER); + PlacesUtils.annotations.setItemAnnotation( + newId, SMART_BOOKMARKS_ANNO, record.queryId, 0, + PlacesUtils.annotations.EXPIRE_NEVER); } if (Utils.isArray(record.tags)) { this._tagURI(uri, record.tags); } - this._bms.setKeywordForBookmark(newId, record.keyword); + PlacesUtils.bookmarks.setKeywordForBookmark(newId, record.keyword); if (record.description) { - Svc.Annos.setItemAnnotation(newId, DESCRIPTION_ANNO, - record.description, 0, - Svc.Annos.EXPIRE_NEVER); + PlacesUtils.annotations.setItemAnnotation( + newId, DESCRIPTION_ANNO, record.description, 0, + PlacesUtils.annotations.EXPIRE_NEVER); } if (record.loadInSidebar) { - Svc.Annos.setItemAnnotation(newId, SIDEBAR_ANNO, true, 0, - Svc.Annos.EXPIRE_NEVER); + PlacesUtils.annotations.setItemAnnotation( + newId, SIDEBAR_ANNO, true, 0, + PlacesUtils.annotations.EXPIRE_NEVER); } } break; case "folder": - newId = this._bms.createFolder(record._parent, record.title, - Svc.Bookmark.DEFAULT_INDEX); + newId = PlacesUtils.bookmarks.createFolder( + record._parent, record.title, PlacesUtils.bookmarks.DEFAULT_INDEX); this._log.debug("created folder " + newId + " under " + record._parent + " as " + record.title); if (record.description) { - Svc.Annos.setItemAnnotation(newId, DESCRIPTION_ANNO, record.description, - 0, Svc.Annos.EXPIRE_NEVER); + PlacesUtils.annotations.setItemAnnotation( + newId, DESCRIPTION_ANNO, record.description, 0, + PlacesUtils.annotations.EXPIRE_NEVER); } // record.children will be dealt with in _orderChildren. @@ -708,7 +701,7 @@ BookmarksStore.prototype = { this._log.debug("No feed URI: skipping livemark record " + record.id); return; } - if (this._ls.isLivemark(record._parent)) { + if (PlacesUtils.itemIsLivemark(record._parent)) { this._log.debug("Invalid parent: skipping livemark record " + record.id); return; } @@ -718,17 +711,16 @@ BookmarksStore.prototype = { // Use createLivemarkFolderOnly, not createLivemark, to avoid it // automatically updating during a sync. - newId = this._ls.createLivemarkFolderOnly(record._parent, record.title, - siteURI, - Utils.makeURI(record.feedUri), - Svc.Bookmark.DEFAULT_INDEX); + newId = PlacesUtils.livemarks.createLivemarkFolderOnly( + record._parent, record.title, siteURI, Utils.makeURI(record.feedUri), + PlacesUtils.bookmarks.DEFAULT_INDEX); this._log.debug("Created livemark " + newId + " under " + record._parent + " as " + record.title + ", " + record.siteUri + ", " + record.feedUri + ", GUID " + record.id); break; case "separator": - newId = this._bms.insertSeparator(record._parent, - Svc.Bookmark.DEFAULT_INDEX); + newId = PlacesUtils.bookmarks.insertSeparator( + record._parent, PlacesUtils.bookmarks.DEFAULT_INDEX); this._log.debug("created separator " + newId + " under " + record._parent); break; case "item": @@ -746,21 +738,20 @@ BookmarksStore.prototype = { // Factored out of `remove` to avoid redundant DB queries when the Places ID // is already known. removeById: function removeById(itemId, guid) { - let type = this._bms.getItemType(itemId); + let type = PlacesUtils.bookmarks.getItemType(itemId); switch (type) { - case this._bms.TYPE_BOOKMARK: + case PlacesUtils.bookmarks.TYPE_BOOKMARK: this._log.debug(" -> removing bookmark " + guid); - this._ts.untagURI(this._bms.getBookmarkURI(itemId), null); - this._bms.removeItem(itemId); + PlacesUtils.bookmarks.removeItem(itemId); break; - case this._bms.TYPE_FOLDER: + case PlacesUtils.bookmarks.TYPE_FOLDER: this._log.debug(" -> removing folder " + guid); - Svc.Bookmark.removeItem(itemId); + PlacesUtils.bookmarks.removeItem(itemId); break; - case this._bms.TYPE_SEPARATOR: + case PlacesUtils.bookmarks.TYPE_SEPARATOR: this._log.debug(" -> removing separator " + guid); - this._bms.removeItem(itemId); + PlacesUtils.bookmarks.removeItem(itemId); break; default: this._log.error("remove: Unknown item type: " + type); @@ -808,49 +799,54 @@ BookmarksStore.prototype = { // Move the bookmark to a new parent or new position if necessary if (record._parent > 0 && - Svc.Bookmark.getFolderIdForItem(itemId) != record._parent) { + PlacesUtils.bookmarks.getFolderIdForItem(itemId) != record._parent) { this._reparentItem(itemId, record._parent); } for (let [key, val] in Iterator(record.cleartext)) { switch (key) { case "title": - val = val || ""; - this._bms.setItemTitle(itemId, val); + PlacesUtils.bookmarks.setItemTitle(itemId, val); break; case "bmkUri": - this._bms.changeBookmarkURI(itemId, Utils.makeURI(val)); + PlacesUtils.bookmarks.changeBookmarkURI(itemId, Utils.makeURI(val)); break; case "tags": if (Utils.isArray(val)) { - this._tagURI(this._bms.getBookmarkURI(itemId), val); + this._tagURI(PlacesUtils.bookmarks.getBookmarkURI(itemId), val); } break; case "keyword": - this._bms.setKeywordForBookmark(itemId, val); + PlacesUtils.bookmarks.setKeywordForBookmark(itemId, val); break; case "description": - val = val || ""; - Svc.Annos.setItemAnnotation(itemId, DESCRIPTION_ANNO, val, 0, - Svc.Annos.EXPIRE_NEVER); + if (val) { + PlacesUtils.annotations.setItemAnnotation( + itemId, DESCRIPTION_ANNO, val, 0, + PlacesUtils.annotations.EXPIRE_NEVER); + } else { + PlacesUtils.annotations.removeItemAnnotation(itemId, DESCRIPTION_ANNO); + } break; case "loadInSidebar": if (val) { - Svc.Annos.setItemAnnotation(itemId, SIDEBAR_ANNO, true, 0, - Svc.Annos.EXPIRE_NEVER); + PlacesUtils.annotations.setItemAnnotation( + itemId, SIDEBAR_ANNO, true, 0, + PlacesUtils.annotations.EXPIRE_NEVER); } else { - Svc.Annos.removeItemAnnotation(itemId, SIDEBAR_ANNO); + PlacesUtils.annotations.removeItemAnnotation(itemId, SIDEBAR_ANNO); } break; case "queryId": - Svc.Annos.setItemAnnotation(itemId, SMART_BOOKMARKS_ANNO, val, 0, - Svc.Annos.EXPIRE_NEVER); + PlacesUtils.annotations.setItemAnnotation( + itemId, SMART_BOOKMARKS_ANNO, val, 0, + PlacesUtils.annotations.EXPIRE_NEVER); break; case "siteUri": - this._ls.setSiteURI(itemId, Utils.makeURI(val)); + PlacesUtils.livemarks.setSiteURI(itemId, Utils.makeURI(val)); break; case "feedUri": - this._ls.setFeedURI(itemId, Utils.makeURI(val)); + PlacesUtils.livemarks.setFeedURI(itemId, Utils.makeURI(val)); break; } } @@ -873,9 +869,10 @@ BookmarksStore.prototype = { // This code path could be optimized by caching the parent earlier. // Doing so should take in count any edge case due to reparenting // or parent invalidations though. - if (!parent) - parent = Svc.Bookmark.getFolderIdForItem(itemid); - Svc.Bookmark.moveItem(itemid, parent, idx - delta); + if (!parent) { + parent = PlacesUtils.bookmarks.getFolderIdForItem(itemid); + } + PlacesUtils.bookmarks.moveItem(itemid, parent, idx - delta); } catch (ex) { this._log.debug("Could not move item " + children[idx] + ": " + ex); } @@ -895,9 +892,10 @@ BookmarksStore.prototype = { }, _getNode: function BStore__getNode(folder) { - let query = this._hsvc.getNewQuery(); + let query = PlacesUtils.history.getNewQuery(); query.setFolders([folder], 1); - return this._hsvc.executeQuery(query, this._hsvc.getNewQueryOptions()).root; + return PlacesUtils.history.executeQuery( + query, PlacesUtils.history.getNewQueryOptions()).root; }, _getTags: function BStore__getTags(uri) { @@ -907,19 +905,19 @@ BookmarksStore.prototype = { } catch(e) { this._log.warn("Could not parse URI \"" + uri + "\": " + e); } - return this._ts.getTagsForURI(uri, {}); + return PlacesUtils.tagging.getTagsForURI(uri, {}); }, _getDescription: function BStore__getDescription(id) { try { - return Svc.Annos.getItemAnnotation(id, DESCRIPTION_ANNO); + return PlacesUtils.annotations.getItemAnnotation(id, DESCRIPTION_ANNO); } catch (e) { return null; } }, _isLoadInSidebar: function BStore__isLoadInSidebar(id) { - return Svc.Annos.itemHasAnnotation(id, SIDEBAR_ANNO); + return PlacesUtils.annotations.itemHasAnnotation(id, SIDEBAR_ANNO); }, get _childGUIDsStm() { @@ -954,10 +952,10 @@ BookmarksStore.prototype = { return record; } - let parent = Svc.Bookmark.getFolderIdForItem(placeId); - switch (this._bms.getItemType(placeId)) { - case this._bms.TYPE_BOOKMARK: - let bmkUri = this._bms.getBookmarkURI(placeId).spec; + let parent = PlacesUtils.bookmarks.getFolderIdForItem(placeId); + switch (PlacesUtils.bookmarks.getItemType(placeId)) { + case PlacesUtils.bookmarks.TYPE_BOOKMARK: + let bmkUri = PlacesUtils.bookmarks.getBookmarkURI(placeId).spec; if (bmkUri.search(/^place:/) == 0) { record = new BookmarkQuery(collection, id); @@ -967,7 +965,7 @@ BookmarksStore.prototype = { // There might not be the tag yet when creating on a new client if (folder != null) { folder = folder[1]; - record.folderName = this._bms.getItemTitle(folder); + record.folderName = PlacesUtils.bookmarks.getItemTitle(folder); this._log.trace("query id: " + folder + " = " + record.folderName); } } @@ -975,7 +973,7 @@ BookmarksStore.prototype = { // Persist the Smart Bookmark anno, if found. try { - let anno = Svc.Annos.getItemAnnotation(placeId, SMART_BOOKMARKS_ANNO); + let anno = PlacesUtils.annotations.getItemAnnotation(placeId, SMART_BOOKMARKS_ANNO); if (anno != null) { this._log.trace("query anno: " + SMART_BOOKMARKS_ANNO + " = " + anno); @@ -987,45 +985,45 @@ BookmarksStore.prototype = { else { record = new Bookmark(collection, id); } - record.title = this._bms.getItemTitle(placeId); + record.title = PlacesUtils.bookmarks.getItemTitle(placeId); - record.parentName = Svc.Bookmark.getItemTitle(parent); + record.parentName = PlacesUtils.bookmarks.getItemTitle(parent); record.bmkUri = bmkUri; record.tags = this._getTags(record.bmkUri); - record.keyword = this._bms.getKeywordForBookmark(placeId); + record.keyword = PlacesUtils.bookmarks.getKeywordForBookmark(placeId); record.description = this._getDescription(placeId); record.loadInSidebar = this._isLoadInSidebar(placeId); break; - case this._bms.TYPE_FOLDER: - if (this._ls.isLivemark(placeId)) { + case PlacesUtils.bookmarks.TYPE_FOLDER: + if (PlacesUtils.itemIsLivemark(placeId)) { record = new Livemark(collection, id); - let siteURI = this._ls.getSiteURI(placeId); + let siteURI = PlacesUtils.livemarks.getSiteURI(placeId); if (siteURI != null) record.siteUri = siteURI.spec; - record.feedUri = this._ls.getFeedURI(placeId).spec; + record.feedUri = PlacesUtils.livemarks.getFeedURI(placeId).spec; } else { record = new BookmarkFolder(collection, id); } if (parent > 0) - record.parentName = Svc.Bookmark.getItemTitle(parent); - record.title = this._bms.getItemTitle(placeId); + record.parentName = PlacesUtils.bookmarks.getItemTitle(parent); + record.title = PlacesUtils.bookmarks.getItemTitle(placeId); record.description = this._getDescription(placeId); record.children = this._getChildGUIDsForId(placeId); break; - case this._bms.TYPE_SEPARATOR: + case PlacesUtils.bookmarks.TYPE_SEPARATOR: record = new BookmarkSeparator(collection, id); if (parent > 0) - record.parentName = Svc.Bookmark.getItemTitle(parent); + record.parentName = PlacesUtils.bookmarks.getItemTitle(parent); // Create a positioning identifier for the separator, used by _lazyMap - record.pos = Svc.Bookmark.getItemIndex(placeId); + record.pos = PlacesUtils.bookmarks.getItemIndex(placeId); break; - case this._bms.TYPE_DYNAMIC_CONTAINER: + case PlacesUtils.bookmarks.TYPE_DYNAMIC_CONTAINER: record = new PlacesItem(collection, id); this._log.warn("Don't know how to serialize dynamic containers yet"); break; @@ -1033,7 +1031,7 @@ BookmarksStore.prototype = { default: record = new PlacesItem(collection, id); this._log.warn("Unknown item type, cannot serialize: " + - this._bms.getItemType(placeId)); + PlacesUtils.bookmarks.getItemType(placeId)); } record.parentid = this.GUIDForId(parent); @@ -1048,8 +1046,9 @@ BookmarksStore.prototype = { return this._stmts[query]; this._log.trace("Creating SQL statement: " + query); - return this._stmts[query] = this._hsvc.DBConnection - .createAsyncStatement(query); + let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase) + .DBConnection; + return this._stmts[query] = db.createAsyncStatement(query); }, get _frecencyStm() { @@ -1170,7 +1169,7 @@ BookmarksStore.prototype = { } if (node.type == node.RESULT_TYPE_FOLDER && - !this._ls.isLivemark(node.itemId)) { + !PlacesUtils.itemIsLivemark(node.itemId)) { node.QueryInterface(Ci.nsINavHistoryQueryResultNode); node.containerOpen = true; try { @@ -1195,10 +1194,10 @@ BookmarksStore.prototype = { // Temporarily tag a dummy uri to preserve tag ids when untagging let dummyURI = Utils.makeURI("about:weave#BStore_tagURI"); - this._ts.tagURI(dummyURI, tags); - this._ts.untagURI(bmkURI, null); - this._ts.tagURI(bmkURI, tags); - this._ts.untagURI(dummyURI, null); + PlacesUtils.tagging.tagURI(dummyURI, tags); + PlacesUtils.tagging.untagURI(bmkURI, null); + PlacesUtils.tagging.tagURI(bmkURI, tags); + PlacesUtils.tagging.untagURI(dummyURI, null); }, getAllIDs: function BStore_getAllIDs() { @@ -1219,7 +1218,7 @@ BookmarksStore.prototype = { if (guid != "places") { let id = kSpecialIds.specialIdForGUID(guid); if (id) - this._bms.removeFolderChildren(id); + PlacesUtils.bookmarks.removeFolderChildren(id); } } }; @@ -1239,7 +1238,7 @@ BookmarksTracker.prototype = { switch (topic) { case "weave:engine:start-tracking": if (!this._enabled) { - Svc.Bookmark.addObserver(this, true); + PlacesUtils.bookmarks.addObserver(this, true); Svc.Obs.add("bookmarks-restore-begin", this); Svc.Obs.add("bookmarks-restore-success", this); Svc.Obs.add("bookmarks-restore-failed", this); @@ -1248,18 +1247,12 @@ BookmarksTracker.prototype = { break; case "weave:engine:stop-tracking": if (this._enabled) { - Svc.Bookmark.removeObserver(this); + PlacesUtils.bookmarks.removeObserver(this); Svc.Obs.remove("bookmarks-restore-begin", this); Svc.Obs.remove("bookmarks-restore-success", this); Svc.Obs.remove("bookmarks-restore-failed", this); this._enabled = false; } - // Fall through to clean up. - case "places-shutdown": - // Explicitly nullify our references to our cached services so - // we don't leak - this.__ls = null; - this.__bms = null; break; case "bookmarks-restore-begin": @@ -1282,46 +1275,21 @@ BookmarksTracker.prototype = { } }, - __bms: null, - get _bms() { - if (!this.__bms) - this.__bms = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. - getService(Ci.nsINavBookmarksService); - return this.__bms; - }, - - __ls: null, - get _ls() { - if (!this.__ls) - this.__ls = Cc["@mozilla.org/browser/livemark-service;2"]. - getService(Ci.nsILivemarkService); - return this.__ls; - }, - QueryInterface: XPCOMUtils.generateQI([ Ci.nsINavBookmarkObserver, Ci.nsINavBookmarkObserver_MOZILLA_1_9_1_ADDITIONS, Ci.nsISupportsWeakReference ]), - _idForGUID: function _idForGUID(item_id) { - // Isn't indirection fun... - return Engines.get("bookmarks")._store.idForGUID(item_id); - }, - - _GUIDForId: function _GUIDForId(item_id) { - // Isn't indirection fun... - return Engines.get("bookmarks")._store.GUIDForId(item_id); - }, - /** - * Add a bookmark (places) id to be uploaded and bump up the sync score + * Add a bookmark guid to be uploaded and bump up the sync score * - * @param itemId - * Places internal id of the bookmark to upload + * @param itemGuid + * Guid of the bookmark to upload */ - _addId: function BMT__addId(itemId) { - if (this.addChangedID(this._GUIDForId(itemId))) + _add: function BMT__add(itemId, guid) { + guid = kSpecialIds.specialGUIDForId(itemId) || guid; + if (this.addChangedID(guid)) this._upScore(); }, @@ -1339,7 +1307,7 @@ BookmarksTracker.prototype = { * @param folder (optional) * Folder of the item being changed */ - _ignore: function BMT__ignore(itemId, folder) { + _ignore: function BMT__ignore(itemId, folder, guid) { // Ignore unconditionally if the engine tells us to. if (this.ignoreAll) return true; @@ -1347,19 +1315,19 @@ BookmarksTracker.prototype = { // Get the folder id if we weren't given one. if (folder == null) { try { - folder = this._bms.getFolderIdForItem(itemId); + folder = PlacesUtils.bookmarks.getFolderIdForItem(itemId); } catch (ex) { this._log.debug("getFolderIdForItem(" + itemId + ") threw; calling _ensureMobileQuery."); // I'm guessing that gFIFI can throw, and perhaps that's why // _ensureMobileQuery is here at all. Try not to call it. this._ensureMobileQuery(); - folder = this._bms.getFolderIdForItem(itemId); + folder = PlacesUtils.bookmarks.getFolderIdForItem(itemId); } } // Ignore livemark children. - if (this._ls.isLivemark(folder)) + if (PlacesUtils.itemIsLivemark(folder)) return true; // Ignore changes to tags (folders under the tags folder). @@ -1368,41 +1336,44 @@ BookmarksTracker.prototype = { return true; // Ignore tag items (the actual instance of a tag for a bookmark). - if (this._bms.getFolderIdForItem(folder) == tags) + if (PlacesUtils.bookmarks.getFolderIdForItem(folder) == tags) return true; // Make sure to remove items that have the exclude annotation. - if (Svc.Annos.itemHasAnnotation(itemId, EXCLUDEBACKUP_ANNO)) { - this.removeChangedID(this._GUIDForId(itemId)); + if (PlacesUtils.annotations.itemHasAnnotation(itemId, EXCLUDEBACKUP_ANNO)) { + this.removeChangedID(guid); return true; } return false; }, - onItemAdded: function BMT_onEndUpdateBatch(itemId, folder, index) { - if (this._ignore(itemId, folder)) + onItemAdded: function BMT_onItemAdded(itemId, folder, index, + itemType, uri, title, dateAdded, + guid, parentGuid) { + if (this._ignore(itemId, folder, guid)) return; this._log.trace("onItemAdded: " + itemId); - this._addId(itemId); - this._addId(folder); + this._add(itemId, guid); + this._add(folder, parentGuid); }, - onBeforeItemRemoved: function BMT_onBeforeItemRemoved(itemId) { - if (this._ignore(itemId)) + onItemRemoved: function BMT_onItemRemoved(itemId, parentId, index, type, uri, + guid, parentGuid) { + if (this._ignore(itemId, parentId, guid)) return; this._log.trace("onBeforeItemRemoved: " + itemId); - this._addId(itemId); - let folder = Svc.Bookmark.getFolderIdForItem(itemId); - this._addId(folder); + this._add(itemId, guid); + this._add(parentId, parentGuid); }, _ensureMobileQuery: function _ensureMobileQuery() { - let anno = "PlacesOrganizer/OrganizerQuery"; - let find = function(val) Svc.Annos.getItemsWithAnnotation(anno, {}).filter( - function(id) Svc.Annos.getItemAnnotation(id, anno) == val); + let find = function (val) + PlacesUtils.annotations.getItemsWithAnnotation(ORGANIZERQUERY_ANNO, {}).filter( + function (id) PlacesUtils.annotations.getItemAnnotation(id, ORGANIZERQUERY_ANNO) == val + ); // Don't continue if the Library isn't ready let all = find(ALLBOOKMARKS_ANNO); @@ -1417,21 +1388,22 @@ BookmarksTracker.prototype = { let title = Str.sync.get("mobile.label"); // Don't add OR remove the mobile bookmarks if there's nothing. - if (Svc.Bookmark.getIdForItemAt(kSpecialIds.mobile, 0) == -1) { + if (PlacesUtils.bookmarks.getIdForItemAt(kSpecialIds.mobile, 0) == -1) { if (mobile.length != 0) - Svc.Bookmark.removeItem(mobile[0]); + PlacesUtils.bookmarks.removeItem(mobile[0]); } // Add the mobile bookmarks query if it doesn't exist else if (mobile.length == 0) { - let query = Svc.Bookmark.insertBookmark(all[0], queryURI, -1, title); - Svc.Annos.setItemAnnotation(query, anno, MOBILE_ANNO, 0, - Svc.Annos.EXPIRE_NEVER); - Svc.Annos.setItemAnnotation(query, EXCLUDEBACKUP_ANNO, 1, 0, - Svc.Annos.EXPIRE_NEVER); + let query = PlacesUtils.bookmarks.insertBookmark(all[0], queryURI, -1, title); + PlacesUtils.annotations.setItemAnnotation(query, ORGANIZERQUERY_ANNO, MOBILE_ANNO, 0, + PlacesUtils.annotations.EXPIRE_NEVER); + PlacesUtils.annotations.setItemAnnotation(query, EXCLUDEBACKUP_ANNO, 1, 0, + PlacesUtils.annotations.EXPIRE_NEVER); } // Make sure the existing title is correct - else if (Svc.Bookmark.getItemTitle(mobile[0]) != title) - Svc.Bookmark.setItemTitle(mobile[0], title); + else if (PlacesUtils.bookmarks.getItemTitle(mobile[0]) != title) { + PlacesUtils.bookmarks.setItemTitle(mobile[0], title); + } this.ignoreAll = false; }, @@ -1440,7 +1412,9 @@ BookmarksTracker.prototype = { // possible -- this handler gets called *every time* a bookmark changes, for // *each change*. That's particularly bad when a bunch of livemarks are // updated. - onItemChanged: function BMT_onItemChanged(itemId, property, isAnno, value) { + onItemChanged: function BMT_onItemChanged(itemId, property, isAnno, value, + lastModified, itemType, parentId, + guid, parentGuid) { // Quicker checks first. if (this.ignoreAll) return; @@ -1453,32 +1427,34 @@ BookmarksTracker.prototype = { if (property == "favicon") return; - if (this._ignore(itemId)) + if (this._ignore(itemId, parentId, guid)) return; this._log.trace("onItemChanged: " + itemId + (", " + property + (isAnno? " (anno)" : "")) + (value ? (" = \"" + value + "\"") : "")); - this._addId(itemId); + this._add(itemId, guid); }, - onItemMoved: function BMT_onItemMoved(itemId, oldParent, oldIndex, newParent, newIndex) { - if (this._ignore(itemId)) + onItemMoved: function BMT_onItemMoved(itemId, oldParent, oldIndex, + newParent, newIndex, itemType, + guid, oldParentGuid, newParentGuid) { + if (this._ignore(itemId, newParent, guid)) return; this._log.trace("onItemMoved: " + itemId); - this._addId(oldParent); + this._add(oldParent, oldParentGuid); if (oldParent != newParent) { - this._addId(itemId); - this._addId(newParent); + this._add(itemId, guid); + this._add(newParent, newParentGuid); } // Remove any position annotations now that the user moved the item - Svc.Annos.removeItemAnnotation(itemId, PARENT_ANNO); + PlacesUtils.annotations.removeItemAnnotation(itemId, PARENT_ANNO); }, - onBeginUpdateBatch: function BMT_onBeginUpdateBatch() {}, - onEndUpdateBatch: function BMT_onEndUpdateBatch() {}, - onItemRemoved: function BMT_onItemRemoved(itemId, folder, index) {}, - onItemVisited: function BMT_onItemVisited(itemId, aVisitID, time) {} + onBeginUpdateBatch: function () {}, + onEndUpdateBatch: function () {}, + onBeforeItemRemoved: function () {}, + onItemVisited: function () {} }; diff --git a/services/sync/modules/engines/clients.js b/services/sync/modules/engines/clients.js index 0027d0f0994..e6a62060379 100644 --- a/services/sync/modules/engines/clients.js +++ b/services/sync/modules/engines/clients.js @@ -63,7 +63,9 @@ ClientsRec.prototype = { Utils.deferGetSet(ClientsRec, "cleartext", ["name", "type", "commands"]); -Utils.lazy(this, "Clients", ClientEngine); +XPCOMUtils.defineLazyGetter(this, "Clients", function () { + return new ClientEngine(); +}); function ClientEngine() { SyncEngine.call(this, "Clients"); @@ -151,12 +153,15 @@ ClientEngine.prototype = { return localName; // Generate a client name if we don't have a useful one yet - let user = Svc.Env.get("USER") || Svc.Env.get("USERNAME") || + let env = Cc["@mozilla.org/process/environment;1"] + .getService(Ci.nsIEnvironment); + let user = env.get("USER") || env.get("USERNAME") || Svc.Prefs.get("account") || Svc.Prefs.get("username"); let brand = new StringBundle("chrome://branding/locale/brand.properties"); let app = brand.get("brandShortName"); - let system = Svc.SysInfo.get("device") || + let system = Cc["@mozilla.org/system-info;1"] + .getService(Ci.nsIPropertyBag2).get("device") || Cc["@mozilla.org/network/protocol;1?name=http"] .getService(Ci.nsIHttpProtocolHandler).oscpu; diff --git a/services/sync/modules/engines/history.js b/services/sync/modules/engines/history.js index 2be6f995011..9641ccd7edb 100644 --- a/services/sync/modules/engines/history.js +++ b/services/sync/modules/engines/history.js @@ -89,24 +89,12 @@ function HistoryStore(name) { Svc.Obs.add("places-shutdown", function() { for each ([query, stmt] in Iterator(this._stmts)) stmt.finalize(); - this.__hsvc = null; this._stmts = []; }, this); } HistoryStore.prototype = { __proto__: Store.prototype, - __hsvc: null, - get _hsvc() { - if (!this.__hsvc) - this.__hsvc = Cc["@mozilla.org/browser/nav-history-service;1"]. - getService(Ci.nsINavHistoryService). - QueryInterface(Ci.nsIGlobalHistory2). - QueryInterface(Ci.nsIBrowserHistory). - QueryInterface(Ci.nsPIPlacesDatabase); - return this.__hsvc; - }, - __asyncHistory: null, get _asyncHistory() { if (!this.__asyncHistory) { @@ -122,8 +110,9 @@ HistoryStore.prototype = { return this._stmts[query]; this._log.trace("Creating SQL statement: " + query); - return this._stmts[query] = this._hsvc.DBConnection - .createAsyncStatement(query); + let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase) + .DBConnection; + return this._stmts[query] = db.createAsyncStatement(query); }, get _setGUIDStm() { @@ -299,7 +288,7 @@ HistoryStore.prototype = { } record.guid = record.id; - if (!this._hsvc.canAddURI(record.uri)) { + if (!PlacesUtils.history.canAddURI(record.uri)) { this._log.trace("Ignoring record " + record.id + " with URI " + record.uri.spec + ": can't add this URI."); return false; @@ -325,8 +314,8 @@ HistoryStore.prototype = { + visit.date); throw "Visit has no date!"; } - if (!visit.type || !(visit.type >= Svc.History.TRANSITION_LINK && - visit.type <= Svc.History.TRANSITION_FRAMED_LINK)) { + if (!visit.type || !(visit.type >= PlacesUtils.history.TRANSITION_LINK && + visit.type <= PlacesUtils.history.TRANSITION_FRAMED_LINK)) { this._log.warn("Encountered record with invalid visit type: " + visit.type); throw "Invalid visit type!"; @@ -366,7 +355,7 @@ HistoryStore.prototype = { } let uri = Utils.makeURI(page.url); - Svc.History.removePage(uri); + PlacesUtils.history.removePage(uri); this._log.trace("Removed page: " + [record.id, page.url, page.title]); }, @@ -380,7 +369,7 @@ HistoryStore.prototype = { if (typeof(url) == "string") url = Utils.makeURI(url); // Don't call isVisited on a null URL to work around crasher bug 492442. - return url ? this._hsvc.isVisited(url) : false; + return url ? PlacesUtils.history.isVisited(url) : false; }, createRecord: function createRecord(id, collection) { @@ -399,7 +388,7 @@ HistoryStore.prototype = { }, wipe: function HistStore_wipe() { - this._hsvc.removeAllPages(); + PlacesUtils.history.removeAllPages(); } }; @@ -416,13 +405,13 @@ HistoryTracker.prototype = { switch (topic) { case "weave:engine:start-tracking": if (!this._enabled) { - Svc.History.addObserver(this, true); + PlacesUtils.history.addObserver(this, true); this._enabled = true; } break; case "weave:engine:stop-tracking": if (this._enabled) { - Svc.History.removeObserver(this); + PlacesUtils.history.removeObserver(this); this._enabled = false; } break; diff --git a/services/sync/modules/engines/passwords.js b/services/sync/modules/engines/passwords.js index 7b9b0d07299..8609250ab23 100644 --- a/services/sync/modules/engines/passwords.js +++ b/services/sync/modules/engines/passwords.js @@ -77,8 +77,10 @@ PasswordEngine.prototype = { // Delete the weave credentials from the server once if (!Svc.Prefs.get("deletePwd", false)) { try { - let ids = Svc.Login.findLogins({}, PWDMGR_HOST, "", "").map(function(info) - info.QueryInterface(Components.interfaces.nsILoginMetaInfo).guid); + let ids = Services.logins.findLogins({}, PWDMGR_HOST, "", "") + .map(function(info) { + return info.QueryInterface(Components.interfaces.nsILoginMetaInfo).guid; + }); let coll = new Collection(this.engineURL); coll.ids = ids; let ret = coll.delete(); @@ -97,8 +99,8 @@ PasswordEngine.prototype = { if (!login) return; - let logins = Svc.Login.findLogins({}, login.hostname, login.formSubmitURL, - login.httpRealm); + let logins = Services.logins.findLogins( + {}, login.hostname, login.formSubmitURL, login.httpRealm); this._store._sleep(0); // Yield back to main thread after synchronous operation. // Look for existing logins that match the hostname but ignore the password @@ -113,9 +115,9 @@ function PasswordStore(name) { this._nsLoginInfo = new Components.Constructor( "@mozilla.org/login-manager/loginInfo;1", Ci.nsILoginInfo, "init"); - Utils.lazy2(this, "DBConnection", function() { - return Svc.Login.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.mozIStorageConnection); + XPCOMUtils.defineLazyGetter(this, "DBConnection", function() { + return Services.logins.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.mozIStorageConnection); }); } PasswordStore.prototype = { @@ -150,7 +152,7 @@ PasswordStore.prototype = { createInstance(Ci.nsIWritablePropertyBag2); prop.setPropertyAsAUTF8String("guid", id); - let logins = Svc.Login.searchLogins({}, prop); + let logins = Services.logins.searchLogins({}, prop); this._sleep(0); // Yield back to main thread after synchronous operation. if (logins.length > 0) { this._log.trace(logins.length + " items matching " + id + " found."); @@ -178,7 +180,7 @@ PasswordStore.prototype = { getAllIDs: function PasswordStore__getAllIDs() { let items = {}; - let logins = Svc.Login.getAllLogins({}); + let logins = Services.logins.getAllLogins({}); for (let i = 0; i < logins.length; i++) { // Skip over Weave password/passphrase entries @@ -209,7 +211,7 @@ PasswordStore.prototype = { createInstance(Ci.nsIWritablePropertyBag2); prop.setPropertyAsAUTF8String("guid", newID); - Svc.Login.modifyLogin(oldLogin, prop); + Services.logins.modifyLogin(oldLogin, prop); }, itemExists: function PasswordStore__itemExists(id) { @@ -244,7 +246,7 @@ PasswordStore.prototype = { this._log.trace("httpRealm: " + JSON.stringify(login.httpRealm) + "; " + "formSubmitURL: " + JSON.stringify(login.formSubmitURL)); try { - Svc.Login.addLogin(login); + Services.logins.addLogin(login); } catch(ex) { this._log.debug("Adding record " + record.id + " resulted in exception " + Utils.exceptionStr(ex)); @@ -260,7 +262,7 @@ PasswordStore.prototype = { return; } - Svc.Login.removeLogin(loginItem); + Services.logins.removeLogin(loginItem); }, update: function PasswordStore__update(record) { @@ -275,7 +277,7 @@ PasswordStore.prototype = { if (!newinfo) return; try { - Svc.Login.modifyLogin(loginItem, newinfo); + Services.logins.modifyLogin(loginItem, newinfo); } catch(ex) { this._log.debug("Modifying record " + record.id + " resulted in exception " + Utils.exceptionStr(ex) + @@ -284,7 +286,7 @@ PasswordStore.prototype = { }, wipe: function PasswordStore_wipe() { - Svc.Login.removeAllLogins(); + Services.logins.removeAllLogins(); } }; diff --git a/services/sync/modules/engines/prefs.js b/services/sync/modules/engines/prefs.js index cf79f51d2f3..3ddeea83d58 100644 --- a/services/sync/modules/engines/prefs.js +++ b/services/sync/modules/engines/prefs.js @@ -49,7 +49,7 @@ Cu.import("resource://services-sync/util.js"); Cu.import("resource://services-sync/ext/Preferences.js"); Cu.import("resource://gre/modules/LightweightThemeManager.jsm"); -const PREFS_GUID = Utils.encodeBase64url(Svc.AppInfo.ID); +const PREFS_GUID = Utils.encodeBase64url(Services.appinfo.ID); function PrefRec(collection, id) { CryptoWrapper.call(this, collection, id); diff --git a/services/sync/modules/engines/tabs.js b/services/sync/modules/engines/tabs.js index 0b2e55dc4d7..c1b9e5eaa97 100644 --- a/services/sync/modules/engines/tabs.js +++ b/services/sync/modules/engines/tabs.js @@ -301,7 +301,7 @@ TabTracker.prototype = { if (!this._enabled) { Svc.Obs.add("private-browsing", this); Svc.Obs.add("domwindowopened", this); - let wins = Svc.WinMediator.getEnumerator("navigator:browser"); + let wins = Services.wm.getEnumerator("navigator:browser"); while (wins.hasMoreElements()) this._registerListenersForWindow(wins.getNext()); this._enabled = true; @@ -311,7 +311,7 @@ TabTracker.prototype = { if (this._enabled) { Svc.Obs.remove("private-browsing", this); Svc.Obs.remove("domwindowopened", this); - let wins = Svc.WinMediator.getEnumerator("navigator:browser"); + let wins = Services.wm.getEnumerator("navigator:browser"); while (wins.hasMoreElements()) this._unregisterListenersForWindow(wins.getNext()); this._enabled = false; diff --git a/services/sync/modules/identity.js b/services/sync/modules/identity.js index cbaf2692908..2c662a0b113 100644 --- a/services/sync/modules/identity.js +++ b/services/sync/modules/identity.js @@ -52,7 +52,9 @@ __defineGetter__("Service", function() { return this.Service; }); -Utils.lazy(this, 'ID', IDManager); +XPCOMUtils.defineLazyGetter(this, "ID", function () { + return new IDManager(); +}); // For storing identities we'll use throughout Weave function IDManager() { @@ -118,7 +120,7 @@ Identity.prototype = { if (login.username == this.username && login.password == this._password) exists = true; else - Svc.Login.removeLogin(login); + Services.logins.removeLogin(login); } // No need to create the login after clearing out the other ones @@ -134,8 +136,8 @@ Identity.prototype = { "@mozilla.org/login-manager/loginInfo;1", Ci.nsILoginInfo, "init"); let newLogin = new nsLoginInfo(PWDMGR_HOST, null, this.realm, this.username, this.password, "", ""); - Svc.Login.addLogin(newLogin); + Services.logins.addLogin(newLogin); }, - get _logins() Svc.Login.findLogins({}, PWDMGR_HOST, null, this.realm) + get _logins() Services.logins.findLogins({}, PWDMGR_HOST, null, this.realm) }; diff --git a/services/sync/modules/record.js b/services/sync/modules/record.js index d75051c1593..12fc93ca5b2 100644 --- a/services/sync/modules/record.js +++ b/services/sync/modules/record.js @@ -123,7 +123,9 @@ WBORecord.prototype = { Utils.deferGetSet(WBORecord, "data", ["id", "modified", "sortindex", "payload"]); -Utils.lazy(this, 'Records', RecordManager); +XPCOMUtils.defineLazyGetter(this, "Records", function () { + return new RecordManager(); +}); function RecordManager() { this._log = Log4Moz.repository.getLogger(this._logName); @@ -279,7 +281,9 @@ CryptoWrapper.prototype = { Utils.deferGetSet(CryptoWrapper, "payload", ["ciphertext", "IV", "hmac"]); Utils.deferGetSet(CryptoWrapper, "cleartext", "deleted"); -Utils.lazy(this, "CollectionKeys", CollectionKeyManager); +XPCOMUtils.defineLazyGetter(this, "CollectionKeys", function () { + return new CollectionKeyManager(); +}); /** diff --git a/services/sync/modules/resource.js b/services/sync/modules/resource.js index 402dba6e910..3c33d5d8e4b 100644 --- a/services/sync/modules/resource.js +++ b/services/sync/modules/resource.js @@ -52,7 +52,9 @@ Cu.import("resource://services-sync/ext/Preferences.js"); Cu.import("resource://services-sync/log4moz.js"); Cu.import("resource://services-sync/util.js"); -Utils.lazy(this, 'Auth', AuthMgr); +XPCOMUtils.defineLazyGetter(this, "Auth", function () { + return new AuthMgr(); +}); // XXX: the authenticator api will probably need to be changed to support // other methods (digest, oauth, etc) @@ -134,7 +136,7 @@ AuthMgr.prototype = { function AsyncResource(uri) { this._log = Log4Moz.repository.getLogger(this._logName); this._log.level = - Log4Moz.Level[Utils.prefs.getCharPref("log.logger.network.resources")]; + Log4Moz.Level[Svc.Prefs.get("log.logger.network.resources")]; this.uri = uri; this._headers = {}; this._onComplete = Utils.bind2(this, this._onComplete); @@ -152,9 +154,9 @@ AsyncResource.prototype = { // Firefox Aurora/5.0a1 FxSync/1.9.0.20110409.desktop // _userAgent: - Svc.AppInfo.name + "/" + Svc.AppInfo.version + // Product. - " FxSync/" + WEAVE_VERSION + "." + // Sync. - Svc.AppInfo.appBuildID + ".", // Build. + Services.appinfo.name + "/" + Services.appinfo.version + // Product. + " FxSync/" + WEAVE_VERSION + "." + // Sync. + Services.appinfo.appBuildID + ".", // Build. // Wait 5 minutes before killing a request. ABORT_TIMEOUT: 300000, @@ -228,8 +230,9 @@ AsyncResource.prototype = { // to obtain a request channel. // _createRequest: function Res__createRequest() { - let channel = Svc.IO.newChannel(this.spec, null, null). - QueryInterface(Ci.nsIRequest).QueryInterface(Ci.nsIHttpChannel); + let channel = Services.io.newChannel(this.spec, null, null) + .QueryInterface(Ci.nsIRequest) + .QueryInterface(Ci.nsIHttpChannel); // Always validate the cache: channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE; @@ -378,7 +381,7 @@ AsyncResource.prototype = { // Make a lazy getter to convert the json response into an object. // Note that this can cause a parse error to be thrown far away from the // actual fetch, so be warned! - Utils.lazy2(ret, "obj", function() JSON.parse(ret)); + XPCOMUtils.defineLazyGetter(ret, "obj", function() JSON.parse(ret)); // Notify if we get a 401 to maybe try again with a new URI. // TODO: more retry logic. @@ -633,7 +636,7 @@ BadCertListener.prototype = { // Silently ignore? let log = Log4Moz.repository.getLogger("Service.CertListener"); log.level = - Log4Moz.Level[Utils.prefs.getCharPref("log.logger.network.resources")]; + Log4Moz.Level[Svc.Prefs.get("log.logger.network.resources")]; log.debug("Invalid HTTPS certificate encountered, ignoring!"); return true; diff --git a/services/sync/modules/service.js b/services/sync/modules/service.js index 474c9124d2e..9876cada627 100644 --- a/services/sync/modules/service.js +++ b/services/sync/modules/service.js @@ -60,6 +60,7 @@ const KEYS_WBO = "keys"; const LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/FileUtils.jsm"); Cu.import("resource://services-sync/record.js"); Cu.import("resource://services-sync/constants.js"); Cu.import("resource://services-sync/engines.js"); @@ -72,8 +73,6 @@ Cu.import("resource://services-sync/status.js"); Cu.import("resource://services-sync/util.js"); Cu.import("resource://services-sync/main.js"); -Utils.lazy(this, 'Service', WeaveSvc); - /* * Service singleton * Main entry point into Weave's sync framework @@ -492,13 +491,8 @@ WeaveSvc.prototype = { let enabled = Svc.Prefs.get("log.appender.debugLog.enabled", false); if (enabled) { - let verbose = Svc.Directory.get("ProfD", Ci.nsIFile); - verbose.QueryInterface(Ci.nsILocalFile); - verbose.append("weave"); - verbose.append("logs"); - verbose.append("verbose-log.txt"); - if (!verbose.exists()) - verbose.create(verbose.NORMAL_FILE_TYPE, PERMS_FILE); + let verbose = FileUtils.getFile( + "ProfD", ["weave", "logs", "verbose-log.txt"], true); if (Svc.Prefs.get("log.appender.debugLog.rotate", true)) { let maxSize = Svc.Prefs.get("log.appender.debugLog.maxSize"); @@ -551,7 +545,8 @@ WeaveSvc.prototype = { this._checkSyncStatus(); break; case "weave:service:login:error": - if (Status.login == LOGIN_FAILED_NETWORK_ERROR && !Svc.IO.offline) { + if (Status.login == LOGIN_FAILED_NETWORK_ERROR && + !Services.io.offline) { this._ignorableErrorCount += 1; } break; @@ -559,7 +554,7 @@ WeaveSvc.prototype = { this._handleSyncError(); switch (Status.sync) { case LOGIN_FAILED_NETWORK_ERROR: - if (!Svc.IO.offline) { + if (!Services.io.offline) { this._ignorableErrorCount += 1; } break; @@ -1087,8 +1082,8 @@ WeaveSvc.prototype = { // Find weave logins and remove them. this.password = ""; this.passphrase = ""; - Svc.Login.findLogins({}, PWDMGR_HOST, "", "").map(function(login) { - Svc.Login.removeLogin(login); + Services.logins.findLogins({}, PWDMGR_HOST, "", "").map(function(login) { + Services.logins.removeLogin(login); }); Svc.Obs.notify("weave:service:start-over"); Svc.Obs.notify("weave:engine:stop-tracking"); @@ -1152,7 +1147,7 @@ WeaveSvc.prototype = { this._catch(this._lock("service.js: login", this._notify("login", "", function() { this._loggedIn = false; - if (Svc.IO.offline) { + if (Services.io.offline) { Status.login = LOGIN_FAILED_NETWORK_ERROR; throw "Application is offline, login should not be called"; } @@ -1443,7 +1438,7 @@ WeaveSvc.prototype = { */ _shouldLogin: function _shouldLogin() { return this.enabled && - !Svc.IO.offline && + !Services.io.offline && !this.isLoggedIn; }, @@ -1459,7 +1454,7 @@ WeaveSvc.prototype = { let reason = ""; if (!this.enabled) reason = kSyncWeaveDisabled; - else if (Svc.IO.offline) + else if (Services.io.offline) reason = kSyncNetworkOffline; else if (Status.minimumNextSync > Date.now()) reason = kSyncBackoffNotMet; @@ -2340,4 +2335,5 @@ WeaveSvc.prototype = { }; // Load Weave on the first time this file is loaded +let Service = new WeaveSvc(); Service.onStartup(); diff --git a/services/sync/modules/util.js b/services/sync/modules/util.js index 63588f2f739..e487792d898 100644 --- a/services/sync/modules/util.js +++ b/services/sync/modules/util.js @@ -35,7 +35,8 @@ * * ***** END LICENSE BLOCK ***** */ -const EXPORTED_SYMBOLS = ['Utils', 'Svc', 'Str']; +const EXPORTED_SYMBOLS = ["XPCOMUtils", "Services", "NetUtil", "PlacesUtils", + "Utils", "Svc", "Str"]; const Cc = Components.classes; const Ci = Components.interfaces; @@ -47,7 +48,11 @@ Cu.import("resource://services-sync/ext/Observers.js"); Cu.import("resource://services-sync/ext/Preferences.js"); Cu.import("resource://services-sync/ext/StringBundle.js"); Cu.import("resource://services-sync/log4moz.js"); +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/PlacesUtils.jsm"); Cu.import("resource://gre/modules/NetUtil.jsm"); +Cu.import("resource://gre/modules/FileUtils.jsm"); // Constants for makeSyncCallback, waitForSyncCallback const CB_READY = {}; @@ -173,29 +178,6 @@ let Utils = { }; }, - batchSync: function batchSync(service, engineType) { - return function batchedSync() { - let engine = this; - let batchEx = null; - - // Try running sync in batch mode - Svc[service].runInBatchMode({ - runBatched: function wrappedSync() { - try { - engineType.prototype._sync.call(engine); - } - catch(ex) { - batchEx = ex; - } - } - }, null); - - // Expose the exception if something inside the batch failed - if (batchEx!= null) - throw batchEx; - }; - }, - runInTransaction: function(db, callback, thisObj) { let hasTransaction = false; try { @@ -315,32 +297,12 @@ let Utils = { window.addEventListener("unload", function() windows[url] = null, false); }, - // Returns a nsILocalFile representing a file relative to the - // current user's profile directory. If the argument is a string, - // it should be a string with unix-style slashes for directory names - // (these slashes are automatically converted to platform-specific - // path separators). - // - // Alternatively, if the argument is an object, it should contain - // the following attributes: - // - // path: the path to the file, relative to the current user's - // profile dir. - // - // autoCreate: whether or not the file should be created if it - // doesn't already exist. - getProfileFile: function getProfileFile(arg) { - if (typeof arg == "string") - arg = {path: arg}; - - let pathParts = arg.path.split("/"); - let file = Svc.Directory.get("ProfD", Ci.nsIFile); - file.QueryInterface(Ci.nsILocalFile); - for (let i = 0; i < pathParts.length; i++) - file.append(pathParts[i]); - if (arg.autoCreate && !file.exists()) - file.create(file.NORMAL_FILE_TYPE, PERMS_FILE); - return file; + // Returns a nsILocalFile representing a file relative to the current + // user's profile directory. The argument should be a string with + // unix-style slashes for directory names (these slashes are automatically + // converted to platform-specific path separators). + getProfileFile: function getProfileFile(path) { + return FileUtils.getFile("ProfD", path.split("/"), true); }, /** @@ -385,55 +347,6 @@ let Utils = { isArray: function Utils_isArray(val) val != null && typeof val == "object" && val.constructor.name == "Array", - // lazy load objects from a constructor on first access. It will - // work with the global object ('this' in the global context). - lazy: function Weave_lazy(dest, prop, ctr) { - delete dest[prop]; - dest.__defineGetter__(prop, Utils.lazyCb(dest, prop, ctr)); - }, - lazyCb: function Weave_lazyCb(dest, prop, ctr) { - return function() { - delete dest[prop]; - dest[prop] = new ctr(); - return dest[prop]; - }; - }, - - // like lazy, but rather than new'ing the 3rd arg we use its return value - lazy2: function Weave_lazy2(dest, prop, fn) { - delete dest[prop]; - dest.__defineGetter__(prop, Utils.lazyCb2(dest, prop, fn)); - }, - lazyCb2: function Weave_lazyCb2(dest, prop, fn) { - return function() { - delete dest[prop]; - return dest[prop] = fn(); - }; - }, - - lazySvc: function Weave_lazySvc(dest, prop, cid, iface) { - let getter = function() { - delete dest[prop]; - let svc = null; - - // Use the platform's service if it exists - if (cid in Cc && iface in Ci) - svc = Cc[cid].getService(Ci[iface]); - else { - svc = FakeSvc[cid]; - - let log = Log4Moz.repository.getLogger("Service.Util"); - if (svc == null) - log.warn("Component " + cid + " doesn't exist on this platform."); - else - log.debug("Using a fake svc object for " + cid); - } - - return dest[prop] = svc; - }; - dest.__defineGetter__(prop, getter); - }, - lazyStrings: function Weave_lazyStrings(name) { let bundle = "chrome://weave/locale/services/" + name + ".properties"; return function() new StringBundle(bundle); @@ -545,32 +458,6 @@ let Utils = { return ex && ex.indexOf && (ex.indexOf(hmacFail) == 0); }, - checkStatus: function Weave_checkStatus(code, msg, ranges) { - if (!ranges) - ranges = [[200,300]]; - - for (let i = 0; i < ranges.length; i++) { - var rng = ranges[i]; - if (typeof(rng) == "object" && code >= rng[0] && code < rng[1]) - return true; - else if (typeof(rng) == "number" && code == rng) { - return true; - } - } - - if (msg) { - let log = Log4Moz.repository.getLogger("Service.Util"); - log.error(msg + " Error code: " + code); - } - - return false; - }, - - ensureStatus: function Weave_ensureStatus(args) { - if (!Utils.checkStatus.apply(Utils, arguments)) - throw 'checkStatus failed'; - }, - /** * UTF8-encode a message and hash it with the given hasher. Returns a * string containing bytes. The hasher is reset if it's an HMAC hasher. @@ -1001,7 +888,7 @@ let Utils = { if (!URIString) return null; try { - return Svc.IO.newURI(URIString, null, null); + return Services.io.newURI(URIString, null, null); } catch (e) { let log = Log4Moz.repository.getLogger("Service.Util"); log.debug("Could not create URI: " + Utils.exceptionStr(e)); @@ -1015,30 +902,6 @@ let Utils = { return url; }, - xpath: function Weave_xpath(xmlDoc, xpathString) { - let root = xmlDoc.ownerDocument == null ? - xmlDoc.documentElement : xmlDoc.ownerDocument.documentElement; - let nsResolver = xmlDoc.createNSResolver(root); - - return xmlDoc.evaluate(xpathString, xmlDoc, nsResolver, - Ci.nsIDOMXPathResult.ANY_TYPE, null); - }, - - getTmp: function Weave_getTmp(name) { - let tmp = Svc.Directory.get("ProfD", Ci.nsIFile); - tmp.QueryInterface(Ci.nsILocalFile); - - tmp.append("weave"); - tmp.append("tmp"); - if (!tmp.exists()) - tmp.create(tmp.DIRECTORY_TYPE, PERMS_DIRECTORY); - - if (name) - tmp.append(name); - - return tmp; - }, - /** * Load a json object from disk * @@ -1099,14 +962,11 @@ let Utils = { if (that._log) that._log.trace("Saving json to disk: " + filePath); - let file = Utils.getProfileFile({ autoCreate: true, path: filePath }); + let file = Utils.getProfileFile(filePath); let json = typeof obj == "function" ? obj.call(that) : obj; let out = JSON.stringify(json); - let fos = Cc["@mozilla.org/network/safe-file-output-stream;1"] - .createInstance(Ci.nsIFileOutputStream); - fos.init(file, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, PERMS_FILE, - fos.DEFER_OPEN); + let fos = FileUtils.openSafeFileOutputStream(file); let is = this._utf8Converter.convertToInputStream(out); NetUtil.asyncCopy(is, fos, function (result) { if (typeof callback == "function") { @@ -1158,12 +1018,12 @@ let Utils = { getIcon: function(iconUri, defaultIcon) { try { let iconURI = Utils.makeURI(iconUri); - return Svc.Favicon.getFaviconLinkForIcon(iconURI).spec; + return PlacesUtils.favicons.getFaviconLinkForIcon(iconURI).spec; } catch(ex) {} // Just give the provided default icon or the system's default - return defaultIcon || Svc.Favicon.defaultFavicon.spec; + return defaultIcon || PlacesUtils.favicons.defaultFavicon.spec; }, getErrorString: function Utils_getErrorString(error, args) { @@ -1302,38 +1162,6 @@ let Utils = { return over ? atob(b64.substr(0, len - over)) : atob(b64); }, - /* - * Calculate the strength of a passphrase provided by the user - * according to the NIST algorithm (NIST 800-63 Appendix A.1). - */ - passphraseStrength: function passphraseStrength(value) { - let bits = 0; - - // The entropy of the first character is taken to be 4 bits. - if (value.length) - bits = 4; - - // The entropy of the next 7 characters are 2 bits per character. - if (value.length > 1) - bits += Math.min(value.length - 1, 7) * 2; - - // For the 9th through the 20th character the entropy is taken to - // be 1.5 bits per character. - if (value.length > 8) - bits += Math.min(value.length - 8, 12) * 1.5; - - // For characters 21 and above the entropy is taken to be 1 bit per character. - if (value.length > 20) - bits += value.length - 20; - - // Bonus of 6 bits if we find non-alphabetic characters - if ([char.charCodeAt() for each (char in value.toLowerCase())] - .some(function(chr) chr < 97 || chr > 122)) - bits += 6; - - return bits; - }, - /** * Create an array like the first but without elements of the second */ @@ -1382,17 +1210,6 @@ let Utils = { return false; }, - __prefs: null, - get prefs() { - if (!this.__prefs) { - this.__prefs = Cc["@mozilla.org/preferences-service;1"] - .getService(Ci.nsIPrefService); - this.__prefs = this.__prefs.getBranch(PREFS_BRANCH); - this.__prefs.QueryInterface(Ci.nsIPrefBranch2); - } - return this.__prefs; - }, - /** * Helpers for making asynchronous calls within a synchronous API possible. * @@ -1465,69 +1282,7 @@ let Utils = { } }; -let FakeSvc = { - // Private Browsing - "@mozilla.org/privatebrowsing;1": { - autoStarted: false, - privateBrowsingEnabled: false - }, - // Session Restore - "@mozilla.org/browser/sessionstore;1": { - setTabValue: function(tab, key, value) { - if (!tab.__SS_extdata) - tab.__SS_extdata = {}; - tab.__SS_extData[key] = value; - }, - getBrowserState: function() { - // Fennec should have only one window. Not more, not less. - let state = { windows: [{ tabs: [] }] }; - let window = Svc.WinMediator.getMostRecentWindow("navigator:browser"); - - // Extract various pieces of tab data - window.Browser._tabs.forEach(function(tab) { - let tabState = { entries: [{}] }; - let browser = tab.browser; - - // Cases when we want to skip the tab. Could come up if we get - // state as a tab is opening or closing. - if (!browser || !browser.currentURI || !browser.sessionHistory) - return; - - let history = browser.sessionHistory; - if (history.count > 0) { - // We're only grabbing the current history entry for now. - let entry = history.getEntryAtIndex(history.index, false); - tabState.entries[0].url = entry.URI.spec; - // Like SessionStore really does it... - if (entry.title && entry.title != entry.url) - tabState.entries[0].title = entry.title; - } - // index is 1-based - tabState.index = 1; - - // Get the image for the tab. Fennec doesn't quite work the same - // way as Firefox, so we'll just get this from the browser object. - tabState.attributes = { image: browser.mIconURL }; - - // Collect the extdata - if (tab.__SS_extdata) { - tabState.extData = {}; - for (let key in tab.__SS_extdata) - tabState.extData[key] = tab.__SS_extdata[key]; - } - - // Add the tab to the window - state.windows[0].tabs.push(tabState); - }); - return JSON.stringify(state); - } - }, - // A fake service only used for testing - "@labs.mozilla.com/Fake/Thing;1": { - isFake: true - } -}; -Utils.lazy2(Utils, "_utf8Converter", function() { +XPCOMUtils.defineLazyGetter(Utils, "_utf8Converter", function() { let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"] .createInstance(Ci.nsIScriptableUnicodeConverter); converter.charset = "UTF-8"; @@ -1542,35 +1297,18 @@ Svc.Prefs = new Preferences(PREFS_BRANCH); Svc.DefaultPrefs = new Preferences({branch: PREFS_BRANCH, defaultBranch: true}); Svc.Obs = Observers; -this.__defineGetter__("_sessionCID", function() { - //sets session CID based on browser type - let appInfo = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo); - return appInfo.ID == SEAMONKEY_ID ? "@mozilla.org/suite/sessionstore;1" - : "@mozilla.org/browser/sessionstore;1"; -}); -[["Annos", "@mozilla.org/browser/annotation-service;1", "nsIAnnotationService"], - ["AppInfo", "@mozilla.org/xre/app-info;1", "nsIXULAppInfo"], - ["Bookmark", "@mozilla.org/browser/nav-bookmarks-service;1", "nsINavBookmarksService"], - ["Directory", "@mozilla.org/file/directory_service;1", "nsIProperties"], - ["Env", "@mozilla.org/process/environment;1", "nsIEnvironment"], - ["Favicon", "@mozilla.org/browser/favicon-service;1", "nsIFaviconService"], - ["Form", "@mozilla.org/satchel/form-history;1", "nsIFormHistory2"], - ["History", "@mozilla.org/browser/nav-history-service;1", "nsPIPlacesDatabase"], +let _sessionCID = Services.appinfo.ID == SEAMONKEY_ID ? + "@mozilla.org/suite/sessionstore;1" : + "@mozilla.org/browser/sessionstore;1"; + +[["Form", "@mozilla.org/satchel/form-history;1", "nsIFormHistory2"], ["Idle", "@mozilla.org/widget/idleservice;1", "nsIIdleService"], - ["IO", "@mozilla.org/network/io-service;1", "nsIIOService"], ["KeyFactory", "@mozilla.org/security/keyobjectfactory;1", "nsIKeyObjectFactory"], - ["Login", "@mozilla.org/login-manager;1", "nsILoginManager"], - ["Memory", "@mozilla.org/xpcom/memory-service;1", "nsIMemory"], ["Private", "@mozilla.org/privatebrowsing;1", "nsIPrivateBrowsingService"], - ["Profiles", "@mozilla.org/toolkit/profile-service;1", "nsIToolkitProfileService"], - ["Prompt", "@mozilla.org/embedcomp/prompt-service;1", "nsIPromptService"], - ["Script", "@mozilla.org/moz/jssubscript-loader;1", "mozIJSSubScriptLoader"], - ["SysInfo", "@mozilla.org/system-info;1", "nsIPropertyBag2"], - ["Version", "@mozilla.org/xpcom/version-comparator;1", "nsIVersionComparator"], - ["WinMediator", "@mozilla.org/appshell/window-mediator;1", "nsIWindowMediator"], - ["WinWatcher", "@mozilla.org/embedcomp/window-watcher;1", "nsIWindowWatcher"], - ["Session", this._sessionCID, "nsISessionStore"], -].forEach(function(lazy) Utils.lazySvc(Svc, lazy[0], lazy[1], lazy[2])); + ["Session", _sessionCID, "nsISessionStore"] +].forEach(function([name, contract, iface]) { + XPCOMUtils.defineLazyServiceGetter(Svc, name, contract, iface); +}); Svc.__defineGetter__("Crypto", function() { let cryptoSvc; @@ -1582,8 +1320,9 @@ Svc.__defineGetter__("Crypto", function() { }); let Str = {}; -["errors", "sync"] - .forEach(function(lazy) Utils.lazy2(Str, lazy, Utils.lazyStrings(lazy))); +["errors", "sync"].forEach(function(lazy) { + XPCOMUtils.defineLazyGetter(Str, lazy, Utils.lazyStrings(lazy)); +}); Svc.Obs.add("xpcom-shutdown", function () { for (let name in Svc) diff --git a/services/sync/tests/unit/fake_login_manager.js b/services/sync/tests/unit/fake_login_manager.js index e45a13aca28..32adcbcb522 100644 --- a/services/sync/tests/unit/fake_login_manager.js +++ b/services/sync/tests/unit/fake_login_manager.js @@ -25,8 +25,8 @@ function FakeLoginManager(fakeLogins) { let self = this; // Use a fake nsILoginManager object. - delete Svc.Login; - Svc.Login = { + delete Services.logins; + Services.logins = { removeAllLogins: function() { self.fakeLogins = []; }, getAllLogins: function() { return self.fakeLogins; }, addLogin: function(login) { diff --git a/services/sync/tests/unit/head_appinfo.js.in b/services/sync/tests/unit/head_appinfo.js.in index 6353726228a..3eb1732090d 100644 --- a/services/sync/tests/unit/head_appinfo.js.in +++ b/services/sync/tests/unit/head_appinfo.js.in @@ -1,32 +1,10 @@ var gProfD; -// Load httpd from the add-on test harness or from xpcshell and declare Cc, etc. -// without a var/const so they don't get hoisted and conflict with load_httpd. -if (this.do_load_httpd_js == null) { - Cc = Components.classes; - Ci = Components.interfaces; - Cr = Components.results; - Cu = Components.utils; - Cu.import("resource://harness/modules/httpd.js"); - - let file = Cc["@mozilla.org/file/directory_service;1"] - .getService(Ci.nsIProperties) - .get("ProfD", Ci.nsIFile); - gProfD = file.clone(); -} -else { - do_load_httpd_js(); - gProfD = do_get_profile(); -} +do_load_httpd_js(); +gProfD = do_get_profile(); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -try { - // In the context of xpcshell tests, there won't be a default AppInfo - Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo); -} -catch(ex) { - // Make sure to provide the right OS so crypto loads the right binaries let OS = "XPCShell"; if ("@mozilla.org/windows-registry-key;1" in Cc) @@ -64,7 +42,6 @@ registrar.registerFactory(Components.ID("{fbfae60b-64a4-44ef-a911-08ceb70b9f31}" "XULAppInfo", "@mozilla.org/xre/app-info;1", XULAppInfoFactory); -} // Register resource aliases. Normally done in SyncComponents.manifest. function addResourceAlias() { diff --git a/services/sync/tests/unit/head_helpers.js b/services/sync/tests/unit/head_helpers.js index 396db5b085e..68553a20392 100644 --- a/services/sync/tests/unit/head_helpers.js +++ b/services/sync/tests/unit/head_helpers.js @@ -2,77 +2,23 @@ Cu.import("resource://services-sync/util.js"); Cu.import("resource://services-sync/record.js"); var btoa; -// initialize nss -let ch = Cc["@mozilla.org/security/hash;1"]. - createInstance(Ci.nsICryptoHash); - -let ds = Cc["@mozilla.org/file/directory_service;1"] - .getService(Ci.nsIProperties); - let provider = { getFile: function(prop, persistent) { persistent.value = true; switch (prop) { case "ExtPrefDL": - return [ds.get("CurProcD", Ci.nsIFile)]; - case "ProfD": - return ds.get("CurProcD", Ci.nsIFile); + return [Services.dirsvc.get("CurProcD", Ci.nsIFile)]; case "UHist": - let histFile = ds.get("CurProcD", Ci.nsIFile); + let histFile = Services.dirsvc.get("ProfD", Ci.nsIFile); histFile.append("history.dat"); return histFile; default: throw Cr.NS_ERROR_FAILURE; } }, - QueryInterface: function(iid) { - if (iid.equals(Ci.nsIDirectoryServiceProvider) || - iid.equals(Ci.nsISupports)) { - return this; - } - throw Cr.NS_ERROR_NO_INTERFACE; - } -}; -ds.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider); - -function loadInSandbox(aUri) { - var sandbox = Components.utils.Sandbox(this); - var request = Components. - classes["@mozilla.org/xmlextras/xmlhttprequest;1"]. - createInstance(); - - request.open("GET", aUri, false); - request.overrideMimeType("application/javascript"); - request.send(null); - Components.utils.evalInSandbox(request.responseText, sandbox, "1.8"); - - return sandbox; -} - -function FakeTimerService() { - this.callbackQueue = []; - - var self = this; - - this.__proto__ = { - makeTimerForCall: function FTS_makeTimerForCall(cb) { - // Just add the callback to our queue and we'll call it later, so - // as to simulate a real nsITimer. - self.callbackQueue.push(cb); - return "fake nsITimer"; - }, - processCallback: function FTS_processCallbacks() { - var cb = self.callbackQueue.pop(); - if (cb) { - cb(); - return true; - } - return false; - } - }; - - Utils.makeTimerForCall = self.makeTimerForCall; + QueryInterface: XPCOMUtils.generateQI([Ci.nsIDirectoryServiceProvider]) }; +Services.dirsvc.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider); btoa = Cu.import("resource://services-sync/log4moz.js").btoa; function getTestLogger(component) { @@ -110,45 +56,6 @@ function initTestLogging(level) { return logStats; } -function FakePrefService(contents) { - Cu.import("resource://services-sync/util.js"); - this.fakeContents = contents; - Utils.__prefs = this; -} - -FakePrefService.prototype = { - _getPref: function fake__getPref(pref) { - getTestLogger().trace("Getting pref: " + pref); - return this.fakeContents[pref]; - }, - getCharPref: function fake_getCharPref(pref) { - return this._getPref(pref); - }, - getBoolPref: function fake_getBoolPref(pref) { - return this._getPref(pref); - }, - getIntPref: function fake_getIntPref(pref) { - return this._getPref(pref); - }, - addObserver: function fake_addObserver() {} -}; - -function FakePasswordService(contents) { - Cu.import("resource://services-sync/util.js"); - - this.fakeContents = contents; - let self = this; - - Utils.findPassword = function fake_findPassword(realm, username) { - getTestLogger().trace("Password requested for " + - realm + ":" + username); - if (realm in self.fakeContents && username in self.fakeContents[realm]) - return self.fakeContents[realm][username]; - else - return null; - }; -}; - function FakeFilesystemService(contents) { this.fakeContents = contents; let self = this; @@ -232,128 +139,24 @@ FakeCryptoService.prototype = { generateRandomBytes: function(aByteCount) { return "not-so-random-now-are-we-HA-HA-HA! >:)".slice(aByteCount); - }, + } }; -function SyncTestingInfrastructure(engineFactory) { - let __fakePasswords = { - 'Mozilla Services Password': {foo: "bar"}, - 'Mozilla Services Encryption Passphrase': {foo: "a-abcde-abcde-abcde-abcde-abcde"} - }; - - let __fakePrefs = { - "encryption" : "none", - "log.logger.service.crypto" : "Debug", - "log.logger.service.engine" : "Debug", - "log.logger.async" : "Debug", - "xmpp.enabled" : false - }; - +function SyncTestingInfrastructure() { Cu.import("resource://services-sync/identity.js"); - Cu.import("resource://services-sync/util.js"); ID.set('WeaveID', new Identity('Mozilla Services Encryption Passphrase', 'foo')); ID.set('WeaveCryptoID', new Identity('Mozilla Services Encryption Passphrase', 'foo')); - this.fakePasswordService = new FakePasswordService(__fakePasswords); - this.fakePrefService = new FakePrefService(__fakePrefs); - this.fakeTimerService = new FakeTimerService(); this.logStats = initTestLogging(); this.fakeFilesystem = new FakeFilesystemService({}); this.fakeGUIDService = new FakeGUIDService(); this.fakeCryptoService = new FakeCryptoService(); - - this._logger = getTestLogger(); - this._engineFactory = engineFactory; - this._clientStates = []; - - this.saveClientState = function pushClientState(label) { - let state = Utils.deepCopy(this.fakeFilesystem.fakeContents); - let currContents = this.fakeFilesystem.fakeContents; - this.fakeFilesystem.fakeContents = []; - let engine = this._engineFactory(); - let snapshot = Utils.deepCopy(engine._store.wrap()); - this._clientStates[label] = {state: state, snapshot: snapshot}; - this.fakeFilesystem.fakeContents = currContents; - }; - - this.restoreClientState = function restoreClientState(label) { - let state = this._clientStates[label].state; - let snapshot = this._clientStates[label].snapshot; - - function _restoreState() { - let self = yield; - - this.fakeFilesystem.fakeContents = []; - let engine = this._engineFactory(); - engine._store.wipe(); - let originalSnapshot = Utils.deepCopy(engine._store.wrap()); - - engine._core.detectUpdates(self.cb, originalSnapshot, snapshot); - let commands = yield; - - engine._store.applyCommands.async(engine._store, self.cb, commands); - yield; - - this.fakeFilesystem.fakeContents = Utils.deepCopy(state); - } - - let self = this; - - function restoreState(cb) { - _restoreState.async(self, cb); - } - - this.runAsyncFunc("restore client state of " + label, - restoreState); - }; - - this.__makeCallback = function __makeCallback() { - this.__callbackCalled = false; - let self = this; - return function callback() { - self.__callbackCalled = true; - }; - }; - - this.doSync = function doSync(name) { - let self = this; - - function freshEngineSync(cb) { - let engine = self._engineFactory(); - engine.sync(cb); - } - - this.runAsyncFunc(name, freshEngineSync); - }; - - this.runAsyncFunc = function runAsyncFunc(name, func) { - let logger = this._logger; - - logger.info("-----------------------------------------"); - logger.info("Step '" + name + "' starting."); - logger.info("-----------------------------------------"); - func(this.__makeCallback()); - while (this.fakeTimerService.processCallback()) {} - do_check_true(this.__callbackCalled); - for (name in Async.outstandingGenerators) - logger.warn("Outstanding generator exists: " + name); - do_check_eq(this.logStats.errorsLogged, 0); - do_check_eq(Async.outstandingGenerators.length, 0); - logger.info("Step '" + name + "' succeeded."); - }; - - this.resetClientState = function resetClientState() { - this.fakeFilesystem.fakeContents = {}; - let engine = this._engineFactory(); - engine._store.wipe(); - }; } - /* * Ensure exceptions from inside callbacks leads to test failures. */ diff --git a/services/sync/tests/unit/test_Observers.js b/services/sync/tests/unit/test_Observers.js new file mode 100644 index 00000000000..c85eacf019c --- /dev/null +++ b/services/sync/tests/unit/test_Observers.js @@ -0,0 +1,77 @@ +Components.utils.import("resource://services-sync/ext/Observers.js"); + +let gSubject = {}; + +function test_function_observer() { + let foo = false; + + let onFoo = function(subject, data) { + foo = !foo; + do_check_eq(subject, gSubject); + do_check_eq(data, "some data"); + }; + + Observers.add("foo", onFoo); + Observers.notify("foo", gSubject, "some data"); + + // The observer was notified after being added. + do_check_true(foo); + + Observers.remove("foo", onFoo); + Observers.notify("foo"); + + // The observer was not notified after being removed. + do_check_true(foo); +} + +function test_method_observer() { + let obj = { + foo: false, + onFoo: function(subject, data) { + this.foo = !this.foo; + do_check_eq(subject, gSubject); + do_check_eq(data, "some data"); + } + }; + + // The observer is notified after being added. + Observers.add("foo", obj.onFoo, obj); + Observers.notify("foo", gSubject, "some data"); + do_check_true(obj.foo); + + // The observer is not notified after being removed. + Observers.remove("foo", obj.onFoo, obj); + Observers.notify("foo"); + do_check_true(obj.foo); +} + +function test_object_observer() { + let obj = { + foo: false, + observe: function(subject, topic, data) { + this.foo = !this.foo; + + do_check_eq(subject, gSubject); + do_check_eq(topic, "foo"); + do_check_eq(data, "some data"); + } + }; + + Observers.add("foo", obj); + Observers.notify("foo", gSubject, "some data"); + + // The observer is notified after being added. + do_check_true(obj.foo); + + Observers.remove("foo", obj); + Observers.notify("foo"); + + // The observer is not notified after being removed. + do_check_true(obj.foo); +} + +function run_test() { + test_function_observer(); + test_method_observer(); + test_object_observer(); +} diff --git a/services/sync/tests/unit/test_Preferences.js b/services/sync/tests/unit/test_Preferences.js new file mode 100644 index 00000000000..105834fe8e6 --- /dev/null +++ b/services/sync/tests/unit/test_Preferences.js @@ -0,0 +1,354 @@ +Components.utils.import("resource://services-sync/ext/Preferences.js"); + +function test_set_get_pref() { + Preferences.set("test_set_get_pref.integer", 1); + do_check_eq(Preferences.get("test_set_get_pref.integer"), 1); + + Preferences.set("test_set_get_pref.string", "foo"); + do_check_eq(Preferences.get("test_set_get_pref.string"), "foo"); + + Preferences.set("test_set_get_pref.boolean", true); + do_check_eq(Preferences.get("test_set_get_pref.boolean"), true); + + // Clean up. + Preferences.resetBranch("test_set_get_pref."); +} + +function test_set_get_branch_pref() { + let prefs = new Preferences("test_set_get_branch_pref."); + + prefs.set("something", 1); + do_check_eq(prefs.get("something"), 1); + do_check_false(Preferences.has("something")); + + // Clean up. + prefs.reset("something"); +} + +function test_set_get_multiple_prefs() { + Preferences.set({ "test_set_get_multiple_prefs.integer": 1, + "test_set_get_multiple_prefs.string": "foo", + "test_set_get_multiple_prefs.boolean": true }); + + let [i, s, b] = Preferences.get(["test_set_get_multiple_prefs.integer", + "test_set_get_multiple_prefs.string", + "test_set_get_multiple_prefs.boolean"]); + + do_check_eq(i, 1); + do_check_eq(s, "foo"); + do_check_eq(b, true); + + // Clean up. + Preferences.resetBranch("test_set_get_multiple_prefs."); +} + +function test_get_multiple_prefs_with_default_value() { + Preferences.set({ "test_get_multiple_prefs_with_default_value.a": 1, + "test_get_multiple_prefs_with_default_value.b": 2 }); + + let [a, b, c] = Preferences.get(["test_get_multiple_prefs_with_default_value.a", + "test_get_multiple_prefs_with_default_value.b", + "test_get_multiple_prefs_with_default_value.c"], + 0); + + do_check_eq(a, 1); + do_check_eq(b, 2); + do_check_eq(c, 0); + + // Clean up. + Preferences.resetBranch("test_get_multiple_prefs_with_default_value."); +} + +function test_set_get_unicode_pref() { + Preferences.set("test_set_get_unicode_pref", String.fromCharCode(960)); + do_check_eq(Preferences.get("test_set_get_unicode_pref"), String.fromCharCode(960)); + + // Clean up. + Preferences.reset("test_set_get_unicode_pref"); +} + +function test_set_null_pref() { + try { + Preferences.set("test_set_null_pref", null); + // We expect this to throw, so the test is designed to fail if it doesn't. + do_check_true(false); + } + catch(ex) {} +} + +function test_set_undefined_pref() { + try { + Preferences.set("test_set_undefined_pref"); + // We expect this to throw, so the test is designed to fail if it doesn't. + do_check_true(false); + } + catch(ex) {} +} + +function test_set_unsupported_pref() { + try { + Preferences.set("test_set_unsupported_pref", new Array()); + // We expect this to throw, so the test is designed to fail if it doesn't. + do_check_true(false); + } + catch(ex) {} +} + +// Make sure that we can get a string pref that we didn't set ourselves +// (i.e. that the way we get a string pref using getComplexValue doesn't +// hork us getting a string pref that wasn't set using setComplexValue). +function test_get_string_pref() { + let svc = Cc["@mozilla.org/preferences-service;1"]. + getService(Ci.nsIPrefService). + getBranch(""); + svc.setCharPref("test_get_string_pref", "a normal string"); + do_check_eq(Preferences.get("test_get_string_pref"), "a normal string"); + + // Clean up. + Preferences.reset("test_get_string_pref"); +} + +function test_set_get_number_pref() { + Preferences.set("test_set_get_number_pref", 5); + do_check_eq(Preferences.get("test_set_get_number_pref"), 5); + + // Non-integer values get converted to integers. + Preferences.set("test_set_get_number_pref", 3.14159); + do_check_eq(Preferences.get("test_set_get_number_pref"), 3); + + // Values outside the range -(2^31-1) to 2^31-1 overflow. + try { + Preferences.set("test_set_get_number_pref", Math.pow(2, 31)); + // We expect this to throw, so the test is designed to fail if it doesn't. + do_check_true(false); + } + catch(ex) {} + + // Clean up. + Preferences.reset("test_set_get_number_pref"); +} + +function test_reset_pref() { + Preferences.set("test_reset_pref", 1); + Preferences.reset("test_reset_pref"); + do_check_eq(Preferences.get("test_reset_pref"), undefined); +} + +function test_reset_pref_branch() { + Preferences.set("test_reset_pref_branch.foo", 1); + Preferences.set("test_reset_pref_branch.bar", 2); + Preferences.resetBranch("test_reset_pref_branch."); + do_check_eq(Preferences.get("test_reset_pref_branch.foo"), undefined); + do_check_eq(Preferences.get("test_reset_pref_branch.bar"), undefined); +} + +// Make sure the module doesn't throw an exception when asked to reset +// a nonexistent pref. +function test_reset_nonexistent_pref() { + Preferences.reset("test_reset_nonexistent_pref"); +} + +// Make sure the module doesn't throw an exception when asked to reset +// a nonexistent pref branch. +function test_reset_nonexistent_pref_branch() { + Preferences.resetBranch("test_reset_nonexistent_pref_branch."); +} + +function test_observe_prefs_function() { + let observed = false; + let observer = function() { observed = !observed }; + + Preferences.observe("test_observe_prefs_function", observer); + Preferences.set("test_observe_prefs_function", "something"); + do_check_true(observed); + + Preferences.ignore("test_observe_prefs_function", observer); + Preferences.set("test_observe_prefs_function", "something else"); + do_check_true(observed); + + // Clean up. + Preferences.reset("test_observe_prefs_function"); +} + +function test_observe_prefs_object() { + let observer = { + observed: false, + observe: function() { + this.observed = !this.observed; + } + }; + + Preferences.observe("test_observe_prefs_object", observer.observe, observer); + Preferences.set("test_observe_prefs_object", "something"); + do_check_true(observer.observed); + + Preferences.ignore("test_observe_prefs_object", observer.observe, observer); + Preferences.set("test_observe_prefs_object", "something else"); + do_check_true(observer.observed); + + // Clean up. + Preferences.reset("test_observe_prefs_object"); +} + +function test_observe_prefs_nsIObserver() { + let observer = { + observed: false, + observe: function(subject, topic, data) { + this.observed = !this.observed; + do_check_true(subject instanceof Ci.nsIPrefBranch2); + do_check_eq(topic, "nsPref:changed"); + do_check_eq(data, "test_observe_prefs_nsIObserver"); + } + }; + + Preferences.observe("test_observe_prefs_nsIObserver", observer); + Preferences.set("test_observe_prefs_nsIObserver", "something"); + do_check_true(observer.observed); + + Preferences.ignore("test_observe_prefs_nsIObserver", observer); + Preferences.set("test_observe_prefs_nsIObserver", "something else"); + do_check_true(observer.observed); + + // Clean up. + Preferences.reset("test_observe_prefs_nsIObserver"); +} + +function test_observe_exact_pref() { + let observed = false; + let observer = function() { observed = !observed }; + + Preferences.observe("test_observe_exact_pref", observer); + Preferences.set("test_observe_exact_pref.sub-pref", "something"); + do_check_false(observed); + + // Clean up. + Preferences.ignore("test_observe_exact_pref", observer); + Preferences.reset("test_observe_exact_pref.sub-pref"); +} + +function test_observe_value_of_set_pref() { + let observer = function(newVal) { do_check_eq(newVal, "something") }; + + Preferences.observe("test_observe_value_of_set_pref", observer); + Preferences.set("test_observe_value_of_set_pref", "something"); + + // Clean up. + Preferences.ignore("test_observe_value_of_set_pref", observer); + Preferences.reset("test_observe_value_of_set_pref"); +} + +function test_observe_value_of_reset_pref() { + let observer = function(newVal) { do_check_true(typeof newVal == "undefined") }; + + Preferences.set("test_observe_value_of_reset_pref", "something"); + Preferences.observe("test_observe_value_of_reset_pref", observer); + Preferences.reset("test_observe_value_of_reset_pref"); + + // Clean up. + Preferences.ignore("test_observe_value_of_reset_pref", observer); +} + +function test_has_pref() { + do_check_false(Preferences.has("test_has_pref")); + Preferences.set("test_has_pref", "foo"); + do_check_true(Preferences.has("test_has_pref")); + + Preferences.set("test_has_pref.foo", "foo"); + Preferences.set("test_has_pref.bar", "bar"); + let [hasFoo, hasBar, hasBaz] = Preferences.has(["test_has_pref.foo", + "test_has_pref.bar", + "test_has_pref.baz"]); + do_check_true(hasFoo); + do_check_true(hasBar); + do_check_false(hasBaz); + + // Clean up. + Preferences.resetBranch("test_has_pref"); +} + +function test_isSet_pref() { + // Use a pref that we know has a default value but no user-set value. + // This feels dangerous; perhaps we should create some other default prefs + // that we can use for testing. + do_check_false(Preferences.isSet("toolkit.defaultChromeURI")); + Preferences.set("toolkit.defaultChromeURI", "foo"); + do_check_true(Preferences.isSet("toolkit.defaultChromeURI")); + + // Clean up. + Preferences.reset("toolkit.defaultChromeURI"); +} + +function test_lock_prefs() { + // Use a pref that we know has a default value. + // This feels dangerous; perhaps we should create some other default prefs + // that we can use for testing. + do_check_false(Preferences.locked("toolkit.defaultChromeURI")); + Preferences.lock("toolkit.defaultChromeURI"); + do_check_true(Preferences.locked("toolkit.defaultChromeURI")); + Preferences.unlock("toolkit.defaultChromeURI"); + do_check_false(Preferences.locked("toolkit.defaultChromeURI")); + + let val = Preferences.get("toolkit.defaultChromeURI"); + Preferences.set("toolkit.defaultChromeURI", "test_lock_prefs"); + do_check_eq(Preferences.get("toolkit.defaultChromeURI"), "test_lock_prefs"); + Preferences.lock("toolkit.defaultChromeURI"); + do_check_eq(Preferences.get("toolkit.defaultChromeURI"), val); + Preferences.unlock("toolkit.defaultChromeURI"); + do_check_eq(Preferences.get("toolkit.defaultChromeURI"), "test_lock_prefs"); + + // Clean up. + Preferences.reset("toolkit.defaultChromeURI"); +} + +function test_site_prefs() { + let prefs = Preferences.site("www.example.com"); + + prefs.set("test_site_prefs.integer", 1); + do_check_eq(prefs.get("test_site_prefs.integer"), 1); + do_check_true(prefs.has("test_site_prefs.integer")); + do_check_false(Preferences.has("test_site_prefs.integer")); + prefs.reset("test_site_prefs.integer"); + do_check_false(prefs.has("test_site_prefs.integer")); + + prefs.set("test_site_prefs.string", "foo"); + do_check_eq(prefs.get("test_site_prefs.string"), "foo"); + do_check_true(prefs.has("test_site_prefs.string")); + do_check_false(Preferences.has("test_site_prefs.string")); + prefs.reset("test_site_prefs.string"); + do_check_false(prefs.has("test_site_prefs.string")); + + prefs.set("test_site_prefs.boolean", true); + do_check_eq(prefs.get("test_site_prefs.boolean"), true); + do_check_true(prefs.has("test_site_prefs.boolean")); + do_check_false(Preferences.has("test_site_prefs.boolean")); + prefs.reset("test_site_prefs.boolean"); + do_check_false(prefs.has("test_site_prefs.boolean")); +} + + +function run_test() { + test_set_get_pref(); + test_set_get_branch_pref(); + test_set_get_multiple_prefs(); + test_get_multiple_prefs_with_default_value(); + test_set_get_unicode_pref(); + test_set_null_pref(); + test_set_undefined_pref(); + test_set_unsupported_pref(); + test_get_string_pref(); + test_set_get_number_pref(); + test_reset_pref(); + test_reset_pref_branch(); + test_reset_nonexistent_pref(); + test_reset_nonexistent_pref_branch(); + test_observe_prefs_function(); + test_observe_prefs_object(); + test_observe_prefs_nsIObserver(); + //test_observe_exact_pref(); + test_observe_value_of_set_pref(); + test_observe_value_of_reset_pref(); + test_has_pref(); + test_isSet_pref(); + //test_lock_prefs(); + test_site_prefs(); +} diff --git a/services/sync/tests/unit/test_bookmark_engine.js b/services/sync/tests/unit/test_bookmark_engine.js index 71b03906567..c9a338bb0b7 100644 --- a/services/sync/tests/unit/test_bookmark_engine.js +++ b/services/sync/tests/unit/test_bookmark_engine.js @@ -8,25 +8,23 @@ Cu.import("resource://services-sync/service.js"); Cu.import("resource://gre/modules/PlacesUtils.jsm"); Engines.register(BookmarksEngine); - -function makeEngine() { - return new BookmarksEngine(); -} -var syncTesting = new SyncTestingInfrastructure(makeEngine); +var syncTesting = new SyncTestingInfrastructure(); add_test(function bad_record_allIDs() { + let syncTesting = new SyncTestingInfrastructure(); + _("Ensure that bad Places queries don't cause an error in getAllIDs."); let engine = new BookmarksEngine(); let store = engine._store; - let badRecordID = Svc.Bookmark.insertBookmark( - Svc.Bookmark.toolbarFolder, + let badRecordID = PlacesUtils.bookmarks.insertBookmark( + PlacesUtils.bookmarks.toolbarFolder, Utils.makeURI("place:folder=1138"), - Svc.Bookmark.DEFAULT_INDEX, + PlacesUtils.bookmarks.DEFAULT_INDEX, null); do_check_true(badRecordID > 0); _("Record is " + badRecordID); - _("Type: " + Svc.Bookmark.getItemType(badRecordID)); + _("Type: " + PlacesUtils.bookmarks.getItemType(badRecordID)); _("Fetching children."); store._getChildren("toolbar", {}); @@ -39,12 +37,13 @@ add_test(function bad_record_allIDs() { do_check_true("toolbar" in all); _("Clean up."); - Svc.Bookmark.removeItem(badRecordID); + PlacesUtils.bookmarks.removeItem(badRecordID); run_next_test(); }); add_test(function test_ID_caching() { + let syncTesting = new SyncTestingInfrastructure(); _("Ensure that Places IDs are not cached."); let engine = new BookmarksEngine(); @@ -54,7 +53,7 @@ add_test(function test_ID_caching() { let mobileID = store.idForGUID("mobile"); _("Change the GUID for that item, and drop the mobile anno."); store._setGUID(mobileID, "abcdefghijkl"); - Svc.Annos.removeItemAnnotation(mobileID, "mobile/bookmarksRoot"); + PlacesUtils.annotations.removeItemAnnotation(mobileID, "mobile/bookmarksRoot"); let err; let newMobileID; @@ -85,7 +84,7 @@ add_test(function test_ID_caching() { add_test(function test_processIncoming_error_orderChildren() { _("Ensure that _orderChildren() is called even when _processIncoming() throws an error."); - + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); @@ -102,18 +101,18 @@ add_test(function test_processIncoming_error_orderChildren() { try { - let folder1_id = Svc.Bookmark.createFolder( - Svc.Bookmark.toolbarFolder, "Folder 1", 0); + let folder1_id = PlacesUtils.bookmarks.createFolder( + PlacesUtils.bookmarks.toolbarFolder, "Folder 1", 0); let folder1_guid = store.GUIDForId(folder1_id); let fxuri = Utils.makeURI("http://getfirefox.com/"); let tburi = Utils.makeURI("http://getthunderbird.com/"); - let bmk1_id = Svc.Bookmark.insertBookmark( - folder1_id, fxuri, Svc.Bookmark.DEFAULT_INDEX, "Get Firefox!"); + let bmk1_id = PlacesUtils.bookmarks.insertBookmark( + folder1_id, fxuri, PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!"); let bmk1_guid = store.GUIDForId(bmk1_id); - let bmk2_id = Svc.Bookmark.insertBookmark( - folder1_id, tburi, Svc.Bookmark.DEFAULT_INDEX, "Get Thunderbird!"); + let bmk2_id = PlacesUtils.bookmarks.insertBookmark( + folder1_id, tburi, PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Thunderbird!"); let bmk2_guid = store.GUIDForId(bmk2_id); // Create a server record for folder1 where we flip the order of @@ -151,20 +150,20 @@ add_test(function test_processIncoming_error_orderChildren() { do_check_eq(new_children[0], folder1_payload.children[0]); do_check_eq(new_children[1], folder1_payload.children[1]); - do_check_eq(Svc.Bookmark.getItemIndex(bmk1_id), 1); - do_check_eq(Svc.Bookmark.getItemIndex(bmk2_id), 0); + do_check_eq(PlacesUtils.bookmarks.getItemIndex(bmk1_id), 1); + do_check_eq(PlacesUtils.bookmarks.getItemIndex(bmk2_id), 0); } finally { store.wipe(); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeEngine); server.stop(run_next_test); } }); add_test(function test_restorePromptsReupload() { _("Ensure that restoring from a backup will reupload all records."); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("username", "foo"); Service.serverURL = "http://localhost:8080/"; Service.clusterURL = "http://localhost:8080/"; @@ -185,8 +184,8 @@ add_test(function test_restorePromptsReupload() { try { - let folder1_id = Svc.Bookmark.createFolder( - Svc.Bookmark.toolbarFolder, "Folder 1", 0); + let folder1_id = PlacesUtils.bookmarks.createFolder( + PlacesUtils.bookmarks.toolbarFolder, "Folder 1", 0); let folder1_guid = store.GUIDForId(folder1_id); _("Folder 1: " + folder1_id + ", " + folder1_guid); @@ -194,8 +193,8 @@ add_test(function test_restorePromptsReupload() { let tburi = Utils.makeURI("http://getthunderbird.com/"); _("Create a single record."); - let bmk1_id = Svc.Bookmark.insertBookmark( - folder1_id, fxuri, Svc.Bookmark.DEFAULT_INDEX, "Get Firefox!"); + let bmk1_id = PlacesUtils.bookmarks.insertBookmark( + folder1_id, fxuri, PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!"); let bmk1_guid = store.GUIDForId(bmk1_id); _("Get Firefox!: " + bmk1_id + ", " + bmk1_guid); @@ -213,12 +212,12 @@ add_test(function test_restorePromptsReupload() { PlacesUtils.backupBookmarksToFile(backupFile); _("Create a different record and sync."); - let bmk2_id = Svc.Bookmark.insertBookmark( - folder1_id, tburi, Svc.Bookmark.DEFAULT_INDEX, "Get Thunderbird!"); + let bmk2_id = PlacesUtils.bookmarks.insertBookmark( + folder1_id, tburi, PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Thunderbird!"); let bmk2_guid = store.GUIDForId(bmk2_id); _("Get Thunderbird!: " + bmk2_id + ", " + bmk2_guid); - Svc.Bookmark.removeItem(bmk1_id); + PlacesUtils.bookmarks.removeItem(bmk1_id); let error; try { @@ -249,8 +248,8 @@ add_test(function test_restorePromptsReupload() { count++; let id = store.idForGUID(guid, true); // Only one bookmark, so _all_ should be Firefox! - if (Svc.Bookmark.getItemType(id) == Svc.Bookmark.TYPE_BOOKMARK) { - let uri = Svc.Bookmark.getBookmarkURI(id); + if (PlacesUtils.bookmarks.getItemType(id) == PlacesUtils.bookmarks.TYPE_BOOKMARK) { + let uri = PlacesUtils.bookmarks.getBookmarkURI(id); _("Found URI " + uri.spec + " for GUID " + guid); do_check_eq(uri.spec, fxuri.spec); newFX = guid; // Save the new GUID after restore. @@ -297,7 +296,6 @@ add_test(function test_restorePromptsReupload() { store.wipe(); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeEngine); server.stop(run_next_test); } }); @@ -338,6 +336,7 @@ add_test(function test_mismatched_types() { "parentid": "toolbar" }; + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("username", "foo"); Service.serverURL = "http://localhost:8080/"; Service.clusterURL = "http://localhost:8080/"; @@ -356,18 +355,18 @@ add_test(function test_mismatched_types() { }); try { - let bms = store._bms; + let bms = PlacesUtils.bookmarks; let oldR = new FakeRecord(BookmarkFolder, oldRecord); let newR = new FakeRecord(Livemark, newRecord); - oldR._parent = Svc.Bookmark.toolbarFolder; - newR._parent = Svc.Bookmark.toolbarFolder; + oldR._parent = PlacesUtils.bookmarks.toolbarFolder; + newR._parent = PlacesUtils.bookmarks.toolbarFolder; store.applyIncoming(oldR); _("Applied old. It's a folder."); let oldID = store.idForGUID(oldR.id); _("Old ID: " + oldID); do_check_eq(bms.getItemType(oldID), bms.TYPE_FOLDER); - do_check_false(store._ls.isLivemark(oldID)); + do_check_false(PlacesUtils.livemarks.isLivemark(oldID)); store.applyIncoming(newR); let newID = store.idForGUID(newR.id); @@ -375,13 +374,12 @@ add_test(function test_mismatched_types() { _("Applied new. It's a livemark."); do_check_eq(bms.getItemType(newID), bms.TYPE_FOLDER); - do_check_true(store._ls.isLivemark(newID)); + do_check_true(PlacesUtils.livemarks.isLivemark(newID)); } finally { store.wipe(); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeEngine); server.stop(run_next_test); } }); diff --git a/services/sync/tests/unit/test_bookmark_livemarks.js b/services/sync/tests/unit/test_bookmark_livemarks.js index 8eb4b76914f..ae3af810654 100644 --- a/services/sync/tests/unit/test_bookmark_livemarks.js +++ b/services/sync/tests/unit/test_bookmark_livemarks.js @@ -91,8 +91,8 @@ add_test(function test_livemark_descriptions() { // Attempt to provoke an error by adding a bad description anno. let id = store.idForGUID(record.id); - Svc.Annos.setItemAnnotation(id, DESCRIPTION_ANNO, "", 0, - Svc.Annos.EXPIRE_NEVER); + PlacesUtils.annotations.setItemAnnotation(id, DESCRIPTION_ANNO, "", 0, + PlacesUtils.annotations.EXPIRE_NEVER); run_next_test(); }); @@ -106,7 +106,7 @@ add_test(function test_livemark_invalid() { store.create(noParentRec); let recID = store.idForGUID(noParentRec.id, true); do_check_true(recID > 0); - do_check_eq(Svc.Bookmark.getFolderIdForItem(recID), Svc.Bookmark.unfiledBookmarksFolder); + do_check_eq(PlacesUtils.bookmarks.getFolderIdForItem(recID), PlacesUtils.bookmarks.unfiledBookmarksFolder); _("Parent is unknown. Will be set to unfiled."); let lateParentRec = makeLivemark(record631361.payload, true); @@ -118,7 +118,8 @@ add_test(function test_livemark_invalid() { store.create(lateParentRec); recID = store.idForGUID(lateParentRec.id, true); do_check_true(recID > 0); - do_check_eq(Svc.Bookmark.getFolderIdForItem(recID), Svc.Bookmark.unfiledBookmarksFolder); + do_check_eq(PlacesUtils.bookmarks.getFolderIdForItem(recID), + PlacesUtils.bookmarks.unfiledBookmarksFolder); _("No feed URI, which is invalid. Will be skipped."); let noFeedURIRec = makeLivemark(record631361.payload, true); diff --git a/services/sync/tests/unit/test_bookmark_order.js b/services/sync/tests/unit/test_bookmark_order.js index 07f9593f1c9..1f5ab907b96 100644 --- a/services/sync/tests/unit/test_bookmark_order.js +++ b/services/sync/tests/unit/test_bookmark_order.js @@ -7,16 +7,16 @@ function getBookmarks(folderId) { let pos = 0; while (true) { - let itemId = Svc.Bookmark.getIdForItemAt(folderId, pos); + let itemId = PlacesUtils.bookmarks.getIdForItemAt(folderId, pos); _("Got itemId", itemId, "under", folderId, "at", pos); if (itemId == -1) break; - switch (Svc.Bookmark.getItemType(itemId)) { - case Svc.Bookmark.TYPE_BOOKMARK: - bookmarks.push(Svc.Bookmark.getItemTitle(itemId)); + switch (PlacesUtils.bookmarks.getItemType(itemId)) { + case PlacesUtils.bookmarks.TYPE_BOOKMARK: + bookmarks.push(PlacesUtils.bookmarks.getItemTitle(itemId)); break; - case Svc.Bookmark.TYPE_FOLDER: + case PlacesUtils.bookmarks.TYPE_FOLDER: bookmarks.push(getBookmarks(itemId)); break; default: @@ -30,7 +30,7 @@ function getBookmarks(folderId) { } function check(expected) { - let bookmarks = getBookmarks(Svc.Bookmark.unfiledBookmarksFolder); + let bookmarks = getBookmarks(PlacesUtils.bookmarks.unfiledBookmarksFolder); _("Checking if the bookmark structure is", JSON.stringify(expected)); _("Got bookmarks:", JSON.stringify(bookmarks)); diff --git a/services/sync/tests/unit/test_bookmark_places_query_rewriting.js b/services/sync/tests/unit/test_bookmark_places_query_rewriting.js index ca9232fa0c8..e040e1f212b 100644 --- a/services/sync/tests/unit/test_bookmark_places_query_rewriting.js +++ b/services/sync/tests/unit/test_bookmark_places_query_rewriting.js @@ -25,7 +25,7 @@ function run_test() { _("Verify that the URI has been rewritten."); do_check_neq(tagRecord.bmkUri, uri); - let tags = store._getNode(store._bms.tagsFolder); + let tags = store._getNode(PlacesUtils.tagsFolderId); tags.containerOpen = true; let tagID; for (let i = 0; i < tags.childCount; ++i) { diff --git a/services/sync/tests/unit/test_bookmark_smart_bookmarks.js b/services/sync/tests/unit/test_bookmark_smart_bookmarks.js index 0b41b93d26d..c2cb5f099f5 100644 --- a/services/sync/tests/unit/test_bookmark_smart_bookmarks.js +++ b/services/sync/tests/unit/test_bookmark_smart_bookmarks.js @@ -20,10 +20,7 @@ let store = engine._store; // Clean up after other tests. Only necessary in XULRunner. store.wipe(); -function makeEngine() { - return new BookmarksEngine(); -} -var syncTesting = new SyncTestingInfrastructure(makeEngine); +var syncTesting = new SyncTestingInfrastructure(); function newSmartBookmark(parent, uri, position, title, queryID) { let id = PlacesUtils.bookmarks.insertBookmark(parent, uri, position, title); @@ -37,16 +34,16 @@ function smartBookmarkCount() { // We do it this way because PlacesUtils.annotations.getItemsWithAnnotation // doesn't work the same (or at all?) between 3.6 and 4.0. let out = {}; - Svc.Annos.getItemsWithAnnotation(SMART_BOOKMARKS_ANNO, out); + PlacesUtils.annotations.getItemsWithAnnotation(SMART_BOOKMARKS_ANNO, out); return out.value; } function clearBookmarks() { _("Cleaning up existing items."); - Svc.Bookmark.removeFolderChildren(Svc.Bookmark.bookmarksMenuFolder); - Svc.Bookmark.removeFolderChildren(Svc.Bookmark.tagsFolder); - Svc.Bookmark.removeFolderChildren(Svc.Bookmark.toolbarFolder); - Svc.Bookmark.removeFolderChildren(Svc.Bookmark.unfiledBookmarksFolder); + PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.bookmarks.bookmarksMenuFolder); + PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.bookmarks.tagsFolder); + PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.bookmarks.toolbarFolder); + PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.bookmarks.unfiledBookmarksFolder); startCount = smartBookmarkCount(); } @@ -78,7 +75,7 @@ function test_annotation_uploaded() { _("New item ID: " + mostVisitedID); do_check_true(!!mostVisitedID); - let annoValue = Svc.Annos.getItemAnnotation(mostVisitedID, + let annoValue = PlacesUtils.annotations.getItemAnnotation(mostVisitedID, SMART_BOOKMARKS_ANNO); _("Anno: " + annoValue); do_check_eq("MostVisited", annoValue); @@ -135,11 +132,12 @@ function test_annotation_uploaded() { // "Clear" by changing attributes: if we delete it, apparently it sticks // around as a deleted record... - Svc.Bookmark.setItemGUID(mostVisitedID, "abcdefabcdef"); - Svc.Bookmark.setItemTitle(mostVisitedID, "Not Most Visited"); - Svc.Bookmark.changeBookmarkURI(mostVisitedID, - Utils.makeURI("http://something/else")); - Svc.Annos.removeItemAnnotation(mostVisitedID, SMART_BOOKMARKS_ANNO); + PlacesUtils.bookmarks.setItemGUID(mostVisitedID, "abcdefabcdef"); + PlacesUtils.bookmarks.setItemTitle(mostVisitedID, "Not Most Visited"); + PlacesUtils.bookmarks.changeBookmarkURI( + mostVisitedID, Utils.makeURI("http://something/else")); + PlacesUtils.annotations.removeItemAnnotation(mostVisitedID, + SMART_BOOKMARKS_ANNO); store.wipe(); engine.resetClient(); do_check_eq(smartBookmarkCount(), startCount); @@ -153,17 +151,18 @@ function test_annotation_uploaded() { _("Find by GUID and verify that it's annotated."); let newID = store.idForGUID(serverGUID); - let newAnnoValue = Svc.Annos.getItemAnnotation(newID, SMART_BOOKMARKS_ANNO); + let newAnnoValue = PlacesUtils.annotations.getItemAnnotation( + newID, SMART_BOOKMARKS_ANNO); do_check_eq(newAnnoValue, "MostVisited"); - do_check_eq(Svc.Bookmark.getBookmarkURI(newID).spec, uri.spec); + do_check_eq(PlacesUtils.bookmarks.getBookmarkURI(newID).spec, uri.spec); _("Test updating."); let newRecord = store.createRecord(serverGUID); do_check_eq(newRecord.queryId, newAnnoValue); newRecord.queryId = "LeastVisited"; store.update(newRecord); - do_check_eq("LeastVisited", - Svc.Annos.getItemAnnotation(newID, SMART_BOOKMARKS_ANNO)); + do_check_eq("LeastVisited", PlacesUtils.annotations.getItemAnnotation( + newID, SMART_BOOKMARKS_ANNO)); } finally { @@ -211,7 +210,8 @@ function test_smart_bookmarks_duped() { record.bmkUri = "http://foo/"; do_check_eq(mostVisitedGUID, engine._lazyMap(record)); - do_check_neq(Svc.Bookmark.getBookmarkURI(mostVisitedID).spec, record.bmkUri); + do_check_neq(PlacesUtils.bookmarks.getBookmarkURI(mostVisitedID).spec, + record.bmkUri); _("Verify that different annos don't dupe."); let other = new BookmarkQuery("bookmarks", "abcdefabcdef"); diff --git a/services/sync/tests/unit/test_bookmark_store.js b/services/sync/tests/unit/test_bookmark_store.js index 25b7838151c..591517c74be 100644 --- a/services/sync/tests/unit/test_bookmark_store.js +++ b/services/sync/tests/unit/test_bookmark_store.js @@ -14,7 +14,7 @@ let tburi = Utils.makeURI("http://getthunderbird.com/"); function test_bookmark_create() { try { _("Ensure the record isn't present yet."); - let ids = Svc.Bookmark.getBookmarkIdsForURI(fxuri, {}); + let ids = PlacesUtils.bookmarks.getBookmarkIdsForURI(fxuri, {}); do_check_eq(ids.length, 0); _("Let's create a new record."); @@ -32,14 +32,15 @@ function test_bookmark_create() { _("Verify it has been created correctly."); let id = store.idForGUID(fxrecord.id); do_check_eq(store.GUIDForId(id), fxrecord.id); - do_check_eq(Svc.Bookmark.getItemType(id), Svc.Bookmark.TYPE_BOOKMARK); - do_check_true(Svc.Bookmark.getBookmarkURI(id).equals(fxuri)); - do_check_eq(Svc.Bookmark.getItemTitle(id), fxrecord.title); - do_check_eq(Svc.Annos.getItemAnnotation(id, "bookmarkProperties/description"), + do_check_eq(PlacesUtils.bookmarks.getItemType(id), + PlacesUtils.bookmarks.TYPE_BOOKMARK); + do_check_true(PlacesUtils.bookmarks.getBookmarkURI(id).equals(fxuri)); + do_check_eq(PlacesUtils.bookmarks.getItemTitle(id), fxrecord.title); + do_check_eq(PlacesUtils.annotations.getItemAnnotation(id, "bookmarkProperties/description"), fxrecord.description); - do_check_eq(Svc.Bookmark.getFolderIdForItem(id), - Svc.Bookmark.toolbarFolder); - do_check_eq(Svc.Bookmark.getKeywordForBookmark(id), fxrecord.keyword); + do_check_eq(PlacesUtils.bookmarks.getFolderIdForItem(id), + PlacesUtils.bookmarks.toolbarFolder); + do_check_eq(PlacesUtils.bookmarks.getKeywordForBookmark(id), fxrecord.keyword); _("Have the store create a new record object. Verify that it has the same data."); let newrecord = store.createRecord(fxrecord.id); @@ -64,19 +65,20 @@ function test_bookmark_create() { _("Verify it has been created correctly."); id = store.idForGUID(tbrecord.id); do_check_eq(store.GUIDForId(id), tbrecord.id); - do_check_eq(Svc.Bookmark.getItemType(id), Svc.Bookmark.TYPE_BOOKMARK); - do_check_true(Svc.Bookmark.getBookmarkURI(id).equals(tburi)); - do_check_eq(Svc.Bookmark.getItemTitle(id), null); + do_check_eq(PlacesUtils.bookmarks.getItemType(id), + PlacesUtils.bookmarks.TYPE_BOOKMARK); + do_check_true(PlacesUtils.bookmarks.getBookmarkURI(id).equals(tburi)); + do_check_eq(PlacesUtils.bookmarks.getItemTitle(id), null); let error; try { - Svc.Annos.getItemAnnotation(id, "bookmarkProperties/description"); + PlacesUtils.annotations.getItemAnnotation(id, "bookmarkProperties/description"); } catch(ex) { error = ex; } do_check_eq(error.result, Cr.NS_ERROR_NOT_AVAILABLE); - do_check_eq(Svc.Bookmark.getFolderIdForItem(id), - Svc.Bookmark.toolbarFolder); - do_check_eq(Svc.Bookmark.getKeywordForBookmark(id), null); + do_check_eq(PlacesUtils.bookmarks.getFolderIdForItem(id), + PlacesUtils.bookmarks.toolbarFolder); + do_check_eq(PlacesUtils.bookmarks.getKeywordForBookmark(id), null); } finally { _("Clean up."); store.wipe(); @@ -86,12 +88,14 @@ function test_bookmark_create() { function test_bookmark_update() { try { _("Create a bookmark whose values we'll change."); - let bmk1_id = Svc.Bookmark.insertBookmark( - Svc.Bookmark.toolbarFolder, fxuri, Svc.Bookmark.DEFAULT_INDEX, + let bmk1_id = PlacesUtils.bookmarks.insertBookmark( + PlacesUtils.bookmarks.toolbarFolder, fxuri, + PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!"); - Svc.Annos.setItemAnnotation(bmk1_id, "bookmarkProperties/description", - "Firefox is awesome.", 0, Svc.Annos.EXPIRE_NEVER); - Svc.Bookmark.setKeywordForBookmark(bmk1_id, "firefox"); + PlacesUtils.annotations.setItemAnnotation( + bmk1_id, "bookmarkProperties/description", "Firefox is awesome.", 0, + PlacesUtils.annotations.EXPIRE_NEVER); + PlacesUtils.bookmarks.setKeywordForBookmark(bmk1_id, "firefox"); let bmk1_guid = store.GUIDForId(bmk1_id); _("Update the record with some null values."); @@ -103,9 +107,12 @@ function test_bookmark_update() { store.applyIncoming(record); _("Verify that the values have been cleared."); - do_check_eq(Svc.Annos.getItemAnnotation(bmk1_id, "bookmarkProperties/description"), ""); - do_check_eq(Svc.Bookmark.getItemTitle(bmk1_id), ""); - do_check_eq(Svc.Bookmark.getKeywordForBookmark(bmk1_id), null); + do_check_throws(function () { + PlacesUtils.annotations.getItemAnnotation( + bmk1_id, "bookmarkProperties/description"); + }, Cr.NS_ERROR_NOT_AVAILABLE); + do_check_eq(PlacesUtils.bookmarks.getItemTitle(bmk1_id), null); + do_check_eq(PlacesUtils.bookmarks.getKeywordForBookmark(bmk1_id), null); } finally { _("Clean up."); store.wipe(); @@ -115,8 +122,9 @@ function test_bookmark_update() { function test_bookmark_createRecord() { try { _("Create a bookmark without a description or title."); - let bmk1_id = Svc.Bookmark.insertBookmark( - Svc.Bookmark.toolbarFolder, fxuri, Svc.Bookmark.DEFAULT_INDEX, null); + let bmk1_id = PlacesUtils.bookmarks.insertBookmark( + PlacesUtils.bookmarks.toolbarFolder, fxuri, + PlacesUtils.bookmarks.DEFAULT_INDEX, null); let bmk1_guid = store.GUIDForId(bmk1_id); _("Verify that the record is created accordingly."); @@ -142,10 +150,11 @@ function test_folder_create() { _("Verify it has been created correctly."); let id = store.idForGUID(folder.id); - do_check_eq(Svc.Bookmark.getItemType(id), Svc.Bookmark.TYPE_FOLDER); - do_check_eq(Svc.Bookmark.getItemTitle(id), folder.title); - do_check_eq(Svc.Bookmark.getFolderIdForItem(id), - Svc.Bookmark.toolbarFolder); + do_check_eq(PlacesUtils.bookmarks.getItemType(id), + PlacesUtils.bookmarks.TYPE_FOLDER); + do_check_eq(PlacesUtils.bookmarks.getItemTitle(id), folder.title); + do_check_eq(PlacesUtils.bookmarks.getFolderIdForItem(id), + PlacesUtils.bookmarks.toolbarFolder); _("Have the store create a new record object. Verify that it has the same data."); let newrecord = store.createRecord(folder.id); @@ -164,15 +173,15 @@ function test_folder_create() { function test_folder_createRecord() { try { _("Create a folder."); - let folder1_id = Svc.Bookmark.createFolder( - Svc.Bookmark.toolbarFolder, "Folder1", 0); + let folder1_id = PlacesUtils.bookmarks.createFolder( + PlacesUtils.bookmarks.toolbarFolder, "Folder1", 0); let folder1_guid = store.GUIDForId(folder1_id); _("Create two bookmarks in that folder without assigning them GUIDs."); - let bmk1_id = Svc.Bookmark.insertBookmark( - folder1_id, fxuri, Svc.Bookmark.DEFAULT_INDEX, "Get Firefox!"); - let bmk2_id = Svc.Bookmark.insertBookmark( - folder1_id, tburi, Svc.Bookmark.DEFAULT_INDEX, "Get Thunderbird!"); + let bmk1_id = PlacesUtils.bookmarks.insertBookmark( + folder1_id, fxuri, PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!"); + let bmk2_id = PlacesUtils.bookmarks.insertBookmark( + folder1_id, tburi, PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Thunderbird!"); _("Create a record for the folder and verify basic properties."); let record = store.createRecord(folder1_guid); @@ -197,9 +206,9 @@ function test_folder_createRecord() { function test_deleted() { try { _("Create a bookmark that will be deleted."); - let bmk1_id = Svc.Bookmark.insertBookmark( - Svc.Bookmark.toolbarFolder, fxuri, Svc.Bookmark.DEFAULT_INDEX, - "Get Firefox!"); + let bmk1_id = PlacesUtils.bookmarks.insertBookmark( + PlacesUtils.bookmarks.toolbarFolder, fxuri, + PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!"); let bmk1_guid = store.GUIDForId(bmk1_id); _("Delete the bookmark through the store."); @@ -210,7 +219,7 @@ function test_deleted() { _("Ensure it has been deleted."); let error; try { - Svc.Bookmark.getBookmarkURI(bmk1_id); + PlacesUtils.bookmarks.getBookmarkURI(bmk1_id); } catch(ex) { error = ex; } @@ -228,14 +237,14 @@ function test_deleted() { function test_move_folder() { try { _("Create two folders and a bookmark in one of them."); - let folder1_id = Svc.Bookmark.createFolder( - Svc.Bookmark.toolbarFolder, "Folder1", 0); + let folder1_id = PlacesUtils.bookmarks.createFolder( + PlacesUtils.bookmarks.toolbarFolder, "Folder1", 0); let folder1_guid = store.GUIDForId(folder1_id); - let folder2_id = Svc.Bookmark.createFolder( - Svc.Bookmark.toolbarFolder, "Folder2", 0); + let folder2_id = PlacesUtils.bookmarks.createFolder( + PlacesUtils.bookmarks.toolbarFolder, "Folder2", 0); let folder2_guid = store.GUIDForId(folder2_id); - let bmk_id = Svc.Bookmark.insertBookmark( - folder1_id, fxuri, Svc.Bookmark.DEFAULT_INDEX, "Get Firefox!"); + let bmk_id = PlacesUtils.bookmarks.insertBookmark( + folder1_id, fxuri, PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!"); let bmk_guid = store.GUIDForId(bmk_id); _("Get a record, reparent it and apply it to the store."); @@ -245,7 +254,7 @@ function test_move_folder() { store.applyIncoming(record); _("Verify the new parent."); - let new_folder_id = Svc.Bookmark.getFolderIdForItem(bmk_id); + let new_folder_id = PlacesUtils.bookmarks.getFolderIdForItem(bmk_id); do_check_eq(store.GUIDForId(new_folder_id), folder2_guid); } finally { _("Clean up."); @@ -258,18 +267,18 @@ function test_move_order() { Svc.Obs.notify("weave:engine:start-tracking"); try { _("Create two bookmarks"); - let bmk1_id = Svc.Bookmark.insertBookmark( - Svc.Bookmark.toolbarFolder, fxuri, Svc.Bookmark.DEFAULT_INDEX, - "Get Firefox!"); + let bmk1_id = PlacesUtils.bookmarks.insertBookmark( + PlacesUtils.bookmarks.toolbarFolder, fxuri, + PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!"); let bmk1_guid = store.GUIDForId(bmk1_id); - let bmk2_id = Svc.Bookmark.insertBookmark( - Svc.Bookmark.toolbarFolder, tburi, Svc.Bookmark.DEFAULT_INDEX, - "Get Thunderbird!"); + let bmk2_id = PlacesUtils.bookmarks.insertBookmark( + PlacesUtils.bookmarks.toolbarFolder, tburi, + PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Thunderbird!"); let bmk2_guid = store.GUIDForId(bmk2_id); _("Verify order."); - do_check_eq(Svc.Bookmark.getItemIndex(bmk1_id), 0); - do_check_eq(Svc.Bookmark.getItemIndex(bmk2_id), 1); + do_check_eq(PlacesUtils.bookmarks.getItemIndex(bmk1_id), 0); + do_check_eq(PlacesUtils.bookmarks.getItemIndex(bmk2_id), 1); let toolbar = store.createRecord("toolbar"); do_check_eq(toolbar.children.length, 2); do_check_eq(toolbar.children[0], bmk1_guid); @@ -286,8 +295,8 @@ function test_move_order() { delete store._childrenToOrder; _("Verify new order."); - do_check_eq(Svc.Bookmark.getItemIndex(bmk2_id), 0); - do_check_eq(Svc.Bookmark.getItemIndex(bmk1_id), 1); + do_check_eq(PlacesUtils.bookmarks.getItemIndex(bmk2_id), 0); + do_check_eq(PlacesUtils.bookmarks.getItemIndex(bmk1_id), 1); } finally { Svc.Obs.notify("weave:engine:stop-tracking"); @@ -300,14 +309,15 @@ function test_orphan() { try { _("Add a new bookmark locally."); - let bmk1_id = Svc.Bookmark.insertBookmark( - Svc.Bookmark.toolbarFolder, fxuri, Svc.Bookmark.DEFAULT_INDEX, - "Get Firefox!"); + let bmk1_id = PlacesUtils.bookmarks.insertBookmark( + PlacesUtils.bookmarks.toolbarFolder, fxuri, + PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!"); let bmk1_guid = store.GUIDForId(bmk1_id); - do_check_eq(Svc.Bookmark.getFolderIdForItem(bmk1_id), Svc.Bookmark.toolbarFolder); + do_check_eq(PlacesUtils.bookmarks.getFolderIdForItem(bmk1_id), + PlacesUtils.bookmarks.toolbarFolder); let error; try { - Svc.Annos.getItemAnnotation(bmk1_id, PARENT_ANNO); + PlacesUtils.annotations.getItemAnnotation(bmk1_id, PARENT_ANNO); } catch(ex) { error = ex; } @@ -319,8 +329,10 @@ function test_orphan() { store.applyIncoming(record); _("Verify that bookmark has been flagged as orphan, has not moved."); - do_check_eq(Svc.Bookmark.getFolderIdForItem(bmk1_id), Svc.Bookmark.toolbarFolder); - do_check_eq(Svc.Annos.getItemAnnotation(bmk1_id, PARENT_ANNO), "non-existent"); + do_check_eq(PlacesUtils.bookmarks.getFolderIdForItem(bmk1_id), + PlacesUtils.bookmarks.toolbarFolder); + do_check_eq(PlacesUtils.annotations.getItemAnnotation(bmk1_id, PARENT_ANNO), + "non-existent"); } finally { _("Clean up."); @@ -330,20 +342,21 @@ function test_orphan() { function test_reparentOrphans() { try { - let folder1_id = Svc.Bookmark.createFolder( - Svc.Bookmark.toolbarFolder, "Folder1", 0); + let folder1_id = PlacesUtils.bookmarks.createFolder( + PlacesUtils.bookmarks.toolbarFolder, "Folder1", 0); let folder1_guid = store.GUIDForId(folder1_id); _("Create a bogus orphan record and write the record back to the store to trigger _reparentOrphans."); - Svc.Annos.setItemAnnotation(folder1_id, PARENT_ANNO, folder1_guid, 0, - Svc.Annos.EXPIRE_NEVER); + PlacesUtils.annotations.setItemAnnotation( + folder1_id, PARENT_ANNO, folder1_guid, 0, + PlacesUtils.annotations.EXPIRE_NEVER); let record = store.createRecord(folder1_guid); record.title = "New title for Folder 1"; store._childrenToOrder = {}; store.applyIncoming(record); _("Verify that is has been marked as an orphan even though it couldn't be moved into itself."); - do_check_eq(Svc.Annos.getItemAnnotation(folder1_id, PARENT_ANNO), + do_check_eq(PlacesUtils.annotations.getItemAnnotation(folder1_id, PARENT_ANNO), folder1_guid); } finally { diff --git a/services/sync/tests/unit/test_bookmark_tracker.js b/services/sync/tests/unit/test_bookmark_tracker.js index cd199ab9ed6..e30f66ca694 100644 --- a/services/sync/tests/unit/test_bookmark_tracker.js +++ b/services/sync/tests/unit/test_bookmark_tracker.js @@ -8,205 +8,18 @@ let engine = Engines.get("bookmarks"); let store = engine._store; store.wipe(); -function test_copying_places() { - - // Gecko <2.0 - if (store._haveGUIDColumn) { - _("We have a GUID column; not testing anno GUID fixing."); - return; - } - - // - // Copied and simplified from PlacesUIUtils, to which we don't have easy - // access. - // - let ptm; - - try { - ptm = Components.classes["@mozilla.org/browser/placesTransactionsService;1"] - .getService(Ci.nsIPlacesTransactionsService); - } catch (ex) { - _("Can't test transactions -- not running with a browser context."); - return; - } - - function getBookmarkItemCopyTransaction(aData, aContainer, aIndex, - aExcludeAnnotations) { - var itemURL = PlacesUtils._uri(aData.uri); - var itemTitle = aData.title; - var keyword = aData.keyword || null; - var annos = aData.annos || []; - // always exclude GUID when copying any item - var excludeAnnos = [PlacesUtils.GUID_ANNO]; - if (aExcludeAnnotations) - excludeAnnos = excludeAnnos.concat(aExcludeAnnotations); - annos = annos.filter(function(aValue, aIndex, aArray) { - return excludeAnnos.indexOf(aValue.name) == -1; - }); - var childTxns = []; - if (aData.dateAdded) - childTxns.push(ptm.editItemDateAdded(null, aData.dateAdded)); - if (aData.lastModified) - childTxns.push(ptm.editItemLastModified(null, aData.lastModified)); - if (aData.tags) { - var tags = aData.tags.split(", "); - var storedTags = PlacesUtils.tagging.getTagsForURI(itemURL, {}); - tags = tags.filter(function (aTag) { - return (storedTags.indexOf(aTag) == -1); - }, this); - if (tags.length) - childTxns.push(ptm.tagURI(itemURL, tags)); - } - - return ptm.createItem(itemURL, aContainer, aIndex, itemTitle, keyword, - annos, childTxns); - } - - function getFolderCopyTransaction(aData, aContainer, aIndex) { - function getChildItemsTransactions(aChildren) { - var childItemsTransactions = []; - var cc = aChildren.length; - var index = aIndex; - for (var i = 0; i < cc; ++i) { - var txn = null; - var node = aChildren[i]; - - // Make sure that items are given the correct index, this will be - // passed by the transaction manager to the backend for the insertion. - // Insertion behaves differently if index == DEFAULT_INDEX (append) - if (aIndex != PlacesUtils.bookmarks.DEFAULT_INDEX) - index = i; - - if (node.type == PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER) - txn = getFolderCopyTransaction(node, aContainer, index); - else // (node.type == PlacesUtils.TYPE_X_MOZ_PLACE) - txn = getBookmarkItemCopyTransaction(node, -1, index); - - if (txn) - childItemsTransactions.push(txn); - } - return childItemsTransactions; - } - - // tag folders use tag transactions - if (aContainer == PlacesUtils.tagsFolderId) { - var txns = []; - if (aData.children) { - aData.children.forEach(function(aChild) { - txns.push(ptm.tagURI(PlacesUtils._uri(aChild.uri), [aData.title])); - }, this); - } - return ptm.aggregateTransactions("addTags", txns); - } - else { - var childItems = getChildItemsTransactions(aData.children); - if (aData.dateAdded) - childItems.push(ptm.editItemDateAdded(null, aData.dateAdded)); - if (aData.lastModified) - childItems.push(ptm.editItemLastModified(null, aData.lastModified)); - - var annos = aData.annos || []; - annos = annos.filter(function(aAnno) { - // always exclude GUID when copying any item - return aAnno.name != PlacesUtils.GUID_ANNO; - }); - return ptm.createFolder(aData.title, aContainer, aIndex, annos, childItems); - } - } - - // - // End simplified PlacesUIUtils code. - // - - let tracker = engine._tracker; - tracker.clearChangedIDs(); - - try { - _("Test copying using Places transactions."); - Svc.Obs.notify("weave:engine:start-tracking"); - - _("Set up source and destination folders."); - let f1 = Svc.Bookmark.createFolder(PlacesUtils.toolbarFolderId, "Folder One", - Svc.Bookmark.DEFAULT_INDEX); - let f2 = Svc.Bookmark.createFolder(PlacesUtils.toolbarFolderId, "Folder Two", - Svc.Bookmark.DEFAULT_INDEX); - - let b1 = Svc.Bookmark.insertBookmark(f1, - Utils.makeURI("http://example.com/"), - Svc.Bookmark.DEFAULT_INDEX, - "Example!"); - - _("F1: " + f1 + "; F2: " + f2 + "; B1: " + b1); - - _("Fetch GUIDs so our anno exists."); - let f1GUID = store.GUIDForId(f1); - let f2GUID = store.GUIDForId(f2); - let b1GUID = store.GUIDForId(b1); - do_check_true(!!f1GUID); - do_check_true(!!f2GUID); - do_check_true(!!b1GUID); - - _("Make sure the destination folder is empty."); - let root = PlacesUtils.getFolderContents(f2, false, true).root; - do_check_eq(root.childCount, 0); - root.containerOpen = false; - - let f1Node = PlacesUtils.getFolderContents(f1, false, false).root; - _("Node to copy: " + f1Node.itemId); - - let serialized = PlacesUtils.wrapNode(f1Node, PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER); - _("Serialized to " + serialized); - f1Node.containerOpen = false; - - let raw = PlacesUtils.unwrapNodes(serialized, PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER).shift(); - let transaction = getFolderCopyTransaction(raw, f2, Svc.Bookmark.DEFAULT_INDEX, true); - - _("Run the copy transaction."); - ptm.doTransaction(transaction); - - _("Verify that items have been copied."); - let f2Node = PlacesUtils.getFolderContents(f2, false, true).root; - do_check_eq(f2Node.childCount, 1); - - _("Verify that the copied folder has different GUIDs."); - let c0 = f2Node.getChild(0); - do_check_eq(c0.title, "Folder One"); - do_check_neq(c0.itemId, f1); - do_check_neq(store.GUIDForId(c0.itemId), f1GUID); - - _("Verify that this copied folder contains a copied bookmark with different GUIDs."); - c0 = c0.QueryInterface(Ci.nsINavHistoryContainerResultNode); - c0.containerOpen = true; - - do_check_eq(c0.childCount, 1); - let b0 = c0.getChild(0); - - do_check_eq(b0.title, "Example!"); - do_check_eq(b0.uri, "http://example.com/"); - do_check_neq(b0.itemId, b1); - do_check_neq(store.GUIDForId(b0.itemId), b1GUID); - - c0.containerOpen = false; - f2Node.containerOpen = false; - } finally { - tracker.clearChangedIDs(); - Svc.Obs.notify("weave:engine:stop-tracking"); - } -} - function test_tracking() { _("Verify we've got an empty tracker to work with."); let tracker = engine._tracker; do_check_eq([id for (id in tracker.changedIDs)].length, 0); - let folder = Svc.Bookmark.createFolder(Svc.Bookmark.bookmarksMenuFolder, - "Test Folder", - Svc.Bookmark.DEFAULT_INDEX); + let folder = PlacesUtils.bookmarks.createFolder( + PlacesUtils.bookmarks.bookmarksMenuFolder, + "Test Folder", PlacesUtils.bookmarks.DEFAULT_INDEX); function createBmk() { - return Svc.Bookmark.insertBookmark(folder, - Utils.makeURI("http://getfirefox.com"), - Svc.Bookmark.DEFAULT_INDEX, - "Get Firefox!"); + return PlacesUtils.bookmarks.insertBookmark( + folder, Utils.makeURI("http://getfirefox.com"), + PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!"); } try { @@ -255,21 +68,21 @@ function test_onItemChanged() { try { Svc.Obs.notify("weave:engine:stop-tracking"); - let folder = Svc.Bookmark.createFolder(Svc.Bookmark.bookmarksMenuFolder, - "Parent", - Svc.Bookmark.DEFAULT_INDEX); + let folder = PlacesUtils.bookmarks.createFolder( + PlacesUtils.bookmarks.bookmarksMenuFolder, "Parent", + PlacesUtils.bookmarks.DEFAULT_INDEX); _("Track changes to annos."); - let b = Svc.Bookmark.insertBookmark(folder, - Utils.makeURI("http://getfirefox.com"), - Svc.Bookmark.DEFAULT_INDEX, - "Get Firefox!"); + let b = PlacesUtils.bookmarks.insertBookmark( + folder, Utils.makeURI("http://getfirefox.com"), + PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!"); let bGUID = engine._store.GUIDForId(b); _("New item is " + b); _("GUID: " + bGUID); Svc.Obs.notify("weave:engine:start-tracking"); - Svc.Annos.setItemAnnotation(b, DESCRIPTION_ANNO, "A test description", 0, - Svc.Annos.EXPIRE_NEVER); + PlacesUtils.annotations.setItemAnnotation( + b, DESCRIPTION_ANNO, "A test description", 0, + PlacesUtils.annotations.EXPIRE_NEVER); do_check_true(tracker.changedIDs[bGUID] > 0); } finally { @@ -280,6 +93,54 @@ function test_onItemChanged() { } } +function test_onItemMoved() { + _("Verify we've got an empty tracker to work with."); + let tracker = engine._tracker; + do_check_eq([id for (id in tracker.changedIDs)].length, 0); + + try { + let fx_id = PlacesUtils.bookmarks.insertBookmark( + PlacesUtils.bookmarks.bookmarksMenuFolder, + Utils.makeURI("http://getfirefox.com"), + PlacesUtils.bookmarks.DEFAULT_INDEX, + "Get Firefox!"); + let fx_guid = engine._store.GUIDForId(fx_id); + let tb_id = PlacesUtils.bookmarks.insertBookmark( + PlacesUtils.bookmarks.bookmarksMenuFolder, + Utils.makeURI("http://getthunderbird.com"), + PlacesUtils.bookmarks.DEFAULT_INDEX, + "Get Thunderbird!"); + let tb_guid = engine._store.GUIDForId(tb_id); + + Svc.Obs.notify("weave:engine:start-tracking"); + + // Moving within the folder will just track the folder. + PlacesUtils.bookmarks.moveItem( + tb_id, PlacesUtils.bookmarks.bookmarksMenuFolder, 0); + do_check_true(tracker.changedIDs['menu'] > 0); + do_check_eq(tracker.changedIDs['toolbar'], undefined); + do_check_eq(tracker.changedIDs[fx_guid], undefined); + do_check_eq(tracker.changedIDs[tb_guid], undefined); + tracker.clearChangedIDs(); + + // Moving a bookmark to a different folder will track the old + // folder, the new folder and the bookmark. + PlacesUtils.bookmarks.moveItem(tb_id, PlacesUtils.bookmarks.toolbarFolder, + PlacesUtils.bookmarks.DEFAULT_INDEX); + do_check_true(tracker.changedIDs['menu'] > 0); + do_check_true(tracker.changedIDs['toolbar'] > 0); + do_check_eq(tracker.changedIDs[fx_guid], undefined); + do_check_true(tracker.changedIDs[tb_guid] > 0); + + } finally { + _("Clean up."); + store.wipe(); + tracker.clearChangedIDs(); + Svc.Obs.notify("weave:engine:stop-tracking"); + } + +} + function run_test() { initTestLogging("Trace"); @@ -287,8 +148,8 @@ function run_test() { Log4Moz.repository.getLogger("Store.Bookmarks").level = Log4Moz.Level.Trace; Log4Moz.repository.getLogger("Tracker.Bookmarks").level = Log4Moz.Level.Trace; - test_onItemChanged(); - test_copying_places(); test_tracking(); + test_onItemChanged(); + test_onItemMoved(); } diff --git a/services/sync/tests/unit/test_history_engine.js b/services/sync/tests/unit/test_history_engine.js index 1dbe51f1eb1..ff66e2342e1 100644 --- a/services/sync/tests/unit/test_history_engine.js +++ b/services/sync/tests/unit/test_history_engine.js @@ -5,11 +5,7 @@ Cu.import("resource://services-sync/engines.js"); Cu.import("resource://services-sync/identity.js"); Cu.import("resource://services-sync/util.js"); -function makeSteamEngine() { - return new SteamEngine(); -} - -var syncTesting = new SyncTestingInfrastructure(makeSteamEngine); +var syncTesting = new SyncTestingInfrastructure(); function test_processIncoming_mobile_history_batched() { _("SyncEngine._processIncoming works on history engine."); @@ -19,7 +15,7 @@ function test_processIncoming_mobile_history_batched() { Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); Svc.Prefs.set("client.type", "mobile"); - Svc.History.removeAllPages(); + PlacesUtils.history.removeAllPages(); Engines.register(HistoryEngine); // A collection that logs each GET @@ -128,7 +124,7 @@ function test_processIncoming_mobile_history_batched() { } } finally { - Svc.History.removeAllPages(); + PlacesUtils.history.removeAllPages(); server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); diff --git a/services/sync/tests/unit/test_history_store.js b/services/sync/tests/unit/test_history_store.js index 80047993358..25a21206847 100644 --- a/services/sync/tests/unit/test_history_store.js +++ b/services/sync/tests/unit/test_history_store.js @@ -7,9 +7,9 @@ const TIMESTAMP2 = (Date.now() - 6592903) * 1000; const TIMESTAMP3 = (Date.now() - 123894) * 1000; function queryPlaces(uri, options) { - let query = Svc.History.getNewQuery(); + let query = PlacesUtils.history.getNewQuery(); query.uri = uri; - let res = Svc.History.executeQuery(query, options); + let res = PlacesUtils.history.executeQuery(query, options); res.root.containerOpen = true; let results = []; @@ -20,7 +20,7 @@ function queryPlaces(uri, options) { } function queryHistoryVisits(uri) { - let options = Svc.History.getNewQueryOptions(); + let options = PlacesUtils.history.getNewQueryOptions(); options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY; options.resultType = Ci.nsINavHistoryQueryOptions.RESULTS_AS_VISIT; options.sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_DATE_ASCENDING; @@ -28,12 +28,12 @@ function queryHistoryVisits(uri) { } function onNextTitleChanged(callback) { - Svc.History.addObserver({ + PlacesUtils.history.addObserver({ onBeginUpdateBatch: function onBeginUpdateBatch() {}, onEndUpdateBatch: function onEndUpdateBatch() {}, onPageChanged: function onPageChanged() {}, onTitleChanged: function onTitleChanged() { - Svc.History.removeObserver(this); + PlacesUtils.history.removeObserver(this); Utils.delay(callback, 0, this); }, onVisit: function onVisit() {}, @@ -57,7 +57,7 @@ function ensureThrows(func) { try { func.apply(this, arguments); } catch (ex) { - Svc.History.removeAllPages(); + PlacesUtils.history.removeAllPages(); do_throw(ex); } }; @@ -81,7 +81,7 @@ add_test(function test_store() { _("Let's create an entry in the database."); fxuri = Utils.makeURI("http://getfirefox.com/"); - Svc.History.addPageWithDetails(fxuri, "Get Firefox!", TIMESTAMP1); + PlacesUtils.history.addPageWithDetails(fxuri, "Get Firefox!", TIMESTAMP1); _("Verify that the entry exists."); let ids = [id for (id in store.getAllIDs())]; @@ -165,7 +165,7 @@ add_test(function test_invalid_records() { let query = "INSERT INTO moz_places " + "(url, title, rev_host, visit_count, last_visit_date) " + "VALUES ('invalid-uri', 'Invalid URI', '.', 1, " + TIMESTAMP3 + ")"; - let stmt = Svc.History.DBConnection.createAsyncStatement(query); + let stmt = PlacesUtils.history.DBConnection.createAsyncStatement(query); let result = Utils.queryAsync(stmt); do_check_eq([id for (id in store.getAllIDs())].length, 4); @@ -264,6 +264,6 @@ add_test(function test_remove() { add_test(function cleanup() { _("Clean up."); - Svc.History.removeAllPages(); + PlacesUtils.history.removeAllPages(); run_next_test(); }); diff --git a/services/sync/tests/unit/test_history_tracker.js b/services/sync/tests/unit/test_history_tracker.js index 5f68f716f81..a6532ce7315 100644 --- a/services/sync/tests/unit/test_history_tracker.js +++ b/services/sync/tests/unit/test_history_tracker.js @@ -20,8 +20,9 @@ let tracker = engine._tracker; let _counter = 0; function addVisit() { - Svc.History.addVisit(Utils.makeURI("http://getfirefox.com/" + _counter), - Date.now() * 1000, null, 1, false, 0); + PlacesUtils.history.addVisit( + Utils.makeURI("http://getfirefox.com/" + _counter), + Date.now() * 1000, null, 1, false, 0); _counter += 1; } @@ -76,7 +77,7 @@ add_test(function test_track_delete() { do_check_eq([id for (id in tracker.changedIDs)].length, 3); run_next_test(); }); - Svc.History.removePage(uri); + PlacesUtils.history.removePage(uri); }); add_test(function test_stop_tracking() { @@ -102,6 +103,6 @@ add_test(function test_stop_tracking_twice() { add_test(function cleanup() { _("Clean up."); - Svc.History.removeAllPages(); + PlacesUtils.history.removeAllPages(); run_next_test(); }); diff --git a/services/sync/tests/unit/test_password_store.js b/services/sync/tests/unit/test_password_store.js index cd38cc72c93..dd585783b97 100644 --- a/services/sync/tests/unit/test_password_store.js +++ b/services/sync/tests/unit/test_password_store.js @@ -33,14 +33,14 @@ function run_test() { try { applyEnsureNoFailures([recordA, recordB]); - // Only the good record makes it to Svc.Login. + // Only the good record makes it to Services.logins. let badCount = {}; let goodCount = {}; - let badLogins = Svc.Login.findLogins(badCount, recordA.hostname, - recordA.formSubmitURL, - recordA.httpRealm); - let goodLogins = Svc.Login.findLogins(goodCount, recordB.hostname, - recordB.formSubmitURL, null); + let badLogins = Services.logins.findLogins(badCount, recordA.hostname, + recordA.formSubmitURL, + recordA.httpRealm); + let goodLogins = Services.logins.findLogins(goodCount, recordB.hostname, + recordB.formSubmitURL, null); _("Bad: " + JSON.stringify(badLogins)); _("Good: " + JSON.stringify(goodLogins)); diff --git a/services/sync/tests/unit/test_places_guid_downgrade.js b/services/sync/tests/unit/test_places_guid_downgrade.js index dd0e5f76ba8..080f51bd566 100644 --- a/services/sync/tests/unit/test_places_guid_downgrade.js +++ b/services/sync/tests/unit/test_places_guid_downgrade.js @@ -81,13 +81,18 @@ function test_history_guids() { let engine = new HistoryEngine(); let store = engine._store; - Svc.History.addPageWithDetails(fxuri, "Get Firefox!", Date.now() * 1000); - Svc.History.addPageWithDetails(tburi, "Get Thunderbird!", Date.now() * 1000); + PlacesUtils.history.addPageWithDetails(fxuri, "Get Firefox!", + Date.now() * 1000); + PlacesUtils.history.addPageWithDetails(tburi, "Get Thunderbird!", + Date.now() * 1000); // Hack: flush the places db by adding a random bookmark. let uri = Utils.makeURI("http://mozilla.com/"); - let fxid = Svc.Bookmark.insertBookmark( - Svc.Bookmark.toolbarFolder, uri, Svc.Bookmark.DEFAULT_INDEX, "Mozilla"); + let fxid = PlacesUtils.bookmarks.insertBookmark( + PlacesUtils.bookmarks.toolbarFolder, + uri, + PlacesUtils.bookmarks.DEFAULT_INDEX, + "Mozilla"); let fxguid = store.GUIDForUri(fxuri, true); let tbguid = store.GUIDForUri(tburi, true); @@ -95,7 +100,7 @@ function test_history_guids() { dump("tbguid: " + tbguid + "\n"); _("History: Verify GUIDs are added to the guid column."); - let stmt = Svc.History.DBConnection.createAsyncStatement( + let stmt = PlacesUtils.history.DBConnection.createAsyncStatement( "SELECT id FROM moz_places WHERE guid = :guid"); stmt.params.guid = fxguid; @@ -107,7 +112,7 @@ function test_history_guids() { do_check_eq(result.length, 1); _("History: Verify GUIDs weren't added to annotations."); - stmt = Svc.History.DBConnection.createAsyncStatement( + stmt = PlacesUtils.history.DBConnection.createAsyncStatement( "SELECT a.content AS guid FROM moz_annos a WHERE guid = :guid"); stmt.params.guid = fxguid; @@ -123,18 +128,22 @@ function test_bookmark_guids() { let engine = new BookmarksEngine(); let store = engine._store; - let fxid = Svc.Bookmark.insertBookmark( - Svc.Bookmark.toolbarFolder, fxuri, Svc.Bookmark.DEFAULT_INDEX, + let fxid = PlacesUtils.bookmarks.insertBookmark( + PlacesUtils.bookmarks.toolbarFolder, + fxuri, + PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!"); - let tbid = Svc.Bookmark.insertBookmark( - Svc.Bookmark.toolbarFolder, tburi, Svc.Bookmark.DEFAULT_INDEX, + let tbid = PlacesUtils.bookmarks.insertBookmark( + PlacesUtils.bookmarks.toolbarFolder, + tburi, + PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Thunderbird!"); let fxguid = store.GUIDForId(fxid); let tbguid = store.GUIDForId(tbid); _("Bookmarks: Verify GUIDs are added to the guid column."); - let stmt = Svc.History.DBConnection.createAsyncStatement( + let stmt = PlacesUtils.history.DBConnection.createAsyncStatement( "SELECT id FROM moz_bookmarks WHERE guid = :guid"); stmt.params.guid = fxguid; @@ -148,7 +157,7 @@ function test_bookmark_guids() { do_check_eq(result[0].id, tbid); _("Bookmarks: Verify GUIDs weren't added to annotations."); - stmt = Svc.History.DBConnection.createAsyncStatement( + stmt = PlacesUtils.history.DBConnection.createAsyncStatement( "SELECT a.content AS guid FROM moz_items_annos a WHERE guid = :guid"); stmt.params.guid = fxguid; diff --git a/services/sync/tests/unit/test_prefs_store.js b/services/sync/tests/unit/test_prefs_store.js index 562118962ff..3e954ee877f 100644 --- a/services/sync/tests/unit/test_prefs_store.js +++ b/services/sync/tests/unit/test_prefs_store.js @@ -4,7 +4,7 @@ Cu.import("resource://services-sync/ext/Preferences.js"); Cu.import("resource://gre/modules/LightweightThemeManager.jsm"); Cu.import("resource://gre/modules/Services.jsm"); -const PREFS_GUID = Utils.encodeBase64url(Svc.AppInfo.ID); +const PREFS_GUID = Utils.encodeBase64url(Services.appinfo.ID); function makePersona(id) { return { diff --git a/services/sync/tests/unit/test_prefs_tracker.js b/services/sync/tests/unit/test_prefs_tracker.js index 846889fbf79..c4dad9a7fdb 100644 --- a/services/sync/tests/unit/test_prefs_tracker.js +++ b/services/sync/tests/unit/test_prefs_tracker.js @@ -21,7 +21,7 @@ function run_test() { let changedIDs = engine.getChangedIDs(); let ids = [id for (id in changedIDs)]; do_check_eq(ids.length, 1); - do_check_eq(ids[0], Utils.encodeBase64url(Svc.AppInfo.ID)); + do_check_eq(ids[0], Utils.encodeBase64url(Services.appinfo.ID)); Svc.Prefs.set("engine.prefs.modified", false); do_check_false(tracker.modified); diff --git a/services/sync/tests/unit/test_resource.js b/services/sync/tests/unit/test_resource.js index c86cde2f564..ba448f18350 100644 --- a/services/sync/tests/unit/test_resource.js +++ b/services/sync/tests/unit/test_resource.js @@ -154,7 +154,7 @@ function run_test() { "/quota-error": server_quota_error }); - Utils.prefs.setIntPref("network.numRetries", 1); // speed up test + Svc.Prefs.set("network.numRetries", 1); // speed up test _("Resource object members"); let res = new Resource("http://localhost:8080/open"); @@ -430,7 +430,7 @@ function run_test() { let res18 = new Resource("http://localhost:8080/json"); let onProgress = function(rec) { // Provoke an XPC exception without a Javascript wrapper. - Svc.IO.newURI("::::::::", null, null); + Services.io.newURI("::::::::", null, null); }; res18._onProgress = onProgress; let oldWarn = res18._log.warn; diff --git a/services/sync/tests/unit/test_resource_async.js b/services/sync/tests/unit/test_resource_async.js index 3bc72c96b42..2e1603849c2 100644 --- a/services/sync/tests/unit/test_resource_async.js +++ b/services/sync/tests/unit/test_resource_async.js @@ -154,7 +154,7 @@ function run_test() { "/quota-error": server_quota_error }); - Utils.prefs.setIntPref("network.numRetries", 1); // speed up test + Svc.Prefs.set("network.numRetries", 1); // speed up test let did401 = false; Observers.add("weave:resource:status:401", function() did401 = true); @@ -633,7 +633,7 @@ function run_test() { let res14 = new AsyncResource("http://localhost:8080/json"); res14._onProgress = function(rec) { // Provoke an XPC exception without a Javascript wrapper. - Svc.IO.newURI("::::::::", null, null); + Services.io.newURI("::::::::", null, null); }; let warnings = []; res14._log.warn = function(msg) { warnings.push(msg) }; diff --git a/services/sync/tests/unit/test_resource_ua.js b/services/sync/tests/unit/test_resource_ua.js index cf2c286cdef..e998e3aff5a 100644 --- a/services/sync/tests/unit/test_resource_ua.js +++ b/services/sync/tests/unit/test_resource_ua.js @@ -28,8 +28,9 @@ function test_resource_user_agent() { Weave.Service.username = "johndoe"; Weave.Service.password = "ilovejane"; - let expectedUA = Svc.AppInfo.name + "/" + Svc.AppInfo.version + - " FxSync/" + WEAVE_VERSION + "." + Svc.AppInfo.appBuildID; + let expectedUA = Services.appinfo.name + "/" + Services.appinfo.version + + " FxSync/" + WEAVE_VERSION + "." + + Services.appinfo.appBuildID; function test_fetchInfo(next) { _("Testing _fetchInfo."); diff --git a/services/sync/tests/unit/test_service_changePassword.js b/services/sync/tests/unit/test_service_changePassword.js index 8555a5c63cc..c8a5a7b37c5 100644 --- a/services/sync/tests/unit/test_service_changePassword.js +++ b/services/sync/tests/unit/test_service_changePassword.js @@ -38,7 +38,7 @@ function run_test() { do_check_eq(requestBody, "ILoveJane83"); _("Make sure the password has been persisted in the login manager."); - let logins = Weave.Svc.Login.findLogins({}, PWDMGR_HOST, null, + let logins = Services.logins.findLogins({}, PWDMGR_HOST, null, PWDMGR_PASSWORD_REALM); do_check_eq(logins[0].password, "ILoveJane83"); @@ -50,7 +50,7 @@ function run_test() { do_check_eq(requestBody, Utils.encodeUTF8(moneyPassword)); _("changePassword() returns false for a server error, the password won't change."); - Weave.Svc.Login.removeAllLogins(); + Services.logins.removeAllLogins(); Weave.Service.username = "janedoe"; Weave.Service.password = "ilovejohn"; res = Weave.Service.changePassword("ILoveJohn86"); @@ -59,7 +59,7 @@ function run_test() { } finally { Weave.Svc.Prefs.resetBranch(""); - Weave.Svc.Login.removeAllLogins(); + Services.logins.removeAllLogins(); if (server) { server.stop(do_test_finished); } diff --git a/services/sync/tests/unit/test_service_login.js b/services/sync/tests/unit/test_service_login.js index 9db7770ef76..3000a7d5ebd 100644 --- a/services/sync/tests/unit/test_service_login.js +++ b/services/sync/tests/unit/test_service_login.js @@ -23,12 +23,12 @@ function run_test() { try { _("The right bits are set when we're offline."); - Svc.IO.offline = true; + Services.io.offline = true; do_check_eq(Service._ignorableErrorCount, 0); do_check_false(!!Service.login()); do_check_eq(Status.login, LOGIN_FAILED_NETWORK_ERROR); do_check_eq(Service._ignorableErrorCount, 0); - Svc.IO.offline = false; + Services.io.offline = false; } finally { Svc.Prefs.resetBranch(""); } @@ -176,7 +176,7 @@ function run_test() { _("We're ready to sync if locked."); Service.enabled = true; - Svc.IO.offline = false; + Services.io.offline = false; Service._checkSyncStatus(); do_check_true(scheduleCalled); diff --git a/services/sync/tests/unit/test_service_persistLogin.js b/services/sync/tests/unit/test_service_persistLogin.js index c8265d6c5da..d8ce39bc799 100644 --- a/services/sync/tests/unit/test_service_persistLogin.js +++ b/services/sync/tests/unit/test_service_persistLogin.js @@ -1,20 +1,21 @@ Cu.import("resource://services-sync/main.js"); +Cu.import("resource://services-sync/util.js"); Cu.import("resource://services-sync/constants.js"); function run_test() { try { // Ensure we have a blank slate to start. - Weave.Svc.Login.removeAllLogins(); + Services.logins.removeAllLogins(); Weave.Service.username = "johndoe"; Weave.Service.password = "ilovejane"; Weave.Service.passphrase = "abbbbbcccccdddddeeeeefffff"; _("Confirm initial environment is empty."); - let logins = Weave.Svc.Login.findLogins({}, PWDMGR_HOST, null, + let logins = Services.logins.findLogins({}, PWDMGR_HOST, null, PWDMGR_PASSWORD_REALM); do_check_eq(logins.length, 0); - logins = Weave.Svc.Login.findLogins({}, PWDMGR_HOST, null, + logins = Services.logins.findLogins({}, PWDMGR_HOST, null, PWDMGR_PASSPHRASE_REALM); do_check_eq(logins.length, 0); @@ -22,14 +23,14 @@ function run_test() { Weave.Service.persistLogin(); _("The password has been persisted in the login service."); - logins = Weave.Svc.Login.findLogins({}, PWDMGR_HOST, null, + logins = Services.logins.findLogins({}, PWDMGR_HOST, null, PWDMGR_PASSWORD_REALM); do_check_eq(logins.length, 1); do_check_eq(logins[0].username, "johndoe"); do_check_eq(logins[0].password, "ilovejane"); _("The passphrase has been persisted in the login service."); - logins = Weave.Svc.Login.findLogins({}, PWDMGR_HOST, null, + logins = Services.logins.findLogins({}, PWDMGR_HOST, null, PWDMGR_PASSPHRASE_REALM); do_check_eq(logins.length, 1); do_check_eq(logins[0].username, "johndoe"); @@ -37,6 +38,6 @@ function run_test() { } finally { Weave.Svc.Prefs.resetBranch(""); - Weave.Svc.Login.removeAllLogins(); + Services.logins.removeAllLogins(); } } diff --git a/services/sync/tests/unit/test_service_sync_checkServerError.js b/services/sync/tests/unit/test_service_sync_checkServerError.js index 73533f22f50..1a275530821 100644 --- a/services/sync/tests/unit/test_service_sync_checkServerError.js +++ b/services/sync/tests/unit/test_service_sync_checkServerError.js @@ -64,8 +64,8 @@ function generateAndUploadKeys() { add_test(function test_backoff500() { _("Test: HTTP 500 sets backoff status."); - let server = sync_httpd_setup(); setUp(); + let server = sync_httpd_setup(); let engine = Engines.get("catapult"); engine.enabled = true; @@ -89,8 +89,8 @@ add_test(function test_backoff500() { add_test(function test_backoff503() { _("Test: HTTP 503 with Retry-After header leads to backoff notification and sets backoff status."); - let server = sync_httpd_setup(); setUp(); + let server = sync_httpd_setup(); const BACKOFF = 42; let engine = Engines.get("catapult"); @@ -122,8 +122,8 @@ add_test(function test_backoff503() { add_test(function test_overQuota() { _("Test: HTTP 400 with body error code 14 means over quota."); - let server = sync_httpd_setup(); setUp(); + let server = sync_httpd_setup(); let engine = Engines.get("catapult"); engine.enabled = true; @@ -171,7 +171,7 @@ add_test(function test_service_networkError() { add_test(function test_service_offline() { _("Test: Wanting to sync in offline mode leads to the right status code but does not increment the ignorable error count."); setUp(); - Svc.IO.offline = true; + Services.io.offline = true; Service._ignorableErrorCount = 0; try { @@ -186,14 +186,14 @@ add_test(function test_service_offline() { Status.resetSync(); Service.startOver(); } - Svc.IO.offline = false; + Services.io.offline = false; run_next_test(); }); add_test(function test_service_reset_ignorableErrorCount() { _("Test: Successful sync resets the ignorable error count."); - let server = sync_httpd_setup(); setUp(); + let server = sync_httpd_setup(); Service._ignorableErrorCount = 10; // Disable the engine so that sync completes. @@ -219,8 +219,8 @@ add_test(function test_service_reset_ignorableErrorCount() { add_test(function test_engine_networkError() { _("Test: Network related exceptions from engine.sync() lead to the right status code."); - let server = sync_httpd_setup(); setUp(); + let server = sync_httpd_setup(); Service._ignorableErrorCount = 0; let engine = Engines.get("catapult"); @@ -245,11 +245,40 @@ add_test(function test_engine_networkError() { server.stop(run_next_test); }); +add_test(function test_resource_timeout() { + setUp(); + let server = sync_httpd_setup(); + + let engine = Engines.get("catapult"); + engine.enabled = true; + // Resource throws this when it encounters a timeout. + engine.exception = Components.Exception("Aborting due to channel inactivity.", + Cr.NS_ERROR_NET_TIMEOUT); + + try { + do_check_eq(Status.sync, SYNC_SUCCEEDED); + + do_check_true(generateAndUploadKeys()); + + Service.login(); + Service.sync(); + + do_check_eq(Status.sync, LOGIN_FAILED_NETWORK_ERROR); + } finally { + Status.resetSync(); + Service.startOver(); + } + server.stop(run_next_test); +}); + + // Slightly misplaced test as it doesn't actually test checkServerError, // but the observer for "weave:engine:sync:apply-failed". +// This test should be the last one since it monkeypatches the engine object +// and we should only have one engine object throughout the file (bug 629664). add_test(function test_engine_applyFailed() { - let server = sync_httpd_setup(); setUp(); + let server = sync_httpd_setup(); let engine = Engines.get("catapult"); engine.enabled = true; @@ -274,6 +303,7 @@ add_test(function test_engine_applyFailed() { server.stop(run_next_test); }); + function run_test() { if (DISABLE_TESTS_BUG_604565) return; diff --git a/services/sync/tests/unit/test_service_verifyLogin.js b/services/sync/tests/unit/test_service_verifyLogin.js index 5f9268986cd..5db141a2d75 100644 --- a/services/sync/tests/unit/test_service_verifyLogin.js +++ b/services/sync/tests/unit/test_service_verifyLogin.js @@ -28,7 +28,7 @@ function run_test() { Log4Moz.repository.rootLogger.addAppender(new Log4Moz.DumpAppender()); // This test expects a clean slate -- no saved passphrase. - Weave.Svc.Login.removeAllLogins(); + Services.logins.removeAllLogins(); let johnHelper = track_collections_helper(); let johnU = johnHelper.with_updated_collection; let johnColls = johnHelper.collections; diff --git a/services/sync/tests/unit/test_syncengine.js b/services/sync/tests/unit/test_syncengine.js index bf91493934a..cc645587a36 100644 --- a/services/sync/tests/unit/test_syncengine.js +++ b/services/sync/tests/unit/test_syncengine.js @@ -5,10 +5,9 @@ function makeSteamEngine() { return new SyncEngine('Steam'); } -var syncTesting = new SyncTestingInfrastructure(makeSteamEngine); - function test_url_attributes() { _("SyncEngine url attributes"); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "https://cluster/"); let engine = makeSteamEngine(); try { @@ -22,6 +21,7 @@ function test_url_attributes() { function test_syncID() { _("SyncEngine.syncID corresponds to preference"); + let syncTesting = new SyncTestingInfrastructure(); let engine = makeSteamEngine(); try { // Ensure pristine environment @@ -36,12 +36,12 @@ function test_syncID() { do_check_eq(engine.syncID, "fake-guid-1"); } finally { Svc.Prefs.resetBranch(""); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } function test_lastSync() { _("SyncEngine.lastSync and SyncEngine.lastSyncLocal correspond to preferences"); + let syncTesting = new SyncTestingInfrastructure(); let engine = makeSteamEngine(); try { // Ensure pristine environment @@ -71,6 +71,7 @@ function test_lastSync() { function test_toFetch() { _("SyncEngine.toFetch corresponds to file on disk"); + let syncTesting = new SyncTestingInfrastructure(); const filename = "weave/toFetch/steam.json"; let engine = makeSteamEngine(); try { @@ -100,6 +101,7 @@ function test_toFetch() { function test_resetClient() { _("SyncEngine.resetClient resets lastSync and toFetch"); + let syncTesting = new SyncTestingInfrastructure(); let engine = makeSteamEngine(); try { // Ensure pristine environment @@ -123,6 +125,7 @@ function test_resetClient() { function test_wipeServer() { _("SyncEngine.wipeServer deletes server data and resets the client."); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); let engine = makeSteamEngine(); diff --git a/services/sync/tests/unit/test_syncengine_sync.js b/services/sync/tests/unit/test_syncengine_sync.js index ebf93c8cc97..a3d140baf1e 100644 --- a/services/sync/tests/unit/test_syncengine_sync.js +++ b/services/sync/tests/unit/test_syncengine_sync.js @@ -97,8 +97,6 @@ function makeSteamEngine() { return new SteamEngine(); } -var syncTesting = new SyncTestingInfrastructure(makeSteamEngine); - /* * Tests * @@ -116,6 +114,7 @@ var syncTesting = new SyncTestingInfrastructure(makeSteamEngine); function test_syncStartup_emptyOrOutdatedGlobalsResetsSync() { _("SyncEngine._syncStartup resets sync and wipes server data if there's no or an outdated global record"); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); @@ -165,13 +164,13 @@ function test_syncStartup_emptyOrOutdatedGlobalsResetsSync() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } function test_syncStartup_serverHasNewerVersion() { _("SyncEngine._syncStartup "); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); let global = new ServerWBO('global', {engines: {steam: {version: 23456}}}); @@ -197,7 +196,6 @@ function test_syncStartup_serverHasNewerVersion() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } @@ -205,6 +203,7 @@ function test_syncStartup_serverHasNewerVersion() { function test_syncStartup_syncIDMismatchResetsClient() { _("SyncEngine._syncStartup resets sync if syncIDs don't match"); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); let server = sync_httpd_setup({}); @@ -237,7 +236,6 @@ function test_syncStartup_syncIDMismatchResetsClient() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } @@ -245,6 +243,7 @@ function test_syncStartup_syncIDMismatchResetsClient() { function test_processIncoming_emptyServer() { _("SyncEngine._processIncoming working with an empty server backend"); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); let collection = new ServerCollection(); @@ -265,7 +264,6 @@ function test_processIncoming_emptyServer() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } @@ -273,6 +271,7 @@ function test_processIncoming_emptyServer() { function test_processIncoming_createFromServer() { _("SyncEngine._processIncoming creates new records from server data"); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); @@ -329,7 +328,6 @@ function test_processIncoming_createFromServer() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } @@ -337,6 +335,7 @@ function test_processIncoming_createFromServer() { function test_processIncoming_reconcile() { _("SyncEngine._processIncoming updates local records"); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); let collection = new ServerCollection(); @@ -451,7 +450,6 @@ function test_processIncoming_reconcile() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } @@ -459,6 +457,7 @@ function test_processIncoming_reconcile() { function test_processIncoming_mobile_batchSize() { _("SyncEngine._processIncoming doesn't fetch everything at once on mobile clients"); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); Svc.Prefs.set("client.type", "mobile"); @@ -524,13 +523,13 @@ function test_processIncoming_mobile_batchSize() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } function test_processIncoming_store_toFetch() { _("If processIncoming fails in the middle of a batch on mobile, state is saved in toFetch and lastSync."); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); Svc.Prefs.set("client.type", "mobile"); @@ -594,13 +593,13 @@ function test_processIncoming_store_toFetch() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } function test_processIncoming_resume_toFetch() { _("toFetch items left over from previous syncs are fetched on the next sync, along with new items."); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); @@ -654,13 +653,13 @@ function test_processIncoming_resume_toFetch() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } function test_processIncoming_applyIncomingBatchSize_smaller() { _("Ensure that a number of incoming items less than applyIncomingBatchSize is still applied."); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); @@ -711,13 +710,13 @@ function test_processIncoming_applyIncomingBatchSize_smaller() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } function test_processIncoming_applyIncomingBatchSize_multiple() { _("Ensure that incoming items are applied according to applyIncomingBatchSize."); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); @@ -767,13 +766,13 @@ function test_processIncoming_applyIncomingBatchSize_multiple() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } function test_processIncoming_failed_records() { _("Ensure that failed records from _reconcile and applyIncomingBatch are refetched."); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); @@ -981,7 +980,6 @@ function test_processIncoming_decrypt_failed() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } @@ -989,6 +987,7 @@ function test_processIncoming_decrypt_failed() { function test_uploadOutgoing_toEmptyServer() { _("SyncEngine._uploadOutgoing uploads new records to server"); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); let collection = new ServerCollection(); @@ -1042,7 +1041,6 @@ function test_uploadOutgoing_toEmptyServer() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } @@ -1050,6 +1048,7 @@ function test_uploadOutgoing_toEmptyServer() { function test_uploadOutgoing_failed() { _("SyncEngine._uploadOutgoing doesn't clear the tracker of objects that failed to upload."); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); let collection = new ServerCollection(); @@ -1115,6 +1114,7 @@ function test_uploadOutgoing_failed() { function test_uploadOutgoing_MAX_UPLOAD_RECORDS() { _("SyncEngine._uploadOutgoing uploads in batches of MAX_UPLOAD_RECORDS"); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); let collection = new ServerCollection(); @@ -1186,6 +1186,7 @@ function test_syncFinish_noDelete() { function test_syncFinish_deleteByIds() { _("SyncEngine._syncFinish deletes server records slated for deletion (list of record IDs)."); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); let collection = new ServerCollection(); @@ -1222,7 +1223,6 @@ function test_syncFinish_deleteByIds() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } @@ -1230,6 +1230,7 @@ function test_syncFinish_deleteByIds() { function test_syncFinish_deleteLotsInBatches() { _("SyncEngine._syncFinish deletes server records in batches of 100 (list of record IDs)."); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); let collection = new ServerCollection(); @@ -1296,7 +1297,6 @@ function test_syncFinish_deleteLotsInBatches() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } @@ -1304,6 +1304,7 @@ function test_syncFinish_deleteLotsInBatches() { function test_sync_partialUpload() { _("SyncEngine.sync() keeps changedIDs that couldn't be uploaded."); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); @@ -1373,12 +1374,12 @@ function test_sync_partialUpload() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } function test_canDecrypt_noCryptoKeys() { _("SyncEngine.canDecrypt returns false if the engine fails to decrypt items on the server, e.g. due to a missing crypto key collection."); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); @@ -1404,12 +1405,12 @@ function test_canDecrypt_noCryptoKeys() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } function test_canDecrypt_true() { _("SyncEngine.canDecrypt returns true if the engine can decrypt the items on the server."); + let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("clusterURL", "http://localhost:8080/"); Svc.Prefs.set("username", "foo"); @@ -1435,7 +1436,6 @@ function test_canDecrypt_true() { server.stop(do_test_finished); Svc.Prefs.resetBranch(""); Records.clearCache(); - syncTesting = new SyncTestingInfrastructure(makeSteamEngine); } } diff --git a/services/sync/tests/unit/test_tab_tracker.js b/services/sync/tests/unit/test_tab_tracker.js index 377ad5bfa1d..11dd4d4f0a6 100644 --- a/services/sync/tests/unit/test_tab_tracker.js +++ b/services/sync/tests/unit/test_tab_tracker.js @@ -5,8 +5,8 @@ Cu.import("resource://services-sync/util.js"); function fakeSvcWinMediator() { // actions on windows are captured in logs let logs = []; - delete Svc.WinMediator; - Svc.WinMediator = { + delete Services.wm; + Services.wm = { getEnumerator: function() { return { cnt: 2, diff --git a/services/sync/tests/unit/test_utils_json.js b/services/sync/tests/unit/test_utils_json.js index 704ae49f48f..d094090869e 100644 --- a/services/sync/tests/unit/test_utils_json.js +++ b/services/sync/tests/unit/test_utils_json.js @@ -68,8 +68,7 @@ add_test(function test_load_logging() { _("Verify that reads and read errors are logged."); // Write a file with some invalid JSON - let file = Utils.getProfileFile({ autoCreate: true, - path: "weave/log.json" }); + let file = Utils.getProfileFile("weave/log.json"); let fos = Cc["@mozilla.org/network/file-output-stream;1"] .createInstance(Ci.nsIFileOutputStream); fos.init(file, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, PERMS_FILE, diff --git a/services/sync/tests/unit/test_utils_lazy.js b/services/sync/tests/unit/test_utils_lazy.js deleted file mode 100644 index 4df5dc7450f..00000000000 --- a/services/sync/tests/unit/test_utils_lazy.js +++ /dev/null @@ -1,40 +0,0 @@ -_("Make sure lazy constructor calling/assignment works"); -Cu.import("resource://services-sync/util.js"); - -function run_test() { - let count = 0; - let Foo = function() { - this.num = ++count; - } - - _("Make a thing instance of Foo but make sure it isn't initialized yet"); - let obj = {}; - Utils.lazy(obj, "thing", Foo); - do_check_eq(count, 0); - - _("Access the property to make it construct"); - do_check_eq(typeof obj.thing, "object"); - do_check_eq(obj.thing.constructor, Foo); - do_check_eq(count, 1); - do_check_eq(obj.thing.num, 1); - - _("Additional accesses don't construct again (nothing should change"); - do_check_eq(typeof obj.thing, "object"); - do_check_eq(obj.thing.constructor, Foo); - do_check_eq(count, 1); - do_check_eq(obj.thing.num, 1); - - _("More lazy properties will constrct more"); - do_check_eq(typeof obj.other, "undefined"); - Utils.lazy(obj, "other", Foo); - do_check_eq(typeof obj.other, "object"); - do_check_eq(obj.other.constructor, Foo); - do_check_eq(count, 2); - do_check_eq(obj.other.num, 2); - - _("Sanity check that the original property didn't change"); - do_check_eq(typeof obj.thing, "object"); - do_check_eq(obj.thing.constructor, Foo); - do_check_eq(count, 2); - do_check_eq(obj.thing.num, 1); -} diff --git a/services/sync/tests/unit/test_utils_lazy2.js b/services/sync/tests/unit/test_utils_lazy2.js deleted file mode 100644 index 094c9dd8d1a..00000000000 --- a/services/sync/tests/unit/test_utils_lazy2.js +++ /dev/null @@ -1,36 +0,0 @@ -_("Make sure lazy2 function calling/assignment works"); -Cu.import("resource://services-sync/util.js"); - -function run_test() { - let count = 0; - let Foo = function() { - return ++count; - } - - _("Make a thing instance of Foo but make sure it isn't initialized yet"); - let obj = {}; - Utils.lazy2(obj, "thing", Foo); - do_check_eq(count, 0); - - _("Access the property to make it evaluates"); - do_check_eq(typeof obj.thing, "number"); - do_check_eq(count, 1); - do_check_eq(obj.thing, 1); - - _("Additional accesses don't evaluate again (nothing should change"); - do_check_eq(typeof obj.thing, "number"); - do_check_eq(count, 1); - do_check_eq(obj.thing, 1); - - _("More lazy properties will constrct more"); - do_check_eq(typeof obj.other, "undefined"); - Utils.lazy2(obj, "other", Foo); - do_check_eq(typeof obj.other, "number"); - do_check_eq(count, 2); - do_check_eq(obj.other, 2); - - _("Sanity check that the original property didn't change"); - do_check_eq(typeof obj.thing, "number"); - do_check_eq(count, 2); - do_check_eq(obj.thing, 1); -} diff --git a/services/sync/tests/unit/test_utils_lazySvc.js b/services/sync/tests/unit/test_utils_lazySvc.js deleted file mode 100644 index cbef43c4af7..00000000000 --- a/services/sync/tests/unit/test_utils_lazySvc.js +++ /dev/null @@ -1,36 +0,0 @@ -_("Make sure lazySvc get the desired services"); -Cu.import("resource://services-sync/util.js"); - -function run_test() { - _("Load the xul app info service as obj.app"); - let obj = {} - do_check_eq(typeof obj.app, "undefined"); - Utils.lazySvc(obj, "app", "@mozilla.org/xre/app-info;1", "nsIXULAppInfo"); - do_check_eq(typeof obj.app.QueryInterface, "function"); - do_check_eq(typeof obj.app.vendor, "string"); - do_check_eq(typeof obj.app.name, "string"); - - _("Check other types of properties on other services"); - Utils.lazySvc(obj, "io", "@mozilla.org/network/io-service;1", "nsIIOService"); - do_check_eq(typeof obj.io.newURI, "function"); - do_check_eq(typeof obj.io.offline, "boolean"); - - Utils.lazySvc(obj, "thread", "@mozilla.org/thread-manager;1", "nsIThreadManager"); - do_check_true(obj.thread.currentThread instanceof Ci.nsIThread); - - Utils.lazySvc(obj, "net", "@mozilla.org/network/util;1", "nsINetUtil"); - do_check_eq(typeof obj.net.ESCAPE_ALL, "number"); - do_check_eq(obj.net.ESCAPE_URL_SCHEME, 1); - - _("Make sure fake services get loaded correctly (private browsing doesnt exist on all platforms)"); - Utils.lazySvc(obj, "priv", "@mozilla.org/privatebrowsing;1", "nsIPrivateBrowsingService"); - do_check_eq(typeof obj.priv.privateBrowsingEnabled, "boolean"); - - _("Definitely make sure services that should never exist will use fake service if available"); - Utils.lazySvc(obj, "fake", "@labs.mozilla.com/Fake/Thing;1", "fake"); - do_check_eq(obj.fake.isFake, true); - - _("Nonexistant services that aren't fake-implemented will get nothing"); - Utils.lazySvc(obj, "nonexist", "@something?@", "doesnt exist"); - do_check_eq(obj.nonexist, undefined); -} diff --git a/services/sync/tests/unit/test_utils_passphrase.js b/services/sync/tests/unit/test_utils_passphrase.js index 028900b7d79..0d53cc90c8e 100644 --- a/services/sync/tests/unit/test_utils_passphrase.js +++ b/services/sync/tests/unit/test_utils_passphrase.js @@ -67,22 +67,6 @@ function run_test() { do_check_eq(Utils.normalizePassphrase(" abcde-abcde-abcde-abcde "), "abcdeabcdeabcdeabcde"); - _("Passphrase strength calculated according to the NIST algorithm."); - do_check_eq(Utils.passphraseStrength(""), 0); - do_check_eq(Utils.passphraseStrength("a"), 4); - do_check_eq(Utils.passphraseStrength("ab"), 6); - do_check_eq(Utils.passphraseStrength("abc"), 8); - do_check_eq(Utils.passphraseStrength("abcdefgh"), 18); - do_check_eq(Utils.passphraseStrength("abcdefghi"), 19.5); - do_check_eq(Utils.passphraseStrength("abcdefghij"), 21); - do_check_eq(Utils.passphraseStrength("abcdefghijklmnopqrst"), 36); - do_check_eq(Utils.passphraseStrength("abcdefghijklmnopqrstu"), 37); - do_check_eq(Utils.passphraseStrength("abcdefghijklmnopqrstuvwxyz"), 42); - do_check_eq(Utils.passphraseStrength("abcdefghijklmnopqrstuvwxyz!"), 49); - do_check_eq(Utils.passphraseStrength("1"), 10); - do_check_eq(Utils.passphraseStrength("12"), 12); - do_check_eq(Utils.passphraseStrength("a1"), 12); - _("Normalizing username."); do_check_eq(Utils.normalizeAccount(" QA1234+boo@mozilla.com "), "QA1234+boo@mozilla.com"); do_check_eq(Utils.normalizeAccount("QA1234+boo@mozilla.com"), "QA1234+boo@mozilla.com"); diff --git a/services/sync/tests/unit/test_utils_status.js b/services/sync/tests/unit/test_utils_status.js deleted file mode 100644 index b09d7b67de2..00000000000 --- a/services/sync/tests/unit/test_utils_status.js +++ /dev/null @@ -1,53 +0,0 @@ -Cu.import("resource://services-sync/util.js"); - -// both the checkStatus and ensureStatus functions are tested -// here. - -function run_test() { - _test_checkStatus(); - _test_ensureStatus(); -} - -function _test_checkStatus() { - let msg = "msg"; - - _("test with default range"); - do_check_true(Utils.checkStatus(200, msg)); - do_check_true(Utils.checkStatus(299, msg)); - do_check_false(Utils.checkStatus(199, msg)); - do_check_false(Utils.checkStatus(300, msg)); - - _("test with a number"); - do_check_true(Utils.checkStatus(100, msg, [100])); - do_check_false(Utils.checkStatus(200, msg, [100])); - - _("test with two numbers"); - do_check_true(Utils.checkStatus(100, msg, [100, 200])); - do_check_true(Utils.checkStatus(200, msg, [100, 200])); - do_check_false(Utils.checkStatus(50, msg, [100, 200])); - do_check_false(Utils.checkStatus(150, msg, [100, 200])); - do_check_false(Utils.checkStatus(250, msg, [100, 200])); - - _("test with a range and a number"); - do_check_true(Utils.checkStatus(50, msg, [[50, 100], 100])); - do_check_true(Utils.checkStatus(75, msg, [[50, 100], 100])); - do_check_true(Utils.checkStatus(100, msg, [[50, 100], 100])); - do_check_false(Utils.checkStatus(200, msg, [[50, 100], 100])); - - _("test with a number and a range"); - do_check_true(Utils.checkStatus(50, msg, [100, [50, 100]])); - do_check_true(Utils.checkStatus(75, msg, [100, [50, 100]])); - do_check_true(Utils.checkStatus(100, msg, [100, [50, 100]])); - do_check_false(Utils.checkStatus(200, msg, [100, [50, 100]])); -} - -function _test_ensureStatus() { - _("test that ensureStatus throws exception when it should"); - let except; - try { - Utils.ensureStatus(400, "msg", [200]); - } catch(e) { - except = e; - } - do_check_true(!!except); -} diff --git a/services/sync/tests/unit/xpcshell.ini b/services/sync/tests/unit/xpcshell.ini index 3c85921225f..a97e35228e9 100644 --- a/services/sync/tests/unit/xpcshell.ini +++ b/services/sync/tests/unit/xpcshell.ini @@ -2,11 +2,13 @@ head = head_appinfo.js head_helpers.js head_http_server.js tail = +[test_Observers.js] +[test_Preferences.js] [test_auth_manager.js] [test_bookmark_batch_fail.js] [test_bookmark_engine.js] -[test_bookmark_livemarks.js] [test_bookmark_legacy_microsummaries_support.js] +[test_bookmark_livemarks.js] [test_bookmark_order.js] [test_bookmark_places_query_rewriting.js] [test_bookmark_record.js] @@ -84,10 +86,7 @@ tail = [test_utils_hkdfExpand.js] [test_utils_isArray.js] [test_utils_json.js] -[test_utils_lazy.js] -[test_utils_lazy2.js] [test_utils_lazyStrings.js] -[test_utils_lazySvc.js] [test_utils_lock.js] [test_utils_makeGUID.js] [test_utils_makeURI.js] @@ -99,5 +98,4 @@ tail = [test_utils_sha1hmac.js] [test_utils_sha256HMAC.js] [test_utils_stackTrace.js] -[test_utils_status.js] [test_utils_utf8.js] diff --git a/storage/src/mozStorageAsyncStatementExecution.cpp b/storage/src/mozStorageAsyncStatementExecution.cpp index 30c88c53372..cfac39a946c 100644 --- a/storage/src/mozStorageAsyncStatementExecution.cpp +++ b/storage/src/mozStorageAsyncStatementExecution.cpp @@ -534,6 +534,21 @@ NS_IMPL_THREADSAFE_ISUPPORTS2( mozIStoragePendingStatement ) +bool +AsyncExecuteStatements::statementsNeedTransaction() +{ + // If there is more than one write statement, run in a transaction. + // Additionally, if we have only one statement but it needs a transaction, due + // to multiple BindingParams, we will wrap it in one. + for (PRUint32 i = 0, transactionsCount = 0; i < mStatements.Length(); ++i) { + transactionsCount += mStatements[i].needsTransaction(); + if (transactionsCount > 1) { + return true; + } + } + return false; +} + //////////////////////////////////////////////////////////////////////////////// //// mozIStoragePendingStatement @@ -575,13 +590,7 @@ AsyncExecuteStatements::Run() if (mState == CANCELED) return notifyComplete(); - // If there is more than one statement, run it in a transaction. We assume - // that we have been given write statements since getting a batch of read - // statements doesn't make a whole lot of sense. - // Additionally, if we have only one statement and it needs a transaction, we - // will wrap it in one. - if (mStatements.Length() > 1 || mStatements[0].needsTransaction()) { - // We don't error if this failed because it's not terrible if it does. + if (statementsNeedTransaction()) { mTransactionManager = new mozStorageTransaction(mConnection, PR_FALSE, mozIStorageConnection::TRANSACTION_IMMEDIATE); } diff --git a/storage/src/mozStorageAsyncStatementExecution.h b/storage/src/mozStorageAsyncStatementExecution.h index 093b3699153..83c22d7971a 100644 --- a/storage/src/mozStorageAsyncStatementExecution.h +++ b/storage/src/mozStorageAsyncStatementExecution.h @@ -201,6 +201,14 @@ private: */ nsresult notifyResults(); + /** + * Tests whether the current statements should be wrapped in an explicit + * transaction. + * + * @return true if an explicit transaction is needed, false otherwise. + */ + bool statementsNeedTransaction(); + StatementDataArray mStatements; nsRefPtr mConnection; mozStorageTransaction *mTransactionManager; diff --git a/storage/src/mozStorageConnection.h b/storage/src/mozStorageConnection.h index b4d41a6a535..9fd49e82b1f 100644 --- a/storage/src/mozStorageConnection.h +++ b/storage/src/mozStorageConnection.h @@ -46,7 +46,6 @@ #include "mozilla/Mutex.h" #include "nsIInterfaceRequestor.h" -#include "nsString.h" #include "nsDataHashtable.h" #include "mozIStorageProgressHandler.h" #include "SQLiteMutex.h" diff --git a/storage/src/mozStorageStatementData.h b/storage/src/mozStorageStatementData.h index f757a6c78cb..21f3c5dffe4 100644 --- a/storage/src/mozStorageStatementData.h +++ b/storage/src/mozStorageStatementData.h @@ -45,6 +45,8 @@ #include "nsAutoPtr.h" #include "nsTArray.h" #include "nsIEventTarget.h" +#include "mozilla/Util.h" +#include "nsThreadUtils.h" #include "mozStorageBindingParamsArray.h" #include "mozIStorageBaseStatement.h" @@ -143,13 +145,27 @@ public: */ inline bool hasParametersToBeBound() const { return !!mParamsArray; } /** - * Indicates if this statement needs a transaction for execution. + * Indicates the number of implicit statements generated by this statement + * requiring a transaction for execution. For example a single statement + * with N BindingParams will execute N implicit staments. * - * @return true if the statement needs a transaction, false otherwise. + * @return number of statements requiring a transaction for execution. + * + * @note In the case of AsyncStatements this may actually create the + * statement. */ - inline bool needsTransaction() const + inline PRUint32 needsTransaction() { - return mParamsArray != nsnull && mParamsArray->length() > 1; + MOZ_ASSERT(!NS_IsMainThread()); + // Be sure to use the getSqliteStatement helper, since sqlite3_stmt_readonly + // can only analyze prepared statements and AsyncStatements are prepared + // lazily. + sqlite3_stmt *stmt; + int rc = getSqliteStatement(&stmt); + if (SQLITE_OK != rc || ::sqlite3_stmt_readonly(stmt)) { + return 0; + } + return mParamsArray ? mParamsArray->length() : 1; } private: diff --git a/storage/test/Makefile.in b/storage/test/Makefile.in index 1ea6709254c..5ea94ebfcce 100644 --- a/storage/test/Makefile.in +++ b/storage/test/Makefile.in @@ -61,6 +61,7 @@ CPP_UNIT_TESTS = \ test_StatementCache.cpp \ test_async_callbacks_with_spun_event_loops.cpp \ test_file_perms.cpp \ + test_asyncStatementExecution_transaction.cpp \ $(NULL) ifdef MOZ_DEBUG diff --git a/storage/test/storage_test_harness.h b/storage/test/storage_test_harness.h index f8e4e808651..7c61b2ca7e6 100644 --- a/storage/test/storage_test_harness.h +++ b/storage/test/storage_test_harness.h @@ -50,6 +50,7 @@ #include "mozIStorageAsyncStatement.h" #include "mozIStorageStatement.h" #include "mozIStoragePendingStatement.h" +#include "mozIStorageError.h" #include "nsThreadUtils.h" static int gTotalTests = 0; @@ -176,6 +177,20 @@ AsyncStatementSpinner::HandleResult(mozIStorageResultSet *aResultSet) NS_IMETHODIMP AsyncStatementSpinner::HandleError(mozIStorageError *aError) { + PRInt32 result; + nsresult rv = aError->GetResult(&result); + NS_ENSURE_SUCCESS(rv, rv); + nsCAutoString message; + rv = aError->GetMessage(message); + NS_ENSURE_SUCCESS(rv, rv); + + nsCAutoString warnMsg; + warnMsg.Append("An error occurred while executing an async statement: "); + warnMsg.AppendInt(result); + warnMsg.Append(" "); + warnMsg.Append(message); + NS_WARNING(warnMsg.get()); + return NS_OK; } @@ -206,3 +221,33 @@ void AsyncStatementSpinner::SpinUntilCompleted() #define NS_DECL_ASYNCSTATEMENTSPINNER \ NS_IMETHOD HandleResult(mozIStorageResultSet *aResultSet); + +//////////////////////////////////////////////////////////////////////////////// +//// Async Helpers + +/** + * Execute an async statement, blocking the main thread until we get the + * callback completion notification. + */ +void +blocking_async_execute(mozIStorageBaseStatement *stmt) +{ + nsRefPtr spinner(new AsyncStatementSpinner()); + + nsCOMPtr pendy; + (void)stmt->ExecuteAsync(spinner, getter_AddRefs(pendy)); + spinner->SpinUntilCompleted(); +} + +/** + * Invoke AsyncClose on the given connection, blocking the main thread until we + * get the completion notification. + */ +void +blocking_async_close(mozIStorageConnection *db) +{ + nsRefPtr spinner(new AsyncStatementSpinner()); + + db->AsyncClose(spinner); + spinner->SpinUntilCompleted(); +} diff --git a/storage/test/test_asyncStatementExecution_transaction.cpp b/storage/test/test_asyncStatementExecution_transaction.cpp new file mode 100644 index 00000000000..8a9373a4232 --- /dev/null +++ b/storage/test/test_asyncStatementExecution_transaction.cpp @@ -0,0 +1,508 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +#include "storage_test_harness.h" + +#include "nsIEventTarget.h" +#include "mozStorageConnection.h" + +#include "sqlite3.h" + +using namespace mozilla::storage; + +//////////////////////////////////////////////////////////////////////////////// +//// Helpers + +/** + * Commit hook to detect transactions. + * + * @param aArg + * An integer pointer that will be incremented for each commit. + */ +int commit_hook(void *aArg) +{ + int *arg = static_cast(aArg); + (*arg)++; + return 0; +} + +/** + * Executes the passed-in statements and checks if a transaction is created. + * When done statements are finalized and database connection is closed. + * + * @param aDB + * The database connection. + * @param aStmts + * Vector of statements. + * @param aStmtsLen + * Number of statements. + * @param aTransactionExpected + * Whether a transaction is expected or not. + */ +void +check_transaction(mozIStorageConnection *aDB, + mozIStorageBaseStatement **aStmts, + PRUint32 aStmtsLen, + bool aTransactionExpected) +{ + // -- install a transaction commit hook. + int commit = 0; + ::sqlite3_commit_hook(*static_cast(aDB), commit_hook, &commit); + + nsRefPtr asyncSpin(new AsyncStatementSpinner()); + nsCOMPtr asyncPend; + do_check_success(aDB->ExecuteAsync(aStmts, aStmtsLen, asyncSpin, + getter_AddRefs(asyncPend))); + do_check_true(asyncPend); + + // -- complete the execution + asyncSpin->SpinUntilCompleted(); + + // -- uninstall the transaction commit hook. + ::sqlite3_commit_hook(*static_cast(aDB), NULL, NULL); + + // -- check transaction + do_check_eq(aTransactionExpected, !!commit); + + // -- check that only one transaction was created. + if (aTransactionExpected) { + do_check_eq(1, commit); + } + + // -- cleanup + for (PRUint32 i = 0; i < aStmtsLen; ++i) { + aStmts[i]->Finalize(); + } + blocking_async_close(aDB); +} + +//////////////////////////////////////////////////////////////////////////////// +//// Tests + +/** + * Test that executing multiple readonly AsyncStatements doesn't create a + * transaction. + */ +void +test_MultipleAsyncReadStatements() +{ + nsCOMPtr db(getMemoryDatabase()); + + // -- create statements and execute them + nsCOMPtr stmt1; + db->CreateAsyncStatement(NS_LITERAL_CSTRING( + "SELECT * FROM sqlite_master" + ), getter_AddRefs(stmt1)); + + nsCOMPtr stmt2; + db->CreateAsyncStatement(NS_LITERAL_CSTRING( + "SELECT * FROM sqlite_master" + ), getter_AddRefs(stmt2)); + + mozIStorageBaseStatement *stmts[] = { + stmt1, + stmt2, + }; + + check_transaction(db, stmts, NS_ARRAY_LENGTH(stmts), false); +} + +/** + * Test that executing multiple readonly Statements doesn't create a + * transaction. + */ +void +test_MultipleReadStatements() +{ + nsCOMPtr db(getMemoryDatabase()); + + // -- create statements and execute them + nsCOMPtr stmt1; + db->CreateStatement(NS_LITERAL_CSTRING( + "SELECT * FROM sqlite_master" + ), getter_AddRefs(stmt1)); + + nsCOMPtr stmt2; + db->CreateStatement(NS_LITERAL_CSTRING( + "SELECT * FROM sqlite_master" + ), getter_AddRefs(stmt2)); + + mozIStorageBaseStatement *stmts[] = { + stmt1, + stmt2, + }; + + check_transaction(db, stmts, NS_ARRAY_LENGTH(stmts), false); +} + +/** + * Test that executing multiple AsyncStatements causing writes creates a + * transaction. + */ +void +test_MultipleAsyncReadWriteStatements() +{ + nsCOMPtr db(getMemoryDatabase()); + + // -- create statements and execute them + nsCOMPtr stmt1; + db->CreateAsyncStatement(NS_LITERAL_CSTRING( + "SELECT * FROM sqlite_master" + ), getter_AddRefs(stmt1)); + + nsCOMPtr stmt2; + db->CreateAsyncStatement(NS_LITERAL_CSTRING( + "CREATE TABLE test (id INTEGER PRIMARY KEY)" + ), getter_AddRefs(stmt2)); + + mozIStorageBaseStatement *stmts[] = { + stmt1, + stmt2, + }; + + check_transaction(db, stmts, NS_ARRAY_LENGTH(stmts), true); +} + +/** + * Test that executing multiple Statements causing writes creates a transaction. + */ +void +test_MultipleReadWriteStatements() +{ + nsCOMPtr db(getMemoryDatabase()); + + // -- create statements and execute them + nsCOMPtr stmt1; + db->CreateStatement(NS_LITERAL_CSTRING( + "SELECT * FROM sqlite_master" + ), getter_AddRefs(stmt1)); + + nsCOMPtr stmt2; + db->CreateStatement(NS_LITERAL_CSTRING( + "CREATE TABLE test (id INTEGER PRIMARY KEY)" + ), getter_AddRefs(stmt2)); + + mozIStorageBaseStatement *stmts[] = { + stmt1, + stmt2, + }; + + check_transaction(db, stmts, NS_ARRAY_LENGTH(stmts), true); +} + +/** + * Test that executing multiple AsyncStatements causing writes creates a + * single transaction. + */ +void +test_MultipleAsyncWriteStatements() +{ + nsCOMPtr db(getMemoryDatabase()); + + // -- create statements and execute them + nsCOMPtr stmt1; + db->CreateAsyncStatement(NS_LITERAL_CSTRING( + "CREATE TABLE test1 (id INTEGER PRIMARY KEY)" + ), getter_AddRefs(stmt1)); + + nsCOMPtr stmt2; + db->CreateAsyncStatement(NS_LITERAL_CSTRING( + "CREATE TABLE test2 (id INTEGER PRIMARY KEY)" + ), getter_AddRefs(stmt2)); + + mozIStorageBaseStatement *stmts[] = { + stmt1, + stmt2, + }; + + check_transaction(db, stmts, NS_ARRAY_LENGTH(stmts), true); +} + +/** + * Test that executing multiple Statements causing writes creates a + * single transaction. + */ +void +test_MultipleWriteStatements() +{ + nsCOMPtr db(getMemoryDatabase()); + + // -- create statements and execute them + nsCOMPtr stmt1; + db->CreateStatement(NS_LITERAL_CSTRING( + "CREATE TABLE test1 (id INTEGER PRIMARY KEY)" + ), getter_AddRefs(stmt1)); + + nsCOMPtr stmt2; + db->CreateStatement(NS_LITERAL_CSTRING( + "CREATE TABLE test2 (id INTEGER PRIMARY KEY)" + ), getter_AddRefs(stmt2)); + + mozIStorageBaseStatement *stmts[] = { + stmt1, + stmt2, + }; + + check_transaction(db, stmts, NS_ARRAY_LENGTH(stmts), true); +} + +/** + * Test that executing a single read-only AsyncStatement doesn't create a + * transaction. + */ +void +test_SingleAsyncReadStatement() +{ + nsCOMPtr db(getMemoryDatabase()); + + // -- create statements and execute them + nsCOMPtr stmt; + db->CreateAsyncStatement(NS_LITERAL_CSTRING( + "SELECT * FROM sqlite_master" + ), getter_AddRefs(stmt)); + + mozIStorageBaseStatement *stmts[] = { + stmt, + }; + + check_transaction(db, stmts, NS_ARRAY_LENGTH(stmts), false); +} + +/** + * Test that executing a single read-only Statement doesn't create a + * transaction. + */ +void +test_SingleReadStatement() +{ + nsCOMPtr db(getMemoryDatabase()); + + // -- create statements and execute them + nsCOMPtr stmt; + db->CreateStatement(NS_LITERAL_CSTRING( + "SELECT * FROM sqlite_master" + ), getter_AddRefs(stmt)); + + mozIStorageBaseStatement *stmts[] = { + stmt, + }; + + check_transaction(db, stmts, NS_ARRAY_LENGTH(stmts), false); +} + +/** + * Test that executing a single AsyncStatement causing writes creates a + * transaction. + */ +void +test_SingleAsyncWriteStatement() +{ + nsCOMPtr db(getMemoryDatabase()); + + // -- create statements and execute them + nsCOMPtr stmt; + db->CreateAsyncStatement(NS_LITERAL_CSTRING( + "CREATE TABLE test (id INTEGER PRIMARY KEY)" + ), getter_AddRefs(stmt)); + + mozIStorageBaseStatement *stmts[] = { + stmt, + }; + + check_transaction(db, stmts, NS_ARRAY_LENGTH(stmts), true); +} + +/** + * Test that executing a single Statement causing writes creates a transaction. + */ +void +test_SingleWriteStatement() +{ + nsCOMPtr db(getMemoryDatabase()); + + // -- create statements and execute them + nsCOMPtr stmt; + db->CreateStatement(NS_LITERAL_CSTRING( + "CREATE TABLE test (id INTEGER PRIMARY KEY)" + ), getter_AddRefs(stmt)); + + mozIStorageBaseStatement *stmts[] = { + stmt, + }; + + check_transaction(db, stmts, NS_ARRAY_LENGTH(stmts), true); +} + +/** + * Test that executing a single read-only AsyncStatement with multiple params + * doesn't create a transaction. + */ +void +test_MultipleParamsAsyncReadStatement() +{ + nsCOMPtr db(getMemoryDatabase()); + + // -- create statements and execute them + nsCOMPtr stmt; + db->CreateAsyncStatement(NS_LITERAL_CSTRING( + "SELECT :param FROM sqlite_master" + ), getter_AddRefs(stmt)); + + // -- bind multiple BindingParams + nsCOMPtr paramsArray; + stmt->NewBindingParamsArray(getter_AddRefs(paramsArray)); + for (PRInt32 i = 0; i < 2; i++) { + nsCOMPtr params; + paramsArray->NewBindingParams(getter_AddRefs(params)); + params->BindInt32ByName(NS_LITERAL_CSTRING("param"), 1); + paramsArray->AddParams(params); + } + stmt->BindParameters(paramsArray); + paramsArray = nsnull; + + mozIStorageBaseStatement *stmts[] = { + stmt, + }; + + check_transaction(db, stmts, NS_ARRAY_LENGTH(stmts), false); +} + +/** + * Test that executing a single read-only Statement with multiple params + * doesn't create a transaction. + */ +void +test_MultipleParamsReadStatement() +{ + nsCOMPtr db(getMemoryDatabase()); + + // -- create statements and execute them + nsCOMPtr stmt; + db->CreateStatement(NS_LITERAL_CSTRING( + "SELECT :param FROM sqlite_master" + ), getter_AddRefs(stmt)); + + // -- bind multiple BindingParams + nsCOMPtr paramsArray; + stmt->NewBindingParamsArray(getter_AddRefs(paramsArray)); + for (PRInt32 i = 0; i < 2; i++) { + nsCOMPtr params; + paramsArray->NewBindingParams(getter_AddRefs(params)); + params->BindInt32ByName(NS_LITERAL_CSTRING("param"), 1); + paramsArray->AddParams(params); + } + stmt->BindParameters(paramsArray); + paramsArray = nsnull; + + mozIStorageBaseStatement *stmts[] = { + stmt, + }; + + check_transaction(db, stmts, NS_ARRAY_LENGTH(stmts), false); +} + +/** + * Test that executing a single write AsyncStatement with multiple params + * creates a transaction. + */ +void +test_MultipleParamsAsyncWriteStatement() +{ + nsCOMPtr db(getMemoryDatabase()); + + // -- create a table for writes + nsCOMPtr tableStmt; + db->CreateStatement(NS_LITERAL_CSTRING( + "CREATE TABLE test (id INTEGER PRIMARY KEY)" + ), getter_AddRefs(tableStmt)); + tableStmt->Execute(); + tableStmt->Finalize(); + + // -- create statements and execute them + nsCOMPtr stmt; + db->CreateAsyncStatement(NS_LITERAL_CSTRING( + "DELETE FROM test WHERE id = :param" + ), getter_AddRefs(stmt)); + + // -- bind multiple BindingParams + nsCOMPtr paramsArray; + stmt->NewBindingParamsArray(getter_AddRefs(paramsArray)); + for (PRInt32 i = 0; i < 2; i++) { + nsCOMPtr params; + paramsArray->NewBindingParams(getter_AddRefs(params)); + params->BindInt32ByName(NS_LITERAL_CSTRING("param"), 1); + paramsArray->AddParams(params); + } + stmt->BindParameters(paramsArray); + paramsArray = nsnull; + + mozIStorageBaseStatement *stmts[] = { + stmt, + }; + + check_transaction(db, stmts, NS_ARRAY_LENGTH(stmts), true); +} + +/** + * Test that executing a single write Statement with multiple params + * creates a transaction. + */ +void +test_MultipleParamsWriteStatement() +{ + nsCOMPtr db(getMemoryDatabase()); + + // -- create a table for writes + nsCOMPtr tableStmt; + db->CreateStatement(NS_LITERAL_CSTRING( + "CREATE TABLE test (id INTEGER PRIMARY KEY)" + ), getter_AddRefs(tableStmt)); + tableStmt->Execute(); + tableStmt->Finalize(); + + // -- create statements and execute them + nsCOMPtr stmt; + db->CreateStatement(NS_LITERAL_CSTRING( + "DELETE FROM test WHERE id = :param" + ), getter_AddRefs(stmt)); + + // -- bind multiple BindingParams + nsCOMPtr paramsArray; + stmt->NewBindingParamsArray(getter_AddRefs(paramsArray)); + for (PRInt32 i = 0; i < 2; i++) { + nsCOMPtr params; + paramsArray->NewBindingParams(getter_AddRefs(params)); + params->BindInt32ByName(NS_LITERAL_CSTRING("param"), 1); + paramsArray->AddParams(params); + } + stmt->BindParameters(paramsArray); + paramsArray = nsnull; + + mozIStorageBaseStatement *stmts[] = { + stmt, + }; + + check_transaction(db, stmts, NS_ARRAY_LENGTH(stmts), true); +} + +void (*gTests[])(void) = { + test_MultipleAsyncReadStatements, + test_MultipleReadStatements, + test_MultipleAsyncReadWriteStatements, + test_MultipleReadWriteStatements, + test_MultipleAsyncWriteStatements, + test_MultipleWriteStatements, + test_SingleAsyncReadStatement, + test_SingleReadStatement, + test_SingleAsyncWriteStatement, + test_SingleWriteStatement, + test_MultipleParamsAsyncReadStatement, + test_MultipleParamsReadStatement, + test_MultipleParamsAsyncWriteStatement, + test_MultipleParamsWriteStatement, +}; + +const char *file = __FILE__; +#define TEST_NAME "async statement execution transaction" +#define TEST_FILE file +#include "storage_test_harness_tail.h" diff --git a/storage/test/test_async_callbacks_with_spun_event_loops.cpp b/storage/test/test_async_callbacks_with_spun_event_loops.cpp index cdd93f135f7..bf59943bc64 100644 --- a/storage/test/test_async_callbacks_with_spun_event_loops.cpp +++ b/storage/test/test_async_callbacks_with_spun_event_loops.cpp @@ -11,19 +11,6 @@ //////////////////////////////////////////////////////////////////////////////// //// Async Helpers -/** - * Invoke AsyncClose on the given connection, blocking the main thread until we - * get the completion notification. - */ -void -blocking_async_close(mozIStorageConnection *db) -{ - nsRefPtr spinner(new AsyncStatementSpinner()); - - db->AsyncClose(spinner); - spinner->SpinUntilCompleted(); -} - /** * Spins the events loop for current thread until aCondition is true. */ diff --git a/storage/test/test_true_async.cpp b/storage/test/test_true_async.cpp index a97cf1bc0a1..fb8a0ecf697 100644 --- a/storage/test/test_true_async.cpp +++ b/storage/test/test_true_async.cpp @@ -171,33 +171,6 @@ private: //////////////////////////////////////////////////////////////////////////////// //// Async Helpers -/** - * Execute an async statement, blocking the main thread until we get the - * callback completion notification. - */ -void -blocking_async_execute(mozIStorageBaseStatement *stmt) -{ - nsRefPtr spinner(new AsyncStatementSpinner()); - - nsCOMPtr pendy; - (void)stmt->ExecuteAsync(spinner, getter_AddRefs(pendy)); - spinner->SpinUntilCompleted(); -} - -/** - * Invoke AsyncClose on the given connection, blocking the main thread until we - * get the completion notification. - */ -void -blocking_async_close(mozIStorageConnection *db) -{ - nsRefPtr spinner(new AsyncStatementSpinner()); - - db->AsyncClose(spinner); - spinner->SpinUntilCompleted(); -} - /** * A horrible hack to figure out what the connection's async thread is. By * creating a statement and async dispatching we can tell from the mutex who diff --git a/storage/test/unit/test_connection_executeAsync.js b/storage/test/unit/test_connection_executeAsync.js index d920fb1632b..e6d4a2b009b 100644 --- a/storage/test/unit/test_connection_executeAsync.js +++ b/storage/test/unit/test_connection_executeAsync.js @@ -131,39 +131,6 @@ function test_create_and_add() stmts[1].finalize(); } -function test_transaction_created() -{ - let stmts = []; - stmts[0] = getOpenedDatabase().createAsyncStatement( - "BEGIN" - ); - stmts[1] = getOpenedDatabase().createStatement( - "SELECT * FROM test" - ); - - getOpenedDatabase().executeAsync(stmts, stmts.length, { - handleResult: function(aResultSet) - { - dump("handleResults("+aResultSet+")\n"); - do_throw("unexpected results obtained!"); - }, - handleError: function(aError) - { - dump("handleError("+aError.result+")\n"); - }, - handleCompletion: function(aReason) - { - dump("handleCompletion("+aReason+")\n"); - do_check_eq(Ci.mozIStorageStatementCallback.REASON_ERROR, aReason); - - // Run the next test. - run_next_test(); - } - }); - stmts[0].finalize(); - stmts[1].finalize(); -} - function test_multiple_bindings_on_statements() { // This tests to make sure that we pass all the statements multiply bound @@ -309,7 +276,6 @@ function test_double_asyncClose_throws() [ test_create_and_add, - test_transaction_created, test_multiple_bindings_on_statements, test_asyncClose_does_not_complete_before_statements, test_asyncClose_does_not_throw_no_callback, diff --git a/toolkit/components/autocomplete/nsAutoCompleteController.cpp b/toolkit/components/autocomplete/nsAutoCompleteController.cpp index 5ada1446616..7edb8c6882a 100644 --- a/toolkit/components/autocomplete/nsAutoCompleteController.cpp +++ b/toolkit/components/autocomplete/nsAutoCompleteController.cpp @@ -24,6 +24,7 @@ * Dean Tessman * Johnny Stenback * Masayuki Nakano + * Michael Ventnor * * 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 @@ -54,6 +55,7 @@ #include "nsIDOMKeyEvent.h" #include "mozilla/Services.h" #include "mozilla/ModuleUtils.h" +#include "mozilla/Util.h" static const char *kAutoCompleteSearchCID = "@mozilla.org/autocomplete/search;1?name="; @@ -94,6 +96,43 @@ nsAutoCompleteController::~nsAutoCompleteController() SetInput(nsnull); } +//////////////////////////////////////////////////////////////////////// +//// Helper methods + +/** + * Cuts any URL prefixes from a given string, making it suitable for search + * comparisons. + * + * @param aOrigSpec + * The string to look for prefixes in. + * @return A substring, with any URL prefixes removed, that depends on the + * same buffer as aOrigSpec (to save allocations). + */ +static const nsDependentSubstring +RemoveURIPrefixes(const nsAString &aOrigSpec) +{ + nsDependentSubstring result(aOrigSpec, 0); + + if (StringBeginsWith(result, NS_LITERAL_STRING("moz-action:"))) { + PRUint32 locationOfComma = result.FindChar(',', 11); + result.Rebind(result, locationOfComma + 1); + } + + if (StringBeginsWith(result, NS_LITERAL_STRING("http://"))) { + result.Rebind(result, 7); + } else if (StringBeginsWith(result, NS_LITERAL_STRING("https://"))) { + result.Rebind(result, 8); + } else if (StringBeginsWith(result, NS_LITERAL_STRING("ftp://"))) { + result.Rebind(result, 6); + } + + if (StringBeginsWith(result, NS_LITERAL_STRING("www."))) { + result.Rebind(result, 4); + } + + return result; +} + //////////////////////////////////////////////////////////////////////// //// nsIAutoCompleteController @@ -1393,6 +1432,64 @@ nsAutoCompleteController::CompleteDefaultIndex(PRInt32 aSearchIndex) return NS_OK; } +nsresult +nsAutoCompleteController::GetDefaultCompleteURLValue(nsIAutoCompleteResult *aResult, + PRBool aPreserveCasing, + nsAString &_retval) +{ + MOZ_ASSERT(aResult); + + PRUint32 rowCount; + (void)aResult->GetMatchCount(&rowCount); + if (rowCount == 0) { + // Return early if we have no entries, so that we don't waste time + // fixing up mSearchString below + return NS_ERROR_FAILURE; + } + + const nsDependentSubstring& fixedSearchTerm = RemoveURIPrefixes(mSearchString); + for (PRUint32 i = 0; i < rowCount; ++i) { + nsAutoString resultValue; + aResult->GetValueAt(i, resultValue); + const nsDependentSubstring& fixedResult = RemoveURIPrefixes(resultValue); + + if (!StringBeginsWith(fixedResult, fixedSearchTerm, + nsCaseInsensitiveStringComparator())) { + // Not a matching URL + continue; + } + + // Found a matching item! Figure out what needs to be assigned/appended. + if (aPreserveCasing) { + // Use nsDependentString here so we have access to FindCharInSet. + const nsDependentString appendValue(Substring(fixedResult, fixedSearchTerm.Length())); + + // We only want to autocomplete up to the next separator. This lets a user + // go to a toplevel domain, if a longer path in that domain is higher in + // the autocomplete. + // eg. if the user types "m" and "mozilla.org/credits" is the top hit, + // autocomplete only to "mozilla.org/" in case that's where they want to go. + // They're one keystroke away from "/credits", anyway. + PRInt32 separatorIndex = appendValue.FindCharInSet("/?#"); + if (separatorIndex != kNotFound && appendValue[separatorIndex] == '/') { + // Add 1 so we include the directory separator + separatorIndex++; + } + + nsAutoString returnValue; + returnValue.Assign(mSearchString); + returnValue.Append(Substring(appendValue, 0, separatorIndex)); + _retval = returnValue; + } else { + _retval.Assign(fixedResult); + } + return NS_OK; + } + + // No match at all + return NS_ERROR_FAILURE; +} + nsresult nsAutoCompleteController::GetDefaultCompleteValue(PRInt32 aSearchIndex, PRBool aPreserveCasing, @@ -1416,6 +1513,14 @@ nsAutoCompleteController::GetDefaultCompleteValue(PRInt32 aSearchIndex, nsIAutoCompleteResult *result = mResults.SafeObjectAt(index); NS_ENSURE_TRUE(result != nsnull, NS_ERROR_FAILURE); + PRBool isURL; + result->GetIsURLResult(&isURL); + if (isURL) { + // For URLs, we remove needless prefixes, then iterate over all values + // to find a suitable default. + return GetDefaultCompleteURLValue(result, aPreserveCasing, _retval); + } + if (defaultIndex < 0) { // The search must explicitly provide a default index in order // for us to be able to complete. @@ -1466,37 +1571,11 @@ nsAutoCompleteController::CompleteValue(nsString &aValue) // autocomplete to aValue. mInput->SetTextValue(aValue); } else { - nsresult rv; - nsCOMPtr ios = do_GetService(NS_IOSERVICE_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - nsCAutoString scheme; - if (NS_SUCCEEDED(ios->ExtractScheme(NS_ConvertUTF16toUTF8(aValue), scheme))) { - // Trying to autocomplete a URI from somewhere other than the beginning. - // Only succeed if the missing portion is "http://"; otherwise do not - // autocomplete. This prevents us from "helpfully" autocompleting to a - // URI that isn't equivalent to what the user expected. - const PRInt32 findIndex = 7; // length of "http://" - - if ((endSelect < findIndex + mSearchStringLength) || - !scheme.LowerCaseEqualsLiteral("http") || - !Substring(aValue, findIndex, mSearchStringLength).Equals( - mSearchString, nsCaseInsensitiveStringComparator())) { - return NS_OK; - } - - mInput->SetTextValue(mSearchString + - Substring(aValue, mSearchStringLength + findIndex, - endSelect)); - - endSelect -= findIndex; // We're skipping this many characters of aValue. - } else { - // Autocompleting something other than a URI from the middle. - // Use the format "searchstring >> full string" to indicate to the user - // what we are going to replace their search string with. - mInput->SetTextValue(mSearchString + NS_LITERAL_STRING(" >> ") + aValue); - - endSelect = mSearchString.Length() + 4 + aValue.Length(); - } + // Autocompleting something from the middle. + // Use the format "searchstring >> full string" to indicate to the user + // what we are going to replace their search string with. + mInput->SetTextValue(mSearchString + NS_LITERAL_STRING(" >> ") + aValue); + endSelect = mSearchString.Length() + 4 + aValue.Length(); } mInput->SelectTextRange(mSearchStringLength, endSelect); diff --git a/toolkit/components/autocomplete/nsAutoCompleteController.h b/toolkit/components/autocomplete/nsAutoCompleteController.h index c188f4edfd2..b2ce200a7ed 100644 --- a/toolkit/components/autocomplete/nsAutoCompleteController.h +++ b/toolkit/components/autocomplete/nsAutoCompleteController.h @@ -97,6 +97,21 @@ protected: private: nsresult GetResultValueLabelAt(PRInt32 aIndex, PRBool aValueOnly, PRBool aGetValue, nsAString & _retval); + /** + * Searches for a suitable value to complete to, by comparing all values + * as URLs, and completing only up to the next URL separator. + * + * @param aResult + * An autocomplete result to search in. + * @param aPreserveCasing + * Preserve the casing of what the user typed in. + * @param [out] _retval + * The value to complete to. + * @return A result, NS_OK if there is a value to complete to. + */ + nsresult GetDefaultCompleteURLValue(nsIAutoCompleteResult *aResult, + PRBool aPreserveCasing, + nsAString &_retval); protected: nsresult GetDefaultCompleteValue(PRInt32 aSearchIndex, PRBool aPreserveCasing, nsAString &_retval); diff --git a/toolkit/components/autocomplete/nsAutoCompleteSimpleResult.cpp b/toolkit/components/autocomplete/nsAutoCompleteSimpleResult.cpp index af0c06bdbec..7c540be6a13 100644 --- a/toolkit/components/autocomplete/nsAutoCompleteSimpleResult.cpp +++ b/toolkit/components/autocomplete/nsAutoCompleteSimpleResult.cpp @@ -43,7 +43,8 @@ NS_IMPL_ISUPPORTS2(nsAutoCompleteSimpleResult, nsAutoCompleteSimpleResult::nsAutoCompleteSimpleResult() : mDefaultIndex(-1), - mSearchResult(RESULT_NOMATCH) + mSearchResult(RESULT_NOMATCH), + mIsURLResult(PR_FALSE) { } @@ -104,6 +105,21 @@ nsAutoCompleteSimpleResult::SetErrorDescription( return NS_OK; } +// isURLResult +NS_IMETHODIMP +nsAutoCompleteSimpleResult::GetIsURLResult(PRBool *aIsURLResult) +{ + *aIsURLResult = mIsURLResult; + return NS_OK; +} + +NS_IMETHODIMP +nsAutoCompleteSimpleResult::SetIsURLResult(PRBool aIsURLResult) +{ + mIsURLResult = aIsURLResult; + return NS_OK; +} + NS_IMETHODIMP nsAutoCompleteSimpleResult::AppendMatch(const nsAString& aValue, const nsAString& aComment, diff --git a/toolkit/components/autocomplete/nsAutoCompleteSimpleResult.h b/toolkit/components/autocomplete/nsAutoCompleteSimpleResult.h index adb0b3037e8..65765fb0fbe 100644 --- a/toolkit/components/autocomplete/nsAutoCompleteSimpleResult.h +++ b/toolkit/components/autocomplete/nsAutoCompleteSimpleResult.h @@ -78,6 +78,8 @@ protected: PRInt32 mDefaultIndex; PRUint32 mSearchResult; + PRBool mIsURLResult; + nsCOMPtr mListener; }; diff --git a/toolkit/components/autocomplete/nsIAutoCompleteResult.idl b/toolkit/components/autocomplete/nsIAutoCompleteResult.idl index 7645a46559b..2b2f0510413 100644 --- a/toolkit/components/autocomplete/nsIAutoCompleteResult.idl +++ b/toolkit/components/autocomplete/nsIAutoCompleteResult.idl @@ -82,6 +82,14 @@ interface nsIAutoCompleteResult : nsISupports */ readonly attribute unsigned long matchCount; + /** + * Whether the values in this result are URLs. This will cause + * slightly different behaviour where defaultIndex is intelligently chosen + * for you (while the attribute defaultIndex is ignored), and + * searching is fine-tuned for URLs. + */ + readonly attribute boolean isURLResult; + /** * Get the value of the result at the given index */ diff --git a/toolkit/components/autocomplete/nsIAutoCompleteSimpleResult.idl b/toolkit/components/autocomplete/nsIAutoCompleteSimpleResult.idl index 523fb641a8a..2f4375f7bf5 100644 --- a/toolkit/components/autocomplete/nsIAutoCompleteSimpleResult.idl +++ b/toolkit/components/autocomplete/nsIAutoCompleteSimpleResult.idl @@ -74,6 +74,12 @@ interface nsIAutoCompleteSimpleResult : nsIAutoCompleteResult */ void setSearchResult(in unsigned short aSearchResult); + /** + * A writer for the readonly attribute 'isURLResult'. + * Sets whether the values in this result are URLs. + */ + void setIsURLResult(in boolean aIsURLResult); + /** * Appends a result item consisting of the given value, comment, image and style. * This is how you add results. Note: image and style are optional. diff --git a/toolkit/components/autocomplete/tests/unit/test_autofill.js b/toolkit/components/autocomplete/tests/unit/test_autofill.js new file mode 100644 index 00000000000..dfb2696187a --- /dev/null +++ b/toolkit/components/autocomplete/tests/unit/test_autofill.js @@ -0,0 +1,344 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); + +const Cc = Components.classes; +const Ci = Components.interfaces; + +/** + * Unit test for Bug 566489 - Inline Autocomplete. + */ + + +/** + * Dummy nsIAutoCompleteInput source that returns + * the given list of AutoCompleteSearch names. + */ +function AutoCompleteInput(aSearches) { + this.searches = aSearches; +} +AutoCompleteInput.prototype = { + constructor: AutoCompleteInput, + + // Array of AutoCompleteSearch names + searches: null, + + minResultsForPopup: 0, + timeout: 10, + searchParam: "", + textValue: "", + disableAutoComplete: false, + completeDefaultIndex: true, + + // Text selection range + selStart: 0, + selEnd: 0, + get selectionStart() { + return selStart; + }, + get selectionEnd() { + return selEnd; + }, + selectTextRange: function(aStart, aEnd) { + selStart = aStart; + selEnd = aEnd; + }, + + get searchCount() { + return this.searches.length; + }, + + getSearchAt: function(aIndex) { + return this.searches[aIndex]; + }, + + onSearchBegin: function() {}, + onSearchComplete: function() {}, + + popupOpen: false, + + popup: { + setSelectedIndex: function(aIndex) {}, + invalidate: function() {}, + + // nsISupports implementation + QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, + Ci.nsIAutoCompletePopup]) + }, + + // nsISupports implementation + QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, + Ci.nsIAutoCompleteInput]) +} + + + +/** + * nsIAutoCompleteResult implementation + */ +function AutoCompleteResult(aValues, aComments, aStyles) { + this._values = aValues; + this._comments = aComments; + this._styles = aStyles; +} +AutoCompleteResult.prototype = { + constructor: AutoCompleteResult, + + // Arrays + _values: null, + _comments: null, + _styles: null, + + searchString: "", + searchResult: Ci.nsIAutoCompleteResult.RESULT_SUCCESS, + + defaultIndex: 0, + isURLResult: true, + + get matchCount() { + return this._values.length; + }, + + getValueAt: function(aIndex) { + return this._values[aIndex]; + }, + + getLabelAt: function(aIndex) { + return this.getValueAt(aIndex); + }, + + getCommentAt: function(aIndex) { + return this._comments[aIndex]; + }, + + getStyleAt: function(aIndex) { + return this._styles[aIndex]; + }, + + getImageAt: function(aIndex) { + return ""; + }, + + removeValueAt: function (aRowIndex, aRemoveFromDb) {}, + + // nsISupports implementation + QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, + Ci.nsIAutoCompleteResult]) +} + + +/** + * nsIAutoCompleteSearch implementation that always returns + * the same result set. + */ +function AutoCompleteSearch(aName, aResult) { + this.name = aName; + this._result = aResult; +} +AutoCompleteSearch.prototype = { + constructor: AutoCompleteSearch, + + // Search name. Used by AutoCompleteController + name: null, + + // AutoCompleteResult + _result: null, + + + /** + * Return the same result set for every search + */ + startSearch: function(aSearchString, + aSearchParam, + aPreviousResult, + aListener) + { + aListener.onSearchResult(this, this._result); + }, + + stopSearch: function() {}, + + // nsISupports implementation + QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, + Ci.nsIFactory, + Ci.nsIAutoCompleteSearch]), + + // nsIFactory implementation + createInstance: function(outer, iid) { + return this.QueryInterface(iid); + } +} + + +/** + * Helper to register an AutoCompleteSearch with the given name. + * Allows the AutoCompleteController to find the search. + */ +function registerAutoCompleteSearch(aSearch) { + var name = "@mozilla.org/autocomplete/search;1?name=" + aSearch.name; + + var uuidGenerator = Cc["@mozilla.org/uuid-generator;1"]. + getService(Ci.nsIUUIDGenerator); + var cid = uuidGenerator.generateUUID(); + + var desc = "Test AutoCompleteSearch"; + + var componentManager = Components.manager + .QueryInterface(Ci.nsIComponentRegistrar); + componentManager.registerFactory(cid, desc, name, aSearch); + + // Keep the id on the object so we can unregister later + aSearch.cid = cid; +} + + +/** + * Helper to unregister an AutoCompleteSearch. + */ +function unregisterAutoCompleteSearch(aSearch) { + var componentManager = Components.manager + .QueryInterface(Ci.nsIComponentRegistrar); + componentManager.unregisterFactory(aSearch.cid, aSearch); +} + + +/** + * The array of autocomplete test data to run. + */ +var tests = [ + { + searchValues: ["mozilla.org"], // Autocomplete results + inputString: "moz", // The search string + expectedAutocomplete: "mozilla.org", // The string we expect to be autocompleted to + expectedSelStart: 3, // The range of the selection we expect + expectedSelEnd: 11 + }, + { + // Test URL schemes + searchValues: ["http://www.mozilla.org", "mozNotFirstMatch.org"], + inputString: "moz", + expectedAutocomplete: "mozilla.org", + expectedSelStart: 3, + expectedSelEnd: 11 + }, + { + // Test URL schemes + searchValues: ["ftp://ftp.mozilla.org/"], + inputString: "ft", + expectedAutocomplete: "ftp.mozilla.org/", + expectedSelStart: 2, + expectedSelEnd: 16 + }, + { + // Test the moz-action scheme, used internally for things like switch-to-tab + searchValues: ["moz-action:someaction,http://www.mozilla.org", "mozNotFirstMatch.org"], + inputString: "moz", + expectedAutocomplete: "mozilla.org", + expectedSelStart: 3, + expectedSelEnd: 11 + }, + { + // Test that we autocomplete to the first match, not necessarily the first entry + searchValues: ["unimportantTLD.org/moz", "mozilla.org"], + inputString: "moz", + expectedAutocomplete: "mozilla.org", + expectedSelStart: 3, + expectedSelEnd: 11 + }, + { + // Test that we only autocomplete to the next URL separator (/) + searchValues: ["http://mozilla.org/credits/morecredits"], + inputString: "moz", + expectedAutocomplete: "mozilla.org/", + expectedSelStart: 3, + expectedSelEnd: 12 + }, + { + // Test that we only autocomplete to the next URL separator (/) + searchValues: ["http://mozilla.org/credits/morecredits"], + inputString: "mozilla.org/cr", + expectedAutocomplete: "mozilla.org/credits/", + expectedSelStart: 14, + expectedSelEnd: 20 + }, + { + // Test that we only autocomplete to before the next URL separator (#) + searchValues: ["http://mozilla.org/credits#VENTNOR"], + inputString: "mozilla.org/cr", + expectedAutocomplete: "mozilla.org/credits", + expectedSelStart: 14, + expectedSelEnd: 19 + }, + { + // Test that we only autocomplete to before the next URL separator (?) + searchValues: ["http://mozilla.org/credits?mozilla=awesome"], + inputString: "mozilla.org/cr", + expectedAutocomplete: "mozilla.org/credits", + expectedSelStart: 14, + expectedSelEnd: 19 + }, + { + // Test that schemes are removed from the input + searchValues: ["http://www.mozilla.org/credits"], + inputString: "http://mozi", + expectedAutocomplete: "http://mozilla.org/", + expectedSelStart: 11, + expectedSelEnd: 19 + }, +]; + + +/** + * Run an individual autocomplete search, one at a time. + */ +function run_search() { + if (tests.length == 0) { + do_test_finished(); + return; + } + + var test = tests.shift(); + + var search = new AutoCompleteSearch("test-autofill1", + new AutoCompleteResult(test.searchValues, ["", ""], ["", ""])); + + // Register search so AutoCompleteController can find them + registerAutoCompleteSearch(search); + + var controller = Cc["@mozilla.org/autocomplete/controller;1"]. + getService(Ci.nsIAutoCompleteController); + + // Make an AutoCompleteInput that uses our search + // and confirms results on search complete + var input = new AutoCompleteInput([search.name]); + input.textValue = test.inputString; + + // Caret must be at the end. Autofill doesn't happen unless you're typing + // characters at the end. + var strLen = test.inputString.length; + input.selectTextRange(strLen, strLen); + + input.onSearchComplete = function() { + do_check_eq(input.textValue, test.expectedAutocomplete); + do_check_eq(input.selectionStart, test.expectedSelStart); + do_check_eq(input.selectionEnd, test.expectedSelEnd); + + // Unregister searches + unregisterAutoCompleteSearch(search); + run_search(); + }; + + controller.input = input; + controller.startSearch(test.inputString); +} + + +/** + */ +function run_test() { + // Search is asynchronous, so don't let the test finish immediately + do_test_pending(); + run_search(); +} + diff --git a/toolkit/components/autocomplete/tests/unit/xpcshell.ini b/toolkit/components/autocomplete/tests/unit/xpcshell.ini index a6765bb5bcb..cc414969607 100644 --- a/toolkit/components/autocomplete/tests/unit/xpcshell.ini +++ b/toolkit/components/autocomplete/tests/unit/xpcshell.ini @@ -9,3 +9,4 @@ tail = [test_autocomplete_multiple.js] [test_previousResult.js] [test_stopSearch.js] +[test_autofill.js] diff --git a/toolkit/components/filepicker/nsFilePicker.js b/toolkit/components/filepicker/nsFilePicker.js index c0782860feb..332bbaf4f0f 100644 --- a/toolkit/components/filepicker/nsFilePicker.js +++ b/toolkit/components/filepicker/nsFilePicker.js @@ -155,6 +155,10 @@ nsFilePicker.prototype = { set filterIndex(a) { this.mFilterIndex = a; }, get filterIndex() { return this.mFilterIndex; }, + /* attribute boolean addToRecentDocs; */ + set addToRecentDocs(a) {}, + get addToRecentDocs() { return false; }, + /* members */ mFilesEnumerator: undefined, mParentWindow: null, diff --git a/toolkit/components/filepicker/nsFileView.cpp b/toolkit/components/filepicker/nsFileView.cpp index 502909d0d8a..aa18630a2b8 100644 --- a/toolkit/components/filepicker/nsFileView.cpp +++ b/toolkit/components/filepicker/nsFileView.cpp @@ -154,6 +154,13 @@ NS_IMETHODIMP nsFileResult::GetErrorDescription(nsAString & aErrorDescription) return NS_OK; } +NS_IMETHODIMP nsFileResult::GetIsURLResult(PRBool *aIsURLResult) +{ + NS_ENSURE_ARG_POINTER(aIsURLResult); + *aIsURLResult = PR_FALSE; + return NS_OK; +} + NS_IMETHODIMP nsFileResult::GetMatchCount(PRUint32 *aMatchCount) { NS_ENSURE_ARG_POINTER(aMatchCount); diff --git a/toolkit/components/places/Makefile.in b/toolkit/components/places/Makefile.in index c55fc872fd0..69871fd0beb 100644 --- a/toolkit/components/places/Makefile.in +++ b/toolkit/components/places/Makefile.in @@ -104,12 +104,6 @@ EXTRA_DSO_LDOPTS += \ $(MOZ_COMPONENT_LIBS) \ $(NULL) -ifndef MOZ_ENABLE_LIBXUL -EXTRA_DSO_LDOPTS += \ - $(MOZ_JS_LIBS) \ - $(NULL) -endif - LOCAL_INCLUDES += -I$(srcdir)/../build # This is the default value. Must be in sync with the one defined in SQLite. diff --git a/toolkit/components/places/nsPlacesAutoComplete.js b/toolkit/components/places/nsPlacesAutoComplete.js index ac496285c00..2fded4c6745 100644 --- a/toolkit/components/places/nsPlacesAutoComplete.js +++ b/toolkit/components/places/nsPlacesAutoComplete.js @@ -458,6 +458,7 @@ nsPlacesAutoComplete.prototype = { createInstance(Ci.nsIAutoCompleteSimpleResult); result.setSearchString(aSearchString); result.setListener(this); + result.setIsURLResult(true); this._result = result; // If we are not enabled, we need to return now. @@ -737,7 +738,6 @@ nsPlacesAutoComplete.prototype = { if (aSearchOngoing) resultCode += "_ONGOING"; result.setSearchResult(Ci.nsIAutoCompleteResult[resultCode]); - result.setDefaultIndex(result.matchCount ? 0 : -1); this._listener.onSearchResult(this, result); }, diff --git a/toolkit/components/satchel/nsFormFillController.cpp b/toolkit/components/satchel/nsFormFillController.cpp index 17f7757ce72..78354a90e85 100644 --- a/toolkit/components/satchel/nsFormFillController.cpp +++ b/toolkit/components/satchel/nsFormFillController.cpp @@ -63,7 +63,6 @@ #include "nsIPresShell.h" #include "nsIFrame.h" #include "nsRect.h" -#include "nsIDOMDocumentEvent.h" #include "nsIDOMHTMLFormElement.h" #include "nsILoginManager.h" #include "nsIDOMMouseEvent.h" @@ -528,12 +527,10 @@ nsFormFillController::OnTextEntered(PRBool* aPrevent) // Fire off a DOMAutoComplete event nsCOMPtr domDoc; mFocusedInput->GetOwnerDocument(getter_AddRefs(domDoc)); - - nsCOMPtr doc = do_QueryInterface(domDoc); - NS_ENSURE_STATE(doc); + NS_ENSURE_STATE(domDoc); nsCOMPtr event; - doc->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event)); + domDoc->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event)); nsCOMPtr privateEvent(do_QueryInterface(event)); NS_ENSURE_STATE(privateEvent); diff --git a/toolkit/components/startup/nsAppStartup.cpp b/toolkit/components/startup/nsAppStartup.cpp index a6489253d69..cf3d7fb1955 100644 --- a/toolkit/components/startup/nsAppStartup.cpp +++ b/toolkit/components/startup/nsAppStartup.cpp @@ -97,10 +97,8 @@ #endif static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); -#ifdef MOZ_ENABLE_LIBXUL extern PRTime gXRE_mainTimestamp; extern PRTime gFirstPaintTimestamp; -#endif // mfinklesessionstore-browser-state-restored might be a better choice than the one below static PRTime gRestoredTimestamp = 0; // Timestamp of sessionstore-windows-restored static PRTime gProcessCreationTimestamp = 0;// Timestamp of sessionstore-windows-restored @@ -724,10 +722,8 @@ nsAppStartup::GetStartupInfo() } MaybeDefineProperty(cx, obj, "process", gProcessCreationTimestamp); -#ifdef MOZ_ENABLE_LIBXUL MaybeDefineProperty(cx, obj, "main", gXRE_mainTimestamp); MaybeDefineProperty(cx, obj, "firstPaint", gFirstPaintTimestamp); -#endif MaybeDefineProperty(cx, obj, "sessionRestored", gRestoredTimestamp); return NS_OK; } diff --git a/toolkit/components/url-classifier/tests/Makefile.in b/toolkit/components/url-classifier/tests/Makefile.in index ea742cb3f98..3445fcd712d 100644 --- a/toolkit/components/url-classifier/tests/Makefile.in +++ b/toolkit/components/url-classifier/tests/Makefile.in @@ -56,23 +56,10 @@ DIRS += mochitest \ # xpcshell tests XPCSHELL_TESTS=unit -ifndef MOZ_ENABLE_LIBXUL -# simple c++ tests (no xpcom) -CPP_UNIT_TESTS = \ - TestUrlClassifierUtils.cpp \ - $(NULL) - -LOCAL_INCLUDES = \ - -I$(srcdir)/../src \ - -I$(srcdir)/../public \ - $(NULL) - -LIBS = \ - ../src/$(LIB_PREFIX)urlclassifier_s.$(LIB_SUFFIX) \ - $(MOZ_COMPONENT_LIBS) \ - $(XPCOM_LIBS) \ - $(NSPR_LIBS) \ - $(NULL) -endif +# XXX Get this to work in libxul builds. +## simple c++ tests (no xpcom) +#CPP_UNIT_TESTS = \ +# TestUrlClassifierUtils.cpp \ +# $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/toolkit/content/widgets/notification.xml b/toolkit/content/widgets/notification.xml index 76c971ac822..0ca21e36075 100644 --- a/toolkit/content/widgets/notification.xml +++ b/toolkit/content/widgets/notification.xml @@ -444,7 +444,7 @@ diff --git a/toolkit/content/widgets/popup.xml b/toolkit/content/widgets/popup.xml index be5ed3b937f..39601909c0f 100644 --- a/toolkit/content/widgets/popup.xml +++ b/toolkit/content/widgets/popup.xml @@ -287,6 +287,7 @@ + diff --git a/toolkit/crashreporter/test/Makefile.in b/toolkit/crashreporter/test/Makefile.in index b54531787f8..f93fb1cf475 100644 --- a/toolkit/crashreporter/test/Makefile.in +++ b/toolkit/crashreporter/test/Makefile.in @@ -49,6 +49,8 @@ XPCSHELL_TESTS = unit LIBRARY_NAME = testcrasher NO_DIST_INSTALL = 1 +FORCE_SHARED_LIB = 1 + VPATH += \ $(srcdir)/../google-breakpad/src/processor/ \ $(srcdir)/../google-breakpad/src/common/ \ @@ -70,23 +72,7 @@ LOCAL_INCLUDES += \ -I$(srcdir)/../google-breakpad/src/ \ $(NULL) EXTRA_DSO_LIBS += xpcom -EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(MOZ_COMPONENT_LIBS) - -ifdef MOZ_ENABLE_LIBXUL -EXTRA_DSO_LDOPTS += $(XPCOM_GLUE_LDOPTS) -else - -MOZILLA_INTERNAL_API = 1 - -ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) -EXTRA_DSO_LDOPTS += $(DIST)/bin/XUL -else -EXTRA_DSO_LIBS += xul -endif - -EXTRA_DSO_LDOPTS += $(EXTRA_DSO_LIBS) $(XPCOM_LIBS) - -endif +EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(MOZ_COMPONENT_LIBS) $(XPCOM_GLUE_LDOPTS) EXTRA_JS_MODULES = CrashTestUtils.jsm diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in index 9023dcb3aae..2db6cfb0922 100644 --- a/toolkit/library/Makefile.in +++ b/toolkit/library/Makefile.in @@ -87,7 +87,6 @@ SHARED_LIBRARY_LIBS += \ $(foreach lib,$(STATIC_LIBS),$(DEPTH)/staticlib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX)) \ $(NULL) -ifdef MOZ_ENABLE_LIBXUL include $(srcdir)/libxul-config.mk EXTRA_DEPS += \ @@ -124,7 +123,6 @@ GARBAGE += \ $(RDF_UTIL_SRC_LCPPSRCS) \ $(NULL) endif -endif ifneq (,$(filter OS2 WINNT,$(OS_ARCH))) SDK_LIBRARY = $(IMPORT_LIBRARY) @@ -144,13 +142,6 @@ endif EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(EXTRA_DSO_LIBS) -ifndef MOZ_ENABLE_LIBXUL -EXTRA_DSO_LDOPTS += \ - $(MOZ_COMPONENT_LIBS) \ - $(MOZ_JS_LIBS) \ - $(NULL) -endif - DEFINES += -DIMPL_XREAPI EXTRA_DSO_LDOPTS += $(NSPR_LIBS) $(MOZALLOC_LIB) @@ -253,9 +244,7 @@ include $(topsrcdir)/config/rules.mk export:: $(RDF_UTIL_SRC_CPPSRCS) $(INTL_UNICHARUTIL_UTIL_CPPSRCS) $(INSTALL) $^ . -ifdef MOZ_ENABLE_LIBXUL include $(srcdir)/libxul-rules.mk -endif ifeq ($(OS_ARCH),OpenBSD) # Needed by nsAuthGSSAPI diff --git a/toolkit/library/libxul-config.mk b/toolkit/library/libxul-config.mk index 23a88182c36..a479c37c03a 100644 --- a/toolkit/library/libxul-config.mk +++ b/toolkit/library/libxul-config.mk @@ -50,7 +50,6 @@ endif ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_) CPPSRCS += \ - dlldeps.cpp \ nsGFXDeps.cpp \ $(NULL) @@ -73,7 +72,6 @@ ifeq ($(OS_ARCH),OS2) REQUIRES += widget gfx CPPSRCS += \ - dlldeps.cpp \ nsGFXDeps.cpp \ $(NULL) @@ -81,10 +79,8 @@ ifndef MOZ_NATIVE_ZLIB CPPSRCS += dlldeps-zlib.cpp endif -ifdef MOZ_ENABLE_LIBXUL RESFILE = xulrunos2.res RCFLAGS += -i $(topsrcdir)/widget/src/os2 -endif LOCAL_INCLUDES += -I$(topsrcdir)/widget/src/os2 LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/base diff --git a/toolkit/library/libxul-rules.mk b/toolkit/library/libxul-rules.mk index 16143e2382b..e4517595f0c 100644 --- a/toolkit/library/libxul-rules.mk +++ b/toolkit/library/libxul-rules.mk @@ -57,10 +57,3 @@ DEFINES += \ ifeq ($(MOZ_WIDGET_TOOLKIT),windows) OS_LIBS += $(call EXPAND_LIBNAME,usp10 oleaut32) endif - -export:: dlldeps.cpp - -dlldeps.cpp: $(topsrcdir)/xpcom/build/dlldeps.cpp - $(INSTALL) $^ . - -GARBAGE += dlldeps.cpp diff --git a/toolkit/mozapps/extensions/Makefile.in b/toolkit/mozapps/extensions/Makefile.in index 4d99cab6025..0293fd68961 100644 --- a/toolkit/mozapps/extensions/Makefile.in +++ b/toolkit/mozapps/extensions/Makefile.in @@ -39,6 +39,10 @@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ +ifeq (,$(filter aurora beta release,$(MOZ_UPDATE_CHANNEL))) +DEFINES += -DMOZ_COMPATABILITY_NIGHTLY=1 +endif + include $(DEPTH)/config/autoconf.mk MODULE = extensions diff --git a/toolkit/mozapps/extensions/XPIProvider.jsm b/toolkit/mozapps/extensions/XPIProvider.jsm index 864f42c5328..03efa6742f5 100644 --- a/toolkit/mozapps/extensions/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/XPIProvider.jsm @@ -60,7 +60,7 @@ const PREF_EM_DSS_ENABLED = "extensions.dss.enabled"; const PREF_DSS_SWITCHPENDING = "extensions.dss.switchPending"; const PREF_DSS_SKIN_TO_SELECT = "extensions.lastSelectedSkin"; const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin"; -const PREF_EM_CHECK_COMPATIBILITY = "extensions.checkCompatibility"; +const PREF_EM_CHECK_COMPATIBILITY_BASE = "extensions.checkCompatibility"; const PREF_EM_CHECK_UPDATE_SECURITY = "extensions.checkUpdateSecurity"; const PREF_EM_UPDATE_URL = "extensions.update.url"; const PREF_EM_ENABLED_ADDONS = "extensions.enabledAddons"; @@ -121,6 +121,14 @@ const BRANCH_REGEXP = /^([^\.]+\.[0-9]+[a-z]*).*/gi; const DB_SCHEMA = 4; const REQ_VERSION = 2; +#ifdef MOZ_COMPATABILITY_NIGHTLY +const PREF_EM_CHECK_COMPATIBILITY = PREF_EM_CHECK_COMPATIBILITY_BASE + + ".nightly"; +#else +const PREF_EM_CHECK_COMPATIBILITY = PREF_EM_CHECK_COMPATIBILITY_BASE + "." + + Services.appinfo.version.replace(BRANCH_REGEXP, "$1"); +#endif + // Properties that exist in the install manifest const PROP_METADATA = ["id", "version", "type", "internalName", "updateURL", "updateKey", "optionsURL", "aboutURL", "iconURL", @@ -1380,9 +1388,6 @@ var XPIProvider = { // will be the same as currentSkin when it is the skin to be used when the // application is restarted selectedSkin: null, - // The name of the checkCompatibility preference for the current application - // version - checkCompatibilityPref: null, // The value of the checkCompatibility preference checkCompatibility: true, // The value of the checkUpdateSecurity preference @@ -1516,15 +1521,13 @@ var XPIProvider = { this.selectedSkin = this.currentSkin; this.applyThemeChange(); - var version = Services.appinfo.version.replace(BRANCH_REGEXP, "$1"); - this.checkCompatibilityPref = PREF_EM_CHECK_COMPATIBILITY + "." + version; - this.checkCompatibility = Prefs.getBoolPref(this.checkCompatibilityPref, + this.checkCompatibility = Prefs.getBoolPref(PREF_EM_CHECK_COMPATIBILITY, true) this.checkUpdateSecurity = Prefs.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, true) this.enabledAddons = []; - Services.prefs.addObserver(this.checkCompatibilityPref, this, false); + Services.prefs.addObserver(PREF_EM_CHECK_COMPATIBILITY, this, false); Services.prefs.addObserver(PREF_EM_CHECK_UPDATE_SECURITY, this, false); let flushCaches = this.checkForChanges(aAppChanged, aOldAppVersion, @@ -1613,7 +1616,7 @@ var XPIProvider = { shutdown: function XPI_shutdown() { LOG("shutdown"); - Services.prefs.removeObserver(this.checkCompatibilityPref, this); + Services.prefs.removeObserver(PREF_EM_CHECK_COMPATIBILITY, this); Services.prefs.removeObserver(PREF_EM_CHECK_UPDATE_SECURITY, this); this.bootstrappedAddons = {}; @@ -3119,9 +3122,9 @@ var XPIProvider = { */ observe: function XPI_observe(aSubject, aTopic, aData) { switch (aData) { - case this.checkCompatibilityPref: + case PREF_EM_CHECK_COMPATIBILITY: case PREF_EM_CHECK_UPDATE_SECURITY: - this.checkCompatibility = Prefs.getBoolPref(this.checkCompatibilityPref, + this.checkCompatibility = Prefs.getBoolPref(PREF_EM_CHECK_COMPATIBILITY, true); this.checkUpdateSecurity = Prefs.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, true); diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js index 02a9e81bdf5..7b54633c9be 100644 --- a/toolkit/mozapps/extensions/content/extensions.js +++ b/toolkit/mozapps/extensions/content/extensions.js @@ -50,7 +50,7 @@ Cu.import("resource://gre/modules/AddonRepository.jsm"); const PREF_DISCOVERURL = "extensions.webservice.discoverURL"; const PREF_MAXRESULTS = "extensions.getAddons.maxResults"; -const PREF_CHECK_COMPATIBILITY = "extensions.checkCompatibility"; +const PREF_CHECK_COMPATIBILITY_BASE = "extensions.checkCompatibility"; const PREF_CHECK_UPDATE_SECURITY = "extensions.checkUpdateSecurity"; const PREF_AUTOUPDATE_DEFAULT = "extensions.update.autoUpdateDefault"; const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled"; @@ -60,6 +60,14 @@ const PREF_UI_LASTCATEGORY = "extensions.ui.lastCategory"; const BRANCH_REGEXP = /^([^\.]+\.[0-9]+[a-z]*).*/gi; +#ifdef MOZ_COMPATABILITY_NIGHTLY +const PREF_CHECK_COMPATIBILITY = PREF_CHECK_COMPATIBILITY_BASE + + ".nightly"; +#else +const PREF_CHECK_COMPATIBILITY = PREF_CHECK_COMPATIBILITY_BASE + "." + + Services.appinfo.version.replace(BRANCH_REGEXP, "$1"); +#endif + const LOADING_MSG_DELAY = 100; const SEARCH_SCORE_MULTIPLIER_NAME = 2; @@ -306,7 +314,6 @@ else { var gEventManager = { _listeners: {}, _installListeners: [], - checkCompatibilityPref: "", initialize: function() { var self = this; @@ -329,11 +336,8 @@ var gEventManager = { }); AddonManager.addInstallListener(this); AddonManager.addAddonListener(this); - - var version = Services.appinfo.version.replace(BRANCH_REGEXP, "$1"); - this.checkCompatibilityPref = PREF_CHECK_COMPATIBILITY + "." + version; - Services.prefs.addObserver(this.checkCompatibilityPref, this, false); + Services.prefs.addObserver(PREF_CHECK_COMPATIBILITY, this, false); Services.prefs.addObserver(PREF_CHECK_UPDATE_SECURITY, this, false); Services.prefs.addObserver(PREF_AUTOUPDATE_DEFAULT, this, false); @@ -361,7 +365,7 @@ var gEventManager = { }, shutdown: function() { - Services.prefs.removeObserver(this.checkCompatibilityPref, this); + Services.prefs.removeObserver(PREF_CHECK_COMPATIBILITY, this); Services.prefs.removeObserver(PREF_CHECK_UPDATE_SECURITY, this); Services.prefs.removeObserver(PREF_AUTOUPDATE_DEFAULT, this, false); @@ -462,7 +466,7 @@ var gEventManager = { var checkCompatibility = true; try { - checkCompatibility = Services.prefs.getBoolPref(this.checkCompatibilityPref); + checkCompatibility = Services.prefs.getBoolPref(PREF_CHECK_COMPATIBILITY); } catch(e) { } if (!checkCompatibility) { page.setAttribute("warning", "checkcompatibility"); @@ -485,7 +489,7 @@ var gEventManager = { observe: function(aSubject, aTopic, aData) { switch (aData) { - case this.checkCompatibilityPref: + case PREF_CHECK_COMPATIBILITY: case PREF_CHECK_UPDATE_SECURITY: this.refreshGlobalWarning(); break; @@ -720,7 +724,7 @@ var gViewController = { cmd_enableCheckCompatibility: { isEnabled: function() true, doCommand: function() { - Services.prefs.clearUserPref(gEventManager.checkCompatibilityPref); + Services.prefs.clearUserPref(PREF_CHECK_COMPATIBILITY); } }, diff --git a/toolkit/mozapps/extensions/jar.mn b/toolkit/mozapps/extensions/jar.mn index c44638743ea..4aab3dfdd56 100644 --- a/toolkit/mozapps/extensions/jar.mn +++ b/toolkit/mozapps/extensions/jar.mn @@ -2,7 +2,7 @@ toolkit.jar: % content mozapps %content/mozapps/ * content/mozapps/extensions/extensions.xul (content/extensions.xul) content/mozapps/extensions/extensions.css (content/extensions.css) - content/mozapps/extensions/extensions.js (content/extensions.js) +* content/mozapps/extensions/extensions.js (content/extensions.js) * content/mozapps/extensions/extensions.xml (content/extensions.xml) content/mozapps/extensions/updateinfo.xsl (content/updateinfo.xsl) content/mozapps/extensions/extensions-content.js (content/extensions-content.js) diff --git a/toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js b/toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js index a0a7fdaacd9..dc2646abae2 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js +++ b/toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js @@ -16,7 +16,20 @@ function end_test() { add_test(function() { info("Testing compatibility checking warning"); - var version = Services.appinfo.version.replace(/^([^\.]+\.[0-9]+[a-z]*).*/gi, "$1"); + var channel = "default"; + try { + channel = Services.prefs.getCharPref("app.update.channel"); + } + catch (e) { } + if (channel != "aurora" && + channel != "beta" && + channel != "release") { + var version = "nightly"; + } + else { + version = Services.appinfo.version.replace(/^([^\.]+\.[0-9]+[a-z]*).*/gi, "$1"); + } + var pref = "extensions.checkCompatibility." + version; info("Setting " + pref + " pref to false") Services.prefs.setBoolPref(pref, false); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js index 285126a48b4..2cecdfe29b9 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js @@ -39,7 +39,20 @@ // Disables security checking our updates which haven't been signed Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false); // Disables compatibility checking -Services.prefs.setBoolPref("extensions.checkCompatibility.2", false); +var channel = "default"; +try { + channel = Services.prefs.getCharPref("app.update.channel"); +} +catch (e) { } + +if (channel != "aurora" && + channel != "beta" && + channel != "release") { + Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false); +} +else { + Services.prefs.setBoolPref("extensions.checkCompatibility.2", false); +} var ADDONS = [ "test_bug470377_1", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js index 6b943f71f31..83a0539d293 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js @@ -101,7 +101,20 @@ function run_test_1() { function run_test_2() { // Disable compatibility checks - Services.prefs.setBoolPref("extensions.checkCompatibility.2.2", false); + var channel = "default"; + try { + channel = Services.prefs.getCharPref("app.update.channel"); + } + catch (e) { } + + if (channel != "aurora" && + channel != "beta" && + channel != "release") { + Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false); + } + else { + Services.prefs.setBoolPref("extensions.checkCompatibility.2.2", false); + } restartManager(); AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js index e9782c343cb..3958ad681da 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js @@ -36,6 +36,21 @@ * ***** END LICENSE BLOCK ***** */ +var channel = "default"; +try { + channel = Services.prefs.getCharPref("app.update.channel"); +} +catch (e) { } + +if (channel != "aurora" && + channel != "beta" && + channel != "release") { + var checkCompatPref = "extensions.checkCompatibility.nightly"; +} +else { + checkCompatPref = "extensions.checkCompatibility.2.1a"; +} + function run_test() { do_test_pending(); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2.1a4", "2"); @@ -74,7 +89,7 @@ function run_test() { function run_test_1() { // Disable compatibility checks - Services.prefs.setBoolPref("extensions.checkCompatibility.2.1a", false); + Services.prefs.setBoolPref(checkCompatPref, false); startupManager(); AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org", @@ -100,7 +115,7 @@ function run_test_1() { function run_test_2() { // Enable compatibility checks - Services.prefs.setBoolPref("extensions.checkCompatibility.2.1a", true); + Services.prefs.setBoolPref(checkCompatPref, true); restartManager(); AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug521905.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug521905.js index 502c95788ca..1bbb1b40369 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug521905.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug521905.js @@ -45,6 +45,20 @@ Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false); Services.prefs.setBoolPref("extensions.checkCompatibility.2.0pre", false); function run_test() { + var channel = "default"; + try { + channel = Services.prefs.getCharPref("app.update.channel"); + } + catch (e) { } + + // This test is only relevant on builds where the version is included in the + // checkCompatibility preference name + if (channel != "aurora" && + channel != "beta" && + channel != "release") { + return; + } + do_test_pending(); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2.0pre", "2"); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_checkcompatibility.js b/toolkit/mozapps/extensions/test/xpcshell/test_checkcompatibility.js index 289ab26f96a..a49cafc7bd2 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_checkcompatibility.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_checkcompatibility.js @@ -59,6 +59,8 @@ var ADDONS = [{ const profileDir = gProfD.clone(); profileDir.append("extensions"); +var gIsNightly = false; + function run_test() { do_test_pending(); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2.2.3", "2"); @@ -67,6 +69,16 @@ function run_test() { writeInstallRDFForExtension(a, profileDir); }); + var channel = "default"; + try { + channel = Services.prefs.getCharPref("app.update.channel"); + } + catch (e) { } + + gIsNightly = channel != "aurora" && + channel != "beta" && + channel != "release"; + startupManager(); run_test_1(); @@ -133,7 +145,10 @@ function run_test_1() { // Tests that with compatibility checking disabled we see the incompatible // add-ons enabled function run_test_2() { - Services.prefs.setBoolPref("extensions.checkCompatibility.2.2", false); + if (gIsNightly) + Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false); + else + Services.prefs.setBoolPref("extensions.checkCompatibility.2.2", false); restartManager(); AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", @@ -151,7 +166,8 @@ function run_test_2() { // Tests that with compatibility checking disabled we see the incompatible // add-ons enabled. function run_test_3() { - Services.prefs.setBoolPref("extensions.checkCompatibility.2.1a", false); + if (!gIsNightly) + Services.prefs.setBoolPref("extensions.checkCompatibility.2.1a", false); restartManager("2.1a4"); AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", @@ -169,7 +185,10 @@ function run_test_3() { // Tests that with compatibility checking enabled we see the incompatible // add-ons disabled. function run_test_4() { - Services.prefs.setBoolPref("extensions.checkCompatibility.2.1a", true); + if (gIsNightly) + Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", true); + else + Services.prefs.setBoolPref("extensions.checkCompatibility.2.1a", true); restartManager(); AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", diff --git a/toolkit/mozapps/installer/packager.mk b/toolkit/mozapps/installer/packager.mk index 93d6a36d60b..7038e14a3d2 100644 --- a/toolkit/mozapps/installer/packager.mk +++ b/toolkit/mozapps/installer/packager.mk @@ -390,8 +390,7 @@ PACK_OMNIJAR = \ grep -h '^binary-component' components/*.manifest > binary.manifest ; \ sed -e 's/^binary-component/\#binary-component/' components/components.manifest > components.manifest && \ mv components.manifest components && \ - find . | xargs touch -t 201001010000 && \ - zip -r9mX omni.jar $(OMNIJAR_FILES) -x $(NON_OMNIJAR_FILES) && \ + zip -r9m omni.jar $(OMNIJAR_FILES) -x $(NON_OMNIJAR_FILES) && \ $(GENERATE_CACHE) && \ $(OPTIMIZE_JARS_CMD) --optimize $(JARLOG_DIR) ./ ./ && \ mv binary.manifest components && \ diff --git a/toolkit/toolkit-tiers.mk b/toolkit/toolkit-tiers.mk index 2e0df0c4bae..2323206a517 100644 --- a/toolkit/toolkit-tiers.mk +++ b/toolkit/toolkit-tiers.mk @@ -226,11 +226,8 @@ endif tier_platform_dirs += services/crypto/component -ifdef MOZ_ENABLE_LIBXUL tier_platform_dirs += startupcache -endif -ifndef BUILD_STATIC_LIBS ifdef APP_LIBXUL_STATICDIRS # Applications can cheat and ask for code to be # built before libxul so libxul can be linked against it. @@ -243,11 +240,8 @@ tier_platform_dirs += $(APP_LIBXUL_DIRS) endif tier_platform_dirs += toolkit/library -endif -ifdef MOZ_ENABLE_LIBXUL tier_platform_dirs += xpcom/stub -endif ifdef NS_TRACE_MALLOC tier_platform_dirs += tools/trace-malloc diff --git a/toolkit/xre/Makefile.in b/toolkit/xre/Makefile.in index 7771a7ee048..28ad29b5563 100644 --- a/toolkit/xre/Makefile.in +++ b/toolkit/xre/Makefile.in @@ -64,6 +64,7 @@ CPPSRCS = \ nsNativeAppSupportBase.cpp \ nsAppData.cpp \ nsSigHandlers.cpp \ + nsEmbedFunctions.cpp \ $(NULL) ifdef MOZ_X11 @@ -82,10 +83,6 @@ endif DEFINES += -DIMPL_XREAPI -DMOZ_APP_NAME='"$(MOZ_APP_NAME)"' -ifndef BUILD_STATIC_LIBS -CPPSRCS += nsEmbedFunctions.cpp -endif - ifdef MOZ_UPDATER ifneq ($(OS_TARGET),Android) CPPSRCS += nsUpdateDriver.cpp @@ -196,11 +193,6 @@ LOCAL_INCLUDES += \ -I$(topsrcdir)/dom/base \ $(NULL) -ifdef BUILD_STATIC_LIBS -export:: - @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_LINK_COMP_NAMES) Apprunner -endif - LOCAL_INCLUDES += \ -I$(srcdir) \ -I$(srcdir)/../profile \ @@ -213,10 +205,6 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2) CXXFLAGS += $(MOZ_PANGO_CFLAGS) endif -ifdef BUILD_STATIC_LIBS -DEFINES += -D_BUILD_STATIC_BIN -endif - DEFINES += \ -DOS_TARGET=\"$(OS_TARGET)\" \ -DMOZ_WIDGET_TOOLKIT=\"$(MOZ_WIDGET_TOOLKIT)\" diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 5fae29c22ab..b8fcfcda1cd 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -1134,16 +1134,6 @@ ScopedXPCOMStartup::Initialize() nsresult rv; -#ifndef MOZ_ENABLE_LIBXUL -#ifndef _BUILD_STATIC_BIN - XRE_AddStaticComponent(&kXREModule); -#else - for (const mozilla::Module *const *const *staticModules = kPStaticModules; - *staticModules; ++staticModules) - XRE_AddStaticComponent(**staticModules); -#endif -#endif - rv = NS_InitXPCOM2(&mServiceManager, gDirServiceProvider->GetAppDir(), gDirServiceProvider); if (NS_FAILED(rv)) { @@ -1707,9 +1697,7 @@ static nsresult LaunchChild(nsINativeAppSupport* aNative, #if defined(XP_MACOSX) CommandLineServiceMac::SetupMacCommandLine(gRestartArgc, gRestartArgv, PR_TRUE); PRUint32 restartMode = 0; -#if defined(MOZ_ENABLE_LIBXUL) restartMode = gRestartMode; -#endif LaunchChildMac(gRestartArgc, gRestartArgv, restartMode); #else nsCOMPtr lf; diff --git a/tools/trace-malloc/Makefile.in b/tools/trace-malloc/Makefile.in index ac50f705cd9..ad956026532 100644 --- a/tools/trace-malloc/Makefile.in +++ b/tools/trace-malloc/Makefile.in @@ -78,11 +78,9 @@ endif include $(topsrcdir)/config/config.mk -ifdef MOZ_ENABLE_LIBXUL ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT)) EXTRA_DSO_LIBS = xul endif -endif LIBS += \ $(LIBS_DIR) \ @@ -93,11 +91,9 @@ LIBS += \ $(NSPR_LIBS) \ $(NULL) -ifdef MOZ_ENABLE_LIBXUL ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) LIBS += $(DIST)/bin/XUL endif -endif ifdef HAVE_BOUTELL_GD ifeq ($(OS_ARCH),WINNT) diff --git a/widget/public/nsGUIEvent.h b/widget/public/nsGUIEvent.h index 43c75365337..85126c4e47a 100644 --- a/widget/public/nsGUIEvent.h +++ b/widget/public/nsGUIEvent.h @@ -1346,6 +1346,13 @@ public: PRInt32 mLineHeight; PRInt32 mPageWidth; PRInt32 mPageHeight; + // used by NS_QUERY_SCROLL_TARGET_INFO + // the mouse wheel scrolling amount may be overridden by prefs or + // overriding system scrolling speed mechanism. + // If mMouseScrollEvent is a line scroll event, the unit of this value is + // line. If mMouseScrollEvent is a page scroll event, the unit of this + // value is page. + PRInt32 mComputedScrollAmount; } mReply; enum { diff --git a/widget/public/nsGUIEventIPC.h b/widget/public/nsGUIEventIPC.h index 78901256e19..4c021a5b309 100644 --- a/widget/public/nsGUIEventIPC.h +++ b/widget/public/nsGUIEventIPC.h @@ -289,6 +289,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mReply.mLineHeight); WriteParam(aMsg, aParam.mReply.mPageHeight); WriteParam(aMsg, aParam.mReply.mPageWidth); + WriteParam(aMsg, aParam.mReply.mComputedScrollAmount); } static bool Read(const Message* aMsg, void** aIter, paramType* aResult) @@ -307,7 +308,8 @@ struct ParamTraits ReadParam(aMsg, aIter, &aResult->mReply.mWidgetIsHit) && ReadParam(aMsg, aIter, &aResult->mReply.mLineHeight) && ReadParam(aMsg, aIter, &aResult->mReply.mPageHeight) && - ReadParam(aMsg, aIter, &aResult->mReply.mPageWidth); + ReadParam(aMsg, aIter, &aResult->mReply.mPageWidth) && + ReadParam(aMsg, aIter, &aResult->mReply.mComputedScrollAmount); } }; diff --git a/widget/public/nsIFilePicker.idl b/widget/public/nsIFilePicker.idl index 4fa41f862a5..8223ec299e8 100644 --- a/widget/public/nsIFilePicker.idl +++ b/widget/public/nsIFilePicker.idl @@ -44,7 +44,7 @@ interface nsIURI; interface nsIDOMWindow; interface nsISimpleEnumerator; -[scriptable, uuid(d24ef0aa-d555-4117-84af-9cbbb7406909)] +[scriptable, uuid(f2c0e216-5d07-4df4-bbcb-37683077ae7e)] interface nsIFilePicker : nsISupports { const short modeOpen = 0; // Load a file or directory @@ -162,6 +162,14 @@ interface nsIFilePicker : nsISupports */ readonly attribute nsISimpleEnumerator files; + /** + * Controls whether the chosen file(s) should be added to the system's recent + * documents list. This attribute will be ignored if the system has no "Recent + * Docs" concept, or if the application is in private browsing mode (in which + * case the file will not be added). Defaults to true. + */ + attribute boolean addToRecentDocs; + /** * Show File Dialog. The dialog is displayed modally. * diff --git a/widget/reftests/progressbar-fallback-default-style-ref.html b/widget/reftests/progressbar-fallback-default-style-ref.html index 30918cf36c9..8627319ee4a 100644 --- a/widget/reftests/progressbar-fallback-default-style-ref.html +++ b/widget/reftests/progressbar-fallback-default-style-ref.html @@ -13,11 +13,11 @@ /* Default style in case of there is -moz-appearance: none; */ border: 2px solid; - -moz-border-top-colors: ThreeDShadow -moz-Dialog; - -moz-border-right-colors: ThreeDHighlight -moz-Dialog; - -moz-border-bottom-colors: ThreeDHighlight -moz-Dialog; - -moz-border-left-colors: ThreeDShadow -moz-Dialog; - background-color: -moz-Dialog; + -moz-border-top-colors: ThreeDShadow #e6e6e6; + -moz-border-right-colors: ThreeDHighlight #e6e6e6; + -moz-border-bottom-colors: ThreeDHighlight #e6e6e6; + -moz-border-left-colors: ThreeDShadow #e6e6e6; + background-color: #e6e6e6; } div.progress-bar { @@ -32,7 +32,7 @@ -moz-box-sizing: border-box; /* Default style in case of there is -moz-appearance: none; */ - background-color: ThreeDShadow; + background-color: #0064b4; } div.progress-element { padding: 5px; } diff --git a/widget/src/android/AndroidBridge.cpp b/widget/src/android/AndroidBridge.cpp index b604ef2b7bf..3d1ab067b55 100644 --- a/widget/src/android/AndroidBridge.cpp +++ b/widget/src/android/AndroidBridge.cpp @@ -390,9 +390,9 @@ AndroidBridge::GetHandlersForMimeType(const char *aMimeType, NS_ConvertUTF8toUTF16 wMimeType(aMimeType); jstring jstrMimeType = mJNIEnv->NewString(wMimeType.get(), wMimeType.Length()); - const PRUnichar* wAction; - PRUint32 actionLen = NS_StringGetData(aAction, &wAction); - jstring jstrAction = mJNIEnv->NewString(wAction, actionLen); + + jstring jstrAction = mJNIEnv->NewString(nsPromiseFlatString(aAction).get(), + aAction.Length()); jobject obj = mJNIEnv->CallStaticObjectMethod(mGeckoAppShellClass, jGetHandlersForMimeType, @@ -423,9 +423,8 @@ AndroidBridge::GetHandlersForURL(const char *aURL, AutoLocalJNIFrame jniFrame; NS_ConvertUTF8toUTF16 wScheme(aURL); jstring jstrScheme = mJNIEnv->NewString(wScheme.get(), wScheme.Length()); - const PRUnichar* wAction; - PRUint32 actionLen = NS_StringGetData(aAction, &wAction); - jstring jstrAction = mJNIEnv->NewString(wAction, actionLen); + jstring jstrAction = mJNIEnv->NewString(nsPromiseFlatString(aAction).get(), + aAction.Length()); jobject obj = mJNIEnv->CallStaticObjectMethod(mGeckoAppShellClass, jGetHandlersForURL, @@ -454,21 +453,18 @@ AndroidBridge::OpenUriExternal(const nsACString& aUriSpec, const nsACString& aMi AutoLocalJNIFrame jniFrame; NS_ConvertUTF8toUTF16 wUriSpec(aUriSpec); NS_ConvertUTF8toUTF16 wMimeType(aMimeType); - const PRUnichar* wPackageName; - PRUint32 packageNameLen = NS_StringGetData(aPackageName, &wPackageName); - const PRUnichar* wClassName; - PRUint32 classNameLen = NS_StringGetData(aClassName, &wClassName); - const PRUnichar* wAction; - PRUint32 actionLen = NS_StringGetData(aAction, &wAction); - const PRUnichar* wTitle; - PRUint32 titleLen = NS_StringGetData(aTitle, &wTitle); jstring jstrUri = mJNIEnv->NewString(wUriSpec.get(), wUriSpec.Length()); jstring jstrType = mJNIEnv->NewString(wMimeType.get(), wMimeType.Length()); - jstring jstrPackage = mJNIEnv->NewString(wPackageName, packageNameLen); - jstring jstrClass = mJNIEnv->NewString(wClassName, classNameLen); - jstring jstrAction = mJNIEnv->NewString(wAction, actionLen); - jstring jstrTitle = mJNIEnv->NewString(wTitle, titleLen); + + jstring jstrPackage = mJNIEnv->NewString(nsPromiseFlatString(aPackageName).get(), + aPackageName.Length()); + jstring jstrClass = mJNIEnv->NewString(nsPromiseFlatString(aClassName).get(), + aClassName.Length()); + jstring jstrAction = mJNIEnv->NewString(nsPromiseFlatString(aAction).get(), + aAction.Length()); + jstring jstrTitle = mJNIEnv->NewString(nsPromiseFlatString(aTitle).get(), + aTitle.Length()); return mJNIEnv->CallStaticBooleanMethod(mGeckoAppShellClass, jOpenUriExternal, @@ -535,10 +531,9 @@ void AndroidBridge::SetClipboardText(const nsAString& aText) { ALOG_BRIDGE("AndroidBridge::SetClipboardText"); - - const PRUnichar* wText; - PRUint32 wTextLen = NS_StringGetData(aText, &wText); - jstring jstr = mJNIEnv->NewString(wText, wTextLen); + AutoLocalJNIFrame jniFrame; + jstring jstr = mJNIEnv->NewString(nsPromiseFlatString(aText).get(), + aText.Length()); mJNIEnv->CallStaticObjectMethod(mGeckoAppShellClass, jSetClipboardText, jstr); } @@ -677,6 +672,7 @@ void AndroidBridge::SetSelectedLocale(const nsAString& aLocale) { ALOG_BRIDGE("AndroidBridge::SetSelectedLocale"); + AutoLocalJNIFrame jniFrame; jstring jLocale = GetJNIForThread()->NewString(PromiseFlatString(aLocale).get(), aLocale.Length()); GetJNIForThread()->CallStaticVoidMethod(mGeckoAppShellClass, jSetSelectedLocale, jLocale); } @@ -855,6 +851,7 @@ jclass GetGeckoAppShellClass() void AndroidBridge::ScanMedia(const nsAString& aFile, const nsACString& aMimeType) { + AutoLocalJNIFrame jniFrame; jstring jstrFile = mJNIEnv->NewString(nsPromiseFlatString(aFile).get(), aFile.Length()); nsString mimeType2; diff --git a/widget/src/android/GfxInfo.cpp b/widget/src/android/GfxInfo.cpp index 01f1f3fa97e..8a0638bba85 100644 --- a/widget/src/android/GfxInfo.cpp +++ b/widget/src/android/GfxInfo.cpp @@ -43,7 +43,7 @@ #include "AndroidBridge.h" -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#if defined(MOZ_CRASHREPORTER) #include "nsExceptionHandler.h" #include "nsICrashReporter.h" #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" @@ -159,7 +159,7 @@ void GfxInfo::AddCrashReportAnnotations() { #if 0 -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#if defined(MOZ_CRASHREPORTER) nsCAutoString deviceIDString, vendorIDString; PRUint32 deviceID, vendorID; diff --git a/widget/src/cocoa/GfxInfo.mm b/widget/src/cocoa/GfxInfo.mm index 6e3eff38b92..83e7bbc7711 100644 --- a/widget/src/cocoa/GfxInfo.mm +++ b/widget/src/cocoa/GfxInfo.mm @@ -44,7 +44,7 @@ #include "mozilla/FunctionTimer.h" #include "nsToolkit.h" -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#if defined(MOZ_CRASHREPORTER) #include "nsExceptionHandler.h" #include "nsICrashReporter.h" #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" @@ -180,7 +180,7 @@ GfxInfo::GetAdapterDeviceID(PRUint32 *aAdapterDeviceID) void GfxInfo::AddCrashReportAnnotations() { -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterRendererIDs"), NS_LossyConvertUTF16toASCII(mRendererIDsString)); diff --git a/widget/src/cocoa/nsMenuItemX.mm b/widget/src/cocoa/nsMenuItemX.mm index 9bb92179c2a..b33f76b729b 100644 --- a/widget/src/cocoa/nsMenuItemX.mm +++ b/widget/src/cocoa/nsMenuItemX.mm @@ -54,7 +54,6 @@ #include "nsIDOMDocument.h" #include "nsIPrivateDOMEvent.h" #include "nsIDOMEventTarget.h" -#include "nsIDOMDocumentEvent.h" #include "nsIDOMElement.h" nsMenuItemX::nsMenuItemX() @@ -211,15 +210,15 @@ nsresult nsMenuItemX::DispatchDOMEvent(const nsString &eventName, PRBool *preven } // get interface for creating DOM events from content owner document - nsCOMPtr DOMEventFactory = do_QueryInterface(parentDoc); - if (!DOMEventFactory) { - NS_WARNING("Failed to QI parent nsIDocument to nsIDOMDocumentEvent"); + nsCOMPtr domDoc = do_QueryInterface(parentDoc); + if (!domDoc) { + NS_WARNING("Failed to QI parent nsIDocument to nsIDOMDocument"); return NS_ERROR_FAILURE; } // create DOM event nsCOMPtr event; - nsresult rv = DOMEventFactory->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event)); + nsresult rv = domDoc->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event)); if (NS_FAILED(rv)) { NS_WARNING("Failed to create nsIDOMEvent"); return rv; diff --git a/widget/src/cocoa/nsMenuUtilsX.mm b/widget/src/cocoa/nsMenuUtilsX.mm index eecef2c4f28..9539a0e6278 100644 --- a/widget/src/cocoa/nsMenuUtilsX.mm +++ b/widget/src/cocoa/nsMenuUtilsX.mm @@ -46,7 +46,7 @@ #include "nsCocoaWindow.h" #include "nsWidgetAtoms.h" #include "nsIDocument.h" -#include "nsIDOMDocumentEvent.h" +#include "nsIDOMDocument.h" #include "nsIDOMEventTarget.h" #include "nsIDOMXULCommandEvent.h" #include "nsIPrivateDOMEvent.h" @@ -57,12 +57,12 @@ void nsMenuUtilsX::DispatchCommandTo(nsIContent* aTargetContent) NS_PRECONDITION(aTargetContent, "null ptr"); nsIDocument* doc = aTargetContent->GetOwnerDoc(); - nsCOMPtr docEvent = do_QueryInterface(doc); + nsCOMPtr domDoc = do_QueryInterface(doc); nsCOMPtr target = do_QueryInterface(aTargetContent); - if (docEvent && target) { + if (domDoc && target) { nsCOMPtr event; - docEvent->CreateEvent(NS_LITERAL_STRING("xulcommandevent"), - getter_AddRefs(event)); + domDoc->CreateEvent(NS_LITERAL_STRING("xulcommandevent"), + getter_AddRefs(event)); nsCOMPtr command = do_QueryInterface(event); nsCOMPtr pEvent = do_QueryInterface(command); diff --git a/widget/src/os2/Makefile.in b/widget/src/os2/Makefile.in index 0a194ba6d19..4751cfec83d 100644 --- a/widget/src/os2/Makefile.in +++ b/widget/src/os2/Makefile.in @@ -52,10 +52,6 @@ GRE_MODULE = 1 LIBXUL_LIBRARY = 1 -ifdef BUILD_STATIC_LIBS -EXPORTS = wdgtos2rc.h -endif - CPPSRCS = \ nsAppShell.cpp \ nsBidiKeyboard.cpp \ diff --git a/widget/src/windows/GfxInfo.cpp b/widget/src/windows/GfxInfo.cpp index 89001a49abe..9e91ab02711 100644 --- a/widget/src/windows/GfxInfo.cpp +++ b/widget/src/windows/GfxInfo.cpp @@ -48,7 +48,7 @@ #include "prprf.h" #include "GfxDriverInfo.h" -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#if defined(MOZ_CRASHREPORTER) #include "nsExceptionHandler.h" #include "nsICrashReporter.h" #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" @@ -533,7 +533,7 @@ GfxInfo::GetAdapterDeviceID(PRUint32 *aAdapterDeviceID) return NS_OK; } -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#if defined(MOZ_CRASHREPORTER) /* Cisco's VPN software can cause corruption of the floating point state. * Make a note of this in our crash reports so that some weird crashes * make more sense */ @@ -553,7 +553,7 @@ CheckForCiscoVPN() { void GfxInfo::AddCrashReportAnnotations() { -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#if defined(MOZ_CRASHREPORTER) CheckForCiscoVPN(); nsCAutoString deviceIDString, vendorIDString; diff --git a/widget/src/windows/Makefile.in b/widget/src/windows/Makefile.in index 2e2ce57d958..cc00a920164 100644 --- a/widget/src/windows/Makefile.in +++ b/widget/src/windows/Makefile.in @@ -114,10 +114,6 @@ ifdef MOZ_ENABLE_D3D10_LAYER DEFINES += -DMOZ_ENABLE_D3D10_LAYER endif -ifdef BUILD_STATIC_LIBS -DEFINES += -DMOZ_STATIC_COMPONENT_LIBS -endif # BUILD_STATIC_LIBS - EXPORTS = nsdefs.h WindowHook.h diff --git a/widget/src/windows/nsFilePicker.cpp b/widget/src/windows/nsFilePicker.cpp index 653c1b891fc..4ce495bef40 100644 --- a/widget/src/windows/nsFilePicker.cpp +++ b/widget/src/windows/nsFilePicker.cpp @@ -46,6 +46,7 @@ #include "nsIServiceManager.h" #include "nsIPlatformCharset.h" #include "nsICharsetConverterManager.h" +#include "nsIPrivateBrowsingService.h" #include "nsFilePicker.h" #include "nsILocalFile.h" #include "nsIURL.h" @@ -69,21 +70,11 @@ char nsFilePicker::mLastUsedDirectory[MAX_PATH+1] = { 0 }; #define MAX_EXTENSION_LENGTH 10 -//------------------------------------------------------------------------- -// -// nsFilePicker constructor -// -//------------------------------------------------------------------------- nsFilePicker::nsFilePicker() { mSelectedType = 1; } -//------------------------------------------------------------------------- -// -// nsFilePicker destructor -// -//------------------------------------------------------------------------- nsFilePicker::~nsFilePicker() { if (mLastUsedUnicodeDirectory) { @@ -92,12 +83,7 @@ nsFilePicker::~nsFilePicker() } } -//------------------------------------------------------------------------- -// // Show - Display the file dialog -// -//------------------------------------------------------------------------- - int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) { if (uMsg == BFFM_INITIALIZED) @@ -195,7 +181,20 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal) ofn.lpstrFile = fileBuffer; ofn.nMaxFile = FILE_BUFFER_SIZE; - ofn.Flags = OFN_NOCHANGEDIR | OFN_SHAREAWARE | OFN_LONGNAMES | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST; + ofn.Flags = OFN_NOCHANGEDIR | OFN_SHAREAWARE | + OFN_LONGNAMES | OFN_OVERWRITEPROMPT | + OFN_HIDEREADONLY | OFN_PATHMUSTEXIST; + + // Handle add to recent docs settings + nsCOMPtr pbs = + do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID); + PRBool privacyModeEnabled = PR_FALSE; + if (pbs) { + pbs->GetPrivateBrowsingEnabled(&privacyModeEnabled); + } + if (privacyModeEnabled || !mAddToRecentDocs) { + ofn.Flags |= OFN_DONTADDTORECENT; + } if (!mDefaultExtension.IsEmpty()) { ofn.lpstrDefExt = mDefaultExtension.get(); @@ -405,7 +404,6 @@ NS_IMETHODIMP nsFilePicker::GetFile(nsILocalFile **aFile) return NS_OK; } -//------------------------------------------------------------------------- NS_IMETHODIMP nsFilePicker::GetFileURL(nsIURI **aFileURL) { *aFileURL = nsnull; @@ -423,11 +421,7 @@ NS_IMETHODIMP nsFilePicker::GetFiles(nsISimpleEnumerator **aFiles) return NS_NewArrayEnumerator(aFiles, mFiles); } -//------------------------------------------------------------------------- -// // Get the file + path -// -//------------------------------------------------------------------------- NS_IMETHODIMP nsFilePicker::SetDefaultString(const nsAString& aString) { mDefault = aString; @@ -465,11 +459,7 @@ NS_IMETHODIMP nsFilePicker::GetDefaultString(nsAString& aString) return NS_ERROR_FAILURE; } -//------------------------------------------------------------------------- -// // The default extension to use for files -// -//------------------------------------------------------------------------- NS_IMETHODIMP nsFilePicker::GetDefaultExtension(nsAString& aExtension) { aExtension = mDefaultExtension; @@ -482,11 +472,7 @@ NS_IMETHODIMP nsFilePicker::SetDefaultExtension(const nsAString& aExtension) return NS_OK; } -//------------------------------------------------------------------------- -// // Set the filter index -// -//------------------------------------------------------------------------- NS_IMETHODIMP nsFilePicker::GetFilterIndex(PRInt32 *aFilterIndex) { // Windows' filter index is 1-based, we use a 0-based system. @@ -501,7 +487,6 @@ NS_IMETHODIMP nsFilePicker::SetFilterIndex(PRInt32 aFilterIndex) return NS_OK; } -//------------------------------------------------------------------------- void nsFilePicker::InitNative(nsIWidget *aParent, const nsAString& aTitle, PRInt16 aMode) diff --git a/widget/src/windows/nsToolkit.cpp b/widget/src/windows/nsToolkit.cpp index 3ebe75d3b9f..a15153d3b46 100644 --- a/widget/src/windows/nsToolkit.cpp +++ b/widget/src/windows/nsToolkit.cpp @@ -75,46 +75,6 @@ StartAllowingD3D9(nsITimer *aTimer, void *aClosure) nsWindow::StartAllowingD3D9(true); } -#if !defined(MOZ_STATIC_COMPONENT_LIBS) && !defined(MOZ_ENABLE_LIBXUL) -// -// Dll entry point. Keep the dll instance -// - -#if defined(__GNUC__) -// If DllMain gets name mangled, it won't be seen. -extern "C" { -#endif - -BOOL APIENTRY DllMain( HINSTANCE hModule, - DWORD reason, - LPVOID lpReserved ) -{ - switch( reason ) { - case DLL_PROCESS_ATTACH: - nsToolkit::Startup(hModule); - break; - - case DLL_THREAD_ATTACH: - break; - - case DLL_THREAD_DETACH: - break; - - case DLL_PROCESS_DETACH: - nsToolkit::Shutdown(); - break; - - } - - return TRUE; -} - -#if defined(__GNUC__) -} // extern "C" -#endif - -#endif - // // main for the message pump thread // diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 0b15ced0a0e..1df847a0546 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -6422,7 +6422,7 @@ nsWindow::OnMouseWheel(UINT aMessage, WPARAM aWParam, LPARAM aLParam, // Our positive delta value means to bottom or right. // But positive nativeDelta value means to top or right. - // Use orienter for computing our delta value. + // Use orienter for computing our delta value with native delta value. PRInt32 orienter = isVertical ? -1 : 1; // Assume the Control key is down if the Elantech touchpad has sent the @@ -6451,6 +6451,9 @@ nsWindow::OnMouseWheel(UINT aMessage, WPARAM aWParam, LPARAM aLParam, // event target information for pixel scroll. PRBool dispatchPixelScrollEvent = PR_FALSE; PRInt32 pixelsPerUnit = 0; + // the amount is the number of lines (or pages) per WHEEL_DELTA + PRInt32 computedScrollAmount = isPageScroll ? 1 : + (isVertical ? sMouseWheelScrollLines : sMouseWheelScrollChars); if (sEnablePixelScrolling) { nsMouseScrollEvent testEvent(PR_TRUE, NS_MOUSE_SCROLL, this); @@ -6462,7 +6465,12 @@ nsWindow::OnMouseWheel(UINT aMessage, WPARAM aWParam, LPARAM aLParam, testEvent.isControl = scrollEvent.isControl; testEvent.isMeta = scrollEvent.isMeta; testEvent.isAlt = scrollEvent.isAlt; - testEvent.delta = sLastMouseWheelDeltaIsPositive ? -1 : 1; + + testEvent.delta = computedScrollAmount; + if ((isVertical && sLastMouseWheelDeltaIsPositive) || + (!isVertical && !sLastMouseWheelDeltaIsPositive)) { + testEvent.delta *= -1; + } nsQueryContentEvent queryEvent(PR_TRUE, NS_QUERY_SCROLL_TARGET_INFO, this); InitEvent(queryEvent); queryEvent.InitForQueryScrollTargetInfo(&testEvent); @@ -6479,7 +6487,14 @@ nsWindow::OnMouseWheel(UINT aMessage, WPARAM aWParam, LPARAM aLParam, } else { pixelsPerUnit = queryEvent.mReply.mLineHeight; } - dispatchPixelScrollEvent = (pixelsPerUnit > 0); + // XXX Currently, we don't support the case that the computed delta has + // different sign. + computedScrollAmount = queryEvent.mReply.mComputedScrollAmount; + if (testEvent.delta < 0) { + computedScrollAmount *= -1; + } + dispatchPixelScrollEvent = + (pixelsPerUnit > 0) && (computedScrollAmount > 0); } } @@ -6490,6 +6505,8 @@ nsWindow::OnMouseWheel(UINT aMessage, WPARAM aWParam, LPARAM aLParam, PRInt32 nativeDeltaForScroll = nativeDelta + sRemainingDeltaForScroll; + // NOTE: Don't use computedScrollAmount for computing the delta value of + // line/page scroll event. The value will be recomputed in ESM. if (isPageScroll) { scrollEvent.scrollFlags |= nsMouseScrollEvent::kIsFullPage; if (isVertical) { @@ -6542,17 +6559,8 @@ nsWindow::OnMouseWheel(UINT aMessage, WPARAM aWParam, LPARAM aLParam, PRInt32 nativeDeltaForPixel = nativeDelta + sRemainingDeltaForPixel; - double deltaPerPixel; - if (isPageScroll) { - deltaPerPixel = (double)WHEEL_DELTA / pixelsPerUnit; - } else { - if (isVertical) { - deltaPerPixel = (double)WHEEL_DELTA / sMouseWheelScrollLines; - } else { - deltaPerPixel = (double)WHEEL_DELTA / sMouseWheelScrollChars; - } - deltaPerPixel /= pixelsPerUnit; - } + double deltaPerPixel = + (double)WHEEL_DELTA / computedScrollAmount / pixelsPerUnit; pixelEvent.delta = RoundDelta((double)nativeDeltaForPixel * orienter / deltaPerPixel); PRInt32 recomputedNativeDelta = diff --git a/widget/src/windows/tests/Makefile.in b/widget/src/windows/tests/Makefile.in index 0830f72ec69..9594e916ac3 100644 --- a/widget/src/windows/tests/Makefile.in +++ b/widget/src/windows/tests/Makefile.in @@ -42,28 +42,25 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -ifndef BUILD_STATIC_LIBS -ifndef MOZ_ENABLE_LIBXUL -LOCAL_INCLUDES = -I$(srcdir)/../ \ - -I$(srcdir)/../../xpwidgets \ - $(NULL) - -LIBS = ../$(LIB_PREFIX)widget_windows.$(LIB_SUFFIX) \ - ../../xpwidgets/$(LIB_PREFIX)xpwidgets_s.$(LIB_SUFFIX) \ - $(DIST)/lib/$(LIB_PREFIX)thebes.$(LIB_SUFFIX) \ - $(DIST)/lib/$(LIB_PREFIX)gkgfx.$(LIB_SUFFIX) \ - $(XPCOM_LIBS) \ - $(MOZ_UNICHARUTIL_LIBS) \ - $(QCMS_LIBS) \ - $(NULL) - -EXTRA_DSO_LDOPTS += $(LIBS_DIR) - -OS_LIBS += $(call EXPAND_LIBNAME,ole32 oleaut32 shell32 comctl32 comdlg32 imm32 shlwapi winspool msimg32) - -CPP_UNIT_TESTS = TestWinDND.cpp \ - $(NULL) -endif -endif +# XXX None of these stuff works in libxul builds. +#LOCAL_INCLUDES = -I$(srcdir)/../ \ +# -I$(srcdir)/../../xpwidgets \ +# $(NULL) +# +#LIBS = ../$(LIB_PREFIX)widget_windows.$(LIB_SUFFIX) \ +# ../../xpwidgets/$(LIB_PREFIX)xpwidgets_s.$(LIB_SUFFIX) \ +# $(DIST)/lib/$(LIB_PREFIX)thebes.$(LIB_SUFFIX) \ +# $(DIST)/lib/$(LIB_PREFIX)gkgfx.$(LIB_SUFFIX) \ +# $(XPCOM_LIBS) \ +# $(MOZ_UNICHARUTIL_LIBS) \ +# $(QCMS_LIBS) \ +# $(NULL) +# +#EXTRA_DSO_LDOPTS += $(LIBS_DIR) +# +#OS_LIBS += $(call EXPAND_LIBNAME,ole32 oleaut32 shell32 comctl32 comdlg32 imm32 shlwapi winspool msimg32) +# +#CPP_UNIT_TESTS = TestWinDND.cpp \ +# $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/widget/src/xpwidgets/GfxInfoBase.cpp b/widget/src/xpwidgets/GfxInfoBase.cpp index 1cba0e73270..15878c7b4c1 100644 --- a/widget/src/xpwidgets/GfxInfoBase.cpp +++ b/widget/src/xpwidgets/GfxInfoBase.cpp @@ -41,13 +41,10 @@ #include "GfxInfoWebGL.h" #include "GfxDriverInfo.h" -#include "nsIPrefBranch2.h" -#include "nsIPrefService.h" #include "nsCOMPtr.h" #include "nsCOMArray.h" #include "nsAutoPtr.h" #include "nsString.h" -#include "nsServiceManagerUtils.h" #include "mozilla/Services.h" #include "nsIObserver.h" #include "nsIObserverService.h" @@ -56,8 +53,9 @@ #include "nsIDOM3Node.h" #include "nsIDOMNodeList.h" #include "nsTArray.h" +#include "mozilla/Preferences.h" -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#if defined(MOZ_CRASHREPORTER) #include "nsExceptionHandler.h" #endif @@ -89,7 +87,7 @@ StoreSpline(int ax, int ay, int bx, int by, int cx, int cy, int dx, int dy) { void CrashSpline(double tolerance, int ax, int ay, int bx, int by, int cx, int cy, int dx, int dy) { -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#if defined(MOZ_CRASHREPORTER) static bool annotated; if (!annotated) { @@ -122,6 +120,7 @@ CrashSpline(double tolerance, int ax, int ay, int bx, int by, int cx, int cy, in using namespace mozilla::widget; +using namespace mozilla; NS_IMPL_ISUPPORTS3(GfxInfoBase, nsIGfxInfo, nsIObserver, nsISupportsWeakReference) @@ -171,16 +170,8 @@ GetPrefValueForFeature(PRInt32 aFeature, PRInt32& aValue) if (!prefname) return false; - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (prefs) { - PRInt32 val; - if (NS_SUCCEEDED(prefs->GetIntPref(prefname, &val))) { - aValue = val; - return true; - } - } - - return false; + aValue = PR_FALSE; + return NS_SUCCEEDED(Preferences::GetInt(prefname, &aValue)); } static void @@ -190,10 +181,7 @@ SetPrefValueForFeature(PRInt32 aFeature, PRInt32 aValue) if (!prefname) return; - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (prefs) { - prefs->SetIntPref(prefname, aValue); - } + Preferences::SetInt(prefname, aValue); } static void @@ -203,46 +191,25 @@ RemovePrefForFeature(PRInt32 aFeature) if (!prefname) return; - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (prefs) { - prefs->ClearUserPref(prefname); - } + Preferences::ClearUser(prefname); } static bool -GetPrefValueForDriverVersion(nsACString& aVersion) +GetPrefValueForDriverVersion(nsCString& aVersion) { - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (prefs) { - nsXPIDLCString version; - if (NS_SUCCEEDED(prefs->GetCharPref(SUGGESTED_VERSION_PREF, - getter_Copies(version)))) { - aVersion = version; - return true; - } - } - - return false; + return NS_SUCCEEDED(Preferences::GetChar(SUGGESTED_VERSION_PREF, &aVersion)); } static void -SetPrefValueForDriverVersion(const nsAString& aVersion) +SetPrefValueForDriverVersion(const nsString& aVersion) { - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (prefs) { - nsCAutoString ver = NS_LossyConvertUTF16toASCII(aVersion); - prefs->SetCharPref(SUGGESTED_VERSION_PREF, - PromiseFlatCString(ver).get()); - } + Preferences::SetChar(SUGGESTED_VERSION_PREF, aVersion); } static void RemovePrefForDriverVersion() { - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (prefs) { - prefs->ClearUserPref(SUGGESTED_VERSION_PREF); - } + Preferences::ClearUser(SUGGESTED_VERSION_PREF); } // Hello - "Hello" is stored as a child text node of the foo node. @@ -677,7 +644,7 @@ GfxInfoBase::LogFailure(const nsACString &failure) mFailures[mFailureCount++] = failure; /* record it in the crash notes too */ -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#if defined(MOZ_CRASHREPORTER) CrashReporter::AppendAppNotesToCrashReport(failure); #endif } diff --git a/widget/src/xpwidgets/GfxInfoX11.cpp b/widget/src/xpwidgets/GfxInfoX11.cpp index 546a169fa04..90e63fdc007 100644 --- a/widget/src/xpwidgets/GfxInfoX11.cpp +++ b/widget/src/xpwidgets/GfxInfoX11.cpp @@ -46,7 +46,7 @@ #include "GfxInfoX11.h" -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" #include "nsICrashReporter.h" #endif @@ -165,7 +165,7 @@ GfxInfo::GetData() mAdapterDescription.Append(nsDependentCString(buf)); mAdapterDescription.AppendLiteral("\n"); } -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#ifdef MOZ_CRASHREPORTER CrashReporter::AppendAppNotesToCrashReport(mAdapterDescription); #endif return; @@ -181,7 +181,7 @@ GfxInfo::GetData() note.Append(" -- "); note.Append(mVersion); note.Append("\n"); -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#ifdef MOZ_CRASHREPORTER CrashReporter::AppendAppNotesToCrashReport(note); #endif diff --git a/widget/src/xpwidgets/nsBaseDragService.cpp b/widget/src/xpwidgets/nsBaseDragService.cpp index bd6f9764404..6a04415c9d7 100644 --- a/widget/src/xpwidgets/nsBaseDragService.cpp +++ b/widget/src/xpwidgets/nsBaseDragService.cpp @@ -66,11 +66,13 @@ #include "nsIViewObserver.h" #include "nsRegion.h" #include "nsGUIEvent.h" -#include "nsIPrefService.h" +#include "mozilla/Preferences.h" #include "gfxContext.h" #include "gfxPlatform.h" +using namespace mozilla; + #define DRAGIMAGES_PREF "nglayout.enable_drag_images" nsBaseDragService::nsBaseDragService() @@ -453,10 +455,7 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode, *aPresContext = presShell->GetPresContext(); // check if drag images are disabled - PRBool enableDragImages = PR_TRUE; - nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (prefs) - prefs->GetBoolPref(DRAGIMAGES_PREF, &enableDragImages); + PRBool enableDragImages = Preferences::GetBool(DRAGIMAGES_PREF, PR_TRUE); // didn't want an image, so just set the screen rectangle to the frame size if (!enableDragImages || !mHasImage) { diff --git a/widget/src/xpwidgets/nsBaseFilePicker.cpp b/widget/src/xpwidgets/nsBaseFilePicker.cpp index 319338ec7ec..9cb5a00d53a 100644 --- a/widget/src/xpwidgets/nsBaseFilePicker.cpp +++ b/widget/src/xpwidgets/nsBaseFilePicker.cpp @@ -64,7 +64,8 @@ using namespace mozilla::widget; #define FILEPICKER_TITLES "chrome://global/locale/filepicker.properties" #define FILEPICKER_FILTERS "chrome://global/content/filepicker.properties" -nsBaseFilePicker::nsBaseFilePicker() +nsBaseFilePicker::nsBaseFilePicker() : + mAddToRecentDocs(PR_TRUE) { } @@ -74,7 +75,6 @@ nsBaseFilePicker::~nsBaseFilePicker() } -//------------------------------------------------------------------------- NS_IMETHODIMP nsBaseFilePicker::Init(nsIDOMWindow *aParent, const nsAString& aTitle, PRInt16 aMode) @@ -161,11 +161,7 @@ nsBaseFilePicker::AppendFilters(PRInt32 aFilterMask) return NS_OK; } -//------------------------------------------------------------------------- -// // Set the filter index -// -//------------------------------------------------------------------------- NS_IMETHODIMP nsBaseFilePicker::GetFilterIndex(PRInt32 *aFilterIndex) { *aFilterIndex = 0; @@ -197,11 +193,8 @@ NS_IMETHODIMP nsBaseFilePicker::GetFiles(nsISimpleEnumerator **aFiles) } #ifdef BASEFILEPICKER_HAS_DISPLAYDIRECTORY -//------------------------------------------------------------------------- -// + // Set the display directory -// -//------------------------------------------------------------------------- NS_IMETHODIMP nsBaseFilePicker::SetDisplayDirectory(nsILocalFile *aDirectory) { if (!aDirectory) { @@ -216,11 +209,7 @@ NS_IMETHODIMP nsBaseFilePicker::SetDisplayDirectory(nsILocalFile *aDirectory) return rv; } -//------------------------------------------------------------------------- -// // Get the display directory -// -//------------------------------------------------------------------------- NS_IMETHODIMP nsBaseFilePicker::GetDisplayDirectory(nsILocalFile **aDirectory) { *aDirectory = nsnull; @@ -233,3 +222,17 @@ NS_IMETHODIMP nsBaseFilePicker::GetDisplayDirectory(nsILocalFile **aDirectory) return CallQueryInterface(directory, aDirectory); } #endif + +NS_IMETHODIMP +nsBaseFilePicker::GetAddToRecentDocs(PRBool *aFlag) +{ + *aFlag = mAddToRecentDocs; + return NS_OK; +} + +NS_IMETHODIMP +nsBaseFilePicker::SetAddToRecentDocs(PRBool aFlag) +{ + mAddToRecentDocs = aFlag; + return NS_OK; +} diff --git a/widget/src/xpwidgets/nsBaseFilePicker.h b/widget/src/xpwidgets/nsBaseFilePicker.h index 01a3bb3cbb4..63df5338873 100644 --- a/widget/src/xpwidgets/nsBaseFilePicker.h +++ b/widget/src/xpwidgets/nsBaseFilePicker.h @@ -69,12 +69,15 @@ public: NS_IMETHOD GetDisplayDirectory(nsILocalFile * *aDisplayDirectory); NS_IMETHOD SetDisplayDirectory(nsILocalFile * aDisplayDirectory); #endif + NS_IMETHOD GetAddToRecentDocs(PRBool *aFlag); + NS_IMETHOD SetAddToRecentDocs(PRBool aFlag); protected: virtual void InitNative(nsIWidget *aParent, const nsAString& aTitle, PRInt16 aMode) = 0; + PRBool mAddToRecentDocs; #ifdef BASEFILEPICKER_HAS_DISPLAYDIRECTORY nsCOMPtr mDisplayDirectory; #endif diff --git a/widget/src/xpwidgets/nsBaseWidget.cpp b/widget/src/xpwidgets/nsBaseWidget.cpp index 395c658bd8f..83d2eba95ed 100644 --- a/widget/src/xpwidgets/nsBaseWidget.cpp +++ b/widget/src/xpwidgets/nsBaseWidget.cpp @@ -47,8 +47,7 @@ #include "nsISimpleEnumerator.h" #include "nsIContent.h" #include "nsIServiceManager.h" -#include "nsIPrefService.h" -#include "nsIPrefBranch2.h" +#include "mozilla/Preferences.h" #include "BasicLayers.h" #include "LayerManagerOGL.h" #include "nsIXULRuntime.h" @@ -68,6 +67,7 @@ static PRInt32 gNumWidgets; #endif using namespace mozilla::layers; +using namespace mozilla; nsIContent* nsBaseWidget::mLastRollup = nsnull; @@ -778,10 +778,6 @@ nsBaseWidget::AutoUseBasicLayerManager::~AutoUseBasicLayerManager() PRBool nsBaseWidget::GetShouldAccelerate() { - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); - - PRBool disableAcceleration = PR_FALSE; - PRBool forceAcceleration = PR_FALSE; #if defined(XP_WIN) || defined(ANDROID) || (MOZ_PLATFORM_MAEMO > 5) PRBool accelerateByDefault = PR_TRUE; #elif defined(XP_MACOSX) @@ -815,17 +811,13 @@ nsBaseWidget::GetShouldAccelerate() PRBool accelerateByDefault = PR_FALSE; #endif - if (prefs) { - // we should use AddBoolPrefVarCache - prefs->GetBoolPref("layers.acceleration.disabled", - &disableAcceleration); - - prefs->GetBoolPref("layers.acceleration.force-enabled", - &forceAcceleration); - - prefs->GetBoolPref("layers.acceleration.draw-fps", - &mDrawFPS); - } + // we should use AddBoolPrefVarCache + PRBool disableAcceleration = + Preferences::GetBool("layers.acceleration.disabled", PR_FALSE); + PRBool forceAcceleration = + Preferences::GetBool("layers.acceleration.force-enabled", PR_FALSE); + mDrawFPS = + Preferences::GetBool("layers.acceleration.draw-fps", PR_FALSE); const char *acceleratedEnv = PR_GetEnv("MOZ_ACCELERATED"); accelerateByDefault = accelerateByDefault || @@ -1108,22 +1100,14 @@ nsBaseWidget::OverrideSystemMouseScrollSpeed(PRInt32 aOriginalDelta, { aOverriddenDelta = aOriginalDelta; - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); - NS_ENSURE_TRUE(prefs, NS_ERROR_FAILURE); - nsCOMPtr prefBranch; - nsresult rv = prefs->GetBranch(nsnull, getter_AddRefs(prefBranch)); - NS_ENSURE_SUCCESS(rv, rv); - NS_ENSURE_TRUE(prefBranch, NS_ERROR_FAILURE); - - PRBool isOverrideEnabled; const char* kPrefNameOverrideEnabled = "mousewheel.system_scroll_override_on_root_content.enabled"; - rv = prefBranch->GetBoolPref(kPrefNameOverrideEnabled, &isOverrideEnabled); - if (NS_FAILED(rv) || !isOverrideEnabled) { + PRBool isOverrideEnabled = + Preferences::GetBool(kPrefNameOverrideEnabled, PR_FALSE); + if (!isOverrideEnabled) { return NS_OK; } - PRInt32 iFactor; nsCAutoString factorPrefName( "mousewheel.system_scroll_override_on_root_content."); if (aIsHorizontal) { @@ -1132,10 +1116,10 @@ nsBaseWidget::OverrideSystemMouseScrollSpeed(PRInt32 aOriginalDelta, factorPrefName.AppendLiteral("vertical."); } factorPrefName.AppendLiteral("factor"); - rv = prefBranch->GetIntPref(factorPrefName.get(), &iFactor); + PRInt32 iFactor = Preferences::GetInt(factorPrefName.get(), 0); // The pref value must be larger than 100, otherwise, we don't override the // delta value. - if (NS_FAILED(rv) || iFactor <= 100) { + if (iFactor <= 100) { return NS_OK; } double factor = (double)iFactor / 100; @@ -1347,32 +1331,13 @@ static PrefPair debug_PrefValues[] = { "nglayout.debug.paint_flashing", PR_FALSE } }; -static PRUint32 debug_NumPrefValues = - (sizeof(debug_PrefValues) / sizeof(debug_PrefValues[0])); - - -////////////////////////////////////////////////////////////// -static PRBool debug_GetBoolPref(nsIPrefBranch * aPrefs,const char * aPrefName) -{ - NS_ASSERTION(nsnull != aPrefName,"cmon, pref name is null."); - NS_ASSERTION(nsnull != aPrefs,"cmon, prefs are null."); - - PRBool value = PR_FALSE; - - if (aPrefs) - { - aPrefs->GetBoolPref(aPrefName,&value); - } - - return value; -} ////////////////////////////////////////////////////////////// PRBool nsBaseWidget::debug_GetCachedBoolPref(const char * aPrefName) { NS_ASSERTION(nsnull != aPrefName,"cmon, pref name is null."); - for (PRUint32 i = 0; i < debug_NumPrefValues; i++) + for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(debug_PrefValues); i++) { if (strcmp(debug_PrefValues[i].name, aPrefName) == 0) { @@ -1387,7 +1352,7 @@ static void debug_SetCachedBoolPref(const char * aPrefName,PRBool aValue) { NS_ASSERTION(nsnull != aPrefName,"cmon, pref name is null."); - for (PRUint32 i = 0; i < debug_NumPrefValues; i++) + for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(debug_PrefValues); i++) { if (strcmp(debug_PrefValues[i].name, aPrefName) == 0) { @@ -1413,13 +1378,9 @@ NS_IMETHODIMP Debug_PrefObserver::Observe(nsISupports* subject, const char* topic, const PRUnichar* data) { - nsCOMPtr branch(do_QueryInterface(subject)); - NS_ASSERTION(branch, "must implement nsIPrefBranch"); - NS_ConvertUTF16toUTF8 prefName(data); - PRBool value = PR_FALSE; - branch->GetBoolPref(prefName.get(), &value); + PRBool value = Preferences::GetBool(prefName.get(), PR_FALSE); debug_SetCachedBoolPref(prefName.get(), value); return NS_OK; } @@ -1430,28 +1391,21 @@ debug_RegisterPrefCallbacks() { static PRBool once = PR_TRUE; - if (once) - { - once = PR_FALSE; + if (!once) { + return; + } - nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); - - NS_ASSERTION(prefs, "Prefs services is null."); + once = PR_FALSE; - if (prefs) - { - nsCOMPtr obs(new Debug_PrefObserver()); - for (PRUint32 i = 0; i < debug_NumPrefValues; i++) - { - // Initialize the pref values - debug_PrefValues[i].value = - debug_GetBoolPref(prefs,debug_PrefValues[i].name); + nsCOMPtr obs(new Debug_PrefObserver()); + for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(debug_PrefValues); i++) { + // Initialize the pref values + debug_PrefValues[i].value = + Preferences::GetBool(debug_PrefValues[i].name, PR_FALSE); - if (obs) { - // Register callbacks for when these change - prefs->AddObserver(debug_PrefValues[i].name, obs, PR_FALSE); - } - } + if (obs) { + // Register callbacks for when these change + Preferences::AddStrongObserver(obs, debug_PrefValues[i].name); } } } diff --git a/widget/src/xpwidgets/nsFilePickerProxy.cpp b/widget/src/xpwidgets/nsFilePickerProxy.cpp index d3148729b87..e0a6aa3d7fe 100644 --- a/widget/src/xpwidgets/nsFilePickerProxy.cpp +++ b/widget/src/xpwidgets/nsFilePickerProxy.cpp @@ -175,7 +175,8 @@ NS_IMETHODIMP nsFilePickerProxy::Show(PRInt16* aReturn) InfallibleTArray filePaths; nsresult rv; - cc->SendShowFilePicker(mMode, mSelectedType, mTitle, + cc->SendShowFilePicker(mMode, mSelectedType, + mAddToRecentDocs, mTitle, mDefault, mDefaultExtension, mFilters, mFilterNames, &filePaths, aReturn, &rv); diff --git a/widget/src/xpwidgets/nsIdleService.cpp b/widget/src/xpwidgets/nsIdleService.cpp index f245bac9f6b..29aa17204a1 100644 --- a/widget/src/xpwidgets/nsIdleService.cpp +++ b/widget/src/xpwidgets/nsIdleService.cpp @@ -43,13 +43,14 @@ #include "nsIdleService.h" #include "nsString.h" #include "nsIObserverService.h" -#include "nsIPrefBranch.h" -#include "nsIPrefService.h" #include "nsIServiceManager.h" #include "nsDebug.h" #include "nsCOMArray.h" #include "prinrval.h" #include "mozilla/Services.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; // observer topics used: #define OBSERVER_TOPIC_IDLE "idle" @@ -102,11 +103,8 @@ nsIdleServiceDaily::Observe(nsISupports *, (void)mIdleService->RemoveIdleObserver(this, MAX_IDLE_POLL_INTERVAL); // Set the last idle-daily time pref. - nsCOMPtr pref = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (pref) { - PRInt32 nowSec = static_cast(PR_Now() / PR_USEC_PER_SEC); - (void)pref->SetIntPref(PREF_LAST_DAILY, nowSec); - } + PRInt32 nowSec = static_cast(PR_Now() / PR_USEC_PER_SEC); + Preferences::SetInt(PREF_LAST_DAILY, nowSec); // Start timer for the next check in one day. (void)mTimer->InitWithFuncCallback(DailyCallback, this, SECONDS_PER_DAY * 1000, @@ -127,15 +125,11 @@ nsIdleServiceDaily::Init() { // Check time of the last idle-daily notification. If it was more than 24 // hours ago listen for idle, otherwise set a timer for 24 hours from now. - PRInt32 lastDaily = 0; PRInt32 nowSec = static_cast(PR_Now() / PR_USEC_PER_SEC); - nsCOMPtr pref = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (pref) { - if (NS_FAILED(pref->GetIntPref(PREF_LAST_DAILY, &lastDaily)) || - lastDaily < 0 || lastDaily > nowSec) { - // The time is bogus, use default. - lastDaily = 0; - } + PRInt32 lastDaily = Preferences::GetInt(PREF_LAST_DAILY, 0); + if (lastDaily < 0 || lastDaily > nowSec) { + // The time is bogus, use default. + lastDaily = 0; } // Check if it has been a day since the last notification. diff --git a/widget/src/xpwidgets/nsNativeTheme.cpp b/widget/src/xpwidgets/nsNativeTheme.cpp index 05eeddd79e4..ca45ef174b7 100644 --- a/widget/src/xpwidgets/nsNativeTheme.cpp +++ b/widget/src/xpwidgets/nsNativeTheme.cpp @@ -557,11 +557,7 @@ nsNativeTheme::Notify(nsITimer* aTimer) for (PRUint32 index = 0; index < count; index++) { nsIFrame* frame = mAnimatedContentList[index]->GetPrimaryFrame(); if (frame) { -#ifdef MOZ_ENABLE_LIBXUL frame->InvalidateOverflowRect(); -#else - frame->InvalidateOverflowRectExternal(); -#endif } } diff --git a/widget/src/xpwidgets/nsPrintOptionsImpl.cpp b/widget/src/xpwidgets/nsPrintOptionsImpl.cpp index 788781aeb58..cd9e3aadcff 100644 --- a/widget/src/xpwidgets/nsPrintOptionsImpl.cpp +++ b/widget/src/xpwidgets/nsPrintOptionsImpl.cpp @@ -51,15 +51,14 @@ #include "nsISupportsArray.h" #include "prprf.h" -// For Prefs -#include "nsIPrefBranch.h" -#include "nsIPrefService.h" -#include "nsIServiceManager.h" - #include "nsIStringEnumerator.h" #include "nsISupportsPrimitives.h" #include "stdlib.h" #include "nsAutoPtr.h" +#include "mozilla/Preferences.h" +#include "nsPrintfCString.h" + +using namespace mozilla; NS_IMPL_ISUPPORTS2(nsPrintOptions, nsIPrintOptions, nsIPrintSettingsService) @@ -128,12 +127,7 @@ nsPrintOptions::~nsPrintOptions() nsresult nsPrintOptions::Init() { - nsresult rv; - nsCOMPtr prefService = - do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - return prefService->GetBranch("print.", getter_AddRefs(mPrefBranch)); + return NS_OK; } NS_IMETHODIMP @@ -246,7 +240,6 @@ nsresult nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags) { - NS_ENSURE_STATE(mPrefBranch); NS_ENSURE_ARG_POINTER(aPS); if (aFlags & nsIPrintSettings::kInitSaveMargins) { @@ -308,21 +301,21 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, #define GETBOOLPREF(_prefname, _retval) \ NS_SUCCEEDED( \ - mPrefBranch->GetBoolPref( \ + Preferences::GetBool( \ GetPrefName(_prefname, aPrinterName), _retval \ ) \ ) #define GETSTRPREF(_prefname, _retval) \ NS_SUCCEEDED( \ - ReadPrefString( \ + Preferences::GetChar( \ GetPrefName(_prefname, aPrinterName), _retval \ ) \ ) #define GETINTPREF(_prefname, _retval) \ NS_SUCCEEDED( \ - mPrefBranch->GetIntPref( \ + Preferences::GetInt( \ GetPrefName(_prefname, aPrinterName), _retval \ ) \ ) @@ -343,7 +336,7 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, && GETINTPREF(kPrintPaperSizeType, &sizeType) && GETDBLPREF(kPrintPaperWidth, width) && GETDBLPREF(kPrintPaperHeight, height) - && GETSTRPREF(kPrintPaperName, str); + && GETSTRPREF(kPrintPaperName, &str); // Bug 315687: Sanity check paper size to avoid paper size values in // mm when the size unit flag is inches. The value 100 is arbitrary @@ -383,42 +376,42 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, } if (aFlags & nsIPrintSettings::kInitSaveHeaderLeft) { - if (GETSTRPREF(kPrintHeaderStrLeft, str)) { + if (GETSTRPREF(kPrintHeaderStrLeft, &str)) { aPS->SetHeaderStrLeft(str.get()); DUMP_STR(kReadStr, kPrintHeaderStrLeft, str.get()); } } if (aFlags & nsIPrintSettings::kInitSaveHeaderCenter) { - if (GETSTRPREF(kPrintHeaderStrCenter, str)) { + if (GETSTRPREF(kPrintHeaderStrCenter, &str)) { aPS->SetHeaderStrCenter(str.get()); DUMP_STR(kReadStr, kPrintHeaderStrCenter, str.get()); } } if (aFlags & nsIPrintSettings::kInitSaveHeaderRight) { - if (GETSTRPREF(kPrintHeaderStrRight, str)) { + if (GETSTRPREF(kPrintHeaderStrRight, &str)) { aPS->SetHeaderStrRight(str.get()); DUMP_STR(kReadStr, kPrintHeaderStrRight, str.get()); } } if (aFlags & nsIPrintSettings::kInitSaveFooterLeft) { - if (GETSTRPREF(kPrintFooterStrLeft, str)) { + if (GETSTRPREF(kPrintFooterStrLeft, &str)) { aPS->SetFooterStrLeft(str.get()); DUMP_STR(kReadStr, kPrintFooterStrLeft, str.get()); } } if (aFlags & nsIPrintSettings::kInitSaveFooterCenter) { - if (GETSTRPREF(kPrintFooterStrCenter, str)) { + if (GETSTRPREF(kPrintFooterStrCenter, &str)) { aPS->SetFooterStrCenter(str.get()); DUMP_STR(kReadStr, kPrintFooterStrCenter, str.get()); } } if (aFlags & nsIPrintSettings::kInitSaveFooterRight) { - if (GETSTRPREF(kPrintFooterStrRight, str)) { + if (GETSTRPREF(kPrintFooterStrRight, &str)) { aPS->SetFooterStrRight(str.get()); DUMP_STR(kReadStr, kPrintFooterStrRight, str.get()); } @@ -453,7 +446,7 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, } if (aFlags & nsIPrintSettings::kInitSavePlexName) { - if (GETSTRPREF(kPrintPlexName, str)) { + if (GETSTRPREF(kPrintPlexName, &str)) { aPS->SetPlexName(str.get()); DUMP_STR(kReadStr, kPrintPlexName, str.get()); } @@ -467,14 +460,14 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, } if (aFlags & nsIPrintSettings::kInitSaveColorspace) { - if (GETSTRPREF(kPrintColorspace, str)) { + if (GETSTRPREF(kPrintColorspace, &str)) { aPS->SetColorspace(str.get()); DUMP_STR(kReadStr, kPrintColorspace, str.get()); } } if (aFlags & nsIPrintSettings::kInitSaveResolutionName) { - if (GETSTRPREF(kPrintResolutionName, str)) { + if (GETSTRPREF(kPrintResolutionName, &str)) { aPS->SetResolutionName(str.get()); DUMP_STR(kReadStr, kPrintResolutionName, str.get()); } @@ -495,7 +488,7 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, } if (aFlags & nsIPrintSettings::kInitSavePrintCommand) { - if (GETSTRPREF(kPrintCommand, str)) { + if (GETSTRPREF(kPrintCommand, &str)) { aPS->SetPrintCommand(str.get()); DUMP_STR(kReadStr, kPrintCommand, str.get()); } @@ -509,7 +502,7 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, } if (aFlags & nsIPrintSettings::kInitSaveToFileName) { - if (GETSTRPREF(kPrintToFileName, str)) { + if (GETSTRPREF(kPrintToFileName, &str)) { aPS->SetToFileName(str.get()); DUMP_STR(kReadStr, kPrintToFileName, str.get()); } @@ -551,7 +544,6 @@ nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName, PRUint32 aFlags) { NS_ENSURE_ARG_POINTER(aPS); - NS_ENSURE_STATE(mPrefBranch); nsIntMargin margin; if (aFlags & nsIPrintSettings::kInitSaveMargins) { @@ -621,17 +613,17 @@ nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName, NS_SUCCEEDED(aPS->GetPaperName(&name)) ) { DUMP_INT(kWriteStr, kPrintPaperSizeUnit, sizeUnit); - mPrefBranch->SetIntPref(GetPrefName(kPrintPaperSizeUnit, aPrinterName), - PRInt32(sizeUnit)); + Preferences::SetInt(GetPrefName(kPrintPaperSizeUnit, aPrinterName), + PRInt32(sizeUnit)); DUMP_INT(kWriteStr, kPrintPaperSizeType, sizeType); - mPrefBranch->SetIntPref(GetPrefName(kPrintPaperSizeType, aPrinterName), - PRInt32(sizeType)); + Preferences::SetInt(GetPrefName(kPrintPaperSizeType, aPrinterName), + PRInt32(sizeType)); DUMP_DBL(kWriteStr, kPrintPaperWidth, width); WritePrefDouble(GetPrefName(kPrintPaperWidth, aPrinterName), width); DUMP_DBL(kWriteStr, kPrintPaperHeight, height); WritePrefDouble(GetPrefName(kPrintPaperHeight, aPrinterName), height); DUMP_STR(kWriteStr, kPrintPaperName, name); - WritePrefString(name, GetPrefName(kPrintPaperName, aPrinterName)); + Preferences::SetChar(GetPrefName(kPrintPaperName, aPrinterName), name); } } @@ -645,8 +637,7 @@ nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName, if (NS_SUCCEEDED(aPS->GetPrintOptions(nsIPrintSettings::kPrintEvenPages, &b))) { DUMP_BOOL(kWriteStr, kPrintEvenPages, b); - mPrefBranch->SetBoolPref(GetPrefName(kPrintEvenPages, aPrinterName), - b); + Preferences::SetBool(GetPrefName(kPrintEvenPages, aPrinterName), b); } } @@ -654,130 +645,134 @@ nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName, if (NS_SUCCEEDED(aPS->GetPrintOptions(nsIPrintSettings::kPrintOddPages, &b))) { DUMP_BOOL(kWriteStr, kPrintOddPages, b); - mPrefBranch->SetBoolPref(GetPrefName(kPrintOddPages, aPrinterName), - b); + Preferences::SetBool(GetPrefName(kPrintOddPages, aPrinterName), b); } } if (aFlags & nsIPrintSettings::kInitSaveHeaderLeft) { if (NS_SUCCEEDED(aPS->GetHeaderStrLeft(&uStr))) { DUMP_STR(kWriteStr, kPrintHeaderStrLeft, uStr); - WritePrefString(uStr, GetPrefName(kPrintHeaderStrLeft, aPrinterName)); + Preferences::SetChar(GetPrefName(kPrintHeaderStrLeft, aPrinterName), + uStr); } } if (aFlags & nsIPrintSettings::kInitSaveHeaderCenter) { if (NS_SUCCEEDED(aPS->GetHeaderStrCenter(&uStr))) { DUMP_STR(kWriteStr, kPrintHeaderStrCenter, uStr); - WritePrefString(uStr, GetPrefName(kPrintHeaderStrCenter, aPrinterName)); + Preferences::SetChar(GetPrefName(kPrintHeaderStrCenter, aPrinterName), + uStr); } } if (aFlags & nsIPrintSettings::kInitSaveHeaderRight) { if (NS_SUCCEEDED(aPS->GetHeaderStrRight(&uStr))) { DUMP_STR(kWriteStr, kPrintHeaderStrRight, uStr); - WritePrefString(uStr, GetPrefName(kPrintHeaderStrRight, aPrinterName)); + Preferences::SetChar(GetPrefName(kPrintHeaderStrRight, aPrinterName), + uStr); } } if (aFlags & nsIPrintSettings::kInitSaveFooterLeft) { if (NS_SUCCEEDED(aPS->GetFooterStrLeft(&uStr))) { DUMP_STR(kWriteStr, kPrintFooterStrLeft, uStr); - WritePrefString(uStr, GetPrefName(kPrintFooterStrLeft, aPrinterName)); + Preferences::SetChar(GetPrefName(kPrintFooterStrLeft, aPrinterName), + uStr); } } if (aFlags & nsIPrintSettings::kInitSaveFooterCenter) { if (NS_SUCCEEDED(aPS->GetFooterStrCenter(&uStr))) { DUMP_STR(kWriteStr, kPrintFooterStrCenter, uStr); - WritePrefString(uStr, GetPrefName(kPrintFooterStrCenter, aPrinterName)); + Preferences::SetChar(GetPrefName(kPrintFooterStrCenter, aPrinterName), + uStr); } } if (aFlags & nsIPrintSettings::kInitSaveFooterRight) { if (NS_SUCCEEDED(aPS->GetFooterStrRight(&uStr))) { DUMP_STR(kWriteStr, kPrintFooterStrRight, uStr); - WritePrefString(uStr, GetPrefName(kPrintFooterStrRight, aPrinterName)); + Preferences::SetChar(GetPrefName(kPrintFooterStrRight, aPrinterName), + uStr); } } if (aFlags & nsIPrintSettings::kInitSaveBGColors) { if (NS_SUCCEEDED(aPS->GetPrintBGColors(&b))) { DUMP_BOOL(kWriteStr, kPrintBGColors, b); - mPrefBranch->SetBoolPref(GetPrefName(kPrintBGColors, aPrinterName), b); + Preferences::SetBool(GetPrefName(kPrintBGColors, aPrinterName), b); } } if (aFlags & nsIPrintSettings::kInitSaveBGImages) { if (NS_SUCCEEDED(aPS->GetPrintBGImages(&b))) { DUMP_BOOL(kWriteStr, kPrintBGImages, b); - mPrefBranch->SetBoolPref(GetPrefName(kPrintBGImages, aPrinterName), b); + Preferences::SetBool(GetPrefName(kPrintBGImages, aPrinterName), b); } } if (aFlags & nsIPrintSettings::kInitSaveReversed) { if (NS_SUCCEEDED(aPS->GetPrintReversed(&b))) { DUMP_BOOL(kWriteStr, kPrintReversed, b); - mPrefBranch->SetBoolPref(GetPrefName(kPrintReversed, aPrinterName), b); + Preferences::SetBool(GetPrefName(kPrintReversed, aPrinterName), b); } } if (aFlags & nsIPrintSettings::kInitSaveInColor) { if (NS_SUCCEEDED(aPS->GetPrintInColor(&b))) { DUMP_BOOL(kWriteStr, kPrintInColor, b); - mPrefBranch->SetBoolPref(GetPrefName(kPrintInColor, aPrinterName), b); + Preferences::SetBool(GetPrefName(kPrintInColor, aPrinterName), b); } } if (aFlags & nsIPrintSettings::kInitSavePlexName) { if (NS_SUCCEEDED(aPS->GetPlexName(&uStr))) { DUMP_STR(kWriteStr, kPrintPlexName, uStr); - WritePrefString(uStr, GetPrefName(kPrintPlexName, aPrinterName)); + Preferences::SetChar(GetPrefName(kPrintPlexName, aPrinterName), uStr); } } if (aFlags & nsIPrintSettings::kInitSavePaperData) { if (NS_SUCCEEDED(aPS->GetPaperData(&iVal16))) { DUMP_INT(kWriteStr, kPrintPaperData, iVal16); - mPrefBranch->SetIntPref(GetPrefName(kPrintPaperData, aPrinterName), - PRInt32(iVal16)); + Preferences::SetInt(GetPrefName(kPrintPaperData, aPrinterName), + PRInt32(iVal16)); } } if (aFlags & nsIPrintSettings::kInitSaveColorspace) { if (NS_SUCCEEDED(aPS->GetColorspace(&uStr))) { DUMP_STR(kWriteStr, kPrintColorspace, uStr); - WritePrefString(uStr, GetPrefName(kPrintColorspace, aPrinterName)); + Preferences::SetChar(GetPrefName(kPrintColorspace, aPrinterName), uStr); } } if (aFlags & nsIPrintSettings::kInitSaveResolutionName) { if (NS_SUCCEEDED(aPS->GetResolutionName(&uStr))) { DUMP_STR(kWriteStr, kPrintResolutionName, uStr); - WritePrefString(uStr, GetPrefName(kPrintResolutionName, aPrinterName)); + Preferences::SetChar(GetPrefName(kPrintResolutionName, aPrinterName), + uStr); } } if (aFlags & nsIPrintSettings::kInitSaveDownloadFonts) { if (NS_SUCCEEDED(aPS->GetDownloadFonts(&b))) { DUMP_BOOL(kWriteStr, kPrintDownloadFonts, b); - mPrefBranch->SetBoolPref(GetPrefName(kPrintDownloadFonts, aPrinterName), - b); + Preferences::SetBool(GetPrefName(kPrintDownloadFonts, aPrinterName), b); } } if (aFlags & nsIPrintSettings::kInitSaveOrientation) { if (NS_SUCCEEDED(aPS->GetOrientation(&iVal))) { DUMP_INT(kWriteStr, kPrintOrientation, iVal); - mPrefBranch->SetIntPref(GetPrefName(kPrintOrientation, aPrinterName), - iVal); + Preferences::SetInt(GetPrefName(kPrintOrientation, aPrinterName), iVal); } } if (aFlags & nsIPrintSettings::kInitSavePrintCommand) { if (NS_SUCCEEDED(aPS->GetPrintCommand(&uStr))) { DUMP_STR(kWriteStr, kPrintCommand, uStr); - WritePrefString(uStr, GetPrefName(kPrintCommand, aPrinterName)); + Preferences::SetChar(GetPrefName(kPrintCommand, aPrinterName), uStr); } } @@ -786,35 +781,35 @@ nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName, && aPrinterName.IsEmpty()) { if (NS_SUCCEEDED(aPS->GetPrinterName(&uStr))) { DUMP_STR(kWriteStr, kPrinterName, uStr); - WritePrefString(uStr, kPrinterName); + Preferences::SetChar(kPrinterName, uStr); } } if (aFlags & nsIPrintSettings::kInitSavePrintToFile) { if (NS_SUCCEEDED(aPS->GetPrintToFile(&b))) { DUMP_BOOL(kWriteStr, kPrintToFile, b); - mPrefBranch->SetBoolPref(GetPrefName(kPrintToFile, aPrinterName), b); + Preferences::SetBool(GetPrefName(kPrintToFile, aPrinterName), b); } } if (aFlags & nsIPrintSettings::kInitSaveToFileName) { if (NS_SUCCEEDED(aPS->GetToFileName(&uStr))) { DUMP_STR(kWriteStr, kPrintToFileName, uStr); - WritePrefString(uStr, GetPrefName(kPrintToFileName, aPrinterName)); + Preferences::SetChar(GetPrefName(kPrintToFileName, aPrinterName), uStr); } } if (aFlags & nsIPrintSettings::kInitSavePageDelay) { if (NS_SUCCEEDED(aPS->GetPrintPageDelay(&iVal))) { DUMP_INT(kWriteStr, kPrintPageDelay, iVal); - mPrefBranch->SetIntPref(GetPrefName(kPrintPageDelay, aPrinterName), iVal); + Preferences::SetInt(GetPrefName(kPrintPageDelay, aPrinterName), iVal); } } if (aFlags & nsIPrintSettings::kInitSaveShrinkToFit) { if (NS_SUCCEEDED(aPS->GetShrinkToFit(&b))) { DUMP_BOOL(kWriteStr, kPrintShrinkToFit, b); - mPrefBranch->SetBoolPref(GetPrefName(kPrintShrinkToFit, aPrinterName), b); + Preferences::SetBool(GetPrefName(kPrintShrinkToFit, aPrinterName), b); } } @@ -911,7 +906,7 @@ nsPrintOptions::GetDefaultPrinterName(PRUnichar * *aDefaultPrinterName) // Look up the printer from the last print job nsAutoString lastPrinterName; - ReadPrefString(kPrinterName, lastPrinterName); + Preferences::GetChar(kPrinterName, &lastPrinterName); if (!lastPrinterName.IsEmpty()) { // Verify it's still a valid printer nsCOMPtr printers; @@ -1014,7 +1009,6 @@ NS_IMETHODIMP nsPrintOptions::GetPrinterPrefInt(nsIPrintSettings *aPrintSettings, const PRUnichar *aPrefName, PRInt32 *_retval) { - NS_ENSURE_STATE(mPrefBranch); NS_ENSURE_ARG_POINTER(aPrintSettings); NS_ENSURE_ARG_POINTER(aPrefName); @@ -1029,7 +1023,7 @@ nsPrintOptions::GetPrinterPrefInt(nsIPrintSettings *aPrintSettings, NS_ENSURE_TRUE(prefName, NS_ERROR_FAILURE); PRInt32 iVal; - nsresult rv = mPrefBranch->GetIntPref(prefName, &iVal); + nsresult rv = Preferences::GetInt(prefName, &iVal); NS_ENSURE_SUCCESS(rv, rv); *_retval = iVal; @@ -1096,57 +1090,15 @@ nsPrintOptions::SavePrintSettingsToPrefs(nsIPrintSettings *aPS, //----------------------------------------------------- //-- Protected Methods -------------------------------- //----------------------------------------------------- -nsresult -nsPrintOptions::ReadPrefString(const char * aPrefId, nsAString& aString) -{ - NS_ENSURE_STATE(mPrefBranch); - NS_ENSURE_ARG_POINTER(aPrefId); - - nsXPIDLCString str; - nsresult rv = mPrefBranch->GetCharPref(aPrefId, getter_Copies(str)); - NS_ENSURE_SUCCESS(rv, rv); - - CopyUTF8toUTF16(str.get(), aString); - - return rv; -} - -nsresult -nsPrintOptions::WritePrefString(PRUnichar*& aStr, const char* aPrefId) -{ - NS_ENSURE_STATE(mPrefBranch); - NS_ENSURE_ARG_POINTER(aStr); - NS_ENSURE_ARG_POINTER(aPrefId); - - nsresult rv = mPrefBranch->SetCharPref(aPrefId, - NS_ConvertUTF16toUTF8(aStr).get()); - - nsMemory::Free(aStr); - aStr = nsnull; - return rv; -} - -nsresult -nsPrintOptions::WritePrefString(const char * aPrefId, const nsAString& aString) -{ - NS_ENSURE_STATE(mPrefBranch); - NS_ENSURE_ARG_POINTER(aPrefId); - - return mPrefBranch->SetCharPref(aPrefId, - NS_ConvertUTF16toUTF8(aString).get()); -} - nsresult nsPrintOptions::ReadPrefDouble(const char * aPrefId, double& aVal) { - NS_ENSURE_STATE(mPrefBranch); NS_ENSURE_ARG_POINTER(aPrefId); - char * str; - nsresult rv = mPrefBranch->GetCharPref(aPrefId, &str); - if (NS_SUCCEEDED(rv) && str) { - aVal = atof(str); - nsMemory::Free(str); + nsCAutoString str; + nsresult rv = Preferences::GetChar(aPrefId, &str); + if (NS_SUCCEEDED(rv) && !str.IsEmpty()) { + aVal = atof(str.get()); } return rv; } @@ -1154,29 +1106,24 @@ nsPrintOptions::ReadPrefDouble(const char * aPrefId, double& aVal) nsresult nsPrintOptions::WritePrefDouble(const char * aPrefId, double aVal) { - NS_ENSURE_STATE(mPrefBranch); NS_ENSURE_ARG_POINTER(aPrefId); - char str[16]; // max 9 chars in below snprintf(), 16 will do nicely - int ret = PR_snprintf(str, sizeof(str), "%6.2f", aVal); - NS_ENSURE_TRUE(ret >= 0, NS_ERROR_FAILURE); + nsPrintfCString str("%6.2f", aVal); + NS_ENSURE_TRUE(!str.IsEmpty(), NS_ERROR_FAILURE); - return mPrefBranch->SetCharPref(aPrefId, str); + return Preferences::SetChar(aPrefId, str); } void nsPrintOptions::ReadInchesToTwipsPref(const char * aPrefId, PRInt32& aTwips, const char * aMarginPref) { - if (!mPrefBranch) { - return; + nsCAutoString str; + nsresult rv = Preferences::GetChar(aPrefId, &str); + if (NS_FAILED(rv) || str.IsEmpty()) { + rv = Preferences::GetChar(aMarginPref, &str); } - - char * str = nsnull; - nsresult rv = mPrefBranch->GetCharPref(aPrefId, &str); - if (NS_FAILED(rv) || !str) - rv = mPrefBranch->GetCharPref(aMarginPref, &str); - if (NS_SUCCEEDED(rv) && str) { + if (NS_SUCCEEDED(rv) && !str.IsEmpty()) { nsAutoString justStr; justStr.AssignWithConversion(str); PRInt32 errCode; @@ -1186,36 +1133,27 @@ nsPrintOptions::ReadInchesToTwipsPref(const char * aPrefId, PRInt32& aTwips, } else { aTwips = 0; } - nsMemory::Free(str); } } void nsPrintOptions::WriteInchesFromTwipsPref(const char * aPrefId, PRInt32 aTwips) { - if (!mPrefBranch) { - return; - } - double inches = NS_TWIPS_TO_INCHES(aTwips); nsCAutoString inchesStr; inchesStr.AppendFloat(inches); - mPrefBranch->SetCharPref(aPrefId, inchesStr.get()); + Preferences::SetChar(aPrefId, inchesStr); } void nsPrintOptions::ReadInchesIntToTwipsPref(const char * aPrefId, PRInt32& aTwips, const char * aMarginPref) { - if (!mPrefBranch) { - return; - } - PRInt32 value; - nsresult rv = mPrefBranch->GetIntPref(aPrefId, &value); + nsresult rv = Preferences::GetInt(aPrefId, &value); if (NS_FAILED(rv)) { - rv = mPrefBranch->GetIntPref(aMarginPref, &value); + rv = Preferences::GetInt(aMarginPref, &value); } if (NS_SUCCEEDED(rv)) { aTwips = NS_INCHES_TO_INT_TWIPS(float(value)/100.0f); @@ -1227,11 +1165,8 @@ nsPrintOptions::ReadInchesIntToTwipsPref(const char * aPrefId, PRInt32& aTwips, void nsPrintOptions::WriteInchesIntFromTwipsPref(const char * aPrefId, PRInt32 aTwips) { - if (!mPrefBranch) { - return; - } - - mPrefBranch->SetIntPref(aPrefId, PRInt32(NS_TWIPS_TO_INCHES(aTwips)*100.0f + 0.5f)); + Preferences::SetInt(aPrefId, + PRInt32(NS_TWIPS_TO_INCHES(aTwips) * 100.0f + 0.5f)); } void @@ -1240,13 +1175,11 @@ nsPrintOptions::ReadJustification(const char * aPrefId, PRInt16& aJust, { aJust = aInitValue; nsAutoString justStr; - if (NS_SUCCEEDED(ReadPrefString(aPrefId, justStr))) { + if (NS_SUCCEEDED(Preferences::GetChar(aPrefId, &justStr))) { if (justStr.EqualsASCII(kJustRight)) { aJust = nsIPrintSettings::kJustRight; - } else if (justStr.EqualsASCII(kJustCenter)) { aJust = nsIPrintSettings::kJustCenter; - } else { aJust = nsIPrintSettings::kJustLeft; } @@ -1259,15 +1192,15 @@ nsPrintOptions::WriteJustification(const char * aPrefId, PRInt16 aJust) { switch (aJust) { case nsIPrintSettings::kJustLeft: - mPrefBranch->SetCharPref(aPrefId, kJustLeft); + Preferences::SetChar(aPrefId, kJustLeft); break; case nsIPrintSettings::kJustCenter: - mPrefBranch->SetCharPref(aPrefId, kJustCenter); + Preferences::SetChar(aPrefId, kJustCenter); break; case nsIPrintSettings::kJustRight: - mPrefBranch->SetCharPref(aPrefId, kJustRight); + Preferences::SetChar(aPrefId, kJustRight); break; } //switch } diff --git a/widget/src/xpwidgets/nsPrintOptionsImpl.h b/widget/src/xpwidgets/nsPrintOptionsImpl.h index 53e01e5c288..5d40071bfb5 100644 --- a/widget/src/xpwidgets/nsPrintOptionsImpl.h +++ b/widget/src/xpwidgets/nsPrintOptionsImpl.h @@ -44,7 +44,6 @@ #include "nsCOMPtr.h" #include "nsIPrintOptions.h" #include "nsIPrintSettingsService.h" -#include "nsIPrefBranch.h" #include "nsString.h" #include "nsFont.h" @@ -83,13 +82,6 @@ protected: const char * aMarginPref); void WriteInchesIntFromTwipsPref(const char * aPrefId, PRInt32 aTwips); - nsresult ReadPrefString(const char * aPrefId, nsAString& aString); - /** - * method WritePrefString - * Writes PRUnichar* to Prefs and deletes the contents of aString - */ - nsresult WritePrefString(const char * aPrefId, const nsAString& aString); - nsresult WritePrefString(PRUnichar*& aStr, const char* aPrefId); nsresult ReadPrefDouble(const char * aPrefId, double& aVal); nsresult WritePrefDouble(const char * aPrefId, double aVal); @@ -125,8 +117,6 @@ protected: nsCString mPrefName; - nsCOMPtr mPrefBranch; - private: // These are not supported and are not implemented! nsPrintOptions(const nsPrintOptions& x); diff --git a/widget/src/xpwidgets/nsXPLookAndFeel.cpp b/widget/src/xpwidgets/nsXPLookAndFeel.cpp index d91fab5b428..e9a213ebcd9 100644 --- a/widget/src/xpwidgets/nsXPLookAndFeel.cpp +++ b/widget/src/xpwidgets/nsXPLookAndFeel.cpp @@ -38,13 +38,9 @@ #include "nscore.h" #include "nsXPLookAndFeel.h" -#include "nsIServiceManager.h" -#include "nsIPrefBranch2.h" -#include "nsIPrefBranch.h" -#include "nsIPrefService.h" -#include "nsIObserver.h" #include "nsCRT.h" #include "nsFont.h" +#include "mozilla/Preferences.h" #include "gfxPlatform.h" #include "qcms.h" @@ -53,6 +49,8 @@ #include "nsSize.h" #endif +using namespace mozilla; + NS_IMPL_ISUPPORTS2(nsXPLookAndFeel, nsILookAndFeel, nsIObserver) nsLookAndFeelIntPref nsXPLookAndFeel::sIntPrefs[] = @@ -222,124 +220,113 @@ nsXPLookAndFeel::nsXPLookAndFeel() : nsILookAndFeel() void nsXPLookAndFeel::IntPrefChanged (nsLookAndFeelIntPref *data) { - if (data) - { - nsCOMPtr prefService(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (prefService) - { - PRInt32 intpref; - nsresult rv = prefService->GetIntPref(data->name, &intpref); - if (NS_SUCCEEDED(rv)) - { - data->intVar = intpref; - data->isSet = PR_TRUE; -#ifdef DEBUG_akkana - printf("====== Changed int pref %s to %d\n", data->name, data->intVar); -#endif - } - } + if (!data) { + return; } + + PRInt32 intpref; + nsresult rv = Preferences::GetInt(data->name, &intpref); + if (NS_FAILED(rv)) { + return; + } + data->intVar = intpref; + data->isSet = PR_TRUE; +#ifdef DEBUG_akkana + printf("====== Changed int pref %s to %d\n", data->name, data->intVar); +#endif } void nsXPLookAndFeel::FloatPrefChanged (nsLookAndFeelFloatPref *data) { - if (data) - { - nsCOMPtr prefService(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (prefService) - { - PRInt32 intpref; - nsresult rv = prefService->GetIntPref(data->name, &intpref); - if (NS_SUCCEEDED(rv)) - { - data->floatVar = (float)intpref / 100.; - data->isSet = PR_TRUE; -#ifdef DEBUG_akkana - printf("====== Changed float pref %s to %f\n", data->name, data->floatVar); -#endif - } - } + if (!data) { + return; } + + PRInt32 intpref; + nsresult rv = Preferences::GetInt(data->name, &intpref); + if (NS_FAILED(rv)) { + return; + } + data->floatVar = (float)intpref / 100.; + data->isSet = PR_TRUE; +#ifdef DEBUG_akkana + printf("====== Changed float pref %s to %f\n", data->name, data->floatVar); +#endif } void nsXPLookAndFeel::ColorPrefChanged (unsigned int index, const char *prefName) { - nsCOMPtr prefService(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (prefService) { - nsXPIDLCString colorStr; - nsresult rv = prefService->GetCharPref(prefName, getter_Copies(colorStr)); - if (NS_SUCCEEDED(rv) && !colorStr.IsEmpty()) { - nscolor thecolor; - if (colorStr[0] == '#') { - if (NS_HexToRGB(NS_ConvertASCIItoUTF16(Substring(colorStr, 1, colorStr.Length() - 1)), - &thecolor)) { - PRInt32 id = NS_PTR_TO_INT32(index); - CACHE_COLOR(id, thecolor); - } - } - else if (NS_ColorNameToRGB(NS_ConvertASCIItoUTF16(colorStr), &thecolor)) { + nsAutoString colorStr; + nsresult rv = Preferences::GetChar(prefName, &colorStr); + if (NS_FAILED(rv)) { + return; + } + if (!colorStr.IsEmpty()) { + nscolor thecolor; + if (colorStr[0] == PRUnichar('#')) { + if (NS_HexToRGB(nsDependentString( + Substring(colorStr, 1, colorStr.Length() - 1)), + &thecolor)) { PRInt32 id = NS_PTR_TO_INT32(index); CACHE_COLOR(id, thecolor); -#ifdef DEBUG_akkana - printf("====== Changed color pref %s to 0x%lx\n", - prefName, thecolor); -#endif } - } else if (colorStr.IsEmpty()) { - // Reset to the default color, by clearing the cache - // to force lookup when the color is next used + } else if (NS_ColorNameToRGB(colorStr, &thecolor)) { PRInt32 id = NS_PTR_TO_INT32(index); - CLEAR_COLOR_CACHE(id); + CACHE_COLOR(id, thecolor); +#ifdef DEBUG_akkana + printf("====== Changed color pref %s to 0x%lx\n", + prefName, thecolor); +#endif } + } else { + // Reset to the default color, by clearing the cache + // to force lookup when the color is next used + PRInt32 id = NS_PTR_TO_INT32(index); + CLEAR_COLOR_CACHE(id); } } void -nsXPLookAndFeel::InitFromPref(nsLookAndFeelIntPref* aPref, nsIPrefBranch* aPrefBranch) +nsXPLookAndFeel::InitFromPref(nsLookAndFeelIntPref* aPref) { PRInt32 intpref; - nsresult rv = aPrefBranch->GetIntPref(aPref->name, &intpref); - if (NS_SUCCEEDED(rv)) - { + nsresult rv = Preferences::GetInt(aPref->name, &intpref); + if (NS_SUCCEEDED(rv)) { aPref->isSet = PR_TRUE; aPref->intVar = intpref; } } void -nsXPLookAndFeel::InitFromPref(nsLookAndFeelFloatPref* aPref, nsIPrefBranch* aPrefBranch) +nsXPLookAndFeel::InitFromPref(nsLookAndFeelFloatPref* aPref) { PRInt32 intpref; - nsresult rv = aPrefBranch->GetIntPref(aPref->name, &intpref); - if (NS_SUCCEEDED(rv)) - { + nsresult rv = Preferences::GetInt(aPref->name, &intpref); + if (NS_SUCCEEDED(rv)) { aPref->isSet = PR_TRUE; aPref->floatVar = (float)intpref / 100.; } } void -nsXPLookAndFeel::InitColorFromPref(PRInt32 i, nsIPrefBranch* aPrefBranch) +nsXPLookAndFeel::InitColorFromPref(PRInt32 i) { - nsXPIDLCString colorStr; - nsresult rv = aPrefBranch->GetCharPref(sColorPrefs[i], getter_Copies(colorStr)); - if (NS_SUCCEEDED(rv) && !colorStr.IsEmpty()) - { - nsAutoString colorNSStr; colorNSStr.AssignWithConversion(colorStr); - nscolor thecolor; - if (colorNSStr[0] == '#') { - nsAutoString hexString; - colorNSStr.Right(hexString, colorNSStr.Length() - 1); - if (NS_HexToRGB(hexString, &thecolor)) { - CACHE_COLOR(i, thecolor); - } - } - else if (NS_ColorNameToRGB(colorNSStr, &thecolor)) - { + nsAutoString colorStr; + nsresult rv = Preferences::GetChar(sColorPrefs[i], &colorStr); + if (NS_FAILED(rv) || colorStr.IsEmpty()) { + return; + } + nscolor thecolor; + if (colorStr[0] == PRUnichar('#')) { + nsAutoString hexString; + colorStr.Right(hexString, colorStr.Length() - 1); + if (NS_HexToRGB(hexString, &thecolor)) { CACHE_COLOR(i, thecolor); } + } else if (NS_ColorNameToRGB(colorStr, &thecolor)) { + CACHE_COLOR(i, thecolor); } } @@ -389,31 +376,24 @@ nsXPLookAndFeel::Init() // protects against some other process writing to our static variables. sInitialized = PR_TRUE; - nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (!prefs) - return; - nsCOMPtr prefBranchInternal(do_QueryInterface(prefs)); - if (!prefBranchInternal) - return; - unsigned int i; for (i = 0; i < NS_ARRAY_LENGTH(sIntPrefs); ++i) { - InitFromPref(&sIntPrefs[i], prefs); - prefBranchInternal->AddObserver(sIntPrefs[i].name, this, PR_FALSE); + InitFromPref(&sIntPrefs[i]); + Preferences::AddStrongObserver(this, sIntPrefs[i].name); } for (i = 0; i < NS_ARRAY_LENGTH(sFloatPrefs); ++i) { - InitFromPref(&sFloatPrefs[i], prefs); - prefBranchInternal->AddObserver(sFloatPrefs[i].name, this, PR_FALSE); + InitFromPref(&sFloatPrefs[i]); + Preferences::AddStrongObserver(this, sFloatPrefs[i].name); } for (i = 0; i < NS_ARRAY_LENGTH(sColorPrefs); ++i) { - InitColorFromPref(i, prefs); - prefBranchInternal->AddObserver(sColorPrefs[i], this, PR_FALSE); + InitColorFromPref(i); + Preferences::AddStrongObserver(this, sColorPrefs[i]); } PRBool val; - if (NS_SUCCEEDED(prefs->GetBoolPref("ui.use_native_colors", &val))) { + if (NS_SUCCEEDED(Preferences::GetBool("ui.use_native_colors", &val))) { sUseNativeColors = val; } } @@ -625,12 +605,12 @@ nsXPLookAndFeel::GetMetric(const nsMetricID aID, PRInt32& aMetric) break; } - for (unsigned int i = 0; i < ((sizeof (sIntPrefs) / sizeof (*sIntPrefs))); ++i) - if (sIntPrefs[i].isSet && (sIntPrefs[i].id == aID)) - { + for (unsigned int i = 0; i < NS_ARRAY_LENGTH(sIntPrefs); ++i) { + if (sIntPrefs[i].isSet && (sIntPrefs[i].id == aID)) { aMetric = sIntPrefs[i].intVar; return NS_OK; } + } return NS_ERROR_NOT_AVAILABLE; } @@ -641,12 +621,12 @@ nsXPLookAndFeel::GetMetric(const nsMetricFloatID aID, float& aMetric) if (!sInitialized) Init(); - for (unsigned int i = 0; i < ((sizeof (sFloatPrefs) / sizeof (*sFloatPrefs))); ++i) - if (sFloatPrefs[i].isSet && sFloatPrefs[i].id == aID) - { + for (unsigned int i = 0; i < NS_ARRAY_LENGTH(sFloatPrefs); ++i) { + if (sFloatPrefs[i].isSet && sFloatPrefs[i].id == aID) { aMetric = sFloatPrefs[i].floatVar; return NS_OK; } + } return NS_ERROR_NOT_AVAILABLE; } diff --git a/widget/src/xpwidgets/nsXPLookAndFeel.h b/widget/src/xpwidgets/nsXPLookAndFeel.h index 4b95a084515..dc299b574b9 100644 --- a/widget/src/xpwidgets/nsXPLookAndFeel.h +++ b/widget/src/xpwidgets/nsXPLookAndFeel.h @@ -41,7 +41,6 @@ #include "nsILookAndFeel.h" #include "nsCOMPtr.h" #include "nsIObserver.h" -#include "nsIPrefBranch.h" #ifdef NS_DEBUG struct nsSize; @@ -116,9 +115,9 @@ protected: void IntPrefChanged(nsLookAndFeelIntPref *data); void FloatPrefChanged(nsLookAndFeelFloatPref *data); void ColorPrefChanged(unsigned int index, const char *prefName); - void InitFromPref(nsLookAndFeelIntPref* aPref, nsIPrefBranch* aPrefBranch); - void InitFromPref(nsLookAndFeelFloatPref* aPref, nsIPrefBranch* aPrefBranch); - void InitColorFromPref(PRInt32 aIndex, nsIPrefBranch* aPrefBranch); + void InitFromPref(nsLookAndFeelIntPref* aPref); + void InitFromPref(nsLookAndFeelFloatPref* aPref); + void InitColorFromPref(PRInt32 aIndex); virtual nsresult NativeGetColor(const nsColorID aID, nscolor& aColor) = 0; PRBool IsSpecialColor(const nsColorID aID, nscolor &aColor); diff --git a/xpcom/Makefile.in b/xpcom/Makefile.in index 6e1a5471668..8af06ee85bd 100644 --- a/xpcom/Makefile.in +++ b/xpcom/Makefile.in @@ -61,10 +61,6 @@ DIRS = \ build \ $(NULL) -ifndef MOZ_ENABLE_LIBXUL -DIRS += stub -endif - ifeq ($(OS_ARCH),WINNT) ifdef MOZ_DEBUG DIRS += windbgdlg @@ -79,12 +75,10 @@ TOOL_DIRS += \ proxy/tests # Can't build internal xptcall tests that use symbols which are not exported. -ifndef MOZ_ENABLE_LIBXUL -TOOL_DIRS += \ - reflect/xptinfo/tests \ - reflect/xptcall/tests \ - $(NULL) -endif +#TOOL_DIRS += \ +# reflect/xptinfo/tests \ +# reflect/xptcall/tests \ +# $(NULL) endif # xpcom-config.h is generated by configure diff --git a/xpcom/base/nsDebugImpl.cpp b/xpcom/base/nsDebugImpl.cpp index 5795caaeebe..42e9af82afe 100644 --- a/xpcom/base/nsDebugImpl.cpp +++ b/xpcom/base/nsDebugImpl.cpp @@ -329,7 +329,7 @@ NS_DebugBreak(PRUint32 aSeverity, const char *aStr, const char *aExpr, return; case NS_DEBUG_ABORT: { -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#if defined(MOZ_CRASHREPORTER) nsCString note("xpcom_runtime_abort("); note += buf.buffer; note += ")"; diff --git a/xpcom/base/nsMemoryReporterManager.h b/xpcom/base/nsMemoryReporterManager.h index 951399e7b24..98f4bff96b1 100644 --- a/xpcom/base/nsMemoryReporterManager.h +++ b/xpcom/base/nsMemoryReporterManager.h @@ -20,9 +20,10 @@ public: ~nsMemoryReporter(); protected: - nsCString mPath, mDesc; - PRInt32 mKind; - PRInt64 mMemoryUsed; + nsCString mPath; + PRInt32 mKind; + nsCString mDesc; + PRInt64 mMemoryUsed; }; diff --git a/xpcom/base/nscore.h b/xpcom/base/nscore.h index c1ddece0e43..c1f8ab54676 100644 --- a/xpcom/base/nscore.h +++ b/xpcom/base/nscore.h @@ -295,15 +295,7 @@ #define XPCOM_API(type) IMPORT_XPCOM_API(type) #endif -#ifdef MOZ_ENABLE_LIBXUL #define NS_COM -#elif defined(_IMPL_NS_COM) -#define NS_COM NS_EXPORT -#elif defined(XPCOM_GLUE) -#define NS_COM -#else -#define NS_COM NS_IMPORT -#endif #ifdef MOZILLA_INTERNAL_API # define NS_COM_GLUE NS_COM diff --git a/xpcom/build/Makefile.in b/xpcom/build/Makefile.in index 61e760140a3..c1c087953dc 100644 --- a/xpcom/build/Makefile.in +++ b/xpcom/build/Makefile.in @@ -50,11 +50,7 @@ MODULE = xpcom LIBRARY_NAME = xpcom_core SHORT_LIBNAME = xpcomcor LIBXUL_LIBRARY = 1 - -# This is only a static library in libxul builds -ifdef MOZ_ENABLE_LIBXUL EXPORT_LIBRARY = 1 -endif GRE_MODULE = 1 MOZILLA_INTERNAL_API = 1 @@ -72,12 +68,6 @@ CPPSRCS = \ Omnijar.cpp \ $(NULL) -ifndef MOZ_ENABLE_LIBXUL -ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) -CPPSRCS += dlldeps.cpp -endif -endif - SHARED_LIBRARY_LIBS = \ $(DEPTH)/chrome/src/$(LIB_PREFIX)chrome_s.$(LIB_SUFFIX) \ ../ds/$(LIB_PREFIX)xpcomds_s.$(LIB_SUFFIX) \ @@ -138,10 +128,6 @@ EXPORTS_mozilla = \ # Force use of PIC FORCE_USE_PIC = 1 -ifndef MOZ_ENABLE_LIBXUL -FORCE_SHARED_LIB = 1 -endif - # UNIX98 iconv support OS_LIBS += $(LIBICONV) @@ -189,9 +175,6 @@ OS_LIBS += $(call EXPAND_LIBNAME,shell32 ole32 uuid version) ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC)) OS_LIBS += $(call EXPAND_LIBNAME,imagehlp) endif -ifndef MOZ_ENABLE_LIBXUL -OS_LIBS += $(call EXPAND_LIBNAME,psapi) -endif endif # WINNT export:: $(XPCOM_GLUE_SRC_CSRCS) $(XPCOM_GLUE_SRC_CPPSRCS) $(XPCOM_GLUENS_SRC_CPPSRCS) diff --git a/xpcom/build/dlldeps.cpp b/xpcom/build/dlldeps.cpp deleted file mode 100644 index b5c67b1f2a1..00000000000 --- a/xpcom/build/dlldeps.cpp +++ /dev/null @@ -1,311 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -// Force references to all of the symbols that we want exported from -// the dll that are located in the .lib files we link with - -#ifdef XP_WIN -#include -#include "nsWindowsRegKey.h" -#include "nsSetDllDirectory.h" -#ifdef DEBUG -#include "pure.h" -#endif -#endif -#include "nsXULAppAPI.h" -#include "nsXPCOMGlue.h" -#include "nsVoidArray.h" -#include "nsTArray.h" -#include "nsIAtom.h" -#include "nsFixedSizeAllocator.h" -#include "nsRecyclingAllocator.h" -#include "nsDeque.h" -#include "nsTraceRefcnt.h" -#include "nsTraceRefcntImpl.h" -#include "nsXPIDLString.h" -#include "nsIEnumerator.h" -#include "nsEnumeratorUtils.h" -#include "nsQuickSort.h" -#include "nsString.h" -#include "nsPrintfCString.h" -#include "nsSupportsArray.h" -#include "nsArrayEnumerator.h" -#include "nsProxyRelease.h" -#include "xpt_xdr.h" -#include "xptcall.h" -#include "nsILocalFile.h" -#include "nsIPipe.h" -#include "nsStreamUtils.h" -#include "nsWeakReference.h" -#include "nsTextFormatter.h" -#include "nsIStorageStream.h" -#include "nsStringStream.h" -#include "nsLinebreakConverter.h" -#include "nsIBinaryInputStream.h" -#include "nsIInterfaceRequestor.h" -#include "nsIInterfaceRequestorUtils.h" -#include "nsReadableUtils.h" -#include "nsStaticNameTable.h" -#include "nsProcess.h" -#include "nsStringEnumerator.h" -#include "nsIInputStreamTee.h" -#include "nsCheapSets.h" -#include "nsHashKeys.h" -#include "nsTHashtable.h" -#include "pldhash.h" -#include "nsVariant.h" -#include "nsEscape.h" -#include "nsStreamUtils.h" -#include "nsNativeCharsetUtils.h" -#include "nsInterfaceRequestorAgg.h" -#include "nsHashPropertyBag.h" -#include "nsXPCOMStrings.h" -#include "nsStringBuffer.h" -#include "nsCategoryCache.h" -#include "nsCycleCollectionParticipant.h" -#include "nsCycleCollector.h" -#include "nsThreadUtils.h" -#include "nsTObserverArray.h" -#include "nsWildCard.h" -#include "mozilla/Mutex.h" -#include "mozilla/Monitor.h" -#include "mozilla/CondVar.h" -#include "mozilla/TimeStamp.h" - -using namespace mozilla; - -class nsCStringContainer : private nsStringContainer_base { }; -class nsStringContainer : private nsStringContainer_base { }; - -void XXXNeverCalled() -{ - nsTextFormatter::snprintf(nsnull,0,nsnull); - nsTextFormatter::smprintf(nsnull, nsnull); - nsTextFormatter::smprintf_free(nsnull); - nsVoidArray(); - nsSmallVoidArray(); - { - nsTArray array1(1), array2(1); - PRBool a, b, c; - a = b = c = PR_FALSE; - array1.AppendElement(a); - array2.InsertElementAt(b, 0); - array2.InsertElementAt(c, 0); - array1.AppendElements(array2); - } - { - nsTObserverArray dummyObserverArray; - PRBool a = PR_FALSE; - dummyObserverArray.AppendElement(a); - dummyObserverArray.RemoveElement(a); - dummyObserverArray.Clear(); - } - nsStringHashSet(); - nsCStringHashSet(); - nsInt32HashSet(); - nsVoidHashSet(); - nsCheapStringSet(); - nsCheapInt32Set(); - nsSupportsArray(); - NS_GetNumberOfAtoms(); - NS_NewPipe(nsnull, nsnull, 0, 0, PR_FALSE, PR_FALSE, nsnull); - NS_NewPipe2(nsnull, nsnull, PR_FALSE, PR_FALSE, 0, 0, nsnull); - NS_NewInputStreamReadyEvent(nsnull, nsnull, nsnull); - NS_NewOutputStreamReadyEvent(nsnull, nsnull, nsnull); - NS_AsyncCopy(nsnull, nsnull, nsnull, NS_ASYNCCOPY_VIA_READSEGMENTS, 0, nsnull, nsnull); - { - nsCString temp; - NS_ConsumeStream(nsnull, 0, temp); - } - NS_InputStreamIsBuffered(nsnull); - NS_OutputStreamIsBuffered(nsnull); - NS_CopySegmentToStream(nsnull, nsnull, nsnull, 0, 0, nsnull); - NS_CopySegmentToBuffer(nsnull, nsnull, nsnull, 0, 0, nsnull); - NS_DiscardSegment(nsnull, nsnull, nsnull, 0, 0, nsnull); - NS_WriteSegmentThunk(nsnull, nsnull, nsnull, 0, 0, 0); - NS_NewByteInputStream(nsnull, nsnull, 0, NS_ASSIGNMENT_COPY); - NS_NewCStringInputStream(nsnull, nsCString()); - NS_NewStringInputStream(nsnull, nsString()); - PL_DHashStubEnumRemove(nsnull, nsnull, nsnull, nsnull); - nsIDHashKey::HashKey(nsnull); - nsFixedSizeAllocator a; - nsRecyclingAllocator recyclingAllocator(2); - a.Init(0, 0, 0, 0, 0); - a.Alloc(0); - a.Free(0, 0); - nsDeque d(nsnull); - nsDequeIterator di(d); - nsTraceRefcnt::LogAddCOMPtr(nsnull, nsnull); - nsTraceRefcntImpl::DumpStatistics(); - NS_NewEmptyEnumerator(nsnull); - NS_QuickSort(nsnull, 0, 0, nsnull, nsnull); - nsString(); - NS_ProxyRelease(nsnull, nsnull, PR_FALSE); - XPT_DoString(nsnull, nsnull, nsnull); - XPT_DoHeader(nsnull, nsnull, nsnull); - NS_InvokeByIndex(nsnull, 0, 0, nsnull); - NS_GetWeakReference(nsnull); - nsCOMPtr dummyFoo(do_GetInterface(nsnull)); - NS_NewStorageStream(0,0, nsnull); - nsString foo; - nsPrintfCString bar(""); - nsLinebreakConverter::ConvertStringLineBreaks(foo, - nsLinebreakConverter::eLinebreakAny, nsLinebreakConverter::eLinebreakContent); - NS_NewLocalFile(EmptyString(), PR_FALSE, nsnull); - NS_NewNativeLocalFile(EmptyCString(), PR_FALSE, nsnull); - new nsProcess(); - nsStaticCaseInsensitiveNameTable(); - nsAutoString str1; - str1.AssignWithConversion(nsnull, 0); - nsCAutoString str2; - ToNewUnicode(str1); - ToNewUnicode(str2); - ToNewCString(str1); - ToNewCString(str2); - PL_DHashTableFinish(nsnull); - NS_NewInputStreamTee(nsnull, nsnull, nsnull); - nsCOMArray dummyArray; - NS_NewArrayEnumerator(nsnull, dummyArray); - new nsVariant(); - nsUnescape(nsnull); - nsEscape(nsnull, url_XAlphas); - nsTArray array; - NS_NewStringEnumerator(nsnull, &array); - NS_NewAdoptingStringEnumerator(nsnull, &array); - nsTArray carray; - NS_NewUTF8StringEnumerator(nsnull, &carray); - NS_NewAdoptingUTF8StringEnumerator(nsnull, &carray); - nsVoidableString str3; - { - nsAdoptingCString foo, bar; - foo = bar; - } - { - nsAdoptingString foo, bar; - foo = bar; - } - NS_CopyNativeToUnicode(str2, str1); - NS_CopyUnicodeToNative(str1, str2); - { - nsID id; - CallCreateInstance(id, nsnull, id, nsnull); - CallCreateInstance("", nsnull, id, nsnull); - CallGetClassObject(id, id, nsnull); - CallGetClassObject("", id, nsnull); - } - NS_NewInterfaceRequestorAggregation(nsnull, nsnull, nsnull); - NS_NewHashPropertyBag(nsnull); - nsDependentString depstring; - depstring.Rebind(nsnull, PRUint32(0)); - nsDependentCString depcstring; - depcstring.Rebind(nsnull, PRUint32(0)); - // nsStringAPI - nsCStringContainer sc1; - NS_CStringContainerInit(sc1); - NS_CStringContainerInit2(sc1, nsnull, 0, 0); - NS_CStringContainerFinish(sc1); - NS_CStringGetData(str2, nsnull, nsnull); - NS_CStringGetMutableData(str2, 0, nsnull); - NS_CStringSetData(str2, nsnull, 0); - NS_CStringSetDataRange(str2, 0, 0, nsnull, 0); - NS_CStringCopy(str2, str2); - NS_CStringCloneData(str2); - nsStringContainer sc2; - NS_StringContainerInit(sc2); - NS_StringContainerInit2(sc2, nsnull, 0, 0); - NS_StringContainerFinish(sc2); - NS_StringGetData(str1, nsnull, nsnull); - NS_StringGetMutableData(str1, 0, nsnull); - NS_StringSetData(str1, nsnull, 0); - NS_StringSetDataRange(str1, 0, 0, nsnull, 0); - NS_StringCopy(str1, str1); - NS_StringCloneData(str1); - NS_UTF16ToCString(str1, NS_CSTRING_ENCODING_ASCII, str2); - NS_CStringToUTF16(str2, NS_CSTRING_ENCODING_ASCII, str1); - - nsCategoryObserver catobs(nsnull, nsnull); - nsCategoryCache catcache(nsnull); - - // nsStringBuffer.h - { - nsString x; - nsCString y; - nsStringBuffer b; - b.AddRef(); - b.Release(); - nsStringBuffer::Alloc(0); - nsStringBuffer::Realloc(nsnull, 0); - nsStringBuffer::FromString(x); - nsStringBuffer::FromString(y); - b.ToString(0, x); - b.ToString(0, y); - } - - nsXPCOMCycleCollectionParticipant(); - nsCycleCollector_collect(nsnull); -#ifdef XP_WIN - sXPCOMHasLoadedNewDLLs = !sXPCOMHasLoadedNewDLLs; - NS_SetHasLoadedNewDLLs(); - NS_NewWindowsRegKey(nsnull); - NS_SetDllDirectory(nsnull); -#if defined (DEBUG) - PurePrintf(0); -#endif -#endif - - NS_NewThread(nsnull, nsnull); - NS_GetCurrentThread(nsnull); - NS_GetCurrentThread(); - NS_GetMainThread(nsnull); - NS_DispatchToCurrentThread(nsnull); - NS_DispatchToMainThread(nsnull, 0); - NS_ProcessPendingEvents(nsnull, 0); - NS_HasPendingEvents(nsnull); - NS_ProcessNextEvent(nsnull, PR_FALSE); - Mutex theMutex("dummy"); - Monitor theMonitor("dummy2"); - CondVar theCondVar(theMutex, "dummy3"); - TimeStamp theTimeStamp = TimeStamp::Now(); - TimeDuration theTimeDuration = TimeDuration::FromMilliseconds(0); - - NS_WildCardValid((const char *)nsnull); - NS_WildCardValid((const PRUnichar *)nsnull); - NS_WildCardMatch((const char *)nsnull, (const char *)nsnull, PR_FALSE); - NS_WildCardMatch((const PRUnichar *)nsnull, (const PRUnichar *)nsnull, PR_FALSE); - XRE_AddStaticComponent(NULL); - XRE_AddManifestLocation(NS_COMPONENT_LOCATION, NULL); -} diff --git a/xpcom/build/nsXPComInit.cpp b/xpcom/build/nsXPComInit.cpp index 2d6dbb4c989..aaad42be59d 100644 --- a/xpcom/build/nsXPComInit.cpp +++ b/xpcom/build/nsXPComInit.cpp @@ -145,9 +145,7 @@ extern nsresult nsStringInputStreamConstructor(nsISupports *, REFNSIID, void **) #include "nsChromeRegistry.h" #include "nsChromeProtocolHandler.h" -#ifdef MOZ_ENABLE_LIBXUL #include "mozilla/scache/StartupCache.h" -#endif #include "base/at_exit.h" #include "base/command_line.h" @@ -524,9 +522,7 @@ NS_InitXPCOM2(nsIServiceManager* *result, // to the directory service. nsDirectoryService::gService->RegisterCategoryProviders(); -#ifdef MOZ_ENABLE_LIBXUL mozilla::scache::StartupCache::GetSingleton(); -#endif NS_TIME_FUNCTION_MARK("Next: create services from category"); // Notify observers of xpcom autoregistration start @@ -607,9 +603,7 @@ ShutdownXPCOM(nsIServiceManager* servMgr) } NS_ProcessPendingEvents(thread); -#ifdef MOZ_ENABLE_LIBXUL mozilla::scache::StartupCache::DeleteSingleton(); -#endif if (observerService) (void) observerService-> NotifyObservers(nsnull, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID, diff --git a/xpcom/components/Module.h b/xpcom/components/Module.h index f050ea642c6..efa76216e4b 100644 --- a/xpcom/components/Module.h +++ b/xpcom/components/Module.h @@ -53,7 +53,7 @@ namespace mozilla { */ struct Module { - static const unsigned int kVersion = 6; + static const unsigned int kVersion = 7; struct CIDEntry; diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index 51ee884ec2e..301ebe2a8e7 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -306,11 +306,9 @@ nsComponentManagerImpl::InitializeStaticModules() return; sStaticModules = new nsTArray; -#ifdef MOZ_ENABLE_LIBXUL for (const mozilla::Module *const *const *staticModules = kPStaticModules; *staticModules; ++staticModules) sStaticModules->AppendElement(**staticModules); -#endif } nsTArray* diff --git a/xpcom/glue/nsCycleCollectorUtils.cpp b/xpcom/glue/nsCycleCollectorUtils.cpp index 60f776ab4c3..d5c59aa0088 100644 --- a/xpcom/glue/nsCycleCollectorUtils.cpp +++ b/xpcom/glue/nsCycleCollectorUtils.cpp @@ -83,12 +83,4 @@ NS_IsCycleCollectorThread() return PR_GetCurrentThread() == gCycleCollectorThread; } -#elif !defined(MOZ_ENABLE_LIBXUL) - -bool -NS_IsCycleCollectorThread() -{ - return gTLSThreadID == mozilla::threads::CycleCollector; -} - #endif diff --git a/xpcom/glue/nsCycleCollectorUtils.h b/xpcom/glue/nsCycleCollectorUtils.h index 7d9bca7d36d..49b2d86fb45 100644 --- a/xpcom/glue/nsCycleCollectorUtils.h +++ b/xpcom/glue/nsCycleCollectorUtils.h @@ -47,15 +47,11 @@ NS_COM bool NS_IsCycleCollectorThread(); #elif defined(NS_TLS) // Defined in nsThreadManager.cpp. extern NS_TLS mozilla::threads::ID gTLSThreadID; -#ifdef MOZ_ENABLE_LIBXUL inline bool NS_IsCycleCollectorThread() { return gTLSThreadID == mozilla::threads::CycleCollector; } #else -NS_COM bool NS_IsCycleCollectorThread(); -#endif -#else NS_COM_GLUE bool NS_IsCycleCollectorThread(); #endif #else diff --git a/xpcom/glue/nsISupportsImpl.h b/xpcom/glue/nsISupportsImpl.h index c7e11755087..17e5f052b75 100644 --- a/xpcom/glue/nsISupportsImpl.h +++ b/xpcom/glue/nsISupportsImpl.h @@ -1233,6 +1233,11 @@ NS_IMETHODIMP_(nsrefcnt) Class::Release(void) \ NS_IMPL_QUERY_INTERFACE_INHERITED8(Class, Super, i1, i2, i3, i4, i5, i6, i7, i8) \ NS_IMPL_ADDREF_INHERITED(Class, Super) \ NS_IMPL_RELEASE_INHERITED(Class, Super) \ + +#define NS_IMPL_ISUPPORTS_INHERITED9(Class, Super, i1, i2, i3, i4, i5, i6, i7, i8, i9) \ + NS_IMPL_QUERY_INTERFACE_INHERITED9(Class, Super, i1, i2, i3, i4, i5, i6, i7, i8, i9) \ + NS_IMPL_ADDREF_INHERITED(Class, Super) \ + NS_IMPL_RELEASE_INHERITED(Class, Super) \ /* * Macro to glue together a QI that starts with an interface table * and segues into an interface map (e.g. it uses singleton classinfo diff --git a/xpcom/glue/nsThreadUtils.cpp b/xpcom/glue/nsThreadUtils.cpp index 1e82e004a39..b451097fb5a 100644 --- a/xpcom/glue/nsThreadUtils.cpp +++ b/xpcom/glue/nsThreadUtils.cpp @@ -144,11 +144,6 @@ bool NS_IsMainThread() nsThreadManager::get()->nsThreadManager::GetIsMainThread(&result); return bool(result); } -#elif !defined(MOZ_ENABLE_LIBXUL) -bool NS_IsMainThread() -{ - return gTLSThreadID == mozilla::threads::Main; -} #endif NS_METHOD diff --git a/xpcom/glue/nsThreadUtils.h b/xpcom/glue/nsThreadUtils.h index c482f4d31d0..7b8c8a7e419 100644 --- a/xpcom/glue/nsThreadUtils.h +++ b/xpcom/glue/nsThreadUtils.h @@ -106,15 +106,11 @@ NS_COM bool NS_IsMainThread(); // This is defined in nsThreadManager.cpp and initialized to `Main` for the // main thread by nsThreadManager::Init. extern NS_TLS mozilla::threads::ID gTLSThreadID; -#ifdef MOZ_ENABLE_LIBXUL inline bool NS_IsMainThread() { return gTLSThreadID == mozilla::threads::Main; } #else -NS_COM bool NS_IsMainThread(); -#endif -#else /** * Test to see if the current thread is the main thread. * diff --git a/xpcom/io/nsSegmentedBuffer.cpp b/xpcom/io/nsSegmentedBuffer.cpp index b910980cab2..3df912acd47 100644 --- a/xpcom/io/nsSegmentedBuffer.cpp +++ b/xpcom/io/nsSegmentedBuffer.cpp @@ -167,7 +167,7 @@ nsSegmentedBuffer::Empty() mFirstSegmentIndex = mLastSegmentIndex = 0; } -#if !defined(MOZ_ENABLE_LIBXUL) && defined(DEBUG) +#if 0 NS_COM void TestSegmentedBuffer() { diff --git a/xpcom/stub/Makefile.in b/xpcom/stub/Makefile.in index cb6b7ad079d..0b8b23adf7b 100644 --- a/xpcom/stub/Makefile.in +++ b/xpcom/stub/Makefile.in @@ -81,8 +81,6 @@ DEPENDENT_LIBS_LIST += \ $(DLL_PREFIX)mozalloc$(DLL_SUFFIX) \ $(NULL) -ifdef MOZ_ENABLE_LIBXUL - ifndef MOZ_NATIVE_SQLITE ifeq ($(OS_TARGET),OS2) DEPENDENT_LIBS_LIST += mozsqlt3.dll @@ -111,17 +109,6 @@ EXTRA_DSO_LIBS = xul DEPENDENT_LIBS_LIST += $(DLL_PREFIX)xul$(DLL_SUFFIX) endif -else #!MOZ_ENABLE_LIBXUL - -EXTRA_DSO_LIBS = xpcom_core -ifeq ($(OS_TARGET),OS2) -DEPENDENT_LIBS_LIST += xpcomcor.dll -else -DEPENDENT_LIBS_LIST += $(DLL_PREFIX)xpcom_core$(DLL_SUFFIX) -endif - -endif #ifdef MOZ_ENABLE_LIBXUL - EXTRA_DSO_LDOPTS += \ $(EXTRA_DSO_LIBS) \ $(NSPR_LIBS) \ diff --git a/xpcom/tests/Makefile.in b/xpcom/tests/Makefile.in index 2a045979183..cbf6f67aa73 100644 --- a/xpcom/tests/Makefile.in +++ b/xpcom/tests/Makefile.in @@ -45,10 +45,6 @@ include $(DEPTH)/config/autoconf.mk MODULE = xpcom -ifndef MOZ_ENABLE_LIBXUL -MOZILLA_INTERNAL_API = 1 -endif - DIRS = external component bug656331_component ifeq ($(OS_ARCH),WINNT) @@ -100,30 +96,29 @@ CPP_UNIT_TESTS = \ TestCheckedInt.cpp \ $(NULL) -ifndef MOZ_ENABLE_LIBXUL -CPP_UNIT_TESTS += \ - TestArray.cpp \ - TestCRT.cpp \ - TestDeque.cpp \ - TestEncoding.cpp \ - TestExpirationTracker.cpp \ - TestPipes.cpp \ - TestPriorityQueue.cpp \ - TestProxies.cpp \ - TestStorageStream.cpp \ - TestStrings.cpp \ - TestSynchronization.cpp \ - TestTArray.cpp \ - TestThreadPool.cpp \ - TestThreads.cpp \ - TestTimeStamp.cpp \ - TestXPIDLString.cpp \ - TestUTF.cpp \ - TestAtoms.cpp \ - $(NULL) -# FIXME: bug 577500 TestStaticAtoms fails when run in dist/bin -# TestStaticAtoms.cpp -endif +# XXX Make this tests work in libxul builds. +#CPP_UNIT_TESTS += \ +# TestArray.cpp \ +# TestCRT.cpp \ +# TestDeque.cpp \ +# TestEncoding.cpp \ +# TestExpirationTracker.cpp \ +# TestPipes.cpp \ +# TestPriorityQueue.cpp \ +# TestProxies.cpp \ +# TestStorageStream.cpp \ +# TestStrings.cpp \ +# TestSynchronization.cpp \ +# TestTArray.cpp \ +# TestThreadPool.cpp \ +# TestThreads.cpp \ +# TestTimeStamp.cpp \ +# TestXPIDLString.cpp \ +# TestUTF.cpp \ +# TestAtoms.cpp \ +# $(NULL) +## FIXME: bug 577500 TestStaticAtoms fails when run in dist/bin +## TestStaticAtoms.cpp ifdef MOZ_DEBUG # FIXME bug 523392: TestDeadlockDetector doesn't like Windows diff --git a/xpcom/tests/TestPipes.cpp b/xpcom/tests/TestPipes.cpp index 47c267b05fd..67a4d82743a 100644 --- a/xpcom/tests/TestPipes.cpp +++ b/xpcom/tests/TestPipes.cpp @@ -471,7 +471,7 @@ RunTests(PRUint32 segSize, PRUint32 segCount) //////////////////////////////////////////////////////////////////////////////// -#if !defined(MOZ_ENABLE_LIBXUL) && defined(DEBUG) +#if 0 extern NS_COM void TestSegmentedBuffer(); #endif @@ -488,11 +488,6 @@ main(int argc, char* argv[]) if (argc > 1 && nsCRT::strcmp(argv[1], "-trace") == 0) gTrace = PR_TRUE; -#if !defined(MOZ_ENABLE_LIBXUL) && defined(DEBUG) - printf("Testing segmented buffer...\n"); - TestSegmentedBuffer(); -#endif - rv = TestChainedPipes(); NS_ASSERTION(NS_SUCCEEDED(rv), "TestChainedPipes failed"); RunTests(16, 1); diff --git a/xpcom/tests/bug656331_component/Makefile.in b/xpcom/tests/bug656331_component/Makefile.in index 16ac3366228..6c4fff6e029 100644 --- a/xpcom/tests/bug656331_component/Makefile.in +++ b/xpcom/tests/bug656331_component/Makefile.in @@ -48,6 +48,7 @@ LIBRARY_NAME = test656331 IS_COMPONENT = 1 CPPSRCS = TestComponent.cpp NO_DIST_INSTALL = 1 +FORCE_SHARED_LIB = 1 include $(topsrcdir)/config/config.mk diff --git a/xpcom/tests/component/Makefile.in b/xpcom/tests/component/Makefile.in index 5e9f1dbd019..2acf594bf14 100644 --- a/xpcom/tests/component/Makefile.in +++ b/xpcom/tests/component/Makefile.in @@ -47,6 +47,7 @@ LIBRARY_NAME = testcomponent IS_COMPONENT = 1 CPPSRCS = TestComponent.cpp NO_DIST_INSTALL = 1 +FORCE_SHARED_LIB = 1 include $(topsrcdir)/config/config.mk diff --git a/xpfe/appshell/src/nsXULWindow.cpp b/xpfe/appshell/src/nsXULWindow.cpp index 59262b0cfe5..3c05ec12d18 100644 --- a/xpfe/appshell/src/nsXULWindow.cpp +++ b/xpfe/appshell/src/nsXULWindow.cpp @@ -58,7 +58,6 @@ #include "nsIDocument.h" #include "nsIDOMBarProp.h" #include "nsIDOMDocument.h" -#include "nsIDOMDocumentEvent.h" #include "nsIDOMXULDocument.h" #include "nsIDOMElement.h" #include "nsIPrivateDOMEvent.h" @@ -272,18 +271,17 @@ NS_IMETHODIMP nsXULWindow::SetZLevel(PRUint32 aLevel) nsCOMPtr cv; mDocShell->GetContentViewer(getter_AddRefs(cv)); if (cv) { - nsCOMPtr docEvent( - do_QueryInterface(cv->GetDocument())); - if (docEvent) { + nsCOMPtr domDoc = do_QueryInterface(cv->GetDocument()); + if (domDoc) { nsCOMPtr event; - docEvent->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event)); + domDoc->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event)); if (event) { event->InitEvent(NS_LITERAL_STRING("windowZLevel"), PR_TRUE, PR_FALSE); nsCOMPtr privateEvent(do_QueryInterface(event)); privateEvent->SetTrusted(PR_TRUE); - nsCOMPtr targ(do_QueryInterface(docEvent)); + nsCOMPtr targ = do_QueryInterface(domDoc); if (targ) { PRBool defaultActionEnabled; targ->DispatchEvent(event, &defaultActionEnabled); diff --git a/xpfe/components/autocomplete/src/Makefile.in b/xpfe/components/autocomplete/src/Makefile.in index 7585cbd3aea..c35116e87b1 100644 --- a/xpfe/components/autocomplete/src/Makefile.in +++ b/xpfe/components/autocomplete/src/Makefile.in @@ -46,7 +46,6 @@ MODULE = appcomps MODULE_NAME = xpAutoComplete LIBRARY_NAME = xpautocomplete SHORT_LIBNAME = xpautoc -MOZILLA_INTERNAL_API = $(BUILD_STATIC_LIBS) EXPORT_LIBRARY = 1 LIBXUL_LIBRARY = 1 IS_COMPONENT = 1 diff --git a/xpinstall/src/Makefile.in b/xpinstall/src/Makefile.in index d590d0922c4..fdc7877e4f3 100644 --- a/xpinstall/src/Makefile.in +++ b/xpinstall/src/Makefile.in @@ -49,15 +49,7 @@ include $(DEPTH)/config/autoconf.mk MODULE = xpinstall LIBRARY_NAME = xpinstall -ifndef MOZ_ENABLE_LIBXUL -# Make this a true dynamic component even in static builds because -# this component is shared by installer -FORCE_SHARED_LIB = 1 -BUILD_STATIC_LIBS= -SHORT_LIBNAME = xpinstal -else EXPORT_LIBRARY = 1 -endif IS_COMPONENT = 1 MODULE_NAME = nsSoftwareUpdate GRE_MODULE = 1 @@ -87,7 +79,3 @@ EXTRA_DSO_LDOPTS = \ $(NULL) include $(topsrcdir)/config/rules.mk - -ifeq ($(OS_ARCH)$(MOZ_ENABLE_LIBXUL),WINNT) -DEFINES += -DZLIB_DLL -endif diff --git a/xulrunner/app/Makefile.in b/xulrunner/app/Makefile.in index 5efc305b2fa..c713b421f78 100644 --- a/xulrunner/app/Makefile.in +++ b/xulrunner/app/Makefile.in @@ -79,14 +79,6 @@ ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) TK_LIBS := -framework Cocoa $(TK_LIBS) endif -ifndef MOZ_ENABLE_LIBXUL -ifeq (bundle,$(MOZ_FS_LAYOUT)) -LIBS += $(DIST)/bin/XUL -else -EXTRA_DSO_LIBS += xul -endif -endif - LIBS += \ $(EXTRA_DSO_LIBS) \ $(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \ diff --git a/xulrunner/confvars.sh b/xulrunner/confvars.sh index 20896cb7350..5bca9ea78f1 100755 --- a/xulrunner/confvars.sh +++ b/xulrunner/confvars.sh @@ -40,9 +40,7 @@ MOZ_APP_NAME=xulrunner MOZ_APP_DISPLAYNAME=XULRunner MOZ_UPDATER=1 MOZ_XULRUNNER=1 -MOZ_ENABLE_LIBXUL=1 MOZ_CHROME_FILE_FORMAT=omni -MOZ_STATIC_BUILD_UNSUPPORTED=1 MOZ_APP_VERSION=$MOZILLA_VERSION if test "$MOZ_STORAGE"; then MOZ_PLACES=1