From 57c5b8db3fa074a769892111f46140c7e5fe3bcb Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Fri, 24 Jun 2011 10:29:13 +0200 Subject: [PATCH 001/406] Bug 666475 - Intermittent browser_tabview_privatebrowsing.js | Test timed out; r=ehsan --- .../browser_tabview_privatebrowsing.js | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/browser/base/content/test/tabview/browser_tabview_privatebrowsing.js b/browser/base/content/test/tabview/browser_tabview_privatebrowsing.js index a6f6ae27861..b7893560d7a 100644 --- a/browser/base/content/test/tabview/browser_tabview_privatebrowsing.js +++ b/browser/base/content/test/tabview/browser_tabview_privatebrowsing.js @@ -22,7 +22,7 @@ function onTabViewLoadedAndShown() { ok(TabView.isVisible(), "Tab View is visible"); // Establish initial state - contentWindow = document.getElementById("tab-view").contentWindow; + contentWindow = TabView.getContentWindow(); verifyCleanState("start"); // register a clean up for private browsing just in case @@ -50,40 +50,37 @@ function onTabViewLoadedAndShown() { } // Create a second tab - gBrowser.loadOneTab("about:robots", { inBackground: false }); + gBrowser.addTab("about:robots"); is(gBrowser.tabs.length, 2, "we now have 2 tabs"); registerCleanupFunction(function() { gBrowser.removeTab(gBrowser.tabs[1]); }); afterAllTabsLoaded(function() { - showTabView(function() { - // Get normal tab urls - for (let a = 0; a < gBrowser.tabs.length; a++) - normalURLs.push(gBrowser.tabs[a].linkedBrowser.currentURI.spec); + // Get normal tab urls + for (let a = 0; a < gBrowser.tabs.length; a++) + normalURLs.push(gBrowser.tabs[a].linkedBrowser.currentURI.spec); - // verify that we're all set up for our test - verifyNormal(); + // verify that we're all set up for our test + verifyNormal(); - // go into private browsing and make sure Tab View becomes hidden - togglePBAndThen(function() { - whenTabViewIsHidden(function() { - ok(!TabView.isVisible(), "Tab View is no longer visible"); + // go into private browsing and make sure Tab View becomes hidden + togglePBAndThen(function() { + whenTabViewIsHidden(function() { + ok(!TabView.isVisible(), "Tab View is no longer visible"); + verifyPB(); - verifyPB(); + // exit private browsing and make sure Tab View is shown again + togglePBAndThen(function() { + whenTabViewIsShown(function() { + ok(TabView.isVisible(), "Tab View is visible again"); + verifyNormal(); - // exit private browsing and make sure Tab View is shown again - togglePBAndThen(function() { - whenTabViewIsShown(function() { - ok(TabView.isVisible(), "Tab View is visible again"); - verifyNormal(); - - hideTabView(onTabViewHidden); - }); + hideTabView(onTabViewHidden); }); }); }); - }); + }); }); } From ac9b0db8246729bc3a397a5d8d2e0982cdee4dbf Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Fri, 24 Jun 2011 10:29:13 +0200 Subject: [PATCH 002/406] Bug 666566 - newWindowWithTabView() should wait for browser-delayed-startup-finished; r=dietrich --- browser/base/content/test/tabview/head.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/browser/base/content/test/tabview/head.js b/browser/base/content/test/tabview/head.js index d8adb9af8ed..a1d8b12122c 100644 --- a/browser/base/content/test/tabview/head.js +++ b/browser/base/content/test/tabview/head.js @@ -81,19 +81,15 @@ function newWindowWithTabView(shownCallback, loadCallback, width, height) { let win = window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no,height=" + winHeight + ",width=" + winWidth); - let onLoad = function() { - win.removeEventListener("load", onLoad, false); - if (typeof loadCallback == "function") + + whenWindowLoaded(win, function () { + if (loadCallback) loadCallback(win); - let onShown = function() { - win.removeEventListener("tabviewshown", onShown, false); - shownCallback(win); - }; - win.addEventListener("tabviewshown", onShown, false); - win.TabView.toggle(); - } - win.addEventListener("load", onLoad, false); + whenDelayedStartupFinished(win, function () { + showTabView(function () shownCallback(win), win); + }); + }); } // ---------- From 3fdb1c9045aa99beb0668dc240aa118b05e2b8a7 Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Fri, 24 Jun 2011 10:29:13 +0200 Subject: [PATCH 003/406] Bug 632293 - Why does GroupItem constructor add children before it sets its bounds? r=dietrich --- browser/base/content/tabview/groupitems.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/browser/base/content/tabview/groupitems.js b/browser/base/content/tabview/groupitems.js index bb910d2a64c..9d7bd8561f8 100644 --- a/browser/base/content/tabview/groupitems.js +++ b/browser/base/content/tabview/groupitems.js @@ -249,7 +249,11 @@ function GroupItem(listOfEls, options) { this._init($container[0]); // ___ Children - Array.prototype.forEach.call(listOfEls, function(el) { + // We explicitly set dontArrange=true to prevent the groupItem from + // re-arranging its children after a tabItem has been added. This saves us a + // group.arrange() call per child and therefore some tab.setBounds() calls. + options.dontArrange = true; + listOfEls.forEach(function (el) { self.add(el, options); }); From 6a07f8bf8c56ce9f16b2f824eee30ee6a4682387 Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Fri, 24 Jun 2011 10:29:13 +0200 Subject: [PATCH 004/406] Bug 665801 - Intermittent timeout in browser/base/content/test/tabview/browser_tabview_bug597360.js | application timed out after 330 seconds with no output; r=ehsan --- .../test/tabview/browser_tabview_bug597360.js | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/browser/base/content/test/tabview/browser_tabview_bug597360.js b/browser/base/content/test/tabview/browser_tabview_bug597360.js index 31898bc3837..2638c6cbfc6 100644 --- a/browser/base/content/test/tabview/browser_tabview_bug597360.js +++ b/browser/base/content/test/tabview/browser_tabview_bug597360.js @@ -4,37 +4,29 @@ function test() { waitForExplicitFinish(); - window.addEventListener("tabviewshown", onTabViewWindowLoaded, false); - TabView.show(); + ok(!TabView.isVisible(), "Tab View is hidden"); + showTabView(onTabViewShown); } -function onTabViewWindowLoaded() { - window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); +function onTabViewShown() { + let contentWindow = TabView.getContentWindow(); + let groupItems = contentWindow.GroupItems.groupItems; + let groupItem = groupItems[0]; - let contentWindow = document.getElementById("tab-view").contentWindow; - is(contentWindow.GroupItems.groupItems.length, 1, - "There is one group item on startup"); + is(groupItems.length, 1, "There is one group item on startup"); - let groupItem = contentWindow.GroupItems.groupItems[0]; - groupItem.addSubscriber(groupItem, "groupHidden", function() { - groupItem.removeSubscriber(groupItem, "groupHidden"); - - let onTabViewHidden = function() { - window.removeEventListener("tabviewhidden", onTabViewHidden, false); - - is(contentWindow.GroupItems.groupItems.length, 1, - "There is still one group item"); - isnot(groupItem.id, contentWindow.GroupItems.groupItems[0].id, + hideGroupItem(groupItem, function () { + whenTabViewIsHidden(function () { + is(groupItems.length, 1, "There is still one group item"); + isnot(groupItem.id, groupItems[0].id, "The initial group item is not the same as the final group item"); is(gBrowser.tabs.length, 1, "There is only one tab"); ok(!TabView.isVisible(), "Tab View is hidden"); finish(); - }; - window.addEventListener("tabviewhidden", onTabViewHidden, false); + }); // create a new tab EventUtils.synthesizeKey("t", { accelKey: true }); }); - groupItem.closeAll(); } From 7f17370e0fb6cf24460e89ed9dd82b303a308876 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 2 Jun 2011 10:00:13 +0200 Subject: [PATCH 005/406] Bug 652657 - Allow to opt-in for telemetry reporting. r=gavin,ui-r=limi --- browser/components/nsBrowserGlue.js | 73 ++++++++++++++++++- browser/components/preferences/advanced.xul | 11 ++- .../en-US/chrome/browser/browser.properties | 10 +++ .../chrome/browser/preferences/advanced.dtd | 2 + browser/themes/pinstripe/browser/browser.css | 4 + modules/libpref/src/init/all.js | 4 + 6 files changed, 101 insertions(+), 3 deletions(-) diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js index bdee2a60991..bac3e91de04 100644 --- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -376,8 +376,13 @@ BrowserGlue.prototype = { // Browser startup complete. All initial windows have opened. _onBrowserStartup: function BG__onBrowserStartup() { // Show about:rights notification, if needed. - if (this._shouldShowRights()) + if (this._shouldShowRights()) { this._showRightsNotification(); + } else { + // Only show telemetry notification when about:rights notification is not shown. + this._showTelemetryNotification(); + } + // Show update notification, if needed. if (Services.prefs.prefHasUserValue("app.update.postupdate")) @@ -735,6 +740,72 @@ BrowserGlue.prototype = { } }, + _showTelemetryNotification: function BG__showTelemetryNotification() { + const PREF_TELEMETRY_PROMPTED = "toolkit.telemetry.prompted"; + const PREF_TELEMETRY_ENABLED = "toolkit.telemetry.enabled"; + const PREF_TELEMETRY_INFOURL = "toolkit.telemetry.infoURL"; + const PREF_TELEMETRY_SERVER_OWNER = "toolkit.telemetry.server_owner"; + + try { + // If the user hasn't already been prompted, ask if they want to + // send telemetry data. + if (Services.prefs.getBoolPref(PREF_TELEMETRY_ENABLED) || + Services.prefs.getBoolPref(PREF_TELEMETRY_PROMPTED)) + return; + } catch(e) {} + + // Stick the notification onto the selected tab of the active browser window. + var win = this.getMostRecentBrowserWindow(); + var browser = win.gBrowser; // for closure in notification bar callback + var notifyBox = browser.getNotificationBox(); + + var browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties"); + var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties"); + + var productName = brandBundle.GetStringFromName("brandFullName"); + var serverOwner = Services.prefs.getCharPref(PREF_TELEMETRY_SERVER_OWNER); + var telemetryText = browserBundle.formatStringFromName("telemetryText", [productName, serverOwner], 2); + + var buttons = [ + { + label: browserBundle.GetStringFromName("telemetryYesButtonLabel"), + accessKey: browserBundle.GetStringFromName("telemetryYesButtonAccessKey"), + popup: null, + callback: function(aNotificationBar, aButton) { + Services.prefs.setBoolPref(PREF_TELEMETRY_ENABLED, true); + } + }, + { + label: browserBundle.GetStringFromName("telemetryNoButtonLabel"), + accessKey: browserBundle.GetStringFromName("telemetryNoButtonAccessKey"), + popup: null, + callback: function(aNotificationBar, aButton) {} + } + ]; + + // Set pref to indicate we've shown the notification. + Services.prefs.setBoolPref(PREF_TELEMETRY_PROMPTED, true); + + var notification = notifyBox.appendNotification(telemetryText, "telemetry", null, notifyBox.PRIORITY_INFO_LOW, buttons); + notification.persistence = 3; // arbitrary number, just so bar sticks around for a bit + + let XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; + let link = notification.ownerDocument.createElementNS(XULNS, "label"); + link.className = "text-link telemetry-text-link"; + link.setAttribute("value", browserBundle.GetStringFromName("telemetryLinkLabel")); + link.addEventListener('click', function() { + // Open the learn more url in a new tab + browser.selectedTab = browser.addTab(Services.prefs.getCharPref(PREF_TELEMETRY_INFOURL)); + // Remove the notification on which the user clicked + notification.parentNode.removeNotification(notification, true); + // Add a new notification to that tab, with no "Learn more" link + var notifyBox = browser.getNotificationBox(); + notifyBox.appendNotification(telemetryText, "telemetry", null, notifyBox.PRIORITY_INFO_LOW, buttons); + }, false); + let description = notification.ownerDocument.getAnonymousElementByAttribute(notification, "anonid", "messageText"); + description.appendChild(link); + }, + _showPluginUpdatePage: function BG__showPluginUpdatePage() { Services.prefs.setBoolPref(PREF_PLUGINS_NOTIFYUSER, false); diff --git a/browser/components/preferences/advanced.xul b/browser/components/preferences/advanced.xul index 98a9c47270f..92537f1ea7f 100644 --- a/browser/components/preferences/advanced.xul +++ b/browser/components/preferences/advanced.xul @@ -82,6 +82,10 @@ type="bool"/> #endif + + @@ -193,11 +197,11 @@ preference="layout.spellcheckDefault"/> -#ifdef HAVE_SHELL_SERVICE +#ifdef HAVE_SHELL_SERVICE #endif - #endif + + diff --git a/browser/locales/en-US/chrome/browser/browser.properties b/browser/locales/en-US/chrome/browser/browser.properties index e257ae06d9e..bb680932326 100644 --- a/browser/locales/en-US/chrome/browser/browser.properties +++ b/browser/locales/en-US/chrome/browser/browser.properties @@ -323,3 +323,13 @@ syncPromoNotification.bookmarks.label=You can access your bookmarks on all your # the remember password panel. %S will be replaced by syncBrandShortName. syncPromoNotification.passwords.label=You can access your passwords on all your devices with %S. syncPromoNotification.learnMoreLinkText=Learn More + +# Telemetry prompt +# LOCALIZATION NOTE (telemetryText): %1$S will be replaced by brandFullName, +# and %2$S by the value of the toolkit.telemetry.server_owner preference. +telemetryText = Would you like to help improve %1$S by automatically reporting memory usage, performance, and responsiveness to %2$S? +telemetryLinkLabel = Learn More +telemetryYesButtonLabel = Yes +telemetryYesButtonAccessKey = Y +telemetryNoButtonLabel = No +telemetryNoButtonAccessKey = N diff --git a/browser/locales/en-US/chrome/browser/preferences/advanced.dtd b/browser/locales/en-US/chrome/browser/preferences/advanced.dtd index 042f5b4fe7e..cf3a70c71c8 100644 --- a/browser/locales/en-US/chrome/browser/preferences/advanced.dtd +++ b/browser/locales/en-US/chrome/browser/preferences/advanced.dtd @@ -29,6 +29,8 @@ + + diff --git a/browser/themes/pinstripe/browser/browser.css b/browser/themes/pinstripe/browser/browser.css index 9c71e660b7f..f72b92f74c8 100644 --- a/browser/themes/pinstripe/browser/browser.css +++ b/browser/themes/pinstripe/browser/browser.css @@ -2167,6 +2167,10 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker { -moz-margin-start: 0; /* override default label margin to match description margin */ } +.telemetry-text-link { + color: #fff; +} + #addons-notification-icon { list-style-image: url(chrome://mozapps/skin/extensions/extensionGeneric-16.png); } diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index da1ae77e0cf..37d58b251c5 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -276,6 +276,10 @@ pref("toolkit.scrollbox.clickToScroll.scrollDelay", 150); // Telemetry pref("toolkit.telemetry.enabled", false); pref("toolkit.telemetry.server", "https://data.mozilla.com"); +// Telemetry server owner. Please change if you set toolkit.telemetry.server to a different server +pref("toolkit.telemetry.server_owner", "Mozilla"); +// Information page about telemetry (temporary ; will be about:telemetry in the end) +pref("toolkit.telemetry.infoURL", "http://www.mozilla.com/legal/privacy/firefox.html#telemetry"); // view source pref("view_source.syntax_highlight", true); From 106b9ebf9f82b7c5ccceda5f3cb780a97596fe7a Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Fri, 24 Jun 2011 01:50:25 -0700 Subject: [PATCH 006/406] Bug 666714: Remove unused variable 'start' from nsScanner::Append. r=hsivonen --- parser/htmlparser/src/nsScanner.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/parser/htmlparser/src/nsScanner.cpp b/parser/htmlparser/src/nsScanner.cpp index d88229386ea..fb93b6cd8de 100644 --- a/parser/htmlparser/src/nsScanner.cpp +++ b/parser/htmlparser/src/nsScanner.cpp @@ -301,14 +301,13 @@ nsresult nsScanner::Append(const nsAString& aBuffer) { nsresult nsScanner::Append(const char* aBuffer, PRUint32 aLen, nsIRequest *aRequest) { - nsresult res=NS_OK; - PRUnichar *unichars, *start; + nsresult res = NS_OK; if (mUnicodeDecoder) { PRInt32 unicharBufLen = 0; mUnicodeDecoder->GetMaxLength(aBuffer, aLen, &unicharBufLen); nsScannerString::Buffer* buffer = nsScannerString::AllocBuffer(unicharBufLen + 1); NS_ENSURE_TRUE(buffer,NS_ERROR_OUT_OF_MEMORY); - start = unichars = buffer->DataStart(); + PRUnichar *unichars = buffer->DataStart(); PRInt32 totalChars = 0; PRInt32 unicharLength = unicharBufLen; From 5a2415fcffaa204ea2d2dec88ac50f0fae043f12 Mon Sep 17 00:00:00 2001 From: arno renevier Date: Fri, 24 Jun 2011 01:51:14 -0700 Subject: [PATCH 007/406] Bug 666220: remove unecessary kAppendChromeManifests definition. r=bsmedberg --- toolkit/xre/nsXREDirProvider.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp index 2793f8bfb8d..66a2a58c571 100644 --- a/toolkit/xre/nsXREDirProvider.cpp +++ b/toolkit/xre/nsXREDirProvider.cpp @@ -454,9 +454,6 @@ LoadDirsIntoArray(nsCOMArray& aSourceDirs, } } -static const char *const kAppendChromeManifests[] = - { "chrome.manifest", nsnull }; - NS_IMETHODIMP nsXREDirProvider::GetFiles(const char* aProperty, nsISimpleEnumerator** aResult) { From 66f76afde9e7153bdb9b02511ef65da1a49d56fd Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Fri, 24 Jun 2011 01:52:07 -0700 Subject: [PATCH 008/406] Bug 664979 - Remove unnecessary QueryInterface(Ci.nsISHistory) from nsSessionStore.js; r=bz --- browser/components/sessionstore/src/nsSessionStore.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/browser/components/sessionstore/src/nsSessionStore.js b/browser/components/sessionstore/src/nsSessionStore.js index bb78d1e9ff4..e0348a4d66a 100644 --- a/browser/components/sessionstore/src/nsSessionStore.js +++ b/browser/components/sessionstore/src/nsSessionStore.js @@ -2933,8 +2933,7 @@ SessionStoreService.prototype = { // force session history to update its internal index and call reload // instead of gotoIndex. See bug 597315. browser.webNavigation.sessionHistory.getEntryAtIndex(activeIndex, true); - browser.webNavigation.sessionHistory. - QueryInterface(Ci.nsISHistory).reloadCurrentEntry(); + browser.webNavigation.sessionHistory.reloadCurrentEntry(); } catch (ex) { // ignore page load errors From 4389d7f4900102ad6e6fbaf86cd85003bfc0f3ce Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Fri, 24 Jun 2011 14:49:42 +0200 Subject: [PATCH 009/406] Backout changesets bdd79a4d1dc9, d697b0b26227, 5abf332b2c45, 8e1bf0b98a30 because of increase in Panorama random oranges. --- browser/base/content/tabview/groupitems.js | 6 +-- .../test/tabview/browser_tabview_bug597360.js | 32 +++++++++------ .../browser_tabview_privatebrowsing.js | 41 ++++++++++--------- browser/base/content/test/tabview/head.js | 18 ++++---- 4 files changed, 54 insertions(+), 43 deletions(-) diff --git a/browser/base/content/tabview/groupitems.js b/browser/base/content/tabview/groupitems.js index 9d7bd8561f8..bb910d2a64c 100644 --- a/browser/base/content/tabview/groupitems.js +++ b/browser/base/content/tabview/groupitems.js @@ -249,11 +249,7 @@ function GroupItem(listOfEls, options) { this._init($container[0]); // ___ Children - // We explicitly set dontArrange=true to prevent the groupItem from - // re-arranging its children after a tabItem has been added. This saves us a - // group.arrange() call per child and therefore some tab.setBounds() calls. - options.dontArrange = true; - listOfEls.forEach(function (el) { + Array.prototype.forEach.call(listOfEls, function(el) { self.add(el, options); }); diff --git a/browser/base/content/test/tabview/browser_tabview_bug597360.js b/browser/base/content/test/tabview/browser_tabview_bug597360.js index 2638c6cbfc6..31898bc3837 100644 --- a/browser/base/content/test/tabview/browser_tabview_bug597360.js +++ b/browser/base/content/test/tabview/browser_tabview_bug597360.js @@ -4,29 +4,37 @@ function test() { waitForExplicitFinish(); - ok(!TabView.isVisible(), "Tab View is hidden"); - showTabView(onTabViewShown); + window.addEventListener("tabviewshown", onTabViewWindowLoaded, false); + TabView.show(); } -function onTabViewShown() { - let contentWindow = TabView.getContentWindow(); - let groupItems = contentWindow.GroupItems.groupItems; - let groupItem = groupItems[0]; +function onTabViewWindowLoaded() { + window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); - is(groupItems.length, 1, "There is one group item on startup"); + let contentWindow = document.getElementById("tab-view").contentWindow; + is(contentWindow.GroupItems.groupItems.length, 1, + "There is one group item on startup"); - hideGroupItem(groupItem, function () { - whenTabViewIsHidden(function () { - is(groupItems.length, 1, "There is still one group item"); - isnot(groupItem.id, groupItems[0].id, + let groupItem = contentWindow.GroupItems.groupItems[0]; + groupItem.addSubscriber(groupItem, "groupHidden", function() { + groupItem.removeSubscriber(groupItem, "groupHidden"); + + let onTabViewHidden = function() { + window.removeEventListener("tabviewhidden", onTabViewHidden, false); + + is(contentWindow.GroupItems.groupItems.length, 1, + "There is still one group item"); + isnot(groupItem.id, contentWindow.GroupItems.groupItems[0].id, "The initial group item is not the same as the final group item"); is(gBrowser.tabs.length, 1, "There is only one tab"); ok(!TabView.isVisible(), "Tab View is hidden"); finish(); - }); + }; + window.addEventListener("tabviewhidden", onTabViewHidden, false); // create a new tab EventUtils.synthesizeKey("t", { accelKey: true }); }); + groupItem.closeAll(); } diff --git a/browser/base/content/test/tabview/browser_tabview_privatebrowsing.js b/browser/base/content/test/tabview/browser_tabview_privatebrowsing.js index b7893560d7a..a6f6ae27861 100644 --- a/browser/base/content/test/tabview/browser_tabview_privatebrowsing.js +++ b/browser/base/content/test/tabview/browser_tabview_privatebrowsing.js @@ -22,7 +22,7 @@ function onTabViewLoadedAndShown() { ok(TabView.isVisible(), "Tab View is visible"); // Establish initial state - contentWindow = TabView.getContentWindow(); + contentWindow = document.getElementById("tab-view").contentWindow; verifyCleanState("start"); // register a clean up for private browsing just in case @@ -50,37 +50,40 @@ function onTabViewLoadedAndShown() { } // Create a second tab - gBrowser.addTab("about:robots"); + gBrowser.loadOneTab("about:robots", { inBackground: false }); is(gBrowser.tabs.length, 2, "we now have 2 tabs"); registerCleanupFunction(function() { gBrowser.removeTab(gBrowser.tabs[1]); }); afterAllTabsLoaded(function() { - // Get normal tab urls - for (let a = 0; a < gBrowser.tabs.length; a++) - normalURLs.push(gBrowser.tabs[a].linkedBrowser.currentURI.spec); + showTabView(function() { + // Get normal tab urls + for (let a = 0; a < gBrowser.tabs.length; a++) + normalURLs.push(gBrowser.tabs[a].linkedBrowser.currentURI.spec); - // verify that we're all set up for our test - verifyNormal(); + // verify that we're all set up for our test + verifyNormal(); - // go into private browsing and make sure Tab View becomes hidden - togglePBAndThen(function() { - whenTabViewIsHidden(function() { - ok(!TabView.isVisible(), "Tab View is no longer visible"); - verifyPB(); + // go into private browsing and make sure Tab View becomes hidden + togglePBAndThen(function() { + whenTabViewIsHidden(function() { + ok(!TabView.isVisible(), "Tab View is no longer visible"); - // exit private browsing and make sure Tab View is shown again - togglePBAndThen(function() { - whenTabViewIsShown(function() { - ok(TabView.isVisible(), "Tab View is visible again"); - verifyNormal(); + verifyPB(); - hideTabView(onTabViewHidden); + // exit private browsing and make sure Tab View is shown again + togglePBAndThen(function() { + whenTabViewIsShown(function() { + ok(TabView.isVisible(), "Tab View is visible again"); + verifyNormal(); + + hideTabView(onTabViewHidden); + }); }); }); }); - }); + }); }); } diff --git a/browser/base/content/test/tabview/head.js b/browser/base/content/test/tabview/head.js index a1d8b12122c..d8adb9af8ed 100644 --- a/browser/base/content/test/tabview/head.js +++ b/browser/base/content/test/tabview/head.js @@ -81,15 +81,19 @@ function newWindowWithTabView(shownCallback, loadCallback, width, height) { let win = window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no,height=" + winHeight + ",width=" + winWidth); - - whenWindowLoaded(win, function () { - if (loadCallback) + let onLoad = function() { + win.removeEventListener("load", onLoad, false); + if (typeof loadCallback == "function") loadCallback(win); - whenDelayedStartupFinished(win, function () { - showTabView(function () shownCallback(win), win); - }); - }); + let onShown = function() { + win.removeEventListener("tabviewshown", onShown, false); + shownCallback(win); + }; + win.addEventListener("tabviewshown", onShown, false); + win.TabView.toggle(); + } + win.addEventListener("load", onLoad, false); } // ---------- From d4d3c4883cfba2d02797493ac8d481a61969c5a4 Mon Sep 17 00:00:00 2001 From: Bill Gianopoulos Date: Fri, 24 Jun 2011 14:54:28 +0200 Subject: [PATCH 010/406] Bug 427990 Gecko part - Make XLink href work on MathML element. r=jonas. --- .../mathml/content/src/nsMathMLElement.cpp | 213 +++++++++++++++++- content/mathml/content/src/nsMathMLElement.h | 35 ++- layout/base/nsDocumentViewer.cpp | 41 +--- layout/base/nsPresShell.cpp | 66 ++---- 4 files changed, 269 insertions(+), 86 deletions(-) diff --git a/content/mathml/content/src/nsMathMLElement.cpp b/content/mathml/content/src/nsMathMLElement.cpp index 30b130391fe..261fa83b22a 100644 --- a/content/mathml/content/src/nsMathMLElement.cpp +++ b/content/mathml/content/src/nsMathMLElement.cpp @@ -62,6 +62,8 @@ NS_INTERFACE_TABLE_HEAD(nsMathMLElement) NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsMathMLElement) NS_INTERFACE_TABLE_ENTRY(nsMathMLElement, nsIDOMNode) NS_INTERFACE_TABLE_ENTRY(nsMathMLElement, nsIDOMElement) + NS_INTERFACE_TABLE_ENTRY(nsMathMLElement, nsILink) + NS_INTERFACE_TABLE_ENTRY(nsMathMLElement, Link) NS_OFFSET_AND_INTERFACE_TABLE_END NS_ELEMENT_INTERFACE_TABLE_TO_MAP_SEGUE NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MathMLElement) @@ -77,6 +79,8 @@ nsMathMLElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, { static const char kMathMLStyleSheetURI[] = "resource://gre-resources/mathml.css"; + Link::ResetLinkState(false); + nsresult rv = nsMathMLElementBase::BindToTree(aDocument, aParent, aBindingParent, aCompileEventHandlers); @@ -101,6 +105,16 @@ nsMathMLElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, return rv; } +void +nsMathMLElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent) +{ + // If this link is ever reinserted into a document, it might + // be under a different xml:base, so forget the cached state now. + Link::ResetLinkState(false); + + nsMathMLElementBase::UnbindFromTree(aDeep, aNullParent); +} + PRBool nsMathMLElement::ParseAttribute(PRInt32 aNamespaceID, nsIAtom* aAttribute, @@ -438,12 +452,27 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes, } } +nsresult +nsMathMLElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) +{ + nsresult rv = nsGenericElement::PreHandleEvent(aVisitor); + NS_ENSURE_SUCCESS(rv, rv); + + return PreHandleEventForLinks(aVisitor); +} + +nsresult +nsMathMLElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) +{ + return PostHandleEventForLinks(aVisitor); +} + NS_IMPL_ELEMENT_CLONE(nsMathMLElement) nsEventStates nsMathMLElement::IntrinsicState() const { - return nsMathMLElementBase::IntrinsicState() | + return Link::LinkState() | nsMathMLElementBase::IntrinsicState() | (mIncrementScriptLevel ? NS_EVENT_STATE_INCREMENT_SCRIPT_LEVEL : nsEventStates()); } @@ -465,3 +494,185 @@ nsMathMLElement::SetIncrementScriptLevel(PRBool aIncrementScriptLevel, UpdateState(true); } + +PRBool +nsMathMLElement::IsFocusable(PRInt32 *aTabIndex, PRBool aWithMouse) +{ + nsCOMPtr uri; + if (IsLink(getter_AddRefs(uri))) { + if (aTabIndex) { + *aTabIndex = ((sTabFocusModel & eTabFocus_linksMask) == 0 ? -1 : 0); + } + return PR_TRUE; + } + + if (aTabIndex) { + *aTabIndex = -1; + } + + return PR_FALSE; +} + +PRBool +nsMathMLElement::IsLink(nsIURI** aURI) const +{ + // http://www.w3.org/TR/2010/REC-MathML3-20101021/chapter6.html#interf.link + // The REC says that the following elements should not be linking elements: + nsIAtom* tag = Tag(); + if (tag == nsGkAtoms::mprescripts_ || + tag == nsGkAtoms::none || + tag == nsGkAtoms::malignmark_ || + tag == nsGkAtoms::maligngroup_) { + *aURI = nsnull; + return PR_FALSE; + } + + PRBool hasHref = PR_FALSE; + const nsAttrValue* href = mAttrsAndChildren.GetAttr(nsGkAtoms::href, + kNameSpaceID_None); + if (href) { + // MathML href + // The REC says: "When user agents encounter MathML elements with both href + // and xlink:href attributes, the href attribute should take precedence." + hasHref = PR_TRUE; + } else { + // To be a clickable XLink for styling and interaction purposes, we require: + // + // xlink:href - must be set + // xlink:type - must be unset or set to "" or set to "simple" + // xlink:show - must be unset or set to "", "new" or "replace" + // xlink:actuate - must be unset or set to "" or "onRequest" + // + // For any other values, we're either not a *clickable* XLink, or the end + // result is poorly specified. Either way, we return PR_FALSE. + + static nsIContent::AttrValuesArray sTypeVals[] = + { &nsGkAtoms::_empty, &nsGkAtoms::simple, nsnull }; + + static nsIContent::AttrValuesArray sShowVals[] = + { &nsGkAtoms::_empty, &nsGkAtoms::_new, &nsGkAtoms::replace, nsnull }; + + static nsIContent::AttrValuesArray sActuateVals[] = + { &nsGkAtoms::_empty, &nsGkAtoms::onRequest, nsnull }; + + // Optimization: check for href first for early return + href = mAttrsAndChildren.GetAttr(nsGkAtoms::href, + kNameSpaceID_XLink); + if (href && + FindAttrValueIn(kNameSpaceID_XLink, nsGkAtoms::type, + sTypeVals, eCaseMatters) != + nsIContent::ATTR_VALUE_NO_MATCH && + FindAttrValueIn(kNameSpaceID_XLink, nsGkAtoms::show, + sShowVals, eCaseMatters) != + nsIContent::ATTR_VALUE_NO_MATCH && + FindAttrValueIn(kNameSpaceID_XLink, nsGkAtoms::actuate, + sActuateVals, eCaseMatters) != + nsIContent::ATTR_VALUE_NO_MATCH) { + hasHref = PR_TRUE; + } + } + + if (hasHref) { + nsCOMPtr baseURI = GetBaseURI(); + // Get absolute URI + nsAutoString hrefStr; + href->ToString(hrefStr); + nsContentUtils::NewURIWithDocumentCharset(aURI, hrefStr, + GetOwnerDoc(), baseURI); + // must promise out param is non-null if we return true + return !!*aURI; + } + + *aURI = nsnull; + return PR_FALSE; +} + +void +nsMathMLElement::GetLinkTarget(nsAString& aTarget) +{ + const nsAttrValue* target = mAttrsAndChildren.GetAttr(nsGkAtoms::target, + kNameSpaceID_XLink); + if (target) { + target->ToString(aTarget); + } + + if (aTarget.IsEmpty()) { + + static nsIContent::AttrValuesArray sShowVals[] = + { &nsGkAtoms::_new, &nsGkAtoms::replace, nsnull }; + + switch (FindAttrValueIn(kNameSpaceID_XLink, nsGkAtoms::show, + sShowVals, eCaseMatters)) { + case 0: + aTarget.AssignLiteral("_blank"); + return; + case 1: + return; + } + nsIDocument* ownerDoc = GetOwnerDoc(); + if (ownerDoc) { + ownerDoc->GetBaseTarget(aTarget); + } + } +} + +nsLinkState +nsMathMLElement::GetLinkState() const +{ + return Link::GetLinkState(); +} + +void +nsMathMLElement::RequestLinkStateUpdate() +{ + UpdateLinkState(Link::LinkState()); +} + +already_AddRefed +nsMathMLElement::GetHrefURI() const +{ + nsCOMPtr hrefURI; + return IsLink(getter_AddRefs(hrefURI)) ? hrefURI.forget() : nsnull; +} + +nsresult +nsMathMLElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, + nsIAtom* aPrefix, const nsAString& aValue, + PRBool aNotify) +{ + nsresult rv = nsMathMLElementBase::SetAttr(aNameSpaceID, aName, aPrefix, + aValue, aNotify); + + // The ordering of the parent class's SetAttr call and Link::ResetLinkState + // is important here! The attribute is not set until SetAttr returns, and + // we will need the updated attribute value because notifying the document + // that content states have changed will call IntrinsicState, which will try + // to get updated information about the visitedness from Link. + if (aName == nsGkAtoms::href && + (aNameSpaceID == kNameSpaceID_None || + aNameSpaceID == kNameSpaceID_XLink)) { + Link::ResetLinkState(!!aNotify); + } + + return rv; +} + +nsresult +nsMathMLElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttr, + PRBool aNotify) +{ + nsresult rv = nsMathMLElementBase::UnsetAttr(aNameSpaceID, aAttr, aNotify); + + // The ordering of the parent class's UnsetAttr call and Link::ResetLinkState + // is important here! The attribute is not unset until UnsetAttr returns, and + // we will need the updated attribute value because notifying the document + // that content states have changed will call IntrinsicState, which will try + // to get updated information about the visitedness from Link. + if (aAttr == nsGkAtoms::href && + (aNameSpaceID == kNameSpaceID_None || + aNameSpaceID == kNameSpaceID_XLink)) { + Link::ResetLinkState(!!aNotify); + } + + return rv; +} diff --git a/content/mathml/content/src/nsMathMLElement.h b/content/mathml/content/src/nsMathMLElement.h index 92058f4da12..3e6dd56ba72 100644 --- a/content/mathml/content/src/nsMathMLElement.h +++ b/content/mathml/content/src/nsMathMLElement.h @@ -42,6 +42,8 @@ #include "nsMappedAttributeElement.h" #include "nsIDOMElement.h" +#include "nsILink.h" +#include "Link.h" class nsCSSValue; @@ -50,12 +52,15 @@ typedef nsMappedAttributeElement nsMathMLElementBase; /* * The base class for MathML elements. */ -class nsMathMLElement : public nsMathMLElementBase - , public nsIDOMElement +class nsMathMLElement : public nsMathMLElementBase, + public nsIDOMElement, + public nsILink, + public mozilla::dom::Link { public: nsMathMLElement(already_AddRefed aNodeInfo) - : nsMathMLElementBase(aNodeInfo), mIncrementScriptLevel(PR_FALSE) + : nsMathMLElementBase(aNodeInfo), Link(this), + mIncrementScriptLevel(PR_FALSE) {} // Implementation of nsISupports is inherited from nsMathMLElementBase @@ -69,6 +74,8 @@ public: nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsIContent* aBindingParent, PRBool aCompileEventHandlers); + virtual void UnbindFromTree(PRBool aDeep = PR_TRUE, + PRBool aNullParent = PR_TRUE); virtual PRBool ParseAttribute(PRInt32 aNamespaceID, nsIAtom* aAttribute, @@ -89,6 +96,8 @@ public: static void MapMathMLAttributesInto(const nsMappedAttributes* aAttributes, nsRuleData* aRuleData); + virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor); + virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor); nsresult Clone(nsINodeInfo*, nsINode**) const; virtual nsEventStates IntrinsicState() const; virtual PRBool IsNodeOfType(PRUint32 aFlags) const; @@ -100,6 +109,26 @@ public: return mIncrementScriptLevel; } + NS_IMETHOD LinkAdded() { return NS_OK; } + NS_IMETHOD LinkRemoved() { return NS_OK; } + virtual PRBool IsFocusable(PRInt32 *aTabIndex = nsnull, + PRBool aWithMouse = PR_FALSE); + virtual PRBool IsLink(nsIURI** aURI) const; + virtual void GetLinkTarget(nsAString& aTarget); + virtual nsLinkState GetLinkState() const; + virtual void RequestLinkStateUpdate(); + virtual already_AddRefed GetHrefURI() const; + nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, + const nsAString& aValue, PRBool aNotify) + { + return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify); + } + virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, + nsIAtom* aPrefix, const nsAString& aValue, + PRBool aNotify); + virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, + PRBool aNotify); + virtual nsXPCClassInfo* GetClassInfo(); private: PRPackedBool mIncrementScriptLevel; diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 643648b4531..8016ff1607f 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -3410,37 +3410,20 @@ DocumentViewerImpl::GetPopupLinkNode(nsIDOMNode** aNode) // find out if we have a link in our ancestry while (node) { - // are we an anchor? - nsCOMPtr anchor(do_QueryInterface(node)); - nsCOMPtr area; - nsCOMPtr link; - nsAutoString xlinkType; - if (!anchor) { - // area? - area = do_QueryInterface(node); - if (!area) { - // link? - link = do_QueryInterface(node); - if (!link) { - // XLink? - nsCOMPtr element(do_QueryInterface(node)); - if (element) { - element->GetAttributeNS(NS_LITERAL_STRING("http://www.w3.org/1999/xlink"),NS_LITERAL_STRING("type"),xlinkType); - } - } + nsCOMPtr content(do_QueryInterface(node)); + if (content) { + nsCOMPtr hrefURI = content->GetHrefURI(); + if (hrefURI) { + *aNode = node; + NS_IF_ADDREF(*aNode); // addref + return NS_OK; } } - if (anchor || area || link || xlinkType.EqualsLiteral("simple")) { - *aNode = node; - NS_IF_ADDREF(*aNode); // addref - return NS_OK; - } - else { - // if not, get our parent and keep trying... - nsCOMPtr parentNode; - node->GetParentNode(getter_AddRefs(parentNode)); - node = parentNode; - } + + // get our parent and keep trying... + nsCOMPtr parentNode; + node->GetParentNode(getter_AddRefs(parentNode)); + node = parentNode; } // if we have no node, fail diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index feb63a25c39..91aa9e605e6 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -4365,66 +4365,26 @@ nsresult PresShell::GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocationStrin #endif NS_ENSURE_ARG_POINTER(aNode); - nsresult rv; - nsAutoString anchorText; - static const char strippedChars[] = "\t\r\n"; - // are we an anchor? - nsCOMPtr anchor(do_QueryInterface(aNode)); - nsCOMPtr area; - nsCOMPtr link; - nsAutoString xlinkType; - if (anchor) { - rv = anchor->GetHref(anchorText); - NS_ENSURE_SUCCESS(rv, rv); - } else { - // area? - area = do_QueryInterface(aNode); - if (area) { - rv = area->GetHref(anchorText); + nsCOMPtr content(do_QueryInterface(aNode)); + if (content) { + nsCOMPtr hrefURI = content->GetHrefURI(); + if (hrefURI) { + nsCAutoString specUTF8; + nsresult rv = hrefURI->GetSpec(specUTF8); NS_ENSURE_SUCCESS(rv, rv); - } else { - // link? - link = do_QueryInterface(aNode); - if (link) { - rv = link->GetHref(anchorText); - NS_ENSURE_SUCCESS(rv, rv); - } else { - // Xlink? - nsCOMPtr element(do_QueryInterface(aNode)); - if (element) { - NS_NAMED_LITERAL_STRING(xlinkNS,"http://www.w3.org/1999/xlink"); - element->GetAttributeNS(xlinkNS,NS_LITERAL_STRING("type"),xlinkType); - if (xlinkType.EqualsLiteral("simple")) { - element->GetAttributeNS(xlinkNS,NS_LITERAL_STRING("href"),anchorText); - if (!anchorText.IsEmpty()) { - // Resolve the full URI using baseURI property - nsCOMPtr node = do_QueryInterface(aNode); - NS_ENSURE_TRUE(node, NS_ERROR_UNEXPECTED); - nsCOMPtr baseURI = node->GetBaseURI(); + nsAutoString anchorText; + CopyUTF8toUTF16(specUTF8, anchorText); - nsCAutoString spec; - rv = baseURI->Resolve(NS_ConvertUTF16toUTF8(anchorText),spec); - NS_ENSURE_SUCCESS(rv, rv); - - CopyUTF8toUTF16(spec, anchorText); - } - } - } - } + // Remove all the '\t', '\r' and '\n' from 'anchorText' + static const char strippedChars[] = "\t\r\n"; + anchorText.StripChars(strippedChars); + aLocationString = anchorText; + return NS_OK; } } - if (anchor || area || link || xlinkType.EqualsLiteral("simple")) { - //Remove all the '\t', '\r' and '\n' from 'anchorText' - anchorText.StripChars(strippedChars); - - aLocationString = anchorText; - - return NS_OK; - } - // if no link, fail. return NS_ERROR_FAILURE; } From 7af952e23797de50e9ee8f9e84fdee7615042fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Fri, 24 Jun 2011 14:54:37 +0200 Subject: [PATCH 011/406] Do not underline MathML links (bug 504324). r=roc. --- layout/mathml/mathml.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/layout/mathml/mathml.css b/layout/mathml/mathml.css index 0268ee895dc..37d6cbd946e 100644 --- a/layout/mathml/mathml.css +++ b/layout/mathml/mathml.css @@ -99,6 +99,13 @@ math[display="inline"] { font-weight: normal; } +/**************************************************************************/ +/* Links */ +/**************************************************************************/ +:-moz-any-link { + text-decoration: none !important; +} + /**************************************************************************/ /* attributes common to all tags */ /**************************************************************************/ From 2bd65a9cf7934552b844c237a5115a0c0abc2c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Fri, 24 Jun 2011 14:54:47 +0200 Subject: [PATCH 012/406] Reftest for bug 427990. r=roc. --- layout/reftests/mathml/link-1.xhtml | 12 ++++++++++++ layout/reftests/mathml/link-ref.xhtml | 11 +++++++++++ layout/reftests/mathml/reftest.list | 1 + 3 files changed, 24 insertions(+) create mode 100644 layout/reftests/mathml/link-1.xhtml create mode 100644 layout/reftests/mathml/link-ref.xhtml diff --git a/layout/reftests/mathml/link-1.xhtml b/layout/reftests/mathml/link-1.xhtml new file mode 100644 index 00000000000..13ab701890b --- /dev/null +++ b/layout/reftests/mathml/link-1.xhtml @@ -0,0 +1,12 @@ + + + + Test XLink + + + + MathML Link + + + diff --git a/layout/reftests/mathml/link-ref.xhtml b/layout/reftests/mathml/link-ref.xhtml new file mode 100644 index 00000000000..a5ac817f184 --- /dev/null +++ b/layout/reftests/mathml/link-ref.xhtml @@ -0,0 +1,11 @@ + + + + Test link + + + + MathML Link + + + diff --git a/layout/reftests/mathml/reftest.list b/layout/reftests/mathml/reftest.list index cd8540692f7..5496de575fc 100644 --- a/layout/reftests/mathml/reftest.list +++ b/layout/reftests/mathml/reftest.list @@ -62,3 +62,4 @@ fails == mstyle-5.xhtml mstyle-5-ref.xhtml # See bug 569125#c29 == math-as-mstyle-1.xhtml math-as-mstyle-1-ref.xhtml == mfrac-linethickness-1.xhtml mfrac-linethickness-1-ref.xhtml == mathml-negativespace.html mathml-negativespace-ref.html +!= link-1.xhtml link-ref.xhtml From fc46981b968dd6532a664e899e387b8f85e90e1d Mon Sep 17 00:00:00 2001 From: Ted Mielczarek Date: Fri, 24 Jun 2011 10:28:24 -0400 Subject: [PATCH 013/406] bug 620563 - ignore errors in removing profile directory at end of reftest run, r=philor --- layout/tools/reftest/runreftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layout/tools/reftest/runreftest.py b/layout/tools/reftest/runreftest.py index ee2d522ecd1..2b3c0900827 100644 --- a/layout/tools/reftest/runreftest.py +++ b/layout/tools/reftest/runreftest.py @@ -133,7 +133,7 @@ class RefTest(object): def cleanup(self, profileDir): if profileDir: - shutil.rmtree(profileDir) + shutil.rmtree(profileDir, True) def runTests(self, testPath, options): debuggerInfo = getDebuggerInfo(self.oldcwd, options.debugger, options.debuggerArgs, From ddf88fa93e873e51c836463a16f74991ff44e339 Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Thu, 23 Jun 2011 14:10:52 -0700 Subject: [PATCH 014/406] Bug 665564 - change DescribeNode to DescribeRefCountedNode to remove CCNodeType. r=bent --- content/base/src/nsContentUtils.cpp | 12 ++-- content/base/src/nsDocument.cpp | 5 +- content/base/src/nsGenericElement.cpp | 7 +-- content/base/src/nsNodeInfo.cpp | 5 +- dom/base/nsJSTimeoutHandler.cpp | 9 ++- js/src/xpconnect/src/nsXPConnect.cpp | 18 +++--- js/src/xpconnect/src/xpcwrappedjs.cpp | 5 +- js/src/xpconnect/src/xpcwrappednative.cpp | 7 +-- xpcom/base/nsCycleCollector.cpp | 74 ++++++++++++++--------- xpcom/glue/nsCycleCollectionParticipant.h | 22 +++---- 10 files changed, 89 insertions(+), 75 deletions(-) diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 063901708d9..46a5d54c7cd 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -5362,10 +5362,14 @@ public: mFlags = WANT_ALL_TRACES; } - NS_IMETHOD_(void) DescribeNode(CCNodeType type, - nsrefcnt refcount, - size_t objsz, - const char* objname) + NS_IMETHOD_(void) DescribeRefCountedNode(nsrefcnt refCount, + size_t objSz, + const char *objName) + { + } + NS_IMETHOD_(void) DescribeGCedNode(PRBool isMarked, + size_t objSz, + const char *objName) { } NS_IMETHOD_(void) NoteXPCOMRoot(nsISupports *root) diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index a7de03c22d5..97f638c193f 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -1808,11 +1808,10 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument) else { PR_snprintf(name, sizeof(name), "nsDocument %s", uri.get()); } - cb.DescribeNode(RefCounted, tmp->mRefCnt.get(), sizeof(nsDocument), name); + cb.DescribeRefCountedNode(tmp->mRefCnt.get(), sizeof(nsDocument), name); } else { - cb.DescribeNode(RefCounted, tmp->mRefCnt.get(), sizeof(nsDocument), - "nsDocument"); + NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsDocument, tmp->mRefCnt.get()) } // Always need to traverse script objects, so do that before we check diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index 11289342e71..1df35025342 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -4182,12 +4182,11 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGenericElement) else { PR_snprintf(name, sizeof(name), "nsGenericElement %s", localName.get()); } - cb.DescribeNode(RefCounted, tmp->mRefCnt.get(), sizeof(nsGenericElement), - name); + cb.DescribeRefCountedNode(tmp->mRefCnt.get(), sizeof(nsGenericElement), + name); } else { - cb.DescribeNode(RefCounted, tmp->mRefCnt.get(), sizeof(nsGenericElement), - "nsGenericElement"); + NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsGenericElement, tmp->mRefCnt.get()) } // Always need to traverse script objects, so do that before we check diff --git a/content/base/src/nsNodeInfo.cpp b/content/base/src/nsNodeInfo.cpp index e9e82ad4b3a..4a05d20f558 100644 --- a/content/base/src/nsNodeInfo.cpp +++ b/content/base/src/nsNodeInfo.cpp @@ -198,11 +198,10 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsNodeInfo) PR_snprintf(name, sizeof(name), "nsNodeInfo %s", localName.get()); } - cb.DescribeNode(RefCounted, tmp->mRefCnt.get(), sizeof(nsNodeInfo), name); + cb.DescribeRefCountedNode(tmp->mRefCnt.get(), sizeof(nsNodeInfo), name); } else { - cb.DescribeNode(RefCounted, tmp->mRefCnt.get(), sizeof(nsNodeInfo), - "nsNodeInfo"); + NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsNodeInfo, tmp->mRefCnt.get()) } NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mOwnerManager, diff --git a/dom/base/nsJSTimeoutHandler.cpp b/dom/base/nsJSTimeoutHandler.cpp index a7adb74cd63..cca7ec56920 100644 --- a/dom/base/nsJSTimeoutHandler.cpp +++ b/dom/base/nsJSTimeoutHandler.cpp @@ -142,13 +142,12 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsJSScriptTimeoutHandler) } } } - cb.DescribeNode(RefCounted, tmp->mRefCnt.get(), - sizeof(nsJSScriptTimeoutHandler), foo.get()); + cb.DescribeRefCountedNode(tmp->mRefCnt.get(), + sizeof(nsJSScriptTimeoutHandler), foo.get()); } else { - cb.DescribeNode(RefCounted, tmp->mRefCnt.get(), - sizeof(nsJSScriptTimeoutHandler), - "nsJSScriptTimeoutHandler"); + NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsJSScriptTimeoutHandler, + tmp->mRefCnt.get()) } NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mContext) diff --git a/js/src/xpconnect/src/nsXPConnect.cpp b/js/src/xpconnect/src/nsXPConnect.cpp index 8d76ea09b18..359b00c7256 100644 --- a/js/src/xpconnect/src/nsXPConnect.cpp +++ b/js/src/xpconnect/src/nsXPConnect.cpp @@ -747,7 +747,7 @@ nsXPConnect::Traverse(void *p, nsCycleCollectionTraversalCallback &cb) } } - CCNodeType type; + PRBool isMarked; #ifdef DEBUG_CC // Note that the conditions under which we specify GCMarked vs. @@ -765,14 +765,13 @@ nsXPConnect::Traverse(void *p, nsCycleCollectionTraversalCallback &cb) // ExplainLiveExpectedGarbage codepath PLDHashEntryHdr* entry = PL_DHashTableOperate(&mJSRoots, p, PL_DHASH_LOOKUP); - type = markJSObject || PL_DHASH_ENTRY_IS_BUSY(entry) ? GCMarked : - GCUnmarked; + isMarked = markJSObject || PL_DHASH_ENTRY_IS_BUSY(entry); } else #endif { // Normal codepath (matches non-DEBUG_CC codepath). - type = !markJSObject && xpc_IsGrayGCThing(p) ? GCUnmarked : GCMarked; + isMarked = markJSObject || !xpc_IsGrayGCThing(p); } if (cb.WantDebugInfo()) { @@ -845,19 +844,19 @@ nsXPConnect::Traverse(void *p, nsCycleCollectionTraversalCallback &cb) char fullname[100]; JS_snprintf(fullname, sizeof(fullname), "%s (global=%p)", name, global); - cb.DescribeNode(type, 0, sizeof(JSObject), fullname); + cb.DescribeGCedNode(isMarked, sizeof(JSObject), fullname); } else { - cb.DescribeNode(type, 0, sizeof(JSObject), name); + cb.DescribeGCedNode(isMarked, sizeof(JSObject), name); } } else { - cb.DescribeNode(type, 0, sizeof(JSObject), "JS Object"); + cb.DescribeGCedNode(isMarked, sizeof(JSObject), "JS Object"); } // There's no need to trace objects that have already been marked by the JS // GC. Any JS objects hanging from them will already be marked. Only do this // if DEBUG_CC is not defined, else we do want to know about all JS objects // to get better graphs and explanations. - if(!cb.WantAllTraces() && type == GCMarked) + if(!cb.WantAllTraces() && isMarked) return NS_OK; TraversalTracer trc(cb); @@ -932,8 +931,7 @@ public: // edges will ensure that any cycles this context is in won't be // collected. unsigned refCount = nsXPConnect::GetXPConnect()->GetOutstandingRequests(cx) + 1; - - cb.DescribeNode(RefCounted, refCount, sizeof(JSContext), "JSContext"); + NS_IMPL_CYCLE_COLLECTION_DESCRIBE(JSContext, refCount) NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "[global object]"); if (cx->globalObject) { cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, diff --git a/js/src/xpconnect/src/xpcwrappedjs.cpp b/js/src/xpconnect/src/xpcwrappedjs.cpp index a86af154e27..c2e0e4776c4 100644 --- a/js/src/xpconnect/src/xpcwrappedjs.cpp +++ b/js/src/xpconnect/src/xpcwrappedjs.cpp @@ -67,10 +67,9 @@ NS_CYCLE_COLLECTION_CLASSNAME(nsXPCWrappedJS)::Traverse tmp->GetClass()->GetInterfaceName()); else JS_snprintf(name, sizeof(name), "nsXPCWrappedJS"); - cb.DescribeNode(RefCounted, refcnt, sizeof(nsXPCWrappedJS), name); + cb.DescribeRefCountedNode(refcnt, sizeof(nsXPCWrappedJS), name); } else { - cb.DescribeNode(RefCounted, refcnt, sizeof(nsXPCWrappedJS), - "nsXPCWrappedJS"); + NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsXPCWrappedJS, refcnt) } // nsXPCWrappedJS keeps its own refcount artificially at or above 1, see the diff --git a/js/src/xpconnect/src/xpcwrappednative.cpp b/js/src/xpconnect/src/xpcwrappednative.cpp index be27a7856e8..c19a84613a1 100644 --- a/js/src/xpconnect/src/xpcwrappednative.cpp +++ b/js/src/xpconnect/src/xpcwrappednative.cpp @@ -115,11 +115,10 @@ NS_CYCLE_COLLECTION_CLASSNAME(XPCWrappedNative)::Traverse(void *p, else JS_snprintf(name, sizeof(name), "XPCWrappedNative"); - cb.DescribeNode(RefCounted, tmp->mRefCnt.get(), - sizeof(XPCWrappedNative), name); + cb.DescribeRefCountedNode(tmp->mRefCnt.get(), + sizeof(XPCWrappedNative), name); } else { - cb.DescribeNode(RefCounted, tmp->mRefCnt.get(), - sizeof(XPCWrappedNative), "XPCWrappedNative"); + NS_IMPL_CYCLE_COLLECTION_DESCRIBE(XPCWrappedNative, tmp->mRefCnt.get()) } if(tmp->mRefCnt.get() > 1) { diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index 274c7f95c5c..4fbe1512498 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -1461,8 +1461,30 @@ public: NS_IMETHOD_(void) NoteXPCOMRoot(nsISupports *root); private: - NS_IMETHOD_(void) DescribeNode(CCNodeType type, nsrefcnt refCount, - size_t objSz, const char *objName); + void DescribeNode(PRUint32 refCount, + size_t objSz, + const char *objName) + { +#ifdef DEBUG_CC + mCurrPi->mBytes = objSz; + mCurrPi->mName = PL_strdup(objName); +#endif + + if (mListener) { + mListener->NoteObject((PRUint64)mCurrPi->mPointer, objName); + } + + mCurrPi->mRefCount = refCount; + +#ifdef DEBUG_CC + sCollector->mStats.mVisitedNode++; +#endif + } + + NS_IMETHOD_(void) DescribeRefCountedNode(nsrefcnt refCount, size_t objSz, + const char *objName); + NS_IMETHOD_(void) DescribeGCedNode(PRBool isMarked, size_t objSz, + const char *objName); NS_IMETHOD_(void) NoteRoot(PRUint32 langID, void *child, nsCycleCollectionParticipant* participant); NS_IMETHOD_(void) NoteXPCOMChild(nsISupports *child); @@ -1594,32 +1616,22 @@ GCGraphBuilder::NoteRoot(PRUint32 langID, void *root, } NS_IMETHODIMP_(void) -GCGraphBuilder::DescribeNode(CCNodeType type, nsrefcnt refCount, - size_t objSz, const char *objName) +GCGraphBuilder::DescribeRefCountedNode(nsrefcnt refCount, size_t objSz, + const char *objName) { -#ifdef DEBUG_CC - mCurrPi->mBytes = objSz; - mCurrPi->mName = PL_strdup(objName); -#endif + if (refCount == 0) + Fault("zero refcount", mCurrPi); + if (refCount == PR_UINT32_MAX) + Fault("overflowing refcount", mCurrPi); + DescribeNode(refCount, objSz, objName); +} - if (mListener) { - mListener->NoteObject((PRUint64)mCurrPi->mPointer, objName); - } - - if (type == RefCounted) { - if (refCount == 0) - Fault("zero refcount", mCurrPi); - if (refCount == PR_UINT32_MAX) - Fault("overflowing refcount", mCurrPi); - - mCurrPi->mRefCount = refCount; - } - else { - mCurrPi->mRefCount = type == GCMarked ? PR_UINT32_MAX : 0; - } -#ifdef DEBUG_CC - sCollector->mStats.mVisitedNode++; -#endif +NS_IMETHODIMP_(void) +GCGraphBuilder::DescribeGCedNode(PRBool isMarked, size_t objSz, + const char *objName) +{ + PRUint32 refCount = isMarked ? PR_UINT32_MAX : 0; + DescribeNode(refCount, objSz, objName); } NS_IMETHODIMP_(void) @@ -2279,8 +2291,14 @@ public: return mSuppressThisNode; } - NS_IMETHOD_(void) DescribeNode(CCNodeType type, nsrefcnt refCount, - size_t objSz, const char *objName) + NS_IMETHOD_(void) DescribeRefCountedNode(nsrefcnt refCount, size_t objSz, + const char *objName) + { + mSuppressThisNode = (PL_strstr(sSuppressionList, objName) != nsnull); + } + + NS_IMETHOD_(void) DescribeGCedNode(PRBool isMarked, size_t objSz, + const char *objName) { mSuppressThisNode = (PL_strstr(sSuppressionList, objName) != nsnull); } diff --git a/xpcom/glue/nsCycleCollectionParticipant.h b/xpcom/glue/nsCycleCollectionParticipant.h index 02e1b77fe66..069513f5593 100644 --- a/xpcom/glue/nsCycleCollectionParticipant.h +++ b/xpcom/glue/nsCycleCollectionParticipant.h @@ -81,20 +81,19 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsCycleCollectionISupports, class nsCycleCollectionParticipant; -enum CCNodeType { RefCounted, GCMarked, GCUnmarked }; - class NS_NO_VTABLE nsCycleCollectionTraversalCallback { public: - // If type is RefCounted you must call DescribeNode() with an accurate + // You must call DescribeRefCountedNode() with an accurate // refcount, otherwise cycle collection will fail, and probably crash. - // If type is not refcounted then the refcount will be ignored. // If the callback cares about objsz or objname, it should // put WANT_DEBUG_INFO in mFlags. - NS_IMETHOD_(void) DescribeNode(CCNodeType type, - nsrefcnt refcount, - size_t objsz, - const char *objname) = 0; + NS_IMETHOD_(void) DescribeRefCountedNode(nsrefcnt refcount, + size_t objsz, + const char *objname) = 0; + NS_IMETHOD_(void) DescribeGCedNode(PRBool ismarked, + size_t objsz, + const char *objname) = 0; NS_IMETHOD_(void) NoteXPCOMRoot(nsISupports *root) = 0; NS_IMETHOD_(void) NoteRoot(PRUint32 langID, void *root, nsCycleCollectionParticipant* helper) = 0; @@ -112,8 +111,9 @@ public: enum { // Values for flags: - // Caller should pass useful objsz and objname to DescribeNode - // and should call NoteNextEdgeName. + // Caller should pass useful objsz and objname to + // DescribeRefCountedNode and DescribeGCedNode and should call + // NoteNextEdgeName. WANT_DEBUG_INFO = (1<<0), // Caller should not skip objects that we know will be @@ -307,7 +307,7 @@ public: /////////////////////////////////////////////////////////////////////////////// #define NS_IMPL_CYCLE_COLLECTION_DESCRIBE(_class, _refcnt) \ - cb.DescribeNode(RefCounted, _refcnt, sizeof(_class), #_class); + cb.DescribeRefCountedNode(_refcnt, sizeof(_class), #_class); #define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(_class) \ NS_IMETHODIMP \ From 0a6ee055b5473e8b607fb100f27b2423c2603789 Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Fri, 24 Jun 2011 18:00:07 +0200 Subject: [PATCH 015/406] Bug 666709 - One or more places xpcshell tests modify in-tree default.sqlite. r=ted --- .../places/tests/unit/test_database_replaceOnStartup.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toolkit/components/places/tests/unit/test_database_replaceOnStartup.js b/toolkit/components/places/tests/unit/test_database_replaceOnStartup.js index d55e593f8e6..1f3a95d2e0d 100644 --- a/toolkit/components/places/tests/unit/test_database_replaceOnStartup.js +++ b/toolkit/components/places/tests/unit/test_database_replaceOnStartup.js @@ -16,7 +16,8 @@ function run_test() { } let file = do_get_file("default.sqlite"); - file.copyTo(gProfD, "places.sqlite"); + file.copyToFollowingLinks(gProfD, "places.sqlite"); + file = gProfD.clone().append("places.sqlite"); // Create some unique stuff to check later. let db = Services.storage.openUnsharedDatabase(file); From 41643433ca366b8bec4c90995b44d8fdb7e2c9b2 Mon Sep 17 00:00:00 2001 From: Joel Maher Date: Fri, 24 Jun 2011 12:39:13 -0400 Subject: [PATCH 016/406] Bug 508710 - moving toolkit/content/tests/widgets/*.xul from mochitest to mochitest-chrome. r=enn, a=test-only --HG-- rename : toolkit/content/tests/widgets/frame_popupremoving_frame.xul => toolkit/content/tests/chrome/frame_popupremoving_frame.xul rename : toolkit/content/tests/widgets/popup_childframe_node.xul => toolkit/content/tests/chrome/popup_childframe_node.xul rename : toolkit/content/tests/widgets/popup_trigger.js => toolkit/content/tests/chrome/popup_trigger.js rename : toolkit/content/tests/widgets/test_bug360220.xul => toolkit/content/tests/chrome/test_bug360220.xul rename : toolkit/content/tests/widgets/test_bug365773.xul => toolkit/content/tests/chrome/test_bug365773.xul rename : toolkit/content/tests/widgets/test_bug382990.xul => toolkit/content/tests/chrome/test_bug382990.xul rename : toolkit/content/tests/widgets/test_bug457632.xul => toolkit/content/tests/chrome/test_bug457632.xul rename : toolkit/content/tests/widgets/test_bug460942.xul => toolkit/content/tests/chrome/test_bug460942.xul rename : toolkit/content/tests/widgets/test_bug509732.xul => toolkit/content/tests/chrome/test_bug509732.xul rename : toolkit/content/tests/widgets/test_bug554279.xul => toolkit/content/tests/chrome/test_bug554279.xul rename : toolkit/content/tests/widgets/test_bug557987.xul => toolkit/content/tests/chrome/test_bug557987.xul rename : toolkit/content/tests/widgets/test_bug562554.xul => toolkit/content/tests/chrome/test_bug562554.xul rename : toolkit/content/tests/widgets/test_button.xul => toolkit/content/tests/chrome/test_button.xul rename : toolkit/content/tests/widgets/test_closemenu_attribute.xul => toolkit/content/tests/chrome/test_closemenu_attribute.xul rename : toolkit/content/tests/widgets/test_colorpicker_popup.xul => toolkit/content/tests/chrome/test_colorpicker_popup.xul rename : toolkit/content/tests/widgets/test_contextmenu_list.xul => toolkit/content/tests/chrome/test_contextmenu_list.xul rename : toolkit/content/tests/widgets/test_focus_anons.xul => toolkit/content/tests/chrome/test_focus_anons.xul rename : toolkit/content/tests/widgets/test_hiddenitems.xul => toolkit/content/tests/chrome/test_hiddenitems.xul rename : toolkit/content/tests/widgets/test_hiddenpaging.xul => toolkit/content/tests/chrome/test_hiddenpaging.xul rename : toolkit/content/tests/widgets/test_menu.xul => toolkit/content/tests/chrome/test_menu.xul rename : toolkit/content/tests/widgets/test_menu_hide.xul => toolkit/content/tests/chrome/test_menu_hide.xul rename : toolkit/content/tests/widgets/test_menuitem_blink.xul => toolkit/content/tests/chrome/test_menuitem_blink.xul rename : toolkit/content/tests/widgets/test_menulist.xul => toolkit/content/tests/chrome/test_menulist.xul rename : toolkit/content/tests/widgets/test_menulist_keynav.xul => toolkit/content/tests/chrome/test_menulist_keynav.xul rename : toolkit/content/tests/widgets/test_notificationbox.xul => toolkit/content/tests/chrome/test_notificationbox.xul rename : toolkit/content/tests/widgets/test_panelfrommenu.xul => toolkit/content/tests/chrome/test_panelfrommenu.xul rename : toolkit/content/tests/widgets/test_popup_attribute.xul => toolkit/content/tests/chrome/test_popup_attribute.xul rename : toolkit/content/tests/widgets/test_popup_button.xul => toolkit/content/tests/chrome/test_popup_button.xul rename : toolkit/content/tests/widgets/test_popup_coords.xul => toolkit/content/tests/chrome/test_popup_coords.xul rename : toolkit/content/tests/widgets/test_popup_keys.xul => toolkit/content/tests/chrome/test_popup_keys.xul rename : toolkit/content/tests/widgets/test_popup_preventdefault.xul => toolkit/content/tests/chrome/test_popup_preventdefault.xul rename : toolkit/content/tests/widgets/test_popup_recreate.xul => toolkit/content/tests/chrome/test_popup_recreate.xul rename : toolkit/content/tests/widgets/test_popup_scaled.xul => toolkit/content/tests/chrome/test_popup_scaled.xul rename : toolkit/content/tests/widgets/test_popup_tree.xul => toolkit/content/tests/chrome/test_popup_tree.xul rename : toolkit/content/tests/widgets/test_popuphidden.xul => toolkit/content/tests/chrome/test_popuphidden.xul rename : toolkit/content/tests/widgets/test_popupincontent.xul => toolkit/content/tests/chrome/test_popupincontent.xul rename : toolkit/content/tests/widgets/test_popupremoving.xul => toolkit/content/tests/chrome/test_popupremoving.xul rename : toolkit/content/tests/widgets/test_popupremoving_frame.xul => toolkit/content/tests/chrome/test_popupremoving_frame.xul rename : toolkit/content/tests/widgets/test_position.xul => toolkit/content/tests/chrome/test_position.xul rename : toolkit/content/tests/widgets/test_progressmeter.xul => toolkit/content/tests/chrome/test_progressmeter.xul rename : toolkit/content/tests/widgets/test_props.xul => toolkit/content/tests/chrome/test_props.xul rename : toolkit/content/tests/widgets/test_radio.xul => toolkit/content/tests/chrome/test_radio.xul rename : toolkit/content/tests/widgets/test_richlist_direction.xul => toolkit/content/tests/chrome/test_richlist_direction.xul rename : toolkit/content/tests/widgets/test_scale.xul => toolkit/content/tests/chrome/test_scale.xul rename : toolkit/content/tests/widgets/test_scrollbar.xul => toolkit/content/tests/chrome/test_scrollbar.xul rename : toolkit/content/tests/widgets/test_sorttemplate.xul => toolkit/content/tests/chrome/test_sorttemplate.xul rename : toolkit/content/tests/widgets/test_statusbar.xul => toolkit/content/tests/chrome/test_statusbar.xul rename : toolkit/content/tests/widgets/test_tabbox.xul => toolkit/content/tests/chrome/test_tabbox.xul rename : toolkit/content/tests/widgets/test_tabindex.xul => toolkit/content/tests/chrome/test_tabindex.xul rename : toolkit/content/tests/widgets/test_textbox_emptytext.xul => toolkit/content/tests/chrome/test_textbox_emptytext.xul rename : toolkit/content/tests/widgets/test_textbox_number.xul => toolkit/content/tests/chrome/test_textbox_number.xul rename : toolkit/content/tests/widgets/test_textbox_search.xul => toolkit/content/tests/chrome/test_textbox_search.xul rename : toolkit/content/tests/widgets/test_timepicker.xul => toolkit/content/tests/chrome/test_timepicker.xul rename : toolkit/content/tests/widgets/test_toolbar.xul => toolkit/content/tests/chrome/test_toolbar.xul rename : toolkit/content/tests/widgets/test_tooltip.xul => toolkit/content/tests/chrome/test_tooltip.xul rename : toolkit/content/tests/widgets/test_tooltip_noautohide.xul => toolkit/content/tests/chrome/test_tooltip_noautohide.xul rename : toolkit/content/tests/widgets/test_tree.xul => toolkit/content/tests/chrome/test_tree.xul rename : toolkit/content/tests/widgets/test_tree_single.xul => toolkit/content/tests/chrome/test_tree_single.xul rename : toolkit/content/tests/widgets/test_tree_view.xul => toolkit/content/tests/chrome/test_tree_view.xul rename : toolkit/content/tests/widgets/window_popup_attribute.xul => toolkit/content/tests/chrome/window_popup_attribute.xul rename : toolkit/content/tests/widgets/window_popup_button.xul => toolkit/content/tests/chrome/window_popup_button.xul rename : toolkit/content/tests/widgets/xul_selectcontrol.js => toolkit/content/tests/chrome/xul_selectcontrol.js --- testing/mochitest/harness-overlay.xul | 2 +- toolkit/content/tests/chrome/Makefile.in | 68 ++++++++++++++ .../frame_popupremoving_frame.xul | 0 .../popup_childframe_node.xul | 0 .../{widgets => chrome}/popup_trigger.js | 1 - .../{widgets => chrome}/test_bug360220.xul | 6 +- .../{widgets => chrome}/test_bug365773.xul | 6 +- .../{widgets => chrome}/test_bug382990.xul | 8 +- .../{widgets => chrome}/test_bug457632.xul | 6 +- .../{widgets => chrome}/test_bug460942.xul | 6 +- .../{widgets => chrome}/test_bug509732.xul | 6 +- .../{widgets => chrome}/test_bug554279.xul | 6 +- .../{widgets => chrome}/test_bug557987.xul | 8 +- .../{widgets => chrome}/test_bug562554.xul | 8 +- .../tests/{widgets => chrome}/test_button.xul | 10 +-- .../test_closemenu_attribute.xul | 8 +- .../test_colorpicker_popup.xul | 8 +- .../test_contextmenu_list.xul | 8 +- .../{widgets => chrome}/test_focus_anons.xul | 8 +- .../{widgets => chrome}/test_hiddenitems.xul | 8 +- .../{widgets => chrome}/test_hiddenpaging.xul | 8 +- .../tests/{widgets => chrome}/test_menu.xul | 8 +- .../{widgets => chrome}/test_menu_hide.xul | 8 +- .../test_menuitem_blink.xul | 8 +- .../{widgets => chrome}/test_menulist.xul | 8 +- .../test_menulist_keynav.xul | 8 +- .../test_notificationbox.xul | 6 +- .../test_panelfrommenu.xul | 8 +- .../test_popup_attribute.xul | 6 +- .../{widgets => chrome}/test_popup_button.xul | 6 +- .../{widgets => chrome}/test_popup_coords.xul | 8 +- .../{widgets => chrome}/test_popup_keys.xul | 8 +- .../test_popup_preventdefault.xul | 6 +- .../test_popup_recreate.xul | 8 +- .../{widgets => chrome}/test_popup_scaled.xul | 8 +- .../{widgets => chrome}/test_popup_tree.xul | 8 +- .../{widgets => chrome}/test_popuphidden.xul | 6 +- .../test_popupincontent.xul | 12 +-- .../test_popupremoving.xul | 8 +- .../test_popupremoving_frame.xul | 8 +- .../{widgets => chrome}/test_position.xul | 8 +- .../test_progressmeter.xul | 6 +- .../tests/{widgets => chrome}/test_props.xul | 8 +- .../tests/{widgets => chrome}/test_radio.xul | 8 +- .../test_richlist_direction.xul | 8 +- .../tests/{widgets => chrome}/test_scale.xul | 8 +- .../{widgets => chrome}/test_scrollbar.xul | 8 +- .../{widgets => chrome}/test_sorttemplate.xul | 8 +- .../{widgets => chrome}/test_statusbar.xul | 8 +- .../tests/{widgets => chrome}/test_tabbox.xul | 8 +- .../{widgets => chrome}/test_tabindex.xul | 8 +- .../test_textbox_emptytext.xul | 6 +- .../test_textbox_number.xul | 8 +- .../test_textbox_search.xul | 8 +- .../{widgets => chrome}/test_timepicker.xul | 8 +- .../{widgets => chrome}/test_toolbar.xul | 6 +- .../{widgets => chrome}/test_tooltip.xul | 10 +-- .../test_tooltip_noautohide.xul | 8 +- .../tests/{widgets => chrome}/test_tree.xul | 8 +- .../{widgets => chrome}/test_tree_single.xul | 8 +- .../{widgets => chrome}/test_tree_view.xul | 25 +++--- .../window_popup_attribute.xul | 4 +- .../window_popup_button.xul | 4 +- .../{widgets => chrome}/xul_selectcontrol.js | 0 toolkit/content/tests/widgets/Makefile.in | 90 ++++--------------- .../content/tests/widgets/test_bug359754.xul | 72 --------------- 66 files changed, 312 insertions(+), 374 deletions(-) rename toolkit/content/tests/{widgets => chrome}/frame_popupremoving_frame.xul (100%) rename toolkit/content/tests/{widgets => chrome}/popup_childframe_node.xul (100%) rename toolkit/content/tests/{widgets => chrome}/popup_trigger.js (99%) rename toolkit/content/tests/{widgets => chrome}/test_bug360220.xul (79%) rename toolkit/content/tests/{widgets => chrome}/test_bug365773.xul (84%) rename toolkit/content/tests/{widgets => chrome}/test_bug382990.xul (77%) rename toolkit/content/tests/{widgets => chrome}/test_bug457632.xul (96%) rename toolkit/content/tests/{widgets => chrome}/test_bug460942.xul (78%) rename toolkit/content/tests/{widgets => chrome}/test_bug509732.xul (85%) rename toolkit/content/tests/{widgets => chrome}/test_bug554279.xul (77%) rename toolkit/content/tests/{widgets => chrome}/test_bug557987.xul (84%) rename toolkit/content/tests/{widgets => chrome}/test_bug562554.xul (85%) rename toolkit/content/tests/{widgets => chrome}/test_button.xul (84%) rename toolkit/content/tests/{widgets => chrome}/test_closemenu_attribute.xul (84%) rename toolkit/content/tests/{widgets => chrome}/test_colorpicker_popup.xul (88%) rename toolkit/content/tests/{widgets => chrome}/test_contextmenu_list.xul (95%) rename toolkit/content/tests/{widgets => chrome}/test_focus_anons.xul (87%) rename toolkit/content/tests/{widgets => chrome}/test_hiddenitems.xul (90%) rename toolkit/content/tests/{widgets => chrome}/test_hiddenpaging.xul (95%) rename toolkit/content/tests/{widgets => chrome}/test_menu.xul (84%) rename toolkit/content/tests/{widgets => chrome}/test_menu_hide.xul (72%) rename toolkit/content/tests/{widgets => chrome}/test_menuitem_blink.xul (89%) rename toolkit/content/tests/{widgets => chrome}/test_menulist.xul (95%) rename toolkit/content/tests/{widgets => chrome}/test_menulist_keynav.xul (92%) rename toolkit/content/tests/{widgets => chrome}/test_notificationbox.xul (97%) rename toolkit/content/tests/{widgets => chrome}/test_panelfrommenu.xul (89%) rename toolkit/content/tests/{widgets => chrome}/test_popup_attribute.xul (66%) rename toolkit/content/tests/{widgets => chrome}/test_popup_button.xul (66%) rename toolkit/content/tests/{widgets => chrome}/test_popup_coords.xul (88%) rename toolkit/content/tests/{widgets => chrome}/test_popup_keys.xul (86%) rename toolkit/content/tests/{widgets => chrome}/test_popup_preventdefault.xul (84%) rename toolkit/content/tests/{widgets => chrome}/test_popup_recreate.xul (80%) rename toolkit/content/tests/{widgets => chrome}/test_popup_scaled.xul (87%) rename toolkit/content/tests/{widgets => chrome}/test_popup_tree.xul (81%) rename toolkit/content/tests/{widgets => chrome}/test_popuphidden.xul (86%) rename toolkit/content/tests/{widgets => chrome}/test_popupincontent.xul (88%) rename toolkit/content/tests/{widgets => chrome}/test_popupremoving.xul (91%) rename toolkit/content/tests/{widgets => chrome}/test_popupremoving_frame.xul (83%) rename toolkit/content/tests/{widgets => chrome}/test_position.xul (91%) rename toolkit/content/tests/{widgets => chrome}/test_progressmeter.xul (87%) rename toolkit/content/tests/{widgets => chrome}/test_props.xul (90%) rename toolkit/content/tests/{widgets => chrome}/test_radio.xul (82%) rename toolkit/content/tests/{widgets => chrome}/test_richlist_direction.xul (94%) rename toolkit/content/tests/{widgets => chrome}/test_scale.xul (96%) rename toolkit/content/tests/{widgets => chrome}/test_scrollbar.xul (92%) rename toolkit/content/tests/{widgets => chrome}/test_sorttemplate.xul (85%) rename toolkit/content/tests/{widgets => chrome}/test_statusbar.xul (76%) rename toolkit/content/tests/{widgets => chrome}/test_tabbox.xul (92%) rename toolkit/content/tests/{widgets => chrome}/test_tabindex.xul (89%) rename toolkit/content/tests/{widgets => chrome}/test_textbox_emptytext.xul (81%) rename toolkit/content/tests/{widgets => chrome}/test_textbox_number.xul (96%) rename toolkit/content/tests/{widgets => chrome}/test_textbox_search.xul (94%) rename toolkit/content/tests/{widgets => chrome}/test_timepicker.xul (94%) rename toolkit/content/tests/{widgets => chrome}/test_toolbar.xul (96%) rename toolkit/content/tests/{widgets => chrome}/test_tooltip.xul (94%) rename toolkit/content/tests/{widgets => chrome}/test_tooltip_noautohide.xul (77%) rename toolkit/content/tests/{widgets => chrome}/test_tree.xul (83%) rename toolkit/content/tests/{widgets => chrome}/test_tree_single.xul (87%) rename toolkit/content/tests/{widgets => chrome}/test_tree_view.xul (81%) rename toolkit/content/tests/{widgets => chrome}/window_popup_attribute.xul (86%) rename toolkit/content/tests/{widgets => chrome}/window_popup_button.xul (86%) rename toolkit/content/tests/{widgets => chrome}/xul_selectcontrol.js (100%) delete mode 100644 toolkit/content/tests/widgets/test_bug359754.xul diff --git a/testing/mochitest/harness-overlay.xul b/testing/mochitest/harness-overlay.xul index 2ddc1d14a87..7683fda1382 100644 --- a/testing/mochitest/harness-overlay.xul +++ b/testing/mochitest/harness-overlay.xul @@ -79,7 +79,7 @@ function loadTests()
- +
diff --git a/toolkit/content/tests/chrome/Makefile.in b/toolkit/content/tests/chrome/Makefile.in index 4bdd1e2bee0..bc42321707c 100644 --- a/toolkit/content/tests/chrome/Makefile.in +++ b/toolkit/content/tests/chrome/Makefile.in @@ -107,6 +107,74 @@ _TEST_FILES = findbar_window.xul \ window_panel.xul \ $(NULL) + +_TEST_FILES += \ + test_bug360220.xul \ + test_bug365773.xul \ + test_bug382990.xul \ + test_bug457632.xul \ + test_bug460942.xul \ + test_bug509732.xul \ + test_bug554279.xul \ + test_bug557987.xul\ + test_bug562554.xul \ + test_button.xul \ + test_closemenu_attribute.xul \ + test_colorpicker_popup.xul \ + test_menulist.xul \ + test_menuitem_blink.xul \ + test_menulist_keynav.xul \ + test_popup_coords.xul \ + test_popup_recreate.xul \ + test_popup_preventdefault.xul \ + test_notificationbox.xul \ + test_scale.xul \ + test_radio.xul \ + test_tabbox.xul \ + test_progressmeter.xul \ + test_props.xul \ + test_statusbar.xul \ + test_timepicker.xul \ + test_tree.xul \ + test_tree_view.xul \ + test_tree_single.xul \ + test_textbox_emptytext.xul \ + test_textbox_number.xul \ + test_textbox_search.xul \ + test_toolbar.xul \ + xul_selectcontrol.js \ + test_popupincontent.xul \ + test_panelfrommenu.xul \ + test_hiddenitems.xul \ + test_hiddenpaging.xul \ + test_popup_tree.xul \ + test_popup_keys.xul \ + test_popuphidden.xul \ + test_popup_scaled.xul \ + test_popupremoving.xul \ + test_popupremoving_frame.xul \ + frame_popupremoving_frame.xul \ + test_position.xul \ + test_menu.xul \ + test_menu_hide.xul \ + test_focus_anons.xul \ + test_tabindex.xul \ + test_scrollbar.xul \ + test_sorttemplate.xul \ + test_contextmenu_list.xul \ + test_richlist_direction.xul \ + test_tooltip.xul \ + test_popup_attribute.xul \ + window_popup_attribute.xul \ + test_popup_button.xul \ + window_popup_button.xul \ + popup_childframe_node.xul \ + popup_trigger.js \ + test_tooltip_noautohide.xul \ + $(NULL) + + + # test_panel_focus.xul won't work if the Full Keyboard Access preference is set to # textboxes and lists only, so skip this test on Mac ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT)) diff --git a/toolkit/content/tests/widgets/frame_popupremoving_frame.xul b/toolkit/content/tests/chrome/frame_popupremoving_frame.xul similarity index 100% rename from toolkit/content/tests/widgets/frame_popupremoving_frame.xul rename to toolkit/content/tests/chrome/frame_popupremoving_frame.xul diff --git a/toolkit/content/tests/widgets/popup_childframe_node.xul b/toolkit/content/tests/chrome/popup_childframe_node.xul similarity index 100% rename from toolkit/content/tests/widgets/popup_childframe_node.xul rename to toolkit/content/tests/chrome/popup_childframe_node.xul diff --git a/toolkit/content/tests/widgets/popup_trigger.js b/toolkit/content/tests/chrome/popup_trigger.js similarity index 99% rename from toolkit/content/tests/widgets/popup_trigger.js rename to toolkit/content/tests/chrome/popup_trigger.js index 5027b612249..97b37b8b911 100644 --- a/toolkit/content/tests/widgets/popup_trigger.js +++ b/toolkit/content/tests/chrome/popup_trigger.js @@ -417,7 +417,6 @@ var popupTests = [ var childframe = document.getElementById("childframe"); if (childframe) { for (var t = 0; t < 2; t++) { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var child = childframe.contentDocument; var evt = child.createEvent("Event"); evt.initEvent("click", true, true); diff --git a/toolkit/content/tests/widgets/test_bug360220.xul b/toolkit/content/tests/chrome/test_bug360220.xul similarity index 79% rename from toolkit/content/tests/widgets/test_bug360220.xul rename to toolkit/content/tests/chrome/test_bug360220.xul index ec7007a0477..401a1465c86 100644 --- a/toolkit/content/tests/widgets/test_bug360220.xul +++ b/toolkit/content/tests/chrome/test_bug360220.xul @@ -1,6 +1,6 @@ - + @@ -9,8 +9,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=360220 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> Test for Bug 360220 - - + + Mozilla Bug 360220 diff --git a/toolkit/content/tests/widgets/test_bug365773.xul b/toolkit/content/tests/chrome/test_bug365773.xul similarity index 84% rename from toolkit/content/tests/widgets/test_bug365773.xul rename to toolkit/content/tests/chrome/test_bug365773.xul index cbf6932e095..9b3e0a5c994 100644 --- a/toolkit/content/tests/widgets/test_bug365773.xul +++ b/toolkit/content/tests/chrome/test_bug365773.xul @@ -1,6 +1,6 @@ - + @@ -9,8 +9,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=365773 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> Test for Bug 365773 - - + + Mozilla Bug 365773 diff --git a/toolkit/content/tests/widgets/test_bug382990.xul b/toolkit/content/tests/chrome/test_bug382990.xul similarity index 77% rename from toolkit/content/tests/widgets/test_bug382990.xul rename to toolkit/content/tests/chrome/test_bug382990.xul index bedb6cee850..31523116981 100644 --- a/toolkit/content/tests/widgets/test_bug382990.xul +++ b/toolkit/content/tests/chrome/test_bug382990.xul @@ -1,15 +1,15 @@ - + - - + + diff --git a/toolkit/content/tests/widgets/test_bug460942.xul b/toolkit/content/tests/chrome/test_bug460942.xul similarity index 78% rename from toolkit/content/tests/widgets/test_bug460942.xul rename to toolkit/content/tests/chrome/test_bug460942.xul index 1e9e9d7372c..1f8a760ff08 100644 --- a/toolkit/content/tests/widgets/test_bug460942.xul +++ b/toolkit/content/tests/chrome/test_bug460942.xul @@ -1,14 +1,14 @@ - + - - + +
+
+
+
+ + From 46406908e3af2816a94472f37084be194b176668 Mon Sep 17 00:00:00 2001 From: Doug Turner Date: Mon, 20 Jun 2011 09:40:52 -0700 Subject: [PATCH 062/406] Bug 662678 - Follow to address renaming issues. r=ventnor --- dom/system/unix/nsDeviceMotionSystem.cpp | 18 +++++++++--------- dom/system/unix/nsDeviceMotionSystem.h | 4 ++-- dom/system/windows/nsDeviceMotionSystem.cpp | 18 +++++++++--------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/dom/system/unix/nsDeviceMotionSystem.cpp b/dom/system/unix/nsDeviceMotionSystem.cpp index e92c6511613..4d84539afb3 100644 --- a/dom/system/unix/nsDeviceMotionSystem.cpp +++ b/dom/system/unix/nsDeviceMotionSystem.cpp @@ -42,10 +42,10 @@ typedef struct { const char* mPosition; const char* mCalibrate; - nsDeviceMotionSystemDriver mToken; -} DeviceMotion; + nsAccelerometerSystemDriver mToken; +} AccelerometerData; -static const DeviceMotion gDeviceMotions[] = { +static const AccelerometerData gAccelerometers[] = { // MacBook {"/sys/devices/platform/applesmc.768/position", "/sys/devices/platform/applesmc.768/calibrate", @@ -192,15 +192,15 @@ nsDeviceMotionSystem::UpdateHandler(nsITimer *aTimer, void *aClosure) void nsDeviceMotionSystem::Startup() { - // DeviceMotions in Linux are used by reading a file (yay UNIX!), which is + // Accelerometers in Linux are used by reading a file (yay UNIX!), which is // in a slightly different location depending on the driver. - for (unsigned int i = 0; i < NS_ARRAY_LENGTH(gDeviceMotions); i++) { - if (!(mPositionFile = fopen(gDeviceMotions[i].mPosition, "r"))) + for (unsigned int i = 0; i < NS_ARRAY_LENGTH(gAccelerometers); i++) { + if (!(mPositionFile = fopen(gAccelerometers[i].mPosition, "r"))) continue; - mType = gDeviceMotions[i].mToken; - if (gDeviceMotions[i].mCalibrate) { - mCalibrateFile = fopen(gDeviceMotions[i].mCalibrate, "r"); + mType = gAccelerometers[i].mToken; + if (gAccelerometers[i].mCalibrate) { + mCalibrateFile = fopen(gAccelerometers[i].mCalibrate, "r"); if (!mCalibrateFile) { fclose(mPositionFile); mPositionFile = nsnull; diff --git a/dom/system/unix/nsDeviceMotionSystem.h b/dom/system/unix/nsDeviceMotionSystem.h index 4a94eb9e53e..b26f00c21f9 100644 --- a/dom/system/unix/nsDeviceMotionSystem.h +++ b/dom/system/unix/nsDeviceMotionSystem.h @@ -41,7 +41,7 @@ #include #include "nsDeviceMotion.h" -enum nsDeviceMotionSystemDriver +enum nsAccelerometerSystemDriver { eNoSensor, eAppleSensor, @@ -61,7 +61,7 @@ class nsDeviceMotionSystem : public nsDeviceMotion FILE* mPositionFile; FILE* mCalibrateFile; - nsDeviceMotionSystemDriver mType; + nsAccelerometerSystemDriver mType; nsCOMPtr mUpdateTimer; static void UpdateHandler(nsITimer *aTimer, void *aClosure); diff --git a/dom/system/windows/nsDeviceMotionSystem.cpp b/dom/system/windows/nsDeviceMotionSystem.cpp index ec6efe89b92..b683b5594e6 100644 --- a/dom/system/windows/nsDeviceMotionSystem.cpp +++ b/dom/system/windows/nsDeviceMotionSystem.cpp @@ -52,11 +52,11 @@ typedef struct { char temp; // raw value (could be deg celsius?) unsigned short x0; // Used for "auto-center" unsigned short y0; // Used for "auto-center" -} ThinkPadDeviceMotionData; +} ThinkPadAccelerometerData; -typedef void (__stdcall *ShockproofGetDeviceMotionData)(ThinkPadDeviceMotionData*); +typedef void (__stdcall *ShockproofGetAccelerometerData)(ThinkPadAccelerometerData*); -ShockproofGetDeviceMotionData gShockproofGetDeviceMotionData = nsnull; +ShockproofGetAccelerometerData gShockproofGetAccelerometerData = nsnull; class ThinkPadSensor : public Sensor { @@ -85,9 +85,9 @@ ThinkPadSensor::Startup() if (!mLibrary) return PR_FALSE; - gShockproofGetDeviceMotionData = (ShockproofGetDeviceMotionData) - GetProcAddress(mLibrary, "ShockproofGetDeviceMotionData"); - if (!gShockproofGetDeviceMotionData) { + gShockproofGetAccelerometerData = (ShockproofGetAccelerometerData) + GetProcAddress(mLibrary, "ShockproofGetAccelerometerData"); + if (!gShockproofGetAccelerometerData) { FreeLibrary(mLibrary); mLibrary = nsnull; return PR_FALSE; @@ -101,15 +101,15 @@ ThinkPadSensor::Shutdown() NS_ASSERTION(mLibrary, "Shutdown called when mLibrary is null?"); FreeLibrary(mLibrary); mLibrary = nsnull; - gShockproofGetDeviceMotionData = nsnull; + gShockproofGetAccelerometerData = nsnull; } void ThinkPadSensor::GetValues(double *x, double *y, double *z) { - ThinkPadDeviceMotionData accelData; + ThinkPadAccelerometerData accelData; - gShockproofGetDeviceMotionData(&accelData); + gShockproofGetAccelerometerData(&accelData); // accelData.x and accelData.y is the acceleration measured from the accelerometer. // x and y is switched from what we use, and the accelerometer does not support z axis. From 6db1e5491ac69f871dfcbdfec3fe7306b3ecd64d Mon Sep 17 00:00:00 2001 From: Mounir Lamouri Date: Mon, 20 Jun 2011 19:02:42 +0200 Subject: [PATCH 063/406] Bug 664925 - Don't set NSZeroSize to say that a given control size isn't available. r=mstange Actually, we should patch DrawCellWithSnapping to ignore sizes set to NSZeroSize, see bug 665571. --- widget/reftests/664925.xhtml | 1 + widget/reftests/reftest.list | 1 + widget/src/cocoa/nsNativeThemeCocoa.mm | 10 ++++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 widget/reftests/664925.xhtml diff --git a/widget/reftests/664925.xhtml b/widget/reftests/664925.xhtml new file mode 100644 index 00000000000..b4a11a73861 --- /dev/null +++ b/widget/reftests/664925.xhtml @@ -0,0 +1 @@ +
diff --git a/widget/reftests/reftest.list b/widget/reftests/reftest.list index 1cf1e1f3f3a..7200783baf8 100644 --- a/widget/reftests/reftest.list +++ b/widget/reftests/reftest.list @@ -1,2 +1,3 @@ skip-if(!cocoaWidget) != 507947.html about:blank == progressbar-fallback-default-style.html progressbar-fallback-default-style-ref.html +load 664925.xhtml diff --git a/widget/src/cocoa/nsNativeThemeCocoa.mm b/widget/src/cocoa/nsNativeThemeCocoa.mm index 4831fe9b396..dbc4d932a46 100644 --- a/widget/src/cocoa/nsNativeThemeCocoa.mm +++ b/widget/src/cocoa/nsNativeThemeCocoa.mm @@ -1143,7 +1143,10 @@ static const CellRenderSettings progressSettings[2][2] = { // Determined settings. { { - NSZeroSize, // mini + // TODO: for the moment, DrawCellWithSnapping doesn't handle NSZeroSize + // values in this array so we have to use negative values until + // bug 665571 is fixed. + NSMakeSize(-5, -5), // mini NSMakeSize(10, 0), // small NSMakeSize(16, 0) // regular }, @@ -1161,7 +1164,10 @@ static const CellRenderSettings progressSettings[2][2] = { // There is no horizontal margin in regular undetermined size. { { - NSZeroSize, // mini + // TODO: for the moment, DrawCellWithSnapping doesn't handle NSZeroSize + // values in this array so we have to use negative values until + // bug 665571 is fixed. + NSMakeSize(-5, -5), // mini NSMakeSize(10, 0), // small NSMakeSize(16, 0) // regular }, From d6ed4b6794438e5d380d03bc7c527f0eed7b6907 Mon Sep 17 00:00:00 2001 From: Siddharth Agarwal Date: Mon, 20 Jun 2011 13:58:44 -0400 Subject: [PATCH 064/406] Bug 598794 - Intermittent failure in uriloader\exthandler\tests\unit\test_punycodeURIs.js | test failed (with xpcshell return code: 0), see following log: Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIFileInputStream.init]; r=sdwilsh --HG-- extra : rebase_source : 0152a5ff0932102e55949e25a821f72461733bf9 --- uriloader/exthandler/tests/unit/test_punycodeURIs.js | 1 + 1 file changed, 1 insertion(+) diff --git a/uriloader/exthandler/tests/unit/test_punycodeURIs.js b/uriloader/exthandler/tests/unit/test_punycodeURIs.js index 72c8f18d712..7f3f548bb17 100644 --- a/uriloader/exthandler/tests/unit/test_punycodeURIs.js +++ b/uriloader/exthandler/tests/unit/test_punycodeURIs.js @@ -58,6 +58,7 @@ function checkFile() { ++gCheckExistsAttempts; // Wait a bit longer then try again do_timeout(1000, checkFile); + return; } } From 422a93648a9fe50b2802f5c57071102ebae831f4 Mon Sep 17 00:00:00 2001 From: Michael Wu Date: Mon, 20 Jun 2011 15:23:21 -0400 Subject: [PATCH 065/406] Bug 653143 - Avoid duplicates in omnijar; r=tglek --- config/optimizejars.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/config/optimizejars.py b/config/optimizejars.py index 42fbfdee49d..cbd0e7a0a08 100644 --- a/config/optimizejars.py +++ b/config/optimizejars.py @@ -245,6 +245,9 @@ def optimizejar(jar, outjar, inlog = None): cdir_data = "" written_count = 0 + crc_mapping = {} + dups_found = 0 + dupe_bytes = 0 # store number of bytes suggested for readahead for entry in central_directory: # read in the header twice..first for comparison, second time for convenience when writing out @@ -274,6 +277,14 @@ def optimizejar(jar, outjar, inlog = None): assert_true(len(entry_data) != expected_len, "%s entry size - expected:%d got:%d" % (entry.filename, len(entry_data), expected_len)) written_count += 1 + + if entry.crc32 in crc_mapping: + dups_found += 1 + dupe_bytes += entry.compressed_size + len(data) + len(entry_data) + print("%s\n\tis a duplicate of\n%s\n---"%(entry.filename, crc_mapping[entry.crc32])) + else: + crc_mapping[entry.crc32] = entry.filename; + if inlog is not None: if written_count == reordered_count: readahead = out_offset @@ -288,6 +299,9 @@ def optimizejar(jar, outjar, inlog = None): if inlog is None: dirend.cdir_offset = out_offset + if dups_found > 0: + print("WARNING: Found %d duplicate files taking %d bytes"%(dups_found, dupe_bytes)) + dirend.cdir_size = len(cdir_data) dirend_data = dirend.pack() assert_true(size_of(cdir_end) == len(dirend_data), "Failed to serialize directory end correctly. Serialized size;%d, expected:%d"%(len(dirend_data), size_of(cdir_end))); From eae3886d0e381a0c55620d1d05833a39397ec4b3 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Mon, 20 Jun 2011 15:25:57 -0400 Subject: [PATCH 066/406] Backout 64b58e1da898 (bug 664925) because of reftest oranges on OS X --- widget/reftests/664925.xhtml | 1 - widget/reftests/reftest.list | 1 - widget/src/cocoa/nsNativeThemeCocoa.mm | 10 ++-------- 3 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 widget/reftests/664925.xhtml diff --git a/widget/reftests/664925.xhtml b/widget/reftests/664925.xhtml deleted file mode 100644 index b4a11a73861..00000000000 --- a/widget/reftests/664925.xhtml +++ /dev/null @@ -1 +0,0 @@ -
diff --git a/widget/reftests/reftest.list b/widget/reftests/reftest.list index 7200783baf8..1cf1e1f3f3a 100644 --- a/widget/reftests/reftest.list +++ b/widget/reftests/reftest.list @@ -1,3 +1,2 @@ skip-if(!cocoaWidget) != 507947.html about:blank == progressbar-fallback-default-style.html progressbar-fallback-default-style-ref.html -load 664925.xhtml diff --git a/widget/src/cocoa/nsNativeThemeCocoa.mm b/widget/src/cocoa/nsNativeThemeCocoa.mm index dbc4d932a46..4831fe9b396 100644 --- a/widget/src/cocoa/nsNativeThemeCocoa.mm +++ b/widget/src/cocoa/nsNativeThemeCocoa.mm @@ -1143,10 +1143,7 @@ static const CellRenderSettings progressSettings[2][2] = { // Determined settings. { { - // TODO: for the moment, DrawCellWithSnapping doesn't handle NSZeroSize - // values in this array so we have to use negative values until - // bug 665571 is fixed. - NSMakeSize(-5, -5), // mini + NSZeroSize, // mini NSMakeSize(10, 0), // small NSMakeSize(16, 0) // regular }, @@ -1164,10 +1161,7 @@ static const CellRenderSettings progressSettings[2][2] = { // There is no horizontal margin in regular undetermined size. { { - // TODO: for the moment, DrawCellWithSnapping doesn't handle NSZeroSize - // values in this array so we have to use negative values until - // bug 665571 is fixed. - NSMakeSize(-5, -5), // mini + NSZeroSize, // mini NSMakeSize(10, 0), // small NSMakeSize(16, 0) // regular }, From 84621ef93ec9b2544bf441ef4c9734bf8c79eab2 Mon Sep 17 00:00:00 2001 From: Mehdi Mulani Date: Mon, 13 Jun 2011 17:24:14 -0400 Subject: [PATCH 067/406] Bug 652294 - Fix intermittent failure in test_hashcompleter.js by checking for duplicates. r=dcamp --- .../tests/unit/head_urlclassifier.js | 29 +++++++++++++++ .../tests/unit/test_hashcompleter.js | 37 ++++++++++--------- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/toolkit/components/url-classifier/tests/unit/head_urlclassifier.js b/toolkit/components/url-classifier/tests/unit/head_urlclassifier.js index de564bd38c2..aed072d1668 100644 --- a/toolkit/components/url-classifier/tests/unit/head_urlclassifier.js +++ b/toolkit/components/url-classifier/tests/unit/head_urlclassifier.js @@ -304,4 +304,33 @@ notify: function(timer) { } } +// LFSRgenerator is a 32-bit linear feedback shift register random number +// generator. It is highly predictable and is not intended to be used for +// cryptography but rather to allow easier debugging than a test that uses +// Math.random(). +function LFSRgenerator(seed) { + // Force |seed| to be a number. + seed = +seed; + // LFSR generators do not work with a value of 0. + if (seed == 0) + seed = 1; + + this._value = seed; +} +LFSRgenerator.prototype = { + // nextNum returns a random unsigned integer of in the range [0,2^|bits|]. + nextNum: function(bits) { + if (!bits) + bits = 32; + + let val = this._value; + // Taps are 32, 22, 2 and 1. + let bit = ((val >>> 0) ^ (val >>> 10) ^ (val >>> 30) ^ (val >>> 31)) & 1; + val = (val >>> 1) | (bit << 31); + this._value = val; + + return (val >>> (32 - bits)); + }, +}; + cleanUp(); diff --git a/toolkit/components/url-classifier/tests/unit/test_hashcompleter.js b/toolkit/components/url-classifier/tests/unit/test_hashcompleter.js index c88e86bf502..660fde7d79a 100644 --- a/toolkit/components/url-classifier/tests/unit/test_hashcompleter.js +++ b/toolkit/components/url-classifier/tests/unit/test_hashcompleter.js @@ -121,24 +121,37 @@ let multipleResponsesCompletionSet = [ const SIZE_OF_RANDOM_SET = 16; function addRandomCompletionSet() { let completionSet = []; + let hashPrefixes = []; + + let seed = Math.floor(Math.random() * Math.pow(2, 32)); + dump("Using seed of " + seed + " for random completion set.\n"); + let rand = new LFSRgenerator(seed); + for (let i = 0; i < SIZE_OF_RANDOM_SET; i++) { let completion = {}; // Generate a random 256 bit hash. First we get a random number and then // convert it to a string. - let hash = ""; - let length = 1 + Math.floor(Math.random() * 32); - for (let i = 0; i < length; i++) - hash += String.fromCharCode(Math.floor(Math.random() * 256)); + let hash; + let prefix; + do { + hash = ""; + let length = 1 + rand.nextNum(5); + for (let i = 0; i < length; i++) + hash += String.fromCharCode(rand.nextNum(8)); + prefix = hash.substring(0,4); + } while (hashPrefixes.indexOf(prefix) != -1); + + hashPrefixes.push(prefix); completion.hash = hash; - completion.expectCompletion = Math.random() < 0.5; + completion.expectCompletion = rand.nextNum(1) == 1; if (completion.expectCompletion) { // Generate a random alpha-numeric string of length at most 6 for the // table name. - completion.table = Math.floor(Math.random() * Math.pow(36, 6)).toString(36); + completion.table = (rand.nextNum(31)).toString(36); - completion.chunkId = Math.floor(Math.random() * Math.pow(2, 16)); + completion.chunkId = rand.nextNum(16); } completionSet.push(completion); @@ -264,16 +277,6 @@ function callback(completion) { } callback.prototype = { completion: function completion(hash, table, chunkId, trusted) { - // This check was added as part of diagnostics for bug 652294. - if (!this._completion.expectCompletion) { - dump("Did not expect a completion for this result. Provided values:\n" + - "hash: " + JSON.stringify(hash) + "\ntable: " + table + "chunkId: " + - chunkId + "\n"); - dump("Actual values:\nhash: " + JSON.stringify(this._completion.hash) + - "\ntable: " + this._completion.table + "\nchunkId: " + - this._completion.chunkId + "\n"); - } - do_check_true(this._completion.expectCompletion); if (this._completion.multipleCompletions) { From 903d57b4b53b48138e09e8fe3d6b39e4de651c27 Mon Sep 17 00:00:00 2001 From: Alex Pakhotin Date: Thu, 26 May 2011 12:58:41 -0700 Subject: [PATCH 068/406] Bug 645729 - Make sure 'body' data is sent along with special links (mailto and sms). r=blassey --- embedding/android/GeckoAppShell.java | 29 +++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/embedding/android/GeckoAppShell.java b/embedding/android/GeckoAppShell.java index 1a1d5abe2f7..e453058ba58 100644 --- a/embedding/android/GeckoAppShell.java +++ b/embedding/android/GeckoAppShell.java @@ -772,7 +772,34 @@ public class GeckoAppShell } else if (aMimeType.length() > 0) { intent.setDataAndType(Uri.parse(aUriSpec), aMimeType); } else { - intent.setData(Uri.parse(aUriSpec)); + Uri uri = Uri.parse(aUriSpec); + if ("sms".equals(uri.getScheme())) { + // Have a apecial handling for the SMS, as the message body + // is not extracted from the URI automatically + final String query = uri.getEncodedQuery(); + if (query != null && query.length() > 0) { + final String[] fields = query.split("&"); + boolean foundBody = false; + String resultQuery = ""; + for (int i = 0; i < fields.length; i++) { + final String field = fields[i]; + if (field.length() > 5 && "body=".equals(field.substring(0, 5))) { + final String body = Uri.decode(field.substring(5)); + intent.putExtra("sms_body", body); + foundBody = true; + } + else { + resultQuery = resultQuery.concat(resultQuery.length() > 0 ? "&" + field : field); + } + } + if (foundBody) { + // Put the query without the body field back into the URI + final String prefix = aUriSpec.substring(0, aUriSpec.indexOf('?')); + uri = Uri.parse(resultQuery.length() > 0 ? prefix + "?" + resultQuery : prefix); + } + } + } + intent.setData(uri); } if (aPackageName.length() > 0 && aClassName.length() > 0) intent.setClassName(aPackageName, aClassName); From e8cfcb729979563de5b19d43d6a572a09bcb45bb Mon Sep 17 00:00:00 2001 From: Alex Pakhotin Date: Mon, 13 Jun 2011 14:02:13 -0700 Subject: [PATCH 069/406] Bug 649381 - implement moz-icon android support. r=blassey --- dom/ipc/ContentParent.cpp | 14 ++ dom/ipc/ContentParent.h | 1 + dom/ipc/PContent.ipdl | 3 + embedding/android/GeckoAppShell.java | 56 +++++++ modules/libpr0n/decoders/Makefile.in | 4 + modules/libpr0n/decoders/icon/Makefile.in | 4 + .../libpr0n/decoders/icon/android/Makefile.in | 56 +++++++ .../decoders/icon/android/nsIconChannel.cpp | 155 ++++++++++++++++++ .../decoders/icon/android/nsIconChannel.h | 75 +++++++++ toolkit/library/libxul-config.mk | 2 +- widget/src/android/AndroidBridge.cpp | 32 ++++ widget/src/android/AndroidBridge.h | 3 + 12 files changed, 404 insertions(+), 1 deletion(-) create mode 100644 modules/libpr0n/decoders/icon/android/Makefile.in create mode 100644 modules/libpr0n/decoders/icon/android/nsIconChannel.cpp create mode 100644 modules/libpr0n/decoders/icon/android/nsIconChannel.h diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 479cd58cc74..1b440c4eab4 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -562,6 +562,20 @@ ContentParent::RecvGetSystemColors(const PRUint32& colorsCount, InfallibleTArray return true; } +bool +ContentParent::RecvGetIconForExtension(const nsCString& aFileExt, const PRUint32& aIconSize, InfallibleTArray* bits) +{ +#ifdef ANDROID + if (!AndroidBridge::Bridge()) + return false; + + bits->AppendElements(aIconSize * aIconSize * 4); + + AndroidBridge::Bridge()->GetIconForExtension(aFileExt, aIconSize, bits->Elements()); +#endif + return true; +} + NS_IMPL_THREADSAFE_ISUPPORTS3(ContentParent, nsIObserver, nsIThreadObserver, diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 9d41329b25d..f7f9c4798a7 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -166,6 +166,7 @@ private: virtual bool RecvClipboardHasText(PRBool* hasText); virtual bool RecvGetSystemColors(const PRUint32& colorsCount, InfallibleTArray* colors); + virtual bool RecvGetIconForExtension(const nsCString& aFileExt, const PRUint32& aIconSize, InfallibleTArray* bits); virtual bool RecvStartVisitedQuery(const IPC::URI& uri); diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 939aa6f9dbd..597a2e12a80 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -197,6 +197,9 @@ parent: sync GetSystemColors(PRUint32 colorsCount) returns (PRUint32[] colors); + sync GetIconForExtension(nsCString aFileExt, PRUint32 aIconSize) + returns (PRUint8[] bits); + both: AsyncMessage(nsString aMessage, nsString aJSON); diff --git a/embedding/android/GeckoAppShell.java b/embedding/android/GeckoAppShell.java index e453058ba58..d595b2f9ba5 100644 --- a/embedding/android/GeckoAppShell.java +++ b/embedding/android/GeckoAppShell.java @@ -67,6 +67,9 @@ import android.net.Uri; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.graphics.drawable.*; +import android.graphics.Bitmap; + public class GeckoAppShell { // static members only @@ -1178,4 +1181,57 @@ public class GeckoAppShell Context context = GeckoApp.surfaceView.getContext(); GeckoMediaScannerClient client = new GeckoMediaScannerClient(context, aFile, aMimeType); } + + public static byte[] getIconForExtension(String aExt, int iconSize) { + try { + if (iconSize <= 0) + iconSize = 16; + + if (aExt != null && aExt.length() > 1 && aExt.charAt(0) == '.') + aExt = aExt.substring(1); + + PackageManager pm = GeckoApp.surfaceView.getContext().getPackageManager(); + Drawable icon = getDrawableForExtension(pm, aExt); + if (icon == null) { + // Use a generic icon + icon = pm.getDefaultActivityIcon(); + } + + Bitmap bitmap = ((BitmapDrawable)icon).getBitmap(); + if (bitmap.getWidth() != iconSize || bitmap.getHeight() != iconSize) + bitmap = Bitmap.createScaledBitmap(bitmap, iconSize, iconSize, true); + + ByteBuffer buf = ByteBuffer.allocate(iconSize * iconSize * 4); + bitmap.copyPixelsToBuffer(buf); + + return buf.array(); + } + catch (Exception e) { + Log.i("GeckoAppShell", "getIconForExtension error: ", e); + return null; + } + } + + private static Drawable getDrawableForExtension(PackageManager pm, String aExt) { + Intent intent = new Intent(Intent.ACTION_VIEW); + MimeTypeMap mtm = MimeTypeMap.getSingleton(); + String mimeType = mtm.getMimeTypeFromExtension(aExt); + if (mimeType != null && mimeType.length() > 0) + intent.setType(mimeType); + else + return null; + + List list = pm.queryIntentActivities(intent, 0); + if (list.size() == 0) + return null; + + ResolveInfo resolveInfo = list.get(0); + + if (resolveInfo == null) + return null; + + ActivityInfo activityInfo = resolveInfo.activityInfo; + + return activityInfo.loadIcon(pm); + } } diff --git a/modules/libpr0n/decoders/Makefile.in b/modules/libpr0n/decoders/Makefile.in index a45abf64bea..b91c5d15743 100644 --- a/modules/libpr0n/decoders/Makefile.in +++ b/modules/libpr0n/decoders/Makefile.in @@ -82,6 +82,10 @@ endif ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) DIRS = icon/mac icon endif +ifeq ($(OS_TARGET),Android) +DIRS = icon/android icon +endif + include $(topsrcdir)/config/rules.mk diff --git a/modules/libpr0n/decoders/icon/Makefile.in b/modules/libpr0n/decoders/icon/Makefile.in index e6483ed2210..511c21fba8b 100644 --- a/modules/libpr0n/decoders/icon/Makefile.in +++ b/modules/libpr0n/decoders/icon/Makefile.in @@ -69,6 +69,10 @@ ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) PLATFORM = mac endif +ifeq ($(OS_TARGET),Android) +PLATFORM = android +endif + CPPSRCS = \ nsIconURI.cpp \ nsIconModule.cpp \ diff --git a/modules/libpr0n/decoders/icon/android/Makefile.in b/modules/libpr0n/decoders/icon/android/Makefile.in new file mode 100644 index 00000000000..6696601d6d7 --- /dev/null +++ b/modules/libpr0n/decoders/icon/android/Makefile.in @@ -0,0 +1,56 @@ +# ***** 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 +# Mozilla Foundation +# Portions created by the Initial Developer are Copyright (C) 2011 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Alex Pakhotin +# +# 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 ***** + +DEPTH = ../../../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = imgicon +LIBRARY_NAME = imgiconandroid_s +LIBXUL_LIBRARY = 1 + +CPPSRCS = nsIconChannel.cpp + +# we don't want the shared lib, but we want to force the creation of a static lib. +FORCE_STATIC_LIB = 1 + +include $(topsrcdir)/config/config.mk +include $(topsrcdir)/ipc/chromium/chromium-config.mk +include $(topsrcdir)/config/rules.mk diff --git a/modules/libpr0n/decoders/icon/android/nsIconChannel.cpp b/modules/libpr0n/decoders/icon/android/nsIconChannel.cpp new file mode 100644 index 00000000000..38d1e4f93c8 --- /dev/null +++ b/modules/libpr0n/decoders/icon/android/nsIconChannel.cpp @@ -0,0 +1,155 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** 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 + * Mozilla Foundation + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Alex Pakhotin + * + * 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 ***** */ + +#include +#include "mozilla/dom/ContentChild.h" +#include "nsIURL.h" +#include "nsXULAppAPI.h" +#include "AndroidBridge.h" +#include "nsIconChannel.h" + +NS_IMPL_ISUPPORTS2(nsIconChannel, + nsIRequest, + nsIChannel) + +using namespace mozilla; +using mozilla::dom::ContentChild; + +static nsresult +GetIconForExtension(const nsACString& aFileExt, PRUint32 aIconSize, PRUint8 * const aBuf) +{ + if (!AndroidBridge::Bridge()) + return NS_ERROR_FAILURE; + + AndroidBridge::Bridge()->GetIconForExtension(aFileExt, aIconSize, aBuf); + + return NS_OK; +} + +static nsresult +CallRemoteGetIconForExtension(const nsACString& aFileExt, PRUint32 aIconSize, PRUint8 * const aBuf) +{ + NS_ENSURE_TRUE(aBuf != nsnull, NS_ERROR_NULL_POINTER); + + // An array has to be used to get data from remote process + InfallibleTArray bits; + PRUint32 bufSize = aIconSize * aIconSize * 4; + + if (!ContentChild::GetSingleton()->SendGetIconForExtension(PromiseFlatCString(aFileExt), aIconSize, &bits)) + return NS_ERROR_FAILURE; + + NS_ASSERTION(bits.Length() == bufSize, "Pixels array is incomplete"); + if (bits.Length() != bufSize) + return NS_ERROR_FAILURE; + + memcpy(aBuf, bits.Elements(), bufSize); + + return NS_OK; +} + +static nsresult +moz_icon_to_channel(nsIURI *aURI, const nsACString& aFileExt, PRUint32 aIconSize, nsIChannel **aChannel) +{ + NS_ENSURE_TRUE(aIconSize < 256 && aIconSize > 0, NS_ERROR_UNEXPECTED); + + int width = aIconSize; + int height = aIconSize; + + // moz-icon data should have two bytes for the size, + // then the ARGB pixel values with pre-multiplied Alpha + const int channels = 4; + long int buf_size = 2 + channels * height * width; + PRUint8 * const buf = (PRUint8*)NS_Alloc(buf_size); + NS_ENSURE_TRUE(buf, NS_ERROR_OUT_OF_MEMORY); + PRUint8 * out = buf; + + *(out++) = width; + *(out++) = height; + + nsresult rv; + if (XRE_GetProcessType() == GeckoProcessType_Default) + rv = GetIconForExtension(aFileExt, aIconSize, out); + else + rv = CallRemoteGetIconForExtension(aFileExt, aIconSize, out); + NS_ENSURE_SUCCESS(rv, rv); + + // Encode the RGBA data + const PRUint8 * in = out; + for (int y = 0; y < height; ++y) { + for (int x = 0; x < width; ++x) { + PRUint8 r = *(in++); + PRUint8 g = *(in++); + PRUint8 b = *(in++); + PRUint8 a = *(in++); +#define DO_PREMULTIPLY(c_) PRUint8(PRUint16(c_) * PRUint16(a) / PRUint16(255)) + *(out++) = DO_PREMULTIPLY(b); + *(out++) = DO_PREMULTIPLY(g); + *(out++) = DO_PREMULTIPLY(r); + *(out++) = a; +#undef DO_PREMULTIPLY + } + } + + nsCOMPtr stream = + do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv); + NS_ENSURE_SUCCESS(rv, rv); + + rv = stream->AdoptData((char*)buf, buf_size); + NS_ENSURE_SUCCESS(rv, rv); + + return NS_NewInputStreamChannel(aChannel, aURI, stream, + NS_LITERAL_CSTRING("image/icon")); +} + +nsresult +nsIconChannel::Init(nsIURI* aURI) +{ + nsCOMPtr iconURI = do_QueryInterface(aURI); + NS_ASSERTION(iconURI, "URI is not an nsIMozIconURI"); + + nsCAutoString stockIcon; + iconURI->GetStockIcon(stockIcon); + + PRUint32 desiredImageSize; + iconURI->GetImageSize(&desiredImageSize); + + nsCAutoString iconFileExt; + iconURI->GetFileExtension(iconFileExt); + + return moz_icon_to_channel(iconURI, iconFileExt, desiredImageSize, getter_AddRefs(mRealChannel)); +} diff --git a/modules/libpr0n/decoders/icon/android/nsIconChannel.h b/modules/libpr0n/decoders/icon/android/nsIconChannel.h new file mode 100644 index 00000000000..ca64f698859 --- /dev/null +++ b/modules/libpr0n/decoders/icon/android/nsIconChannel.h @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** 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 + * Mozilla Foundation + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Alex Pakhotin + * + * 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 nsIconChannel_h_ +#define nsIconChannel_h_ + +#include "nsIChannel.h" +#include "nsIURI.h" +#include "nsIIconURI.h" +#include "nsCOMPtr.h" + +/** + * This class is the Android implementation of nsIconChannel. + * It asks Android for an icon, and creates a new channel for + * that file to which all calls will be proxied. + */ +class nsIconChannel : public nsIChannel { + public: + NS_DECL_ISUPPORTS + NS_FORWARD_NSIREQUEST(mRealChannel->) + NS_FORWARD_NSICHANNEL(mRealChannel->) + + nsIconChannel() {} + ~nsIconChannel() {} + + /** + * Called by nsIconProtocolHandler after it creates this channel. + * Must be called before calling any other function on this object. + * If this method fails, no other function must be called on this object. + */ + NS_HIDDEN_(nsresult) Init(nsIURI* aURI); + private: + /** + * The channel to the temp icon file (e.g. to /tmp/2qy9wjqw.html). + * Will always be non-null after a successful Init. + */ + nsCOMPtr mRealChannel; +}; + +#endif diff --git a/toolkit/library/libxul-config.mk b/toolkit/library/libxul-config.mk index a479c37c03a..191e4d3d865 100644 --- a/toolkit/library/libxul-config.mk +++ b/toolkit/library/libxul-config.mk @@ -266,7 +266,7 @@ endif endif # Platform-specific icon channel stuff - supported mostly-everywhere -ifneq (,$(filter windows os2 mac cocoa gtk2 qt,$(MOZ_WIDGET_TOOLKIT))) +ifneq (,$(filter windows os2 mac cocoa gtk2 qt android,$(MOZ_WIDGET_TOOLKIT))) DEFINES += -DICON_DECODER COMPONENT_LIBS += imgicon endif diff --git a/widget/src/android/AndroidBridge.cpp b/widget/src/android/AndroidBridge.cpp index b45c41b31db..1e8493bae3f 100644 --- a/widget/src/android/AndroidBridge.cpp +++ b/widget/src/android/AndroidBridge.cpp @@ -144,6 +144,7 @@ AndroidBridge::Init(JNIEnv *jEnv, jSetSelectedLocale = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "setSelectedLocale", "(Ljava/lang/String;)V"); jScanMedia = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "scanMedia", "(Ljava/lang/String;Ljava/lang/String;)V"); jGetSystemColors = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getSystemColors", "()[I"); + jGetIconForExtension = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getIconForExtension", "(Ljava/lang/String;I)[B"); jEGLContextClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGLContext")); jEGL10Class = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGL10")); @@ -713,6 +714,37 @@ AndroidBridge::GetSystemColors(AndroidSystemColors *aColors) mJNIEnv->ReleaseIntArrayElements(arr, elements, 0); } +void +AndroidBridge::GetIconForExtension(const nsACString& aFileExt, PRUint32 aIconSize, PRUint8 * const aBuf) +{ + ALOG_BRIDGE("AndroidBridge::GetIconForExtension"); + NS_ASSERTION(aBuf != nsnull, "AndroidBridge::GetIconForExtension: aBuf is null!"); + if (!aBuf) + return; + + AutoLocalJNIFrame jniFrame; + + nsString fileExt; + CopyUTF8toUTF16(aFileExt, fileExt); + jstring jstrFileExt = mJNIEnv->NewString(nsPromiseFlatString(fileExt).get(), fileExt.Length()); + + jobject obj = mJNIEnv->CallStaticObjectMethod(mGeckoAppShellClass, jGetIconForExtension, jstrFileExt, aIconSize); + jbyteArray arr = static_cast(obj); + NS_ASSERTION(arr != nsnull, "AndroidBridge::GetIconForExtension: Returned pixels array is null!"); + if (!arr) + return; + + jsize len = mJNIEnv->GetArrayLength(arr); + jbyte *elements = mJNIEnv->GetByteArrayElements(arr, 0); + + PRUint32 bufSize = aIconSize * aIconSize * 4; + NS_ASSERTION(len == bufSize, "AndroidBridge::GetIconForExtension: Pixels array is incomplete!"); + if (len == bufSize) + memcpy(aBuf, elements, bufSize); + + mJNIEnv->ReleaseByteArrayElements(arr, elements, 0); +} + void AndroidBridge::SetSurfaceView(jobject obj) { diff --git a/widget/src/android/AndroidBridge.h b/widget/src/android/AndroidBridge.h index e97c6a13cb6..54c0b75ed8a 100644 --- a/widget/src/android/AndroidBridge.h +++ b/widget/src/android/AndroidBridge.h @@ -208,6 +208,8 @@ public: void GetSystemColors(AndroidSystemColors *aColors); + void GetIconForExtension(const nsACString& aFileExt, PRUint32 aIconSize, PRUint8 * const aBuf); + struct AutoLocalJNIFrame { AutoLocalJNIFrame(int nEntries = 128) : mEntries(nEntries) { // Make sure there is enough space to store a local ref to the @@ -313,6 +315,7 @@ protected: jmethodID jSetSelectedLocale; jmethodID jScanMedia; jmethodID jGetSystemColors; + jmethodID jGetIconForExtension; // stuff we need for CallEglCreateWindowSurface jclass jEGLSurfaceImplClass; From 0abe2f192fc6e743d467f78cabd700839402e89c Mon Sep 17 00:00:00 2001 From: Alex Pakhotin Date: Fri, 20 May 2011 16:29:40 -0700 Subject: [PATCH 070/406] Bug 658691 - remove android:debuggable="true" from AndroidManifest.xml r=blassey --- embedding/android/AndroidManifest.xml.in | 4 ++++ embedding/android/Makefile.in | 1 + 2 files changed, 5 insertions(+) diff --git a/embedding/android/AndroidManifest.xml.in b/embedding/android/AndroidManifest.xml.in index e66ba5aae08..aa463b6f2ca 100644 --- a/embedding/android/AndroidManifest.xml.in +++ b/embedding/android/AndroidManifest.xml.in @@ -21,7 +21,11 @@ +#else android:debuggable="true"> +#endif Date: Tue, 21 Jun 2011 12:37:03 -0700 Subject: [PATCH 071/406] Bug 665985 - Remove unused pref app.update.nagTimer.restart [r=gavin,mfinkle] --- browser/app/profile/firefox.js | 4 ---- mobile/app/mobile.js | 1 - 2 files changed, 5 deletions(-) diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index cd0cc46aef8..f547006a33a 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -166,10 +166,6 @@ pref("app.update.url", "https://aus3.mozilla.org/update/3/%PRODUCT%/%VERSION%/%B // app.update.interval is in branding section -// Interval: Time before prompting the user again to restart to install the -// latest download (in seconds) default=1 day -pref("app.update.nagTimer.restart", 86400); - // Give the user x seconds to react before showing the big UI. default=12 hours pref("app.update.promptWaitTime", 43200); // Show the Update Checking/Ready UI when the user was idle for x seconds diff --git a/mobile/app/mobile.js b/mobile/app/mobile.js index a943c64d17d..88807cb16b8 100644 --- a/mobile/app/mobile.js +++ b/mobile/app/mobile.js @@ -503,7 +503,6 @@ pref("app.update.channel", "@MOZ_UPDATE_CHANNEL@"); pref("app.update.mode", 1); pref("app.update.silent", false); pref("app.update.url", "https://aus2.mozilla.org/update/4/%PRODUCT%/%VERSION%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/%PLATFORM_VERSION%/update.xml"); -pref("app.update.nagTimer.restart", 86400); pref("app.update.promptWaitTime", 43200); pref("app.update.idletime", 60); pref("app.update.showInstalledUI", false); From d36db1500c13a1d50d1f1b11d5585947eabf2f2c Mon Sep 17 00:00:00 2001 From: Steffen Wilberg Date: Tue, 21 Jun 2011 22:23:26 +0200 Subject: [PATCH 072/406] Bug 663253: Remove the 'browser.offline' preference (don't remember offline mode from the previous session). r=gavin --- browser/base/content/browser.js | 4 ---- browser/components/nsBrowserGlue.js | 13 ------------- .../extensions/test/xpinstall/browser_offline.js | 2 -- toolkit/system/dbus/nsDBusService.h | 5 +---- 4 files changed, 1 insertion(+), 23 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index c2ca5bda610..fd973be1205 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -5919,10 +5919,6 @@ var BrowserOffline = { } ioService.offline = !ioService.offline; - - // Save the current state for later use as the initial state - // (if there is no netLinkService) - gPrefService.setBoolPref("browser.offline", ioService.offline); }, ///////////////////////////////////////////////////////////////////////////// diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js index ccacbf0946e..bdee2a60991 100644 --- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -350,19 +350,6 @@ BrowserGlue.prototype = { // handle any UI migration this._migrateUI(); - // if ioService is managing the offline status, then ioservice.offline - // is already set correctly. We will continue to allow the ioService - // to manage its offline state until the user uses the "Work Offline" UI. - if (!Services.io.manageOfflineStatus) { - // set the initial state - try { - Services.io.offline = Services.prefs.getBoolPref("browser.offline"); - } - catch (e) { - Services.io.offline = false; - } - } - Services.obs.notifyObservers(null, "browser-ui-startup-complete", ""); }, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_offline.js b/toolkit/mozapps/extensions/test/xpinstall/browser_offline.js index 0ac1692dd7b..6050f24450c 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_offline.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_offline.js @@ -18,7 +18,6 @@ function test() { function download_progress(addon, value, maxValue) { try { Services.io.manageOfflineStatus = false; - Services.prefs.setBoolPref("browser.offline", true); Services.io.offline = true; } catch (ex) { } @@ -37,7 +36,6 @@ function finish_test(count) { is(count, 0, "No add-ons should have been installed"); try { - Services.prefs.setBoolPref("browser.offline", false); Services.io.offline = false; } catch (ex) { } diff --git a/toolkit/system/dbus/nsDBusService.h b/toolkit/system/dbus/nsDBusService.h index 674702c4576..6a0e1ae6480 100644 --- a/toolkit/system/dbus/nsDBusService.h +++ b/toolkit/system/dbus/nsDBusService.h @@ -67,10 +67,7 @@ public: * for NetworkManager state changes; we set nsIOService's offline status to * FALSE when NetworkManager reports NM_STATE_CONNECTED, and to TRUE otherwise. * We also solicit the current status from NetworkManager when this component - * gets loaded. In addition to setting IOService, we also set the - * "browser.offline" preference (because Firefox treats that preference as - * authoritative). We have to wait until prefs have been loaded before setting - * "browser.offline". + * gets loaded. * * In the future we could extend this class to talk to other daemons. * From 71ce4d4a7fe8608f2c60b857f9381a6e9ffc8c3b Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Tue, 21 Jun 2011 16:44:50 -0400 Subject: [PATCH 073/406] Bug 664290. Lower image.mem.min_discard_timeout_ms. r=joe Lowering this value to try to keep our working set smaller. The last choice was arbitrarily large, and we've run into problems with too many images being kept decoded. --HG-- extra : rebase_source : d439284d15e231055b1daed02f5d90e3ad9d7c79 --- modules/libpref/src/init/all.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 89a12dfe769..a505a793d5b 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -3166,7 +3166,11 @@ pref("image.mem.decodeondraw", false); // Minimum timeout for image discarding (in milliseconds). The actual time in // which an image must inactive for it to be discarded will vary between this // value and twice this value. -pref("image.mem.min_discard_timeout_ms", 120000); +// +// This used to be 120 seconds, but having it that high causes our working +// set to grow very large. Switching it back to 10 seconds will hopefully +// be better. +pref("image.mem.min_discard_timeout_ms", 10000); // Chunk size for calls to the image decoders pref("image.mem.decode_bytes_at_a_time", 200000); From 51fdf6bd68844f5f6d1815cd41a075b87aa024f7 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Wed, 25 May 2011 14:50:08 -0400 Subject: [PATCH 074/406] Bug 659707. Add -Wdeclaration-after-statement to CFLAGS. r=khuey MSVC doesn't like declarations after statements so we should warn on other platforms too. --- configure.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 0c9592470eb..f577ac0f637 100644 --- a/configure.in +++ b/configure.in @@ -1544,10 +1544,11 @@ if test "$GNU_CC"; then # -Wall - turn on all warnings # -pedantic - make compiler warn about non-ANSI stuff, and # be a little bit stricter + # -Wdeclaration-after-statement - MSVC doesn't like these # Warnings slamm took out for now (these were giving more noise than help): # -Wbad-function-cast - warns when casting a function to a new return type # -Wshadow - removed because it generates more noise than help --pete - _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -W -Wno-unused -Wpointer-arith" + _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -W -Wno-unused -Wpointer-arith -Wdeclaration-after-statement" if test -z "$INTEL_CC"; then # Don't use -Wcast-align with ICC case "$CPU_ARCH" in From b817907a2bb707cae40d5c55b9ca9a713c67064e Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Tue, 21 Jun 2011 16:48:18 -0400 Subject: [PATCH 075/406] Bug 660662. Remove unnecessary floor in nsNativeTheme::QueueAnimatedContentForRefresh. r=bent Positive numbers are already floored when truncated so this should have no semantic change, and avoids some implicit conversions. --- widget/src/xpwidgets/nsNativeTheme.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widget/src/xpwidgets/nsNativeTheme.cpp b/widget/src/xpwidgets/nsNativeTheme.cpp index a44e0b8a3aa..ad8f03c02dd 100644 --- a/widget/src/xpwidgets/nsNativeTheme.cpp +++ b/widget/src/xpwidgets/nsNativeTheme.cpp @@ -518,7 +518,7 @@ nsNativeTheme::QueueAnimatedContentForRefresh(nsIContent* aContent, NS_ASSERTION(aMinimumFrameRate <= 1000, "aMinimumFrameRate must be less than 1000!"); - PRUint32 timeout = PRUint32(NS_floor(1000 / aMinimumFrameRate)); + PRUint32 timeout = 1000 / aMinimumFrameRate; timeout = NS_MIN(mAnimatedContentTimeout, timeout); if (!mAnimatedContentTimer) { From ce569d9ab643952638fe3458abd219d44761114a Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 21 Jun 2011 17:00:47 -0400 Subject: [PATCH 076/406] Bug 548734. Get rid of the footgun ui.use_native_popup_windows preference. r=roc,khuey --- configure.in | 5 +++++ layout/forms/nsComboboxControlFrame.cpp | 6 +++++- mobile/app/mobile.js | 3 --- mobile/confvars.sh | 3 +++ modules/libpref/src/init/all.js | 1 - widget/src/cocoa/nsChildView.mm | 6 +++--- widget/src/cocoa/nsCocoaWindow.mm | 6 +++++- widget/src/cocoa/nsToolkit.mm | 7 ++++--- 8 files changed, 25 insertions(+), 12 deletions(-) diff --git a/configure.in b/configure.in index f577ac0f637..18bd27b7684 100644 --- a/configure.in +++ b/configure.in @@ -4808,6 +4808,7 @@ NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket wyciw USE_ARM_KUSER= BUILD_CTYPES=1 XPC_IDISPATCH_SUPPORT= +MOZ_USE_NATIVE_POPUP_WINDOWS= case "${target}" in @@ -6340,6 +6341,10 @@ for extension in $MOZ_EXTENSIONS; do fi done +if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then + AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS) +fi + dnl ======================================================== dnl SVG Display Lists dnl ======================================================== diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 4a582d32369..cc4e4340acd 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -1520,6 +1520,10 @@ nsComboboxControlFrame::RestoreState(nsPresState* aState) PRBool nsComboboxControlFrame::ToolkitHasNativePopup() { - return Preferences::GetBool("ui.use_native_popup_windows"); +#ifdef MOZ_USE_NATIVE_POPUP_WINDOWS + return PR_TRUE; +#else + return PR_FALSE; +#endif /* MOZ_USE_NATIVE_POPUP_WINDOWS */ } diff --git a/mobile/app/mobile.js b/mobile/app/mobile.js index 88807cb16b8..50284e5dbdc 100644 --- a/mobile/app/mobile.js +++ b/mobile/app/mobile.js @@ -73,9 +73,6 @@ pref("toolkit.zoomManager.zoomValues", ".2,.3,.5,.67,.8,.9,1,1.1,1.2,1.33,1.5,1. // Device pixel to CSS px ratio, in percent. Set to -1 to calculate based on display density. pref("browser.viewport.scaleRatio", -1); -/* use custom widget for html:select */ -pref("ui.use_native_popup_windows", true); - /* allow scrollbars to float above chrome ui */ pref("ui.scrollbarsCanOverlapContent", 1); diff --git a/mobile/confvars.sh b/mobile/confvars.sh index a8766a29c2f..fce3e498b8c 100644 --- a/mobile/confvars.sh +++ b/mobile/confvars.sh @@ -60,3 +60,6 @@ fi # Needed for building our components as part of libxul MOZ_APP_COMPONENT_LIBS="browsercomps" MOZ_APP_COMPONENT_INCLUDE=nsBrowserComponents.h + +# use custom widget for html:select +MOZ_USE_NATIVE_POPUP_WINDOWS=1 diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index a505a793d5b..251f4afbf93 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -98,7 +98,6 @@ pref("browser.sessionhistory.max_total_viewers", -1); pref("browser.sessionhistory.optimize_eviction", true); pref("ui.use_native_colors", true); -pref("ui.use_native_popup_windows", false); pref("ui.click_hold_context_menus", false); pref("browser.display.use_document_fonts", 1); // 0 = never, 1 = quick, 2 = always pref("browser.display.use_document_colors", true); diff --git a/widget/src/cocoa/nsChildView.mm b/widget/src/cocoa/nsChildView.mm index 4f3d6dd50ba..833fcd47d9b 100644 --- a/widget/src/cocoa/nsChildView.mm +++ b/widget/src/cocoa/nsChildView.mm @@ -2955,9 +2955,9 @@ NSEvent* gLastDragMouseDownEvent = nil; if (!gRollupWidget) return; - if (Preferences::GetBool("ui.use_native_popup_windows", PR_FALSE)) { - return; - } +#ifdef MOZ_USE_NATIVE_POPUP_WINDOWS + return; +#endif /* MOZ_USE_NATIVE_POPUP_WINDOWS */ NSWindow *popupWindow = (NSWindow*)gRollupWidget->GetNativeData(NS_NATIVE_WINDOW); if (!popupWindow || ![popupWindow isKindOfClass:[PopupWindow class]]) diff --git a/widget/src/cocoa/nsCocoaWindow.mm b/widget/src/cocoa/nsCocoaWindow.mm index b739c3154d8..111b93c627b 100644 --- a/widget/src/cocoa/nsCocoaWindow.mm +++ b/widget/src/cocoa/nsCocoaWindow.mm @@ -227,7 +227,11 @@ static void FitRectToVisibleAreaForScreen(nsIntRect &aRect, NSScreen *screen) // (native context menus, native tooltips) static PRBool UseNativePopupWindows() { - return Preferences::GetBool("ui.use_native_popup_windows", PR_FALSE); +#ifdef MOZ_USE_NATIVE_POPUP_WINDOWS + return PR_TRUE; +#else + return PR_FALSE; +#endif /* MOZ_USE_NATIVE_POPUP_WINDOWS */ } nsresult nsCocoaWindow::Create(nsIWidget *aParent, diff --git a/widget/src/cocoa/nsToolkit.mm b/widget/src/cocoa/nsToolkit.mm index 9459796adf6..09e29badffd 100644 --- a/widget/src/cocoa/nsToolkit.mm +++ b/widget/src/cocoa/nsToolkit.mm @@ -271,9 +271,10 @@ nsToolkit::RegisterForAllProcessMouseEvents() NS_OBJC_BEGIN_TRY_ABORT_BLOCK; // Don't do this for apps that (like Camino) use native context menus. - if (Preferences::GetBool("ui.use_native_popup_windows", PR_FALSE)) { - return; - } +#ifdef MOZ_USE_NATIVE_POPUP_WINDOWS + return; +#endif /* MOZ_USE_NATIVE_POPUP_WINDOWS */ + if (!mEventMonitorHandler) { EventTypeSpec kEvents[] = {{kEventClassMouse, kEventMouseMoved}}; InstallEventHandler(GetEventMonitorTarget(), EventMonitorHandler, From d40e2e3231937f7d6a086989a4c361a47a9c7ff2 Mon Sep 17 00:00:00 2001 From: Taras Glek Date: Tue, 21 Jun 2011 14:39:11 -0700 Subject: [PATCH 077/406] Bug 665805 - Adjust telemetry to work with official metrics server r=Mossop --- modules/libpref/src/init/all.js | 3 +-- toolkit/components/telemetry/TelemetryPing.js | 24 +++++++++++------- .../tests/unit/test_TelemetryPing.js | 25 +++++++++++++------ 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 251f4afbf93..7452142d652 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -272,8 +272,7 @@ pref("toolkit.scrollbox.clickToScroll.scrollDelay", 150); // Telemetry pref("toolkit.telemetry.enabled", false); -// Telemetry test server to be used until the official one is public -pref("toolkit.telemetry.server", "http://telemetry.allizom.org"); +pref("toolkit.telemetry.server", "https://data.mozilla.com"); // view source pref("view_source.syntax_highlight", true); diff --git a/toolkit/components/telemetry/TelemetryPing.js b/toolkit/components/telemetry/TelemetryPing.js index 3885812a89f..46fb70282dd 100644 --- a/toolkit/components/telemetry/TelemetryPing.js +++ b/toolkit/components/telemetry/TelemetryPing.js @@ -97,6 +97,7 @@ function getHistograms() { first = false; retgram.values[r[i - 1]] = 0; } + first = false; last = i + 1; retgram.values[r[i]] = value; } @@ -110,8 +111,9 @@ function getHistograms() { } function generateUUID() { - return Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator) - .generateUUID().toString(); + let str = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator).generateUUID().toString(); + // strip {} + return str.substring(1, str.length - 1); } /** @@ -236,9 +238,6 @@ TelemetryPing.prototype = { if (!this._path) this._path = "/submit/telemetry/" + (isTestPing ? reason : generateUUID()); - const TELEMETRY_PING = "telemetry.ping (ms)"; - const TELEMETRY_SUCCESS = "telemetry.success (No, Yes)"; - let hping = Telemetry.getHistogramById("TELEMETRY_PING"); let hsuccess = Telemetry.getHistogramById("TELEMETRY_SUCCESS"); @@ -248,17 +247,24 @@ TelemetryPing.prototype = { request.mozBackgroundRequest = true; request.open("POST", url, true); request.overrideMimeType("text/plain"); + request.setRequestHeader("Content-Type", "application/json"); let startTime = new Date() - function finishRequest(success_metric) { - hsuccess.add(success_metric); + function finishRequest(channel) { + let success = false; + try { + success = channel.QueryInterface(Ci.nsIHttpChannel).requestSucceeded; + } catch(e) { + } + hsuccess.add(success ? 1 : 0); hping.add(new Date() - startTime); if (isTestPing) Services.obs.notifyObservers(null, "telemetry-test-xhr-complete", null); } - request.onerror = function(aEvent) finishRequest(0); - request.onload = function(aEvent) finishRequest(1); + request.onerror = function(aEvent) finishRequest(request.channel); + request.onload = function(aEvent) finishRequest(request.channel); + request.send(nativeJSON.encode(payload)); }, diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js b/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js index ceea28e0cb1..28e501c824e 100644 --- a/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js @@ -11,7 +11,9 @@ do_load_httpd_js(); Cu.import("resource://gre/modules/Services.jsm"); -const PATH = "/submit/telemetry/test-ping" +const PATH = "/submit/telemetry/test-ping"; +const SERVER = "http://localhost:4444"; + const BinaryInputStream = Components.Constructor( "@mozilla.org/binaryinputstream;1", "nsIBinaryInputStream", @@ -21,7 +23,18 @@ var httpserver = new nsHttpServer(); function telemetry_ping () { let tp = Cc["@mozilla.org/base/telemetry-ping;1"].getService(Ci.nsIObserver); - tp.observe(tp, "test-ping", "http://localhost:4444"); + tp.observe(tp, "test-ping", SERVER); +} + +function nonexistentServerObserver(aSubject, aTopic, aData) { + Services.obs.removeObserver(nonexistentServerObserver, aTopic); + + httpserver.start(4444); + + // Provide a dummy function so it returns 200 instead of 404 to telemetry. + httpserver.registerPathHandler(PATH, function () {}); + Services.obs.addObserver(telemetryObserver, "telemetry-test-xhr-complete", false); + telemetry_ping(); } function telemetryObserver(aSubject, aTopic, aData) { @@ -32,10 +45,7 @@ function telemetryObserver(aSubject, aTopic, aData) { function run_test() { createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); - httpserver.start(4444); - - Services.obs.addObserver(telemetryObserver, "telemetry-test-xhr-complete", false); - + Services.obs.addObserver(nonexistentServerObserver, "telemetry-test-xhr-complete", false); telemetry_ping(); // spin the event loop do_test_pending(); @@ -55,6 +65,7 @@ function checkHistograms(request, response) { let payload = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON) .decode(readBytesFromInputStream(s)) + do_check_eq(request.getHeader("content-type"), "application/json; charset=UTF-8"); do_check_true(payload.simpleMeasurements.uptime >= 0) // get rid of the non-deterministic field @@ -81,7 +92,7 @@ function checkHistograms(request, response) { range: [1, 2], bucket_count: 3, histogram_type: 2, - values: {0:0, 1:1, 2:0} + values: {0:1, 1:1, 2:0} } let tc = payload.histograms[TELEMETRY_SUCCESS] do_check_eq(uneval(tc), From e765320a2de964ca6a7e9e6e81360b477f8963df Mon Sep 17 00:00:00 2001 From: Taras Glek Date: Tue, 21 Jun 2011 14:39:14 -0700 Subject: [PATCH 078/406] Bug 665805 - Include sums in histograms sent to server r=Mossop --- toolkit/components/telemetry/TelemetryPing.js | 3 ++- toolkit/components/telemetry/tests/unit/test_TelemetryPing.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/toolkit/components/telemetry/TelemetryPing.js b/toolkit/components/telemetry/TelemetryPing.js index 46fb70282dd..9c16c1a5fcc 100644 --- a/toolkit/components/telemetry/TelemetryPing.js +++ b/toolkit/components/telemetry/TelemetryPing.js @@ -82,7 +82,8 @@ function getHistograms() { range: [r[1], r[r.length - 1]], bucket_count: r.length, histogram_type: hgram.histogram_type, - values: {} + values: {}, + sum: hgram.sum }; let first = true; let last = 0; diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js b/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js index 28e501c824e..f0734d03bde 100644 --- a/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js @@ -92,7 +92,8 @@ function checkHistograms(request, response) { range: [1, 2], bucket_count: 3, histogram_type: 2, - values: {0:1, 1:1, 2:0} + values: {0:1, 1:1, 2:0}, + sum: 1 } let tc = payload.histograms[TELEMETRY_SUCCESS] do_check_eq(uneval(tc), From 548b9ace6e9494633787cf7e95ab593ba5739a81 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Sun, 22 May 2011 08:23:20 +0200 Subject: [PATCH 079/406] Bug 657297 part 1 - Expose a function to add telemetry samples in XRE. r=tglek,sr=bsmedberg --- toolkit/components/telemetry/Telemetry.cpp | 11 +++++++++++ xpcom/build/nsXULAppAPI.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/toolkit/components/telemetry/Telemetry.cpp b/toolkit/components/telemetry/Telemetry.cpp index f416ab6e23f..e48060d2ab7 100644 --- a/toolkit/components/telemetry/Telemetry.cpp +++ b/toolkit/components/telemetry/Telemetry.cpp @@ -50,6 +50,7 @@ #include "nsTHashtable.h" #include "nsHashKeys.h" #include "nsBaseHashtable.h" +#include "nsXULAppAPI.h" namespace { @@ -359,3 +360,13 @@ Accumulate(ID aHistogram, PRUint32 aSample) } // namespace mozilla NSMODULE_DEFN(nsTelemetryModule) = &kTelemetryModule; + +/** + * The XRE_TelemetryAdd function is to be used by embedding applications + * that can't use mozilla::Telemetry::Accumulate() directly. + */ +void +XRE_TelemetryAccumulate(int aID, PRUint32 aSample) +{ + mozilla::Telemetry::Accumulate((mozilla::Telemetry::ID) aID, aSample); +} diff --git a/xpcom/build/nsXULAppAPI.h b/xpcom/build/nsXULAppAPI.h index 887aa92582e..c11ee1a7d87 100644 --- a/xpcom/build/nsXULAppAPI.h +++ b/xpcom/build/nsXULAppAPI.h @@ -569,4 +569,7 @@ XRE_API(void, XRE_SetupDllBlocklist, ()) #endif +XRE_API(void, + XRE_TelemetryAccumulate, (int aID, PRUint32 aSample)) + #endif // _nsXULAppAPI_h__ From d63a0dc12da8bdc7422d0e4b197179d8b58be669 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Sun, 22 May 2011 08:24:32 +0200 Subject: [PATCH 080/406] Bug 657297 part 2 - Add telemetry samples for initial I/O counters. r=tglek --- browser/app/nsBrowserApp.cpp | 43 +++++++++++++++++-- .../telemetry/TelemetryHistograms.h | 9 ++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/browser/app/nsBrowserApp.cpp b/browser/app/nsBrowserApp.cpp index 78cca4760eb..19da11f9848 100644 --- a/browser/app/nsBrowserApp.cpp +++ b/browser/app/nsBrowserApp.cpp @@ -38,9 +38,12 @@ #include "nsXPCOMGlue.h" #include "nsXULAppAPI.h" -#ifdef XP_WIN +#if defined(XP_WIN) #include #include +#elif defined(XP_UNIX) +#include +#include #endif #include @@ -65,6 +68,8 @@ #include "nsXPCOMPrivate.h" // for MAXPATHLEN and XPCOM_DLL +#include "mozilla/Telemetry.h" + static void Output(const char *fmt, ... ) { va_list ap; @@ -117,6 +122,7 @@ XRE_FreeAppDataType XRE_FreeAppData; #ifdef XRE_HAS_DLL_BLOCKLIST XRE_SetupDllBlocklistType XRE_SetupDllBlocklist; #endif +XRE_TelemetryAccumulateType XRE_TelemetryAccumulate; XRE_mainType XRE_main; static const nsDynamicFunctionLoad kXULFuncs[] = { @@ -126,6 +132,7 @@ static const nsDynamicFunctionLoad kXULFuncs[] = { #ifdef XRE_HAS_DLL_BLOCKLIST { "XRE_SetupDllBlocklist", (NSFuncPtr*) &XRE_SetupDllBlocklist }, #endif + { "XRE_TelemetryAccumulate", (NSFuncPtr*) &XRE_TelemetryAccumulate }, { "XRE_main", (NSFuncPtr*) &XRE_main }, { nsnull, nsnull } }; @@ -209,15 +216,19 @@ int main(int argc, char* argv[]) strcpy(++lastSlash, XPCOM_DLL); -#ifdef XP_WIN + int gotCounters; +#if defined(XP_UNIX) + struct rusage initialRUsage; + gotCounters = !getrusage(RUSAGE_SELF, &initialRUsage); +#elif defined(XP_WIN) // GetProcessIoCounters().ReadOperationCount seems to have little to // do with actual read operations. It reports 0 or 1 at this stage // in the program. Luckily 1 coincides with when prefetch is // enabled. If Windows prefetch didn't happen we can do our own // faster dll preloading. IO_COUNTERS ioCounters; - if (GetProcessIoCounters(GetCurrentProcess(), &ioCounters) - && !ioCounters.ReadOperationCount) + gotCounters = GetProcessIoCounters(GetCurrentProcess(), &ioCounters); + if (gotCounters && !ioCounters.ReadOperationCount) #endif { XPCOMGlueEnablePreload(); @@ -240,6 +251,30 @@ int main(int argc, char* argv[]) XRE_SetupDllBlocklist(); #endif + if (gotCounters) { +#if defined(XP_WIN) + XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_OPS, + int(ioCounters.ReadOperationCount)); + XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_TRANSFER, + int(ioCounters.ReadTransferCount / 1024)); + IO_COUNTERS newIoCounters; + if (GetProcessIoCounters(GetCurrentProcess(), &newIoCounters)) { + XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_OPS, + int(newIoCounters.ReadOperationCount - ioCounters.ReadOperationCount)); + XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_TRANSFER, + int((newIoCounters.ReadTransferCount - ioCounters.ReadTransferCount) / 1024)); + } +#elif defined(XP_UNIX) + XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_HARD_FAULTS, + int(initialRUsage.ru_majflt)); + struct rusage newRUsage; + if (!getrusage(RUSAGE_SELF, &newRUsage)) { + XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_HARD_FAULTS, + int(newRUsage.ru_majflt - initialRUsage.ru_majflt)); + } +#endif + } + int result; { ScopedLogging log; diff --git a/toolkit/components/telemetry/TelemetryHistograms.h b/toolkit/components/telemetry/TelemetryHistograms.h index 739e8a28f0a..7238abf0884 100644 --- a/toolkit/components/telemetry/TelemetryHistograms.h +++ b/toolkit/components/telemetry/TelemetryHistograms.h @@ -48,3 +48,12 @@ HISTOGRAM(TELEMETRY_SUCCESS, 0, 1, 2, BOOLEAN, "Success(No, Yes) rate of teleme HISTOGRAM(MEMORY_JS_GC_HEAP, 1024, 512 * 1024, 10, EXPONENTIAL, "Memory(MB) used by the JavaScript GC") HISTOGRAM(MEMORY_RESIDENT, 32 * 1024, 1024 * 1024, 10, EXPONENTIAL, "Resident memory(MB) reported by OS") HISTOGRAM(MEMORY_LAYOUT_ALL, 1024, 64 * 1024, 10, EXPONENTIAL, "Memory(MB) reported used by layout") +#if defined(XP_WIN) +HISTOGRAM(EARLY_GLUESTARTUP_READ_OPS, 1, 100, 12, LINEAR, "ProcessIoCounters.ReadOperationCount before glue startup") +HISTOGRAM(EARLY_GLUESTARTUP_READ_TRANSFER, 1, 50 * 1024, 12, EXPONENTIAL, "ProcessIoCounters.ReadTransferCount before glue startup (KB)") +HISTOGRAM(GLUESTARTUP_READ_OPS, 1, 100, 12, LINEAR, "ProcessIoCounters.ReadOperationCount after glue startup") +HISTOGRAM(GLUESTARTUP_READ_TRANSFER, 1, 50 * 1024, 12, EXPONENTIAL, "ProcessIoCounters.ReadTransferCount after glue startup (KB)") +#elif defined(XP_UNIX) +HISTOGRAM(EARLY_GLUESTARTUP_HARD_FAULTS, 1, 100, 12, LINEAR, "Hard faults count before glue startup") +HISTOGRAM(GLUESTARTUP_HARD_FAULTS, 1, 500, 12, EXPONENTIAL, "Hard faults count after glue startup") +#endif From c12341f81d0d6200970a1eb10996961ff61e3493 Mon Sep 17 00:00:00 2001 From: Mihai Sucan Date: Tue, 14 Jun 2011 13:44:51 +0300 Subject: [PATCH 081/406] Bug 660560 - Scratchpad lacks indentation, pressing TAB key should indent code. r=dietrich --- browser/app/profile/firefox.js | 6 + browser/base/content/scratchpad.js | 49 ++++++++ browser/base/content/test/Makefile.in | 1 + .../test/browser_scratchpad_bug_660560_tab.js | 116 ++++++++++++++++++ 4 files changed, 172 insertions(+) create mode 100644 browser/base/content/test/browser_scratchpad_bug_660560_tab.js diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 4bd970bc093..821d68f8a24 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -1033,6 +1033,12 @@ pref("devtools.hud.loglimit.cssparser", 200); pref("devtools.hud.loglimit.exception", 200); pref("devtools.hud.loglimit.console", 200); +// The developer tools editor configuration: +// - tabsize: how many spaces to use when a Tab character is displayed. +// - expandtab: expand Tab characters to spaces. +pref("devtools.editor.tabsize", 4); +pref("devtools.editor.expandtab", true); + // Whether the character encoding menu is under the main Firefox button. This // preference is a string so that localizers can alter it. pref("browser.menu.showCharacterEncoding", "chrome://browser/locale/browser.properties"); diff --git a/browser/base/content/scratchpad.js b/browser/base/content/scratchpad.js index 6781d02c052..abb932cd266 100644 --- a/browser/base/content/scratchpad.js +++ b/browser/base/content/scratchpad.js @@ -64,6 +64,9 @@ const SCRATCHPAD_L10N = "chrome://browser/locale/scratchpad.properties"; const SCRATCHPAD_WINDOW_FEATURES = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no"; const DEVTOOLS_CHROME_ENABLED = "devtools.chrome.enabled"; +const PREF_TABSIZE = "devtools.editor.tabsize"; +const PREF_EXPANDTAB = "devtools.editor.expandtab"; + /** * The scratchpad object handles the Scratchpad window functionality. */ @@ -628,7 +631,53 @@ var Scratchpad = { errorConsoleCommand.removeAttribute("disabled"); chromeContextCommand.removeAttribute("disabled"); } + + let tabsize = Services.prefs.getIntPref(PREF_TABSIZE); + if (tabsize < 1) { + // tabsize is invalid, clear back to the default value. + Services.prefs.clearUserPref(PREF_TABSIZE); + tabsize = Services.prefs.getIntPref(PREF_TABSIZE); + } + + let expandtab = Services.prefs.getBoolPref(PREF_EXPANDTAB); + this._tabCharacter = expandtab ? (new Array(tabsize + 1)).join(" ") : "\t"; + this.textbox.style.MozTabSize = tabsize; + this.insertIntro(); + + // Make the Tab key work. + this.textbox.addEventListener("keypress", this.onKeypress.bind(this), false); + + this.textbox.focus(); + }, + + /** + * The textbox keypress event handler which allows users to indent code using + * the Tab key. + * + * @param nsIDOMEvent aEvent + */ + onKeypress: function SP_onKeypress(aEvent) + { + if (aEvent.keyCode == aEvent.DOM_VK_TAB) { + this.insertTextAtCaret(this._tabCharacter); + aEvent.preventDefault(); + } + }, + + /** + * Insert text at the current caret location. + * + * @param string aText + */ + insertTextAtCaret: function SP_insertTextAtCaret(aText) + { + let firstPiece = this.textbox.value.substring(0, this.textbox.selectionStart); + let lastPiece = this.textbox.value.substring(this.textbox.selectionEnd); + this.textbox.value = firstPiece + aText + lastPiece; + + let newCaretPosition = firstPiece.length + aText.length; + this.selectRange(newCaretPosition, newCaretPosition); }, }; diff --git a/browser/base/content/test/Makefile.in b/browser/base/content/test/Makefile.in index 4915d246214..73260d58464 100644 --- a/browser/base/content/test/Makefile.in +++ b/browser/base/content/test/Makefile.in @@ -201,6 +201,7 @@ _BROWSER_FILES = \ browser_scratchpad_files.js \ browser_scratchpad_ui.js \ browser_scratchpad_bug_646070_chrome_context_pref.js \ + browser_scratchpad_bug_660560_tab.js \ browser_overflowScroll.js \ browser_locationBarExternalLoad.js \ browser_pageInfo.js \ diff --git a/browser/base/content/test/browser_scratchpad_bug_660560_tab.js b/browser/base/content/test/browser_scratchpad_bug_660560_tab.js new file mode 100644 index 00000000000..eca5ea2f86f --- /dev/null +++ b/browser/base/content/test/browser_scratchpad_bug_660560_tab.js @@ -0,0 +1,116 @@ +/* vim: set ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Reference to the Scratchpad chrome window object. +let gScratchpadWindow; + +function test() +{ + waitForExplicitFinish(); + + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.selectedBrowser.addEventListener("load", function() { + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); + + ok(window.Scratchpad, "Scratchpad variable exists"); + + Services.prefs.setIntPref("devtools.editor.tabsize", 5); + + gScratchpadWindow = Scratchpad.openScratchpad(); + gScratchpadWindow.addEventListener("load", runTests, false); + }, true); + + content.location = "data:text/html,Scratchpad test for the Tab key, bug 660560"; +} + +function runTests() +{ + gScratchpadWindow.removeEventListener("load", arguments.callee, false); + + let sp = gScratchpadWindow.Scratchpad; + ok(sp, "Scratchpad object exists in new window"); + + is(gScratchpadWindow.document.activeElement, sp.textbox.inputField, + "The textbox has focus"); + + is(sp.textbox.style.MozTabSize, 5, "-moz-tab-size is correct"); + + sp.textbox.value = "window.foo;"; + sp.selectRange(1, 3); + + EventUtils.synthesizeKey("VK_TAB", {}, gScratchpadWindow); + + is(sp.textbox.value, "w dow.foo;", + "Tab key added 5 spaces"); + + is(sp.textbox.selectionStart, 6, "caret location is correct"); + + is(sp.textbox.selectionStart, sp.textbox.selectionEnd, + "caret location is correct, confirmed"); + + // Test the new insertTextAtCaret() method. + + sp.insertTextAtCaret("omg"); + + is(sp.textbox.value, "w omgdow.foo;", "insertTextAtCaret() works"); + + is(sp.textbox.selectionStart, 9, "caret location is correct after update"); + + is(sp.textbox.selectionStart, sp.textbox.selectionEnd, + "caret location is correct, confirmed"); + + gScratchpadWindow.close(); + + Services.prefs.setIntPref("devtools.editor.tabsize", 6); + Services.prefs.setBoolPref("devtools.editor.expandtab", false); + gScratchpadWindow = Scratchpad.openScratchpad(); + gScratchpadWindow.addEventListener("load", runTests2, false); +} + +function runTests2() +{ + gScratchpadWindow.removeEventListener("load", arguments.callee, false); + + let sp = gScratchpadWindow.Scratchpad; + + is(sp.textbox.style.MozTabSize, 6, "-moz-tab-size is correct"); + + sp.textbox.value = "window.foo;"; + sp.selectRange(1, 3); + + EventUtils.synthesizeKey("VK_TAB", {}, gScratchpadWindow); + + is(sp.textbox.value, "w\tdow.foo;", "Tab key added the tab character"); + + is(sp.textbox.selectionStart, 2, "caret location is correct"); + + is(sp.textbox.selectionStart, sp.textbox.selectionEnd, + "caret location is correct, confirmed"); + + gScratchpadWindow.close(); + + // check with an invalid tabsize value. + Services.prefs.setIntPref("devtools.editor.tabsize", 0); + Services.prefs.setBoolPref("devtools.editor.expandtab", true); + gScratchpadWindow = Scratchpad.openScratchpad(); + gScratchpadWindow.addEventListener("load", runTests3, false); +} + +function runTests3() +{ + gScratchpadWindow.removeEventListener("load", arguments.callee, false); + + let sp = gScratchpadWindow.Scratchpad; + + is(sp.textbox.style.MozTabSize, 4, "-moz-tab-size is correct"); + + Services.prefs.clearUserPref("devtools.editor.tabsize"); + Services.prefs.clearUserPref("devtools.editor.expandtab"); + + gScratchpadWindow.close(); + gScratchpadWindow = null; + + gBrowser.removeCurrentTab(); + finish(); +} From c64a3fd0a2987f1b1c81779da5b4c4c48c2b418f Mon Sep 17 00:00:00 2001 From: Panos Astithas Date: Fri, 27 May 2011 21:58:05 +0300 Subject: [PATCH 082/406] Bug 651501 - document.body fails to autocomplete in Web Console. r=dtownsend --- .../console/hudservice/HUDService.jsm | 29 +++++-- .../console/hudservice/PropertyPanel.jsm | 76 ++++++++++++++++--- .../hudservice/tests/browser/Makefile.in | 1 + ...e_bug_651501_document_body_autocomplete.js | 72 ++++++++++++++++++ 4 files changed, 159 insertions(+), 19 deletions(-) create mode 100644 toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_651501_document_body_autocomplete.js diff --git a/toolkit/components/console/hudservice/HUDService.jsm b/toolkit/components/console/hudservice/HUDService.jsm index 55841a0296b..c6076845e98 100644 --- a/toolkit/components/console/hudservice/HUDService.jsm +++ b/toolkit/components/console/hudservice/HUDService.jsm @@ -51,6 +51,7 @@ const CONSOLEAPI_CLASS_ID = "{b49c18f8-3379-4fc0-8c90-d7772c1a9ff3}"; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource:///modules/NetworkHelper.jsm"); +Cu.import("resource:///modules/PropertyPanel.jsm"); var EXPORTED_SYMBOLS = ["HUDService", "ConsoleUtils"]; @@ -4157,6 +4158,8 @@ function findCompletionBeginning(aStr) function JSPropertyProvider(aScope, aInputValue) { let obj = unwrap(aScope); + // Store the scope object, since obj will be modified later on. + let win = obj; // Analyse the aInputValue and find the beginning of the last part that // should be completed. @@ -4195,10 +4198,15 @@ function JSPropertyProvider(aScope, aInputValue) // Check if prop is a getter function on obj. Functions can change other // stuff so we can't execute them to get the next object. Stop here. - if (obj.__lookupGetter__(prop)) { + if (isNonNativeGetter(win, obj, prop)) { + return null; + } + try { + obj = obj[prop]; + } + catch (ex) { return null; } - obj = obj[prop]; } } else { @@ -4241,10 +4249,16 @@ function isIteratorOrGenerator(aObject) return true; } - let str = aObject.toString(); - if (typeof aObject.next == "function" && - str.indexOf("[object Generator") == 0) { - return true; + try { + let str = aObject.toString(); + if (typeof aObject.next == "function" && + str.indexOf("[object Generator") == 0) { + return true; + } + } + catch (ex) { + // window.history.next throws in the typeof check above. + return false; } } @@ -4547,8 +4561,7 @@ JSTerm.prototype = { }, /** - * Evaluates a string in the sandbox. The string is currently wrapped by a - * with(window) { aString } construct, see bug 574033. + * Evaluates a string in the sandbox. * * @param string aString * String to evaluate in the sandbox. diff --git a/toolkit/components/console/hudservice/PropertyPanel.jsm b/toolkit/components/console/hudservice/PropertyPanel.jsm index b23ba617c8e..282a117b14d 100644 --- a/toolkit/components/console/hudservice/PropertyPanel.jsm +++ b/toolkit/components/console/hudservice/PropertyPanel.jsm @@ -1,4 +1,5 @@ /* -*- Mode: js2; js2-basic-offset: 2; indent-tabs-mode: nil; -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -44,7 +45,8 @@ const Cu = Components.utils; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); -var EXPORTED_SYMBOLS = ["PropertyPanel", "PropertyTreeView", "namesAndValuesOf"]; +var EXPORTED_SYMBOLS = ["PropertyPanel", "PropertyTreeView", + "namesAndValuesOf", "isNonNativeGetter"]; /////////////////////////////////////////////////////////////////////////// //// Helper for PropertyTreeView @@ -112,11 +114,20 @@ function presentableValueFor(aObject) presentable = aObject.toString(); let m = /^\[object (\S+)\]/.exec(presentable); - if (typeof aObject == "object" && typeof aObject.next == "function" && - m && m[1] == "Generator") { + try { + if (typeof aObject == "object" && typeof aObject.next == "function" && + m && m[1] == "Generator") { + return { + type: TYPE_OTHER, + display: m[1] + }; + } + } + catch (ex) { + // window.history.next throws in the typeof check above. return { - type: TYPE_OTHER, - display: m[1] + type: TYPE_OBJECT, + display: m ? m[1] : "Object" }; } @@ -148,6 +159,49 @@ function isNativeFunction(aFunction) return typeof aFunction == "function" && !("prototype" in aFunction); } +/** + * Tells if the given property of the provided object is a non-native getter or + * not. + * + * @param object aScope + * Scope to use for the check. + * + * @param object aObject + * The object that contains the property. + * + * @param string aProp + * The property you want to check if it is a getter or not. + * + * @return boolean + * True if the given property is a getter, false otherwise. + */ +function isNonNativeGetter(aScope, aObject, aProp) { + if (typeof aObject != "object") { + return false; + } + let desc; + while (aObject) { + try { + if (desc = aScope.Object.getOwnPropertyDescriptor(aObject, aProp)) { + break; + } + } + catch (ex) { + // Native getters throw here. See bug 520882. + if (ex.name == "NS_ERROR_XPC_BAD_CONVERT_JS" || + ex.name == "NS_ERROR_XPC_BAD_OP_ON_WN_PROTO") { + return false; + } + throw ex; + } + aObject = Object.getPrototypeOf(aObject); + } + if (desc && desc.get && !isNativeFunction(desc.get)) { + return true; + } + return false; +} + /** * Get an array of property name value pairs for the tree. * @@ -159,7 +213,7 @@ function isNativeFunction(aFunction) function namesAndValuesOf(aObject) { let pairs = []; - let value, presentable, getter; + let value, presentable; let isDOMDocument = aObject instanceof Ci.nsIDOMDocument; @@ -169,11 +223,11 @@ function namesAndValuesOf(aObject) continue; } - // Also skip non-native getters. - // TODO: implement a safer way to skip non-native getters. See bug 647235. - getter = aObject.__lookupGetter__ ? - aObject.__lookupGetter__(propName) : null; - if (getter && !isNativeFunction(getter)) { + // Also skip non-native getters. Pass the content window so that + // getOwnPropertyDescriptor can work later on. + let chromeWindow = Services.wm.getMostRecentWindow("navigator:browser"); + let contentWindow = chromeWindow.gBrowser.selectedBrowser.contentWindow; + if (isNonNativeGetter(contentWindow.wrappedJSObject, aObject, propName)) { value = ""; // Value is never displayed. presentable = {type: TYPE_OTHER, display: "Getter"}; } diff --git a/toolkit/components/console/hudservice/tests/browser/Makefile.in b/toolkit/components/console/hudservice/tests/browser/Makefile.in index 3e03cd95cb5..3e4adba9741 100644 --- a/toolkit/components/console/hudservice/tests/browser/Makefile.in +++ b/toolkit/components/console/hudservice/tests/browser/Makefile.in @@ -141,6 +141,7 @@ _BROWSER_TEST_FILES = \ browser_webconsole_bug_642615_autocomplete.js \ browser_webconsole_bug_585991_autocomplete_popup.js \ browser_webconsole_bug_585991_autocomplete_keys.js \ + browser_webconsole_bug_651501_document_body_autocomplete.js \ head.js \ $(NULL) diff --git a/toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_651501_document_body_autocomplete.js b/toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_651501_document_body_autocomplete.js new file mode 100644 index 00000000000..6c9533e2bb9 --- /dev/null +++ b/toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_651501_document_body_autocomplete.js @@ -0,0 +1,72 @@ +/* vim:set ts=2 sw=2 sts=2 et: */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// Tests that document.body autocompletes in the web console. + +Cu.import("resource://gre/modules/PropertyPanel.jsm"); + +function test() { + addTab("data:text/html,Web Console autocompletion bug in document.body"); + browser.addEventListener("load", onLoad, true); +} + +var gHUD; + +function onLoad(aEvent) { + browser.removeEventListener(aEvent.type, arguments.callee, true); + openConsole(); + let hudId = HUDService.getHudIdByWindow(content); + gHUD = HUDService.hudReferences[hudId]; + let jsterm = gHUD.jsterm; + let popup = jsterm.autocompletePopup; + let completeNode = jsterm.completeNode; + + ok(!popup.isOpen, "popup is not open"); + + popup._panel.addEventListener("popupshown", function() { + popup._panel.removeEventListener("popupshown", arguments.callee, false); + + ok(popup.isOpen, "popup is open"); + + let props = namesAndValuesOf(content.wrappedJSObject.document.body).length; + is(popup.itemCount, props, "popup.itemCount is correct"); + + popup._panel.addEventListener("popuphidden", autocompletePopupHidden, false); + + EventUtils.synthesizeKey("VK_ESCAPE", {}); + }, false); + + jsterm.setInputValue("document.body"); + EventUtils.synthesizeKey(".", {}); +} + +function autocompletePopupHidden() +{ + let jsterm = gHUD.jsterm; + let popup = jsterm.autocompletePopup; + let completeNode = jsterm.completeNode; + let inputNode = jsterm.inputNode; + + popup._panel.removeEventListener("popuphidden", arguments.callee, false); + + ok(!popup.isOpen, "popup is not open"); + let inputStr = "document.b"; + jsterm.setInputValue(inputStr); + EventUtils.synthesizeKey("o", {}); + let testStr = inputStr.replace(/./g, " ") + " "; + is(completeNode.value, testStr + "dy", "completeNode is empty"); + jsterm.setInputValue(""); + + // Check the property panel as well. + let propPanel = jsterm.openPropertyPanel("Test", content.document); + is (propPanel.treeView.rowCount, 153, "153 elements shown in propertyPanel"); + + let treeRows = propPanel.treeView._rows; + is (treeRows[30].display, "body: Object", "found document.body"); + propPanel.destroy(); + executeSoon(finishTest); +} + From 23a182b7178e90c229fbe9b602758cc28b904788 Mon Sep 17 00:00:00 2001 From: Mihai Sucan Date: Thu, 16 Jun 2011 11:24:20 -0700 Subject: [PATCH 083/406] Bug 642471 - Rewrite PanelHighlighter using transparent xul iframe and canvas. patch=robcee,msucan,paul r=dietrich --- browser/app/profile/firefox.js | 6 +- browser/base/content/browser.xul | 15 +- browser/base/content/highlighter.xhtml | 63 ++ browser/base/content/insideOutBox.js | 9 +- browser/base/content/inspector.js | 592 ++++++++++++------ browser/base/content/test/Makefile.in | 15 +- .../base/content/test/inspector/Makefile.in | 60 ++ .../browser_inspector_highlighter.js | 40 +- .../browser_inspector_iframeTest.js | 53 +- .../browser_inspector_initialization.js | 31 +- .../browser_inspector_scrolling.js | 38 +- .../browser_inspector_store.js | 2 +- .../browser_inspector_tab_switch.js | 26 +- .../browser_inspector_treePanel_input.html | 6 +- .../browser_inspector_treePanel_output.js | 18 +- .../browser_inspector_treePanel_result.html | 0 .../browser_inspector_treeSelection.js | 29 +- browser/base/jar.mn | 1 + .../gnomestripe/browser/highlighter.css | 104 +++ browser/themes/gnomestripe/browser/jar.mn | 1 + .../themes/pinstripe/browser/highlighter.css | 104 +++ browser/themes/pinstripe/browser/jar.mn | 1 + .../themes/winstripe/browser/highlighter.css | 105 ++++ browser/themes/winstripe/browser/jar.mn | 2 + 24 files changed, 1012 insertions(+), 309 deletions(-) create mode 100644 browser/base/content/highlighter.xhtml create mode 100644 browser/base/content/test/inspector/Makefile.in rename browser/base/content/test/{ => inspector}/browser_inspector_highlighter.js (83%) rename browser/base/content/test/{ => inspector}/browser_inspector_iframeTest.js (77%) rename browser/base/content/test/{ => inspector}/browser_inspector_initialization.js (80%) rename browser/base/content/test/{ => inspector}/browser_inspector_scrolling.js (75%) rename browser/base/content/test/{ => inspector}/browser_inspector_store.js (98%) rename browser/base/content/test/{ => inspector}/browser_inspector_tab_switch.js (87%) rename browser/base/content/test/{ => inspector}/browser_inspector_treePanel_input.html (96%) rename browser/base/content/test/{ => inspector}/browser_inspector_treePanel_output.js (89%) rename browser/base/content/test/{ => inspector}/browser_inspector_treePanel_result.html (100%) rename browser/base/content/test/{ => inspector}/browser_inspector_treeSelection.js (85%) create mode 100644 browser/themes/gnomestripe/browser/highlighter.css create mode 100644 browser/themes/pinstripe/browser/highlighter.css create mode 100644 browser/themes/winstripe/browser/highlighter.css diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 821d68f8a24..84f6aca3288 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -1005,9 +1005,11 @@ pref("services.sync.prefs.sync.spellchecker.dictionary", true); pref("services.sync.prefs.sync.xpinstall.whitelist.required", true); #endif -// Disable the error console and inspector +// Disable the error console pref("devtools.errorconsole.enabled", false); -pref("devtools.inspector.enabled", false); + +// Enable the Inspector +pref("devtools.inspector.enabled", true); // Enable the Scratchpad tool. pref("devtools.scratchpad.enabled", true); diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index 290ae4257a0..a060456ffad 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -224,15 +224,6 @@ -