diff --git a/.clang-format-ignore b/.clang-format-ignore index ff9305ff37..154661830f 100644 --- a/.clang-format-ignore +++ b/.clang-format-ignore @@ -133,17 +133,16 @@ media/webrtc/trunk/.* mfbt/double-conversion/double-conversion/.* mfbt/lz4.* mobile/android/geckoview/src/thirdparty/.* -mobile/android/thirdparty/.* modules/brotli/.* modules/fdlibm/.* modules/freetype2/.* modules/libbz2/.* -modules/libmar/.* modules/pdfium/.* modules/woff2/.* modules/xz-embedded/.* modules/zlib/.* mozglue/misc/decimal/.* +mozglue/tests/glibc_printf_tests/.* netwerk/dns/nsIDNKitInterface.h netwerk/sctp/src/.* netwerk/srtp/src/.* diff --git a/.eslintrc.js b/.eslintrc.js index 9e1014bc2e..1353d05a30 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -248,6 +248,7 @@ module.exports = { "dom/security/test/general/**", "dom/security/test/mixedcontentblocker/**", "dom/security/test/sri/**", + "dom/security/test/referrer-policy/**", "dom/serviceworkers/**", "dom/smil/**", "dom/tests/mochitest/**", diff --git a/.flake8 b/.flake8 index 4be43b2322..623eaa46e3 100644 --- a/.flake8 +++ b/.flake8 @@ -83,7 +83,7 @@ exclude = # - http://pep8.readthedocs.io/en/latest/intro.html#configuration ignore = # These should be triaged and either fixed or moved to the list below. - F632, F633, F811, E117, W504, W605, W606, + F633, F811, E117, W504, W605, W606, # These are intentionally disabled (not necessarily for good reason). # F723: syntax error in type comment # text contains quotes which breaks our custom JSON formatter diff --git a/Makefile.in b/Makefile.in index 098abb7d04..900b45a6da 100644 --- a/Makefile.in +++ b/Makefile.in @@ -31,29 +31,26 @@ GARBAGE_DIRS += _javagen _profile staticlib # subdirectories to remove. So we add to GARBAGE_DIRS once here, globally, # for it to have the desired effect. GARBAGE_DIRS += $(RUST_TARGET) -DIST_GARBAGE = config.cache config.log config.status* config-defs.h \ +GARBAGE_DIRS += config.statusd +DIST_GARBAGE = config.cache config.log config.status config-defs.h \ config/autoconf.mk \ mozilla-config.h \ - netwerk/necko-config.h xpcom/xpcom-config.h xpcom/xpcom-private.h \ + xpcom/xpcom-config.h \ .mozconfig.mk -ifndef MOZ_PROFILE_USE ifneq (mobile/android,$(MOZ_BUILD_APP)) $(MDDEPDIR)/buildid.h.stub $(MDDEPDIR)/source-repo.h.stub: FORCE endif source-repo.h: $(MDDEPDIR)/source-repo.h.stub buildid.h: $(MDDEPDIR)/buildid.h.stub -endif BUILD_BACKEND_FILES := $(addprefix backend.,$(addsuffix Backend,$(BUILD_BACKENDS))) ifndef TEST_MOZBUILD -ifndef MOZ_PROFILE_USE # We need to explicitly put BUILD_BACKEND_FILES here otherwise the rule in # rules.mk doesn't run early enough. $(RUNNABLE_TIERS) binaries:: CLOBBER $(BUILD_BACKEND_FILES) endif -endif ifdef JS_STANDALONE .PHONY: CLOBBER @@ -115,33 +112,17 @@ install-test-files: include $(topsrcdir)/build/moz-automation.mk -# dist and _tests should be purged during cleaning. However, we don't want them -# purged during PGO builds because they contain some auto-generated files. -ifneq ($(filter-out maybe_clobber_profiledbuild,$(MAKECMDGOALS)),) +# dist and _tests should be purged during cleaning. GARBAGE_DIRS += dist _tests -endif # Dummy rule for the cases below where we don't depend on dist/include recurse_pre-export:: -# Windows PGO builds don't perform a clean before the 2nd pass. So, we want -# to preserve content for the 2nd pass on Windows. Everywhere else, we always -# process the install manifests as part of export. # For the binaries rule, not all the install manifests matter, so force only # the interesting ones to be done. -ifdef MOZ_1TIER_PGO -ifndef NO_PROFILE_GUIDED_OPTIMIZE -ifneq ($(OS_ARCH)_$(GNU_CC), WINNT_) recurse_pre-export:: install-manifests binaries:: @$(MAKE) install-manifests install_manifests=dist/include -endif -endif -else # !MOZ_1TIER_PGO (normal build) -recurse_pre-export:: install-manifests -binaries:: - @$(MAKE) install-manifests install_manifests=dist/include -endif # Host binaries are not produced for macOS consumers: that is, there's # no macOS-hosted job to produce them at this time. Therefore we @@ -152,8 +133,21 @@ recurse_artifact: ifdef MOZ_ANDROID_FAT_AAR_ARCHITECTURES recurse_android-fat-aar-artifact: - $(call py_action,fat_aar,$(MOZ_ANDROID_FAT_AAR_ARCHITECTURES) --distdir $(abspath $(DIST)/fat-aar)) -endif # MOZ_ANDROID_FAT_AAR_ARCHITECTURES + $(call py_action,fat_aar,\ + $(addprefix --armeabi-v7a $(MOZ_FETCHES_DIR)/,$(MOZ_ANDROID_FAT_AAR_ARMEABI_V7A)) \ + $(addprefix --arm64-v8a $(MOZ_FETCHES_DIR)/,$(MOZ_ANDROID_FAT_AAR_ARM64_V8A)) \ + $(addprefix --x86 $(MOZ_FETCHES_DIR)/,$(MOZ_ANDROID_FAT_AAR_X86)) \ + $(addprefix --x86-64 $(MOZ_FETCHES_DIR)/,$(MOZ_ANDROID_FAT_AAR_X86_64)) \ + --distdir $(abspath $(DIST)/fat-aar)) +endif + +ifeq ($(MOZ_BUILD_APP),mobile/android) + +recurse_android-stage-package: stage-package + +recurse_android-archive-geckoview: + GRADLE_INVOKED_WITHIN_MACH_BUILD=1 $(topsrcdir)/mach --log-no-times android archive-geckoview +endif ifdef MOZ_WIDGET_TOOLKIT ifdef ENABLE_TESTS @@ -165,37 +159,6 @@ endif default all:: $(call BUILDSTATUS,TIERS $(TIERS) $(if $(MOZ_AUTOMATION),$(MOZ_AUTOMATION_TIERS))) -# PGO build target. -profiledbuild:: - $(call BUILDSTATUS,TIERS pgo_profile_generate pgo_package pgo_profile pgo_clobber pgo_profile_use) - $(call BUILDSTATUS,TIER_START pgo_profile_generate) - $(MAKE) default MOZ_PROFILE_GENERATE=1 MOZ_LTO= - $(call BUILDSTATUS,TIER_FINISH pgo_profile_generate) - $(call BUILDSTATUS,TIER_START pgo_package) - $(MAKE) package - rm -f jarlog/en-US.log - $(call BUILDSTATUS,TIER_FINISH pgo_package) - $(call BUILDSTATUS,TIER_START pgo_profile) - JARLOG_FILE=jarlog/en-US.log $(PYTHON) $(topsrcdir)/build/pgo/profileserver.py - $(call BUILDSTATUS,TIER_FINISH pgo_profile) - $(call BUILDSTATUS,TIER_START pgo_clobber) - $(MAKE) maybe_clobber_profiledbuild - $(call BUILDSTATUS,TIER_FINISH pgo_clobber) - $(call BUILDSTATUS,TIER_START pgo_profile_use) - $(MAKE) default MOZ_PROFILE_USE=1 MOZ_1TIER_PGO=1 - $(call BUILDSTATUS,TIER_FINISH pgo_profile_use) - -# Change default target to PGO build if PGO is enabled. -ifdef MOZ_PGO -ifdef COMPILE_ENVIRONMENT -# If one of these is already set in addition to PGO we are doing a single phase -# of PGO in isolation, so don't override the default target. -ifeq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE)) -OVERRIDE_DEFAULT_GOAL := profiledbuild -endif -endif -endif - include $(topsrcdir)/config/rules.mk ifdef SCCACHE_VERBOSE_STATS @@ -261,19 +224,6 @@ update-packaging: package-generated-sources: $(call py_action,package_generated_sources,'$(DIST)/$(PKG_PATH)$(GENERATED_SOURCE_FILE_PACKAGE)') -# PGO support, but we can't do this test in client.mk -# No point in clobbering if PGO has been explicitly disabled. -ifdef NO_PROFILE_GUIDED_OPTIMIZE -maybe_clobber_profiledbuild: -else -maybe_clobber_profiledbuild: clean -ifneq (,$(findstring clang,$(CC_TYPE))) - $(LLVM_PROFDATA) merge -o $(DEPTH)/merged.profdata $(DEPTH)/*.profraw -endif -endif # NO_PROFILE_GUIDED_OPTIMIZE - -.PHONY: maybe_clobber_profiledbuild - ifdef JS_STANDALONE # Delegate js-specific rules to js check-%: @@ -289,4 +239,9 @@ config/export: endif +ifdef REBASE_DIR +default all:: + $(REBASE_DIR)\Rebase.Exe -b 61d60000 $(DIST)/bin/mozglue.dll $(DIST)/bin/lgpllibs.dll $(DIST)/bin/nss3.dll $(DIST)/bin/xul.dll $(DIST)/bin/softokn3.dll $(DIST)/bin/freebl3.dll $(DIST)/bin/nssckbi.dll $(DIST)/bin/mozavutil.dll $(DIST)/bin/mozavcodec.dll $(DIST)/bin/libEGL.dll $(DIST)/bin/libGLESv2.dll $(DIST)/bin/qipcap.dll +endif + # There used to be build interdependencies here. They are now in config/recurse.mk diff --git a/README.md b/README.md index 29601686a9..eec0a1f9f4 100644 --- a/README.md +++ b/README.md @@ -5,40 +5,43 @@ A browser for Windows XP based on Firefox 68. ![image](https://user-images.githubusercontent.com/19492771/152347482-f51058cd-2967-4bc5-80fd-5d269c328774.png) -**WARNING** +## WARNING This browser does not run well on winxp SP2 and lower. If you do not want to install SP3, be ready for crashes and blue screens. If you are on SP2 and lower, there is no need to post a screenshot from blue_screen_view. And i suggest to apply postready updates of 2019. Some say that it runs fine on sp2 but it is no accurate data what to do. -**IF YOU GOT A BLUE SCREEN** +## IF YOU GOT A BLUE SCREEN Don't post a screenshot of the blue screen, as the screen isn't useful for troubleshooting. For more data look [#3](https://github.com/Feodor2/Mypal68/issues/3), and please do not make new duplicate reports. Suddenly restart may be also this error depends of the settings -**IF YOU GOT A CRASH BUT WITHOUT BLUE SCREEN** +## IF YOU GOT A CRASH BUT WITHOUT BLUE SCREEN Describe detailed how to reproduces the crash, do not forget to put the link. Do not post pictures of the crash, this is useless and a waste. -If i don't reproduce the crash myself then you may to submit drwatson.log. +Also put your pc specs: cpu, ram and graphics card +If I don't reproduce the crash myself then you may to submit drwatson.log. Drwatson log is usually inside All Users\Application Data\Microsoft\Dr Watson. Minidump also may be usefull. Do not post any irrelevent logs. +An issue without details cosider as invalid. -**IF YOU WANT REPORT A SITE** +## IF YOU WANT REPORT A SITE Report [there](https://github.com/Feodor2/Mypal68/issues/228). Put the actual link to the site -Notice that i never would look to the site which requires the login, including any goolag sites. Please try to find what feature is missig by yourself. -Then report like for site 'x' is missing feature 'y' +Notice that I never would look to the site which requires the login, including any goolag sites. +Please try to find what feature is missig by yourself by checking on newer firefoxes and find first version where it works. +Actually I do not look every site, no time for this. -**YOU MAY DONATE** +## YOU MAY DONATE But only by crypto [Look here](https://github.com/Feodor2/Mypal68/issues/84) -**MY MIRROR PAGES** +## MY MIRROR PAGES -https://codeberg.org/Theodor2/Mypal68 +https://codeberg.org/Theodor2/Mypal68 \ https://notabug.org/Theodor/Mypal68 diff --git a/accessible/base/nsCoreUtils.cpp b/accessible/base/nsCoreUtils.cpp index a16e2b0cd3..67864ef1a5 100644 --- a/accessible/base/nsCoreUtils.cpp +++ b/accessible/base/nsCoreUtils.cpp @@ -122,7 +122,7 @@ void nsCoreUtils::DispatchMouseEvent(EventMessage aMessage, int32_t aX, event.mRefPoint = LayoutDeviceIntPoint(aX, aY); event.mClickCount = 1; - event.mButton = MouseButton::eLeft; + event.mButton = MouseButton::ePrimary; event.mTime = PR_IntervalNow(); event.mInputSource = dom::MouseEvent_Binding::MOZ_SOURCE_UNKNOWN; diff --git a/accessible/tests/mochitest/attributes/test_obj_css.xul b/accessible/tests/mochitest/attributes/test_obj_css.xul index f89d318bf1..e110ac5b67 100644 --- a/accessible/tests/mochitest/attributes/test_obj_css.xul +++ b/accessible/tests/mochitest/attributes/test_obj_css.xul @@ -28,7 +28,6 @@ testCSSAttrs("display_mozstack"); testCSSAttrs("display_mozdeck"); testCSSAttrs("display_mozpopup"); - testCSSAttrs("display_mozgroupbox"); SimpleTest.finish(); } @@ -61,7 +60,6 @@ - diff --git a/aclocal.m4 b/aclocal.m4 index 43b7dbd019..2bc8657ba1 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -7,9 +7,6 @@ builtin(include, build/autoconf/hotfixes.m4)dnl builtin(include, build/autoconf/hooks.m4)dnl builtin(include, build/autoconf/config.status.m4)dnl builtin(include, build/autoconf/toolchain.m4)dnl -builtin(include, build/autoconf/nspr.m4)dnl -builtin(include, build/autoconf/nspr-build.m4)dnl -builtin(include, build/autoconf/nss.m4)dnl builtin(include, build/autoconf/pkg.m4)dnl builtin(include, build/autoconf/codeset.m4)dnl builtin(include, build/autoconf/altoptions.m4)dnl @@ -19,11 +16,8 @@ builtin(include, build/autoconf/compiler-opts.m4)dnl builtin(include, build/autoconf/expandlibs.m4)dnl builtin(include, build/autoconf/arch.m4)dnl builtin(include, build/autoconf/android.m4)dnl -builtin(include, build/autoconf/zlib.m4)dnl -builtin(include, build/autoconf/icu.m4)dnl builtin(include, build/autoconf/clang-plugin.m4)dnl builtin(include, build/autoconf/alloc.m4)dnl -builtin(include, build/autoconf/ios.m4)dnl builtin(include, build/autoconf/sanitize.m4)dnl MOZ_PROG_CHECKMSYS() diff --git a/browser/actors/moz.build b/browser/actors/moz.build index cb871edaf2..5eeec819d0 100644 --- a/browser/actors/moz.build +++ b/browser/actors/moz.build @@ -18,7 +18,7 @@ with Files("PluginChild.jsm"): BUG_COMPONENT = ("Core", "Plug-ins") with Files("WebRTCChild.jsm"): - BUG_COMPONENT = ("Firefox", "Device Permissions") + BUG_COMPONENT = ("Firefox", "Site Permissions") FINAL_TARGET_FILES.actors += [ 'AboutReaderChild.jsm', diff --git a/browser/app/macbuild/Contents/MacOS-files.in b/browser/app/macbuild/Contents/MacOS-files.in index 3dac37a298..c54e3257cc 100644 --- a/browser/app/macbuild/Contents/MacOS-files.in +++ b/browser/app/macbuild/Contents/MacOS-files.in @@ -10,7 +10,6 @@ #if defined(MOZ_ASAN) || defined(MOZ_TSAN) /llvm-symbolizer #endif -/pingsender /pk12util /ssltunnel /webrtc-gtest diff --git a/browser/app/module.ver b/browser/app/module.ver index ae6c35acee..dd26a5855b 100644 --- a/browser/app/module.ver +++ b/browser/app/module.ver @@ -1,4 +1,4 @@ -WIN32_MODULE_COMPANYNAME=Feodor2 +WIN32_MODULE_COMPANYNAME=Theodor2 WIN32_MODULE_COPYRIGHT=©Mypal and Mozilla Developers; available under the MPL 2 license. WIN32_MODULE_PRODUCTVERSION=@MOZ_APP_WINVERSION@ WIN32_MODULE_PRODUCTVERSION_STRING=@MOZ_APP_VERSION@ diff --git a/browser/app/moz.build b/browser/app/moz.build index d4b7921931..739134cb96 100644 --- a/browser/app/moz.build +++ b/browser/app/moz.build @@ -67,7 +67,6 @@ if CONFIG['CC_TYPE'] == 'clang-cl': if CONFIG['OS_ARCH'] == 'WINNT': RCINCLUDE = 'splash.rc' - DEFINES['MOZ_PHOENIX'] = True DIRS += [ # 'winlauncher', ] @@ -118,9 +117,6 @@ if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['CC_TYPE'] not in ('clang', 'gcc'): DisableStlWrapping() -if CONFIG['MOZ_LINKER']: - OS_LIBS += CONFIG['MOZ_ZLIB_LIBS'] - if CONFIG['HAVE_CLOCK_MONOTONIC']: OS_LIBS += CONFIG['REALTIME_LIBS'] diff --git a/browser/app/profile/mypal.js b/browser/app/profile/mypal.js index 475e918ef5..c9cd32f144 100644 --- a/browser/app/profile/mypal.js +++ b/browser/app/profile/mypal.js @@ -394,7 +394,7 @@ pref("browser.tabs.insertRelatedAfterCurrent", true); // for non-related links. Note that if this is set to true, it will trump // the value of browser.tabs.insertRelatedAfterCurrent. pref("browser.tabs.insertAfterCurrent", false); -pref("browser.tabs.warnOnClose", true); +pref("browser.tabs.warnOnClose", 1); pref("browser.tabs.warnOnCloseOtherTabs", true); pref("browser.tabs.warnOnOpen", true); pref("browser.tabs.maxOpenBeforeWarn", 15); @@ -515,7 +515,6 @@ pref("privacy.history.custom", false); // 5 - Last 5 minutes // 6 - Last 24 hours pref("privacy.sanitize.timeSpan", 1); -pref("privacy.sanitize.sanitizeOnShutdown", false); pref("privacy.sanitize.migrateFx3Prefs", false); @@ -524,12 +523,6 @@ pref("privacy.panicButton.enabled", true); // Time until temporary permissions expire, in ms pref("privacy.temporary_permission_expire_time_ms", 3600000); -// If Accept-Language should be spoofed by en-US -// 0 - will prompt -// 1 - don't spoof -// 2 - spoof -pref("privacy.spoof_english", 0); - pref("network.proxy.share_proxy_settings", false); // use the same proxy settings for all protocols // simple gestures support @@ -660,16 +653,6 @@ pref("plugins.show_infobar", false); pref("plugin.default.state", 1); #endif -// Plugins bundled in XPIs are enabled by default. -pref("plugin.defaultXpi.state", 2); - -// Flash is Click-to-Activate by default on all channels. Disabled for ARM builds. -#if defined(_ARM64_) && defined(XP_WIN) - pref("plugin.state.flash", 0); -#else - pref("plugin.state.flash", 1); -#endif - // Prefer HTML5 video over Flash content, and don't // load plugin instances with no src declared. // These prefs are documented in details on all.js. @@ -1121,7 +1104,7 @@ pref("services.sync.prefs.sync.browser.sessionstore.restore_on_demand", true); pref("services.sync.prefs.sync.browser.startup.homepage", true); pref("services.sync.prefs.sync.browser.startup.page", true); pref("services.sync.prefs.sync.browser.tabs.loadInBackground", true); -pref("services.sync.prefs.sync.browser.tabs.warnOnClose", true); +pref("services.sync.prefs.sync.browser.tabs.warnOnClose", 1); pref("services.sync.prefs.sync.browser.tabs.warnOnOpen", true); pref("services.sync.prefs.sync.browser.taskbar.previews.enable", true); pref("services.sync.prefs.sync.browser.urlbar.matchBuckets", true); @@ -1535,7 +1518,7 @@ pref("dom.ipc.cpows.forbid-unsafe-from-browser", true); // detection). pref("dom.ipc.processHangMonitor", false); -#if defined(NIGHTLY_BUILD) && defined(XP_WIN) +#if defined(XP_WIN) // Allows us to deprioritize the processes of background tabs at an OS level pref("dom.ipc.processPriorityManager.enabled", true); #endif diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index dd049b57c1..3515e8845b 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1407,13 +1407,14 @@ function _loadURI(browser, uri, params = {}) { } let { - flags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE, triggeringPrincipal, referrerInfo, postData, userContextId, csp, } = params || {}; + let loadFlags = params.loadFlags || params.flags || + Ci.nsIWebNavigation.LOAD_FLAGS_NONE; if (!triggeringPrincipal) { throw new Error("Must load with a triggering Principal"); @@ -1429,7 +1430,7 @@ function _loadURI(browser, uri, params = {}) { uri, gMultiProcessBrowser, gFissionBrowser, - flags + loadFlags ); if (uriObject && handleUriInChrome(browser, uriObject)) { // If we've handled the URI in Chrome then just return here. @@ -1448,7 +1449,7 @@ function _loadURI(browser, uri, params = {}) { let loadURIOptions = { triggeringPrincipal, csp, - loadFlags: flags, + loadFlags, referrerInfo, postData, }; @@ -1479,7 +1480,7 @@ function _loadURI(browser, uri, params = {}) { triggeringPrincipal: triggeringPrincipal ? E10SUtils.serializePrincipal(triggeringPrincipal) : null, - flags, + flags: loadFlags, referrerInfo: E10SUtils.serializeReferrerInfo(referrerInfo), remoteType: requiredRemoteType, postData, diff --git a/browser/base/content/moz.build b/browser/base/content/moz.build index e7b50cba30..c48a4327e3 100644 --- a/browser/base/content/moz.build +++ b/browser/base/content/moz.build @@ -51,7 +51,7 @@ with Files("test/performance/browser_appmenu.js"): BUG_COMPONENT = ("Firefox", "Menus") with Files("test/permissions/**"): - BUG_COMPONENT = ("Firefox", "Site Identity and Permission Panels") + BUG_COMPONENT = ("Firefox", "Site Permissions") with Files("test/plugins/**"): BUG_COMPONENT = ("Core", "Plug-ins") @@ -60,16 +60,16 @@ with Files("test/popupNotifications/**"): BUG_COMPONENT = ("Toolkit", "Notifications and Alerts") with Files("test/popups/**"): - BUG_COMPONENT = ("Firefox", "Site Identity and Permission Panels") + BUG_COMPONENT = ("Firefox", "Site Permissions") with Files("test/referrer/**"): - BUG_COMPONENT = ("Core", "Document Navigation") + BUG_COMPONENT = ("Core", "DOM: Navigation") with Files("test/sanitize/**"): BUG_COMPONENT = ("Toolkit", "Data Sanitization") with Files("test/siteIdentity/**"): - BUG_COMPONENT = ("Firefox", "Site Identity and Permission Panels") + BUG_COMPONENT = ("Firefox", "Site Identity") with Files("test/sidebar/**"): BUG_COMPONENT = ("Firefox", "General") @@ -96,7 +96,7 @@ with Files("test/touch/**"): BUG_COMPONENT = ("Firefox", "General") with Files("test/trackingUI/**"): - BUG_COMPONENT = ("Firefox", "Tracking Protection") + BUG_COMPONENT = ("Firefox", "Protections UI") with Files("test/webextensions/**"): BUG_COMPONENT = ("WebExtensions", "Untriaged") @@ -150,7 +150,7 @@ with Files("contentSearch*"): BUG_COMPONENT = ("Firefox", "Search") with Files("hiddenWindow.xul"): - BUG_COMPONENT = ("Firefox", "Device Permissions") + BUG_COMPONENT = ("Firefox", "Site Permissions") with Files("macWindow.inc.xul"): BUG_COMPONENT = ("Firefox", "Shell Integration") @@ -165,4 +165,4 @@ with Files("webext-panels*"): BUG_COMPONENT = ("WebExtensions", "Frontend") with Files("webrtcIndicator*"): - BUG_COMPONENT = ("Firefox", "Device Permissions") + BUG_COMPONENT = ("Firefox", "Site Permissions") diff --git a/browser/base/content/tabbrowser.js b/browser/base/content/tabbrowser.js index 32c057a158..5c81baf8c7 100644 --- a/browser/base/content/tabbrowser.js +++ b/browser/base/content/tabbrowser.js @@ -2938,11 +2938,12 @@ }, warnAboutClosingTabs(tabsToClose, aCloseTabs) { - const pref = - aCloseTabs == this.closingTabsEnum.ALL - ? "browser.tabs.warnOnClose" - : "browser.tabs.warnOnCloseOtherTabs"; - var shouldPrompt = Services.prefs.getBoolPref(pref); + var shouldPrompt; + if (aCloseTabs == this.closingTabsEnum.ALL) { + shouldPrompt = Services.prefs.getIntPref("browser.tabs.warnOnClose") <= tabsToClose; + } else { + shouldPrompt = Services.prefs.getBoolPref("browser.tabs.warnOnCloseOtherTabs"); + } if (!shouldPrompt) { return true; } diff --git a/browser/base/content/test/menubar/browser.ini b/browser/base/content/test/menubar/browser.ini index 5a9e69e25c..0b904f9802 100644 --- a/browser/base/content/test/menubar/browser.ini +++ b/browser/base/content/test/menubar/browser.ini @@ -1,3 +1,5 @@ [DEFAULT] [browser_file_menu_import_wizard.js] +[browser_window_menu_list.js] +skip-if = os != "mac" # Mac only feature diff --git a/browser/base/content/test/menubar/browser_window_menu_list.js b/browser/base/content/test/menubar/browser_window_menu_list.js new file mode 100644 index 0000000000..0e4e64d30f --- /dev/null +++ b/browser/base/content/test/menubar/browser_window_menu_list.js @@ -0,0 +1,45 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +add_task(async function test_window_menu_list() { + // This title is different depending on the build. For example, it's "Nightly" + // for a local build, "Mozilla Firefox" for an official release build. + const windowTitle = window.document.title; + await checkWindowMenu([windowTitle, "Browser chrome tests"]); + let newWindow = await BrowserTestUtils.openNewBrowserWindow(); + await checkWindowMenu([windowTitle, "Browser chrome tests", windowTitle]); + await BrowserTestUtils.closeWindow(newWindow); +}); + +async function checkWindowMenu(labels) { + let menu = document.querySelector("#windowMenu"); + // We can't toggle menubar items on OSX, so mocking instead. + await new Promise(resolve => { + menu.addEventListener("popupshown", resolve, { once: true }); + menu.dispatchEvent(new MouseEvent("popupshowing")); + menu.dispatchEvent(new MouseEvent("popupshown")); + }); + + let menuitems = [...menu.querySelectorAll("menuseparator ~ menuitem")]; + is(menuitems.length, labels.length, "Correct number of windows in the menu"); + is( + menuitems.map(item => item.label).join(","), + labels.join(","), + "Correct labels on menuitems" + ); + for (let menuitem of menuitems) { + ok( + menuitem instanceof customElements.get("menuitem"), + "sibling is menuitem" + ); + } + + // We can't toggle menubar items on OSX, so mocking instead. + await new Promise(resolve => { + menu.addEventListener("popuphidden", resolve, { once: true }); + menu.dispatchEvent(new MouseEvent("popuphiding")); + menu.dispatchEvent(new MouseEvent("popuphidden")); + }); +} diff --git a/browser/base/content/test/plugins/browser.ini b/browser/base/content/test/plugins/browser.ini index 8b0be6d6fc..df4ccf53dd 100644 --- a/browser/base/content/test/plugins/browser.ini +++ b/browser/base/content/test/plugins/browser.ini @@ -95,8 +95,8 @@ tags = blocklist [browser_globalplugin_crashinfobar.js] skip-if = !crashreporter [browser_pluginCrashCommentAndURL.js] -skip-if = !crashreporter || (processor == 'aarch64' && os == 'win') # aarch64 due to 1538785 +skip-if = !crashreporter [browser_pluginCrashReportNonDeterminism.js] -skip-if = !crashreporter || (processor == 'aarch64' && os == 'win') # aarch64 due to 1538785 +skip-if = !crashreporter [browser_private_clicktoplay.js] [browser_subframe_access_hidden_plugins.js] diff --git a/browser/base/content/test/sanitize/head.js b/browser/base/content/test/sanitize/head.js index 33e243b168..1957fc4c8b 100644 --- a/browser/base/content/test/sanitize/head.js +++ b/browser/base/content/test/sanitize/head.js @@ -49,7 +49,7 @@ function createHostCookie(host, originAttributes) { false, Date.now() + 24000 * 60 * 60, originAttributes, - Ci.nsICookie.SAMESITE_UNSET + Ci.nsICookie.SAMESITE_NONE ); } @@ -64,7 +64,7 @@ function createDomainCookie(host, originAttributes) { false, Date.now() + 24000 * 60 * 60, originAttributes, - Ci.nsICookie.SAMESITE_UNSET + Ci.nsICookie.SAMESITE_NONE ); } diff --git a/browser/base/jar.mn b/browser/base/jar.mn index d348e68cf3..82ad17648e 100644 --- a/browser/base/jar.mn +++ b/browser/base/jar.mn @@ -25,10 +25,10 @@ browser.jar: content/browser/aboutTabCrashed.xhtml (content/aboutTabCrashed.xhtml) * content/browser/browser.css (content/browser.css) content/browser/browser.js (content/browser.js) -#ifdef MOZ_BROWSER_XHTML -* content/browser/browser.xhtml (content/browser.xhtml) -#else +#ifdef MOZ_BROWSER_XUL * content/browser/browser.xul (content/browser.xul) +#else +* content/browser/browser.xhtml (content/browser.xhtml) #endif content/browser/browser-addons.js (content/browser-addons.js) content/browser/browser-allTabsMenu.js (content/browser-allTabsMenu.js) diff --git a/browser/base/moz.build b/browser/base/moz.build index c9be2976f5..513e703e74 100644 --- a/browser/base/moz.build +++ b/browser/base/moz.build @@ -57,8 +57,8 @@ BROWSER_CHROME_MANIFESTS += [ DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION'] DEFINES['MOZ_APP_VERSION_DISPLAY'] = CONFIG['MOZ_APP_VERSION_DISPLAY'] -if CONFIG['MOZ_BROWSER_XHTML']: - DEFINES['MOZ_BROWSER_XHTML'] = CONFIG['MOZ_BROWSER_XHTML'] +if CONFIG['MOZ_BROWSER_XUL']: + DEFINES['MOZ_BROWSER_XUL'] = CONFIG['MOZ_BROWSER_XUL'] DEFINES['APP_LICENSE_BLOCK'] = '%s/content/overrides/app-license.html' % SRCDIR diff --git a/browser/components/BrowserGlue.jsm b/browser/components/BrowserGlue.jsm index 4adf182d09..270202f2a0 100644 --- a/browser/components/BrowserGlue.jsm +++ b/browser/components/BrowserGlue.jsm @@ -426,12 +426,10 @@ XPCOMUtils.defineLazyModuleGetters(this, { Corroborate: "resource://gre/modules/Corroborate.jsm", DateTimePickerParent: "resource://gre/modules/DateTimePickerParent.jsm", ExtensionsUI: "resource:///modules/ExtensionsUI.jsm", - FileSource: "resource://gre/modules/L10nRegistry.jsm", FxAccounts: "resource://gre/modules/FxAccounts.jsm", HomePage: "resource:///modules/HomePage.jsm", HybridContentTelemetry: "resource://gre/modules/HybridContentTelemetry.jsm", Integration: "resource://gre/modules/Integration.jsm", - L10nRegistry: "resource://gre/modules/L10nRegistry.jsm", LiveBookmarkMigrator: "resource:///modules/LiveBookmarkMigrator.jsm", NewTabUtils: "resource://gre/modules/NewTabUtils.jsm", ObjectUtils: "resource://gre/modules/ObjectUtils.jsm", @@ -1046,22 +1044,6 @@ BrowserGlue.prototype = { PdfJs.earlyInit(); } - // Initialize the default l10n resource sources for L10nRegistry. - let locales = Services.locale.packagedLocales; - const greSource = new FileSource( - "toolkit", - locales, - "resource://gre/localization/{locale}/" - ); - L10nRegistry.registerSource(greSource); - - const appSource = new FileSource( - "app", - locales, - "resource://app/localization/{locale}/" - ); - L10nRegistry.registerSource(appSource); - // check if we're in safe mode if (Services.appinfo.inSafeMode) { Services.ww.openWindow( @@ -2009,7 +1991,7 @@ BrowserGlue.prototype = { return; } // Otherwise, we check browser.tabs.warnOnClose - } else if (!Services.prefs.getBoolPref("browser.tabs.warnOnClose")) { + } else if (Services.prefs.getIntPref("browser.tabs.warnOnClose") >= pagecount) { return; } @@ -2563,11 +2545,22 @@ BrowserGlue.prototype = { } }, + _migrateXULStoreForDocument(fromURL, toURL) { + Array.from(Services.xulStore.getIDsEnumerator(fromURL)).forEach((id) => { + Array.from(Services.xulStore.getAttributeEnumerator(fromURL, id)).forEach( + attr => { + let value = Services.xulStore.getValue(fromURL, id, attr); + Services.xulStore.setValue(toURL, id, attr, value); + } + ); + }); + }, + // eslint-disable-next-line complexity _migrateUI: function BG__migrateUI() { // Use an increasing number to keep track of the current migration state. // Completely unrelated to the current Firefox release number. - const UI_VERSION = 81; + const UI_VERSION = 82; const BROWSER_DOCURL = AppConstants.BROWSER_CHROME_URL; let currentUIVersion; @@ -2912,6 +2905,11 @@ BrowserGlue.prototype = { } } + if (currentUIVersion < 82) { + this._migrateXULStoreForDocument("chrome://browser/content/browser.xul", + "chrome://browser/content/browser.xhtml"); + } + // Update the migration version. Services.prefs.setIntPref("browser.migration.version", UI_VERSION); }, diff --git a/browser/components/enterprisepolicies/tests/browser/browser.ini b/browser/components/enterprisepolicies/tests/browser/browser.ini index 0d21a06576..e4593133ed 100644 --- a/browser/components/enterprisepolicies/tests/browser/browser.ini +++ b/browser/components/enterprisepolicies/tests/browser/browser.ini @@ -24,7 +24,8 @@ skip-if = os != 'mac' [browser_policy_cookie_settings.js] [browser_policy_disable_feedback_commands.js] [browser_policy_disable_flash_plugin.js] -skip-if = (processor == 'aarch64' && os == 'win') # aarch64 due to 1538785 +skip-if = (processor == 'aarch64' && os == 'win') +reason = Plugins are not supported on Windows/AArch64 [browser_policy_disable_fxaccounts.js] skip-if = (verify && debug && (os == 'mac')) [browser_policy_disable_masterpassword.js] diff --git a/browser/components/enterprisepolicies/tests/xpcshell/test_clear_blocked_cookies.js b/browser/components/enterprisepolicies/tests/xpcshell/test_clear_blocked_cookies.js index dea9c60433..a4622cbf58 100644 --- a/browser/components/enterprisepolicies/tests/xpcshell/test_clear_blocked_cookies.js +++ b/browser/components/enterprisepolicies/tests/xpcshell/test_clear_blocked_cookies.js @@ -17,7 +17,7 @@ add_task(async function setup() { false, expiry, {}, - Ci.nsICookie.SAMESITE_UNSET + Ci.nsICookie.SAMESITE_NONE ); Services.cookies.add( HOSTNAME_DOMAIN, @@ -29,7 +29,7 @@ add_task(async function setup() { false, expiry, {}, - Ci.nsICookie.SAMESITE_UNSET + Ci.nsICookie.SAMESITE_NONE ); Services.cookies.add( ORIGIN_DOMAIN, @@ -41,7 +41,7 @@ add_task(async function setup() { false, expiry, {}, - Ci.nsICookie.SAMESITE_UNSET + Ci.nsICookie.SAMESITE_NONE ); Services.cookies.add( ORIGIN_DOMAIN, @@ -53,7 +53,7 @@ add_task(async function setup() { false, expiry, {}, - Ci.nsICookie.SAMESITE_UNSET + Ci.nsICookie.SAMESITE_NONE ); Services.cookies.add( "example.net", @@ -65,7 +65,7 @@ add_task(async function setup() { false, expiry, {}, - Ci.nsICookie.SAMESITE_UNSET + Ci.nsICookie.SAMESITE_NONE ); await setupPolicyEngineWithJson({ policies: { diff --git a/browser/components/extensions/test/browser/browser-common.ini b/browser/components/extensions/test/browser/browser-common.ini index 3743e9e74d..013969259a 100644 --- a/browser/components/extensions/test/browser/browser-common.ini +++ b/browser/components/extensions/test/browser/browser-common.ini @@ -159,7 +159,7 @@ disabled = bug 1438663 [browser_ext_popup_sendMessage.js] [browser_ext_popup_shutdown.js] [browser_ext_port_disconnect_on_crash.js] -skip-if = !e10s || !crashreporter || (processor == 'aarch64' && os == 'win') # the tab's process is killed during the test. Without e10s the parent process would die too, aarch64 due to 1538785 +skip-if = !e10s || !crashreporter # the tab's process is killed during the test. Without e10s the parent process would die too [browser_ext_port_disconnect_on_window_close.js] [browser_ext_runtime_openOptionsPage.js] [browser_ext_runtime_openOptionsPage_uninstall.js] diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js b/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js index a7a7bdf416..d629c5a928 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js @@ -1,5 +1,11 @@ "use strict"; +const { AddonTestUtils } = ChromeUtils.import( + "resource://testing-common/AddonTestUtils.jsm" +); + +AddonTestUtils.initMochitest(this); + add_task(async function testExecuteScript() { let { MessageChannel } = ChromeUtils.import( "resource://gre/modules/MessageChannel.jsm" @@ -223,3 +229,90 @@ add_task(async function testInsertCSS_cleanup() { BrowserTestUtils.removeTab(tab); }); + +// Verify that no removeSheet/removeSheetUsingURIString errors are logged while +// cleaning up css injected using a manifest content script or tabs.insertCSS. +add_task(async function test_csscode_cleanup_on_closed_windows() { + let extension = ExtensionTestUtils.loadExtension({ + manifest: { + permissions: ["http://example.com/*"], + content_scripts: [ + { + matches: ["http://example.com/*"], + css: ["content.css"], + run_at: "document_start", + }, + ], + }, + + files: { + "content.css": "body { min-width: 15px; }", + }, + + async background() { + browser.runtime.onConnect.addListener(port => { + port.onDisconnect.addListener(() => { + browser.test.sendMessage("port-disconnected"); + }); + browser.test.sendMessage("port-connected"); + }); + + await browser.tabs.create({ + url: "http://example.com/", + active: true, + }); + + await browser.tabs.insertCSS({ + code: "body { max-width: 50px; }", + }); + + // Create a port, as a way to detect when the content script has been + // destroyed and any removeSheet error already collected (if it has been + // raised during the content scripts cleanup). + await browser.tabs.executeScript({ + code: `(${function() { + const { maxWidth, minWidth } = window.getComputedStyle(document.body); + browser.test.sendMessage("body-styles", { maxWidth, minWidth }); + browser.runtime.connect(); + }})();`, + }); + }, + }); + + await extension.startup(); + + let { messages } = await AddonTestUtils.promiseConsoleOutput(async () => { + info("Waiting for content scripts to be injected"); + + const { maxWidth, minWidth } = await extension.awaitMessage("body-styles"); + is(maxWidth, "50px", "tabs.insertCSS applied"); + is(minWidth, "15px", "manifest.content_scripts CSS applied"); + + await extension.awaitMessage("port-connected"); + const tab = gBrowser.selectedTab; + + info("Close tab and wait for content script port to be disconnected"); + BrowserTestUtils.removeTab(tab); + await extension.awaitMessage("port-disconnected"); + }); + + // Look for nsIDOMWindowUtils.removeSheet and + // nsIDOMWindowUtils.removeSheetUsingURIString errors. + messages = messages.filter( + m => + m.errorMessage && + m.errorMessage.includes( + "(NS_ERROR_FAILURE) [nsIDOMWindowUtils.removeSheet" + ) + ); + + AddonTestUtils.checkMessages( + messages, + { + forbidden: [/nsIDOMWindowUtils.removeSheet/], + }, + "Expect no remoteSheet errors" + ); + + await extension.unload(); +}); diff --git a/browser/components/extensions/test/xpcshell/test_ext_browsingData_cookies_cache.js b/browser/components/extensions/test/xpcshell/test_ext_browsingData_cookies_cache.js index 1cc6f61e5b..dd43f771b9 100644 --- a/browser/components/extensions/test/xpcshell/test_ext_browsingData_cookies_cache.js +++ b/browser/components/extensions/test/xpcshell/test_ext_browsingData_cookies_cache.js @@ -35,7 +35,7 @@ function addCookie(cookie) { false, Date.now() / 1000 + 10000, {}, - Ci.nsICookie.SAMESITE_UNSET + Ci.nsICookie.SAMESITE_NONE ); ok( Services.cookies.cookieExists(cookie.host, cookie.path, cookie.name, {}), diff --git a/browser/components/migration/ChromeProfileMigrator.jsm b/browser/components/migration/ChromeProfileMigrator.jsm index 85592d9761..2f5c406161 100644 --- a/browser/components/migration/ChromeProfileMigrator.jsm +++ b/browser/components/migration/ChromeProfileMigrator.jsm @@ -390,7 +390,7 @@ async function GetCookiesResource(aProfileFolder) { false, parseInt(expiresUtc), {}, - Ci.nsICookie.SAMESITE_UNSET + Ci.nsICookie.SAMESITE_NONE ); } catch (e) { Cu.reportError(e); diff --git a/browser/components/migration/MSMigrationUtils.jsm b/browser/components/migration/MSMigrationUtils.jsm index 7444a5af8b..ea1e4d479c 100644 --- a/browser/components/migration/MSMigrationUtils.jsm +++ b/browser/components/migration/MSMigrationUtils.jsm @@ -727,7 +727,7 @@ Cookies.prototype = { false, // session expireTime, {}, - Ci.nsICookie.SAMESITE_UNSET + Ci.nsICookie.SAMESITE_NONE ); } }, diff --git a/browser/components/migration/tests/marionette/test_refresh_firefox.py b/browser/components/migration/tests/marionette/test_refresh_firefox.py index acb8fdefcb..89d9de30df 100644 --- a/browser/components/migration/tests/marionette/test_refresh_firefox.py +++ b/browser/components/migration/tests/marionette/test_refresh_firefox.py @@ -142,7 +142,7 @@ class TestFirefoxRefresh(MarionetteTestCase): // Expire in 15 minutes: let expireTime = Math.floor(Date.now() / 1000) + 15 * 60; Services.cookies.add(arguments[0], arguments[1], arguments[2], arguments[3], - true, false, false, expireTime, {}, Ci.nsICookie.SAMESITE_UNSET); + true, false, false, expireTime, {}, Ci.nsICookie.SAMESITE_NONE); """, script_args=(self._cookieHost, self._cookiePath, self._cookieName, self._cookieValue)) def createSession(self): diff --git a/browser/components/moz.build b/browser/components/moz.build index 2cf1f56357..a3227b4d32 100644 --- a/browser/components/moz.build +++ b/browser/components/moz.build @@ -15,7 +15,7 @@ with Files("tests/browser/browser_bug538331.js"): BUG_COMPONENT = ("Toolkit", "Application Update") with Files("tests/browser/browser_contentpermissionprompt.js"): - BUG_COMPONENT = ("Firefox", "Site Identity and Permission Panels") + BUG_COMPONENT = ("Firefox", "Site Permissions") with Files("tests/unit/test_distribution.js"): BUG_COMPONENT = ("Firefox", "Distributions") diff --git a/browser/components/preferences/in-content/main.js b/browser/components/preferences/in-content/main.js index 5afa4fc111..33455161dd 100644 --- a/browser/components/preferences/in-content/main.js +++ b/browser/components/preferences/in-content/main.js @@ -117,8 +117,8 @@ Preferences.addAll([ - true if display should switch to a new tab which has been opened from a link, false if display shouldn't switch browser.tabs.warnOnClose - - true if when closing a window with multiple tabs the user is warned and - allowed to cancel the action, false to just close the window + - >0 if when closing a window with multiple tabs the user is warned and + allowed to cancel the action, 0 to just close the window browser.tabs.warnOnOpen - true if the user should be warned if he attempts to open a lot of tabs at once (e.g. a large folder of bookmarks), false otherwise @@ -128,7 +128,7 @@ Preferences.addAll([ { id: "browser.link.open_newwindow", type: "int" }, { id: "browser.tabs.loadInBackground", type: "bool", inverted: true }, - { id: "browser.tabs.warnOnClose", type: "bool" }, + { id: "browser.tabs.warnOnClose", type: "int" }, { id: "browser.tabs.warnOnOpen", type: "bool" }, { id: "browser.sessionstore.restore_on_demand", type: "bool" }, { id: "browser.ctrlTab.recentlyUsedOrder", type: "bool" }, @@ -1038,8 +1038,8 @@ var gMainPane = { * browser.tabs.loadInBackground - bool * True - Whether browser should switch to a new tab opened from a link. * browser.tabs.warnOnClose - bool - * True - If when closing a window with multiple tabs the user is warned and - * allowed to cancel the action, false to just close the window. + * >0 - If when closing a window with multiple tabs the user is warned and + * allowed to cancel the action, 0 to just close the window. * browser.tabs.warnOnOpen - bool * True - Whether the user should be warned when trying to open a lot of * tabs at once (e.g. a large folder of bookmarks), allowing to diff --git a/browser/components/preferences/in-content/tests/siteData/browser_siteData.js b/browser/components/preferences/in-content/tests/siteData/browser_siteData.js index fa60b371ef..2bff34f18d 100644 --- a/browser/components/preferences/in-content/tests/siteData/browser_siteData.js +++ b/browser/components/preferences/in-content/tests/siteData/browser_siteData.js @@ -218,7 +218,7 @@ add_task(async function() { false, Date.now() + 1000 * 60 * 60, {}, - Ci.nsICookie.SAMESITE_UNSET + Ci.nsICookie.SAMESITE_NONE ); Services.cookies.add( uri.host, @@ -230,7 +230,7 @@ add_task(async function() { false, Date.now() + 1000 * 60 * 60, {}, - Ci.nsICookie.SAMESITE_UNSET + Ci.nsICookie.SAMESITE_NONE ); Services.cookies.add( uri2.host, @@ -242,7 +242,7 @@ add_task(async function() { false, Date.now() + 1000 * 60 * 60, {}, - Ci.nsICookie.SAMESITE_UNSET + Ci.nsICookie.SAMESITE_NONE ); // Ensure that private browsing cookies are ignored. @@ -256,7 +256,7 @@ add_task(async function() { false, Date.now() + 1000 * 60 * 60, { privateBrowsingId: 1 }, - Ci.nsICookie.SAMESITE_UNSET + Ci.nsICookie.SAMESITE_NONE ); // Get the exact creation date from the cookies (to avoid intermittents diff --git a/browser/components/sessionstore/ContentRestore.jsm b/browser/components/sessionstore/ContentRestore.jsm index a3b0eda77f..e179edb44c 100644 --- a/browser/components/sessionstore/ContentRestore.jsm +++ b/browser/components/sessionstore/ContentRestore.jsm @@ -423,10 +423,10 @@ HistoryListener.prototype = { // new URL that was passed to loadURI(). The new load will cause a // STATE_START notification to be sent and the ProgressListener will then // notify the parent and do the rest. - let flags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP; + let loadFlags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP; let loadURIOptions = { triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), - loadFlags: flags, + loadFlags, }; this.webNavigation.loadURI(newURI.spec, loadURIOptions); }, diff --git a/browser/components/sessionstore/SessionCookies.jsm b/browser/components/sessionstore/SessionCookies.jsm index 0ee466561b..c80e17fb15 100644 --- a/browser/components/sessionstore/SessionCookies.jsm +++ b/browser/components/sessionstore/SessionCookies.jsm @@ -79,7 +79,7 @@ var SessionCookiesInternal = { /* isSession = */ true, expiry, cookie.originAttributes || {}, - Ci.nsICookie.SAMESITE_UNSET + Ci.nsICookie.SAMESITE_NONE ); } catch (ex) { Cu.reportError( diff --git a/browser/components/sessionstore/test/browser_cookies_privacy.js b/browser/components/sessionstore/test/browser_cookies_privacy.js index 3688aba4c6..d49032de22 100644 --- a/browser/components/sessionstore/test/browser_cookies_privacy.js +++ b/browser/components/sessionstore/test/browser_cookies_privacy.js @@ -15,7 +15,7 @@ function addCookie(scheme, secure = false) { /* isSession = */ true, MAX_EXPIRY, /* originAttributes = */ {}, - Ci.nsICookie.SAMESITE_UNSET + Ci.nsICookie.SAMESITE_NONE ); return cookie; } diff --git a/browser/components/shell/nsWindowsShellService.cpp b/browser/components/shell/nsWindowsShellService.cpp index ac7fbef329..af87953918 100644 --- a/browser/components/shell/nsWindowsShellService.cpp +++ b/browser/components/shell/nsWindowsShellService.cpp @@ -13,6 +13,7 @@ #include "nsIContent.h" #include "nsIImageLoadingContent.h" #include "nsIOutputStream.h" +#include "nsIPrefService.h" #include "nsIStringBundle.h" #include "nsNetUtil.h" #include "nsServiceManagerUtils.h" @@ -27,6 +28,7 @@ #include "nsXULAppAPI.h" #include "mozilla/WindowsVersion.h" #include "mozilla/dom/Element.h" +#include "mozilla/gfx/2D.h" #include "windows.h" #include "shellapi.h" diff --git a/browser/config/mozconfigs/linux32/beta b/browser/config/mozconfigs/linux32/beta index 043e23e9d6..c8aedd4f81 100644 --- a/browser/config/mozconfigs/linux32/beta +++ b/browser/config/mozconfigs/linux32/beta @@ -1,5 +1,3 @@ -export MOZ_PGO=1 - . "$topsrcdir/browser/config/mozconfigs/linux32/common-opt" ac_add_options --enable-official-branding diff --git a/browser/config/mozconfigs/linux32/debug b/browser/config/mozconfigs/linux32/debug index 0ea9942b5d..4a6bbf0b25 100644 --- a/browser/config/mozconfigs/linux32/debug +++ b/browser/config/mozconfigs/linux32/debug @@ -14,6 +14,9 @@ export MOZILLA_OFFICIAL=1 # Package js shell. export MOZ_PACKAGE_JSSHELL=1 +# Keep basic GDB symbols around in debug builds +ac_add_options STRIP_FLAGS=--strip-debug + ac_add_options --with-branding=browser/branding/nightly . "$topsrcdir/build/mozconfig.common.override" diff --git a/browser/config/mozconfigs/linux32/devedition b/browser/config/mozconfigs/linux32/devedition index 51db666f5e..e21f6a0a6f 100644 --- a/browser/config/mozconfigs/linux32/devedition +++ b/browser/config/mozconfigs/linux32/devedition @@ -1,5 +1,3 @@ -export MOZ_PGO=1 - . "$topsrcdir/browser/config/mozconfigs/linux32/common-opt" ac_add_options --with-branding=browser/branding/aurora diff --git a/browser/config/mozconfigs/linux32/nightly b/browser/config/mozconfigs/linux32/nightly index 686266944d..5c1a542260 100644 --- a/browser/config/mozconfigs/linux32/nightly +++ b/browser/config/mozconfigs/linux32/nightly @@ -2,4 +2,10 @@ ac_add_options --with-branding=browser/branding/nightly +# STRIP_FLAGS is only valid for builds that strip; valgrind builds disable stripping +if [ -z "$USE_VALGRIND" ]; then + # Keep basic GDB symbols around in Nightly builds + ac_add_options STRIP_FLAGS=--strip-debug +fi + . "$topsrcdir/build/mozconfig.common.override" diff --git a/browser/config/mozconfigs/linux32/profile-generate b/browser/config/mozconfigs/linux32/profile-generate index bf16ac1f99..9fb7a51970 100644 --- a/browser/config/mozconfigs/linux32/profile-generate +++ b/browser/config/mozconfigs/linux32/profile-generate @@ -1,6 +1,5 @@ . $topsrcdir/browser/config/mozconfigs/linux32/nightly -mk_add_options "export MOZ_AUTOMATION_BUILD_SYMBOLS=0" mk_add_options "export MOZ_AUTOMATION_PACKAGE_TESTS=0" mk_add_options "export MOZ_AUTOMATION_PACKAGE_GENERATED_SOURCES=0" mk_add_options "export MOZ_AUTOMATION_L10N_CHECK=0" diff --git a/browser/config/mozconfigs/linux32/release b/browser/config/mozconfigs/linux32/release index dc3a46d8df..d7ad589810 100644 --- a/browser/config/mozconfigs/linux32/release +++ b/browser/config/mozconfigs/linux32/release @@ -1,8 +1,6 @@ # This make file should be identical to the beta mozconfig, apart from the # safeguard below -export MOZ_PGO=1 - . "$topsrcdir/browser/config/mozconfigs/linux32/common-opt" ac_add_options --enable-official-branding diff --git a/browser/config/mozconfigs/linux32/valgrind b/browser/config/mozconfigs/linux32/valgrind index d335038dea..1b6e1c2225 100644 --- a/browser/config/mozconfigs/linux32/valgrind +++ b/browser/config/mozconfigs/linux32/valgrind @@ -1,3 +1,5 @@ +USE_VALGRIND=1 + . $topsrcdir/browser/config/mozconfigs/linux32/nightly ac_add_options --enable-valgrind diff --git a/browser/config/mozconfigs/linux64/beta b/browser/config/mozconfigs/linux64/beta index c136f06c54..37723c43d4 100644 --- a/browser/config/mozconfigs/linux64/beta +++ b/browser/config/mozconfigs/linux64/beta @@ -1,5 +1,3 @@ -. "$topsrcdir/build/mozconfig.pgo" - . "$topsrcdir/browser/config/mozconfigs/linux64/common-opt" ac_add_options --enable-official-branding diff --git a/browser/config/mozconfigs/linux64/code-coverage b/browser/config/mozconfigs/linux64/code-coverage index b32a5d692e..78c9421d72 100644 --- a/browser/config/mozconfigs/linux64/code-coverage +++ b/browser/config/mozconfigs/linux64/code-coverage @@ -12,6 +12,6 @@ ac_add_options --disable-profiling ac_add_options --disable-warnings-as-errors ac_add_options --enable-coverage -export LDFLAGS="--coverage -L$topsrcdir/clang/lib/clang/8.0.0/lib/linux/" +export LDFLAGS="--coverage -L$MOZ_FETCHES_DIR/clang/lib/clang/8.0.0/lib/linux/" export LIBS="-lclang_rt.profile-x86_64" export RUSTFLAGS="-Ccodegen-units=1 -Zprofile -Zno-landing-pads -Clink-dead-code -Coverflow-checks=off" diff --git a/browser/config/mozconfigs/linux64/debug b/browser/config/mozconfigs/linux64/debug index 8a4b70b489..5f6f2441a1 100644 --- a/browser/config/mozconfigs/linux64/debug +++ b/browser/config/mozconfigs/linux64/debug @@ -14,4 +14,7 @@ export MOZ_PACKAGE_JSSHELL=1 ac_add_options --with-branding=browser/branding/nightly +# Keep basic GDB symbols around in debug builds +ac_add_options STRIP_FLAGS=--strip-debug + . "$topsrcdir/build/mozconfig.common.override" diff --git a/browser/config/mozconfigs/linux64/debug-searchfox-clang b/browser/config/mozconfigs/linux64/debug-searchfox-clang index f7e50e785b..032e0912c0 100644 --- a/browser/config/mozconfigs/linux64/debug-searchfox-clang +++ b/browser/config/mozconfigs/linux64/debug-searchfox-clang @@ -1,6 +1,7 @@ MOZ_AUTOMATION_BUILD_SYMBOLS=0 MOZ_AUTOMATION_PACKAGE_TESTS=0 MOZ_AUTOMATION_L10N_CHECK=0 +MOZ_AUTOMATION_CHECK=0 . "$topsrcdir/build/unix/mozconfig.unix" @@ -9,8 +10,8 @@ ac_add_options --enable-debug . $topsrcdir/build/mozconfig.stylo # Use Clang as specified in manifest -export CC="$topsrcdir/clang/bin/clang" -export CXX="$topsrcdir/clang/bin/clang++" +export CC="$MOZ_FETCHES_DIR/clang/bin/clang" +export CXX="$MOZ_FETCHES_DIR/clang/bin/clang++" # Save rust analysis (this requires unlocking the unstable features, # which is done in the taskcluster task definition via RUSTC_BOOTSTRAP) diff --git a/browser/config/mozconfigs/linux64/debug-static-analysis-clang b/browser/config/mozconfigs/linux64/debug-static-analysis-clang index 0dba5a939c..2b4a162dcb 100644 --- a/browser/config/mozconfigs/linux64/debug-static-analysis-clang +++ b/browser/config/mozconfigs/linux64/debug-static-analysis-clang @@ -9,8 +9,8 @@ ac_add_options --enable-debug . $topsrcdir/build/mozconfig.stylo # Use Clang as specified in manifest -export CC="$topsrcdir/clang/bin/clang" -export CXX="$topsrcdir/clang/bin/clang++" +export CC="$MOZ_FETCHES_DIR/clang/bin/clang" +export CXX="$MOZ_FETCHES_DIR/clang/bin/clang++" # Add the static checker ac_add_options --enable-clang-plugin diff --git a/browser/config/mozconfigs/linux64/devedition b/browser/config/mozconfigs/linux64/devedition index d0839205e2..63995ced77 100644 --- a/browser/config/mozconfigs/linux64/devedition +++ b/browser/config/mozconfigs/linux64/devedition @@ -1,5 +1,3 @@ -export MOZ_PGO=1 - . "$topsrcdir/browser/config/mozconfigs/linux64/common-opt" ac_add_options --with-branding=browser/branding/aurora diff --git a/browser/config/mozconfigs/linux64/nightly b/browser/config/mozconfigs/linux64/nightly index 15090cc01c..fa54d10f4f 100644 --- a/browser/config/mozconfigs/linux64/nightly +++ b/browser/config/mozconfigs/linux64/nightly @@ -2,4 +2,10 @@ ac_add_options --with-branding=browser/branding/nightly +# STRIP_FLAGS is only valid for builds that strip; valgrind builds disable stripping +if [ -z "$USE_VALGRIND" ]; then + # Keep basic GDB symbols around in Nightly builds + ac_add_options STRIP_FLAGS=--strip-debug +fi + . "$topsrcdir/build/mozconfig.common.override" diff --git a/browser/config/mozconfigs/linux64/plain-opt b/browser/config/mozconfigs/linux64/plain-opt index 92c10af2fa..a7c5c78f28 100644 --- a/browser/config/mozconfigs/linux64/plain-opt +++ b/browser/config/mozconfigs/linux64/plain-opt @@ -1,14 +1,14 @@ export TOOLTOOL_DIR="$topsrcdir" -export LLVM_CONFIG="${TOOLTOOL_DIR}/clang/bin/llvm-config" +export LLVM_CONFIG="${MOZ_FETCHES_DIR}/clang/bin/llvm-config" -CARGO="${TOOLTOOL_DIR}/rustc/bin/cargo" -RUSTC="${TOOLTOOL_DIR}/rustc/bin/rustc" -RUSTDOC="${TOOLTOOL_DIR}/rustc/bin/rustdoc" -RUSTFMT="${TOOLTOOL_DIR}/rustc/bin/rustfmt" -CBINDGEN="${TOOLTOOL_DIR}/cbindgen/cbindgen" +CARGO="${MOZ_FETCHES_DIR}/rustc/bin/cargo" +RUSTC="${MOZ_FETCHES_DIR}/rustc/bin/rustc" +RUSTDOC="${MOZ_FETCHES_DIR}/rustc/bin/rustdoc" +RUSTFMT="${MOZ_FETCHES_DIR}/rustc/bin/rustfmt" +CBINDGEN="${MOZ_FETCHES_DIR}/cbindgen/cbindgen" -export NODEJS="${TOOLTOOL_DIR}/node/bin/node" -NASM="${TOOLTOOL_DIR}/nasm/nasm" +export NODEJS="${MOZ_FETCHES_DIR}/node/bin/node" +NASM="${MOZ_FETCHES_DIR}/nasm/nasm" -CC="${TOOLTOOL_DIR}/clang/bin/clang" -CXX="${TOOLTOOL_DIR}/clang/bin/clang++" +CC="${MOZ_FETCHES_DIR}/clang/bin/clang" +CXX="${MOZ_FETCHES_DIR}/clang/bin/clang++" diff --git a/browser/config/mozconfigs/linux64/profile-generate b/browser/config/mozconfigs/linux64/profile-generate index eedfd74a5e..5542f8e478 100644 --- a/browser/config/mozconfigs/linux64/profile-generate +++ b/browser/config/mozconfigs/linux64/profile-generate @@ -1,6 +1,5 @@ -. $topsrcdir/browser/config/mozconfigs/linux64/beta +. $topsrcdir/browser/config/mozconfigs/linux64/nightly -mk_add_options "export MOZ_AUTOMATION_BUILD_SYMBOLS=0" mk_add_options "export MOZ_AUTOMATION_PACKAGE_TESTS=0" mk_add_options "export MOZ_AUTOMATION_PACKAGE_GENERATED_SOURCES=0" mk_add_options "export MOZ_AUTOMATION_L10N_CHECK=0" diff --git a/browser/config/mozconfigs/linux64/release b/browser/config/mozconfigs/linux64/release index 5b4328c779..ab09eef653 100644 --- a/browser/config/mozconfigs/linux64/release +++ b/browser/config/mozconfigs/linux64/release @@ -1,8 +1,6 @@ # This make file should be identical to the beta mozconfig, apart from the # safeguard below -. "$topsrcdir/build/mozconfig.pgo" - . "$topsrcdir/browser/config/mozconfigs/linux64/common-opt" ac_add_options --enable-official-branding diff --git a/browser/config/mozconfigs/linux64/tup b/browser/config/mozconfigs/linux64/tup index 9cdbf6844b..2f76b1f7f4 100644 --- a/browser/config/mozconfigs/linux64/tup +++ b/browser/config/mozconfigs/linux64/tup @@ -6,7 +6,7 @@ MOZ_AUTOMATION_UPLOAD=0 MOZ_AUTOMATION_UPLOAD_SYMBOLS=0 TOOLTOOL_DIR=${TOOLTOOL_DIR:-$topsrcdir} -export TUP=${TOOLTOOL_DIR}/tup/tup +export TUP=${MOZ_FETCHES_DIR}/tup/tup . "$topsrcdir/browser/config/mozconfigs/linux64/common-opt" . "$topsrcdir/build/mozconfig.common.override" diff --git a/browser/config/mozconfigs/linux64/valgrind b/browser/config/mozconfigs/linux64/valgrind index 1ca6b62095..ac9908da95 100644 --- a/browser/config/mozconfigs/linux64/valgrind +++ b/browser/config/mozconfigs/linux64/valgrind @@ -1,3 +1,6 @@ +MOZ_AUTOMATION_CHECK=0 +USE_VALGRIND=1 + . $topsrcdir/browser/config/mozconfigs/linux64/nightly ac_add_options --enable-valgrind diff --git a/browser/config/mozconfigs/macosx64/add-on-devel b/browser/config/mozconfigs/macosx64/add-on-devel index 58739c204e..410c8637ad 100644 --- a/browser/config/mozconfigs/macosx64/add-on-devel +++ b/browser/config/mozconfigs/macosx64/add-on-devel @@ -1,7 +1,5 @@ . $topsrcdir/browser/config/mozconfigs/macosx64/nightly -unset MOZ_LTO - ac_add_options --with-branding=browser/branding/unofficial ac_add_options --enable-update-channel=default diff --git a/browser/config/mozconfigs/macosx64/beta b/browser/config/mozconfigs/macosx64/beta index a4d89d8bf4..232750daa4 100644 --- a/browser/config/mozconfigs/macosx64/beta +++ b/browser/config/mozconfigs/macosx64/beta @@ -2,6 +2,4 @@ ac_add_options --enable-official-branding -export MOZ_LTO=cross - . "$topsrcdir/build/mozconfig.common.override" diff --git a/browser/config/mozconfigs/macosx64/code-coverage b/browser/config/mozconfigs/macosx64/code-coverage index c525272071..62c5336eb6 100644 --- a/browser/config/mozconfigs/macosx64/code-coverage +++ b/browser/config/mozconfigs/macosx64/code-coverage @@ -8,6 +8,6 @@ ac_add_options --disable-sandbox ac_add_options --disable-warnings-as-errors ac_add_options --enable-coverage -export LDFLAGS="-coverage -L$topsrcdir/clang/lib/clang/8.0.0/lib/darwin/" +export LDFLAGS="-coverage -L$MOZ_FETCHES_DIR/clang/lib/clang/8.0.0/lib/darwin/" export LIBS="-lclang_rt.profile_osx" export RUSTFLAGS="-Ccodegen-units=1 -Zprofile -Zno-landing-pads -Clink-dead-code -Coverflow-checks=off" diff --git a/browser/config/mozconfigs/macosx64/debug-searchfox b/browser/config/mozconfigs/macosx64/debug-searchfox index d3207eacc0..0fa9df329d 100644 --- a/browser/config/mozconfigs/macosx64/debug-searchfox +++ b/browser/config/mozconfigs/macosx64/debug-searchfox @@ -1,6 +1,7 @@ MOZ_AUTOMATION_BUILD_SYMBOLS=0 MOZ_AUTOMATION_PACKAGE_TESTS=0 MOZ_AUTOMATION_L10N_CHECK=0 +MOZ_AUTOMATION_CHECK=0 . $topsrcdir/build/macosx/mozconfig.common diff --git a/browser/config/mozconfigs/macosx64/devedition b/browser/config/mozconfigs/macosx64/devedition index bb59121d9a..db700db10d 100644 --- a/browser/config/mozconfigs/macosx64/devedition +++ b/browser/config/mozconfigs/macosx64/devedition @@ -1,9 +1,5 @@ . "$topsrcdir/browser/config/mozconfigs/macosx64/common-opt" -ac_add_options --disable-install-strip - -export MOZ_LTO=cross - ac_add_options --enable-instruments # Cross-compiled builds fail when dtrace is enabled diff --git a/browser/config/mozconfigs/macosx64/l10n-mozconfig-devedition b/browser/config/mozconfigs/macosx64/l10n-mozconfig-devedition index a13d6dee7c..bd64063747 100644 --- a/browser/config/mozconfigs/macosx64/l10n-mozconfig-devedition +++ b/browser/config/mozconfigs/macosx64/l10n-mozconfig-devedition @@ -4,9 +4,9 @@ if test `uname -s` = "Linux"; then # We need to indicate the target for cross builds ac_add_options --target=x86_64-apple-darwin - export MKFSHFS=$topsrcdir/hfsplus-tools/newfs_hfs - export DMG_TOOL=$topsrcdir/dmg/dmg - export HFS_TOOL=$topsrcdir/dmg/hfsplus + export MKFSHFS=$MOZ_FETCHES_DIR/hfsplus-tools/newfs_hfs + export DMG_TOOL=$MOZ_FETCHES_DIR/dmg/dmg + export HFS_TOOL=$MOZ_FETCHES_DIR/dmg/hfsplus fi ac_add_options --with-l10n-base=../../l10n diff --git a/browser/config/mozconfigs/macosx64/nightly b/browser/config/mozconfigs/macosx64/nightly index 0c5b2adbc7..95cd36fe9e 100644 --- a/browser/config/mozconfigs/macosx64/nightly +++ b/browser/config/mozconfigs/macosx64/nightly @@ -1,6 +1,5 @@ . "$topsrcdir/browser/config/mozconfigs/macosx64/common-opt" -ac_add_options --disable-install-strip ac_add_options --enable-instruments # Cross-compiled builds fail when dtrace is enabled @@ -8,8 +7,6 @@ if test `uname -s` != Linux; then ac_add_options --enable-dtrace fi -export MOZ_LTO=cross - ac_add_options --with-branding=browser/branding/nightly . "$topsrcdir/build/mozconfig.common.override" diff --git a/browser/config/mozconfigs/macosx64/release b/browser/config/mozconfigs/macosx64/release index 2439d7131c..840e9afd24 100644 --- a/browser/config/mozconfigs/macosx64/release +++ b/browser/config/mozconfigs/macosx64/release @@ -5,8 +5,6 @@ ac_add_options --enable-official-branding -export MOZ_LTO=cross - # safeguard against someone forgetting to re-set EARLY_BETA_OR_EARLIER in # defines.sh during the beta cycle export BUILDING_RELEASE=1 diff --git a/browser/config/mozconfigs/macosx64/repack b/browser/config/mozconfigs/macosx64/repack index 9974c70bb5..c18e14b895 100644 --- a/browser/config/mozconfigs/macosx64/repack +++ b/browser/config/mozconfigs/macosx64/repack @@ -1,8 +1,8 @@ # This mozconfig is responsible merely for getting the cross tools setup # for repacking a .tar into a .dmg as returned from signing. -export MKFSHFS=$topsrcdir/hfsplus-tools/newfs_hfs -export DMG_TOOL=$topsrcdir/dmg/dmg -export HFS_TOOL=$topsrcdir/dmg/hfsplus -export NODEJS=$topsrcdir/node/bin/node +export MKFSHFS=$MOZ_FETCHES_DIR/hfsplus-tools/newfs_hfs +export DMG_TOOL=$MOZ_FETCHES_DIR/dmg/dmg +export HFS_TOOL=$MOZ_FETCHES_DIR/dmg/hfsplus +export NODEJS=$MOZ_FETCHES_DIR/node/bin/node ac_add_options --disable-compile-environment diff --git a/browser/config/mozconfigs/whitelist b/browser/config/mozconfigs/whitelist index 5e4295ab33..f073b8a45b 100644 --- a/browser/config/mozconfigs/whitelist +++ b/browser/config/mozconfigs/whitelist @@ -13,7 +13,6 @@ for platform in all_platforms: ] whitelist['nightly']['macosx64'] += [ - 'ac_add_options --disable-install-strip', 'ac_add_options --enable-instruments', 'ac_add_options --enable-dtrace', 'if test `uname -s` != Linux; then', @@ -30,16 +29,12 @@ for platform in all_platforms: 'ac_add_options --enable-official-branding', 'export BUILDING_RELEASE=1', ] -whitelist['release']['win32'] += ['export MOZ_PGO=1'] -whitelist['release']['win64'] += ['export MOZ_PGO=1'] whitelist['release']['linux32'] += [ 'export MOZILLA_OFFICIAL=1', - 'export MOZ_PGO=1', ] whitelist['release']['linux64'] += [ 'export MOZILLA_OFFICIAL=1', - '. "$topsrcdir/build/mozconfig.pgo"', ] if __name__ == '__main__': diff --git a/browser/config/mozconfigs/win32/beta b/browser/config/mozconfigs/win32/beta index b7b4dfdd4a..767c514cd6 100644 --- a/browser/config/mozconfigs/win32/beta +++ b/browser/config/mozconfigs/win32/beta @@ -1,5 +1,3 @@ -export MOZ_PGO=1 - . "$topsrcdir/build/mozconfig.win-common" . "$topsrcdir/browser/config/mozconfigs/win32/common-opt" diff --git a/browser/config/mozconfigs/win32/devedition b/browser/config/mozconfigs/win32/devedition index 9cddb0b4d9..62ee0921e6 100644 --- a/browser/config/mozconfigs/win32/devedition +++ b/browser/config/mozconfigs/win32/devedition @@ -1,5 +1,3 @@ -export MOZ_PGO=1 - . "$topsrcdir/build/mozconfig.win-common" . "$topsrcdir/browser/config/mozconfigs/win32/common-opt" diff --git a/browser/config/mozconfigs/win32/mingwclang b/browser/config/mozconfigs/win32/mingwclang index 5ce6fffa09..15e31aeb2d 100644 --- a/browser/config/mozconfigs/win32/mingwclang +++ b/browser/config/mozconfigs/win32/mingwclang @@ -42,24 +42,24 @@ ac_add_options --disable-webrtc # Bug 1393901 ac_add_options --disable-geckodriver # Bug 1489320 # Find our toolchain -HOST_CC="$TOOLTOOL_DIR/clang/bin/clang" -HOST_CXX="$TOOLTOOL_DIR/clang/bin/clang++" -CC="$TOOLTOOL_DIR/clang/bin/i686-w64-mingw32-clang" -CXX="$TOOLTOOL_DIR/clang/bin/i686-w64-mingw32-clang++" +HOST_CC="$MOZ_FETCHES_DIR/clang/bin/clang" +HOST_CXX="$MOZ_FETCHES_DIR/clang/bin/clang++" +CC="$MOZ_FETCHES_DIR/clang/bin/i686-w64-mingw32-clang" +CXX="$MOZ_FETCHES_DIR/clang/bin/i686-w64-mingw32-clang++" ac_add_options --with-clang-path="$CC" -ac_add_options --with-libclang-path="$TOOLTOOL_DIR/clang/lib" +ac_add_options --with-libclang-path="$MOZ_FETCHES_DIR/clang/lib" CXXFLAGS="-fms-extensions" AR=llvm-ar RANLIB=llvm-ranlib # For Stylo -BINDGEN_CFLAGS="-I$TOOLTOOL_DIR/clang/i686-w64-mingw32/include/c++/v1 -I$TOOLTOOL_DIR/clang/i686-w64-mingw32/include" +BINDGEN_CFLAGS="-I$MOZ_FETCHES_DIR/clang/i686-w64-mingw32/include/c++/v1 -I$MOZ_FETCHES_DIR/clang/i686-w64-mingw32/include" # We want to make sure we use binutils and other binaries in the tooltool # package. -mk_add_options "export PATH=$TOOLTOOL_DIR/clang/bin:$TOOLTOOL_DIR/mingw32/bin:$TOOLTOOL_DIR/wine/bin:$TOOLTOOL_DIR/upx/bin:$TOOLTOOL_DIR/fxc2/bin:$PATH" +mk_add_options "export PATH=$MOZ_FETCHES_DIR/clang/bin:$MOZ_FETCHES_DIR/mingw32/bin:$MOZ_FETCHES_DIR/wine/bin:$MOZ_FETCHES_DIR/upx/bin:$MOZ_FETCHES_DIR/fxc2/bin:$PATH" -LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$TOOLTOOL_DIR/mingw32/lib64:$TOOLTOOL_DIR/clang/lib +LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$MOZ_FETCHES_DIR/mingw32/lib64:$MOZ_FETCHES_DIR/clang/lib mk_add_options "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH" # Do not include the visual studio related mozconfigs of course diff --git a/browser/config/mozconfigs/win32/profile-generate b/browser/config/mozconfigs/win32/profile-generate index a02d0b5b8e..1177bb8b31 100644 --- a/browser/config/mozconfigs/win32/profile-generate +++ b/browser/config/mozconfigs/win32/profile-generate @@ -1,6 +1,5 @@ . $topsrcdir/browser/config/mozconfigs/win32/nightly -mk_add_options "export MOZ_AUTOMATION_BUILD_SYMBOLS=0" mk_add_options "export MOZ_AUTOMATION_PACKAGE_TESTS=0" mk_add_options "export MOZ_AUTOMATION_PACKAGE_GENERATED_SOURCES=0" mk_add_options "export MOZ_AUTOMATION_L10N_CHECK=0" diff --git a/browser/config/mozconfigs/win32/release b/browser/config/mozconfigs/win32/release index e692069321..a8fca41487 100644 --- a/browser/config/mozconfigs/win32/release +++ b/browser/config/mozconfigs/win32/release @@ -1,8 +1,6 @@ # This make file should be identical to the beta mozconfig, apart from the # safeguard below -export MOZ_PGO=1 - . "$topsrcdir/build/mozconfig.win-common" . "$topsrcdir/browser/config/mozconfigs/win32/common-opt" diff --git a/browser/config/mozconfigs/win64/beta b/browser/config/mozconfigs/win64/beta index b31df28773..ab3613c373 100644 --- a/browser/config/mozconfigs/win64/beta +++ b/browser/config/mozconfigs/win64/beta @@ -1,5 +1,3 @@ -export MOZ_PGO=1 - . "$topsrcdir/build/mozconfig.win-common" . "$topsrcdir/browser/config/mozconfigs/win64/common-win64" . "$topsrcdir/browser/config/mozconfigs/win64/common-opt" diff --git a/browser/config/mozconfigs/win64/code-coverage b/browser/config/mozconfigs/win64/code-coverage index 9812417bb9..6ec078c555 100644 --- a/browser/config/mozconfigs/win64/code-coverage +++ b/browser/config/mozconfigs/win64/code-coverage @@ -18,8 +18,8 @@ export MOZILLA_OFFICIAL=1 # Package js shell. export MOZ_PACKAGE_JSSHELL=1 -if [ -d "$topsrcdir/clang" ]; then - CLANG_LIB_DIR="$(cd $topsrcdir/clang/lib/clang/* && cd lib/windows && pwd)" +if [ -d "$MOZ_FETCHES_DIR/clang" ]; then + CLANG_LIB_DIR="$(cd $MOZ_FETCHES_DIR/clang/lib/clang/* && cd lib/windows && pwd)" export LIB=$LIB:$CLANG_LIB_DIR export LDFLAGS="clang_rt.profile-x86_64.lib" diff --git a/browser/config/mozconfigs/win64/debug-searchfox b/browser/config/mozconfigs/win64/debug-searchfox index c121359700..2a13adca90 100644 --- a/browser/config/mozconfigs/win64/debug-searchfox +++ b/browser/config/mozconfigs/win64/debug-searchfox @@ -1,6 +1,7 @@ MOZ_AUTOMATION_BUILD_SYMBOLS=0 MOZ_AUTOMATION_PACKAGE_TESTS=0 MOZ_AUTOMATION_L10N_CHECK=0 +MOZ_AUTOMATION_CHECK=0 . "$topsrcdir/build/mozconfig.win-common" . "$topsrcdir/browser/config/mozconfigs/common" diff --git a/browser/config/mozconfigs/win64/devedition b/browser/config/mozconfigs/win64/devedition index 54b3fd90d3..a55a17b45a 100644 --- a/browser/config/mozconfigs/win64/devedition +++ b/browser/config/mozconfigs/win64/devedition @@ -1,5 +1,3 @@ -export MOZ_PGO=1 - . "$topsrcdir/build/mozconfig.win-common" . "$topsrcdir/browser/config/mozconfigs/win64/common-win64" . "$topsrcdir/browser/config/mozconfigs/win64/common-opt" diff --git a/browser/config/mozconfigs/win64/mingwclang b/browser/config/mozconfigs/win64/mingwclang index 18cf2c516d..b8bedc5dfd 100644 --- a/browser/config/mozconfigs/win64/mingwclang +++ b/browser/config/mozconfigs/win64/mingwclang @@ -41,24 +41,24 @@ ac_add_options --disable-webrtc # Bug 1393901 ac_add_options --disable-geckodriver # Bug 1489320 # Find our toolchain -HOST_CC="$TOOLTOOL_DIR/clang/bin/clang" -HOST_CXX="$TOOLTOOL_DIR/clang/bin/clang++" -CC="$TOOLTOOL_DIR/clang/bin/x86_64-w64-mingw32-clang" -CXX="$TOOLTOOL_DIR/clang/bin/x86_64-w64-mingw32-clang++" +HOST_CC="$MOZ_FETCHES_DIR/clang/bin/clang" +HOST_CXX="$MOZ_FETCHES_DIR/clang/bin/clang++" +CC="$MOZ_FETCHES_DIR/clang/bin/x86_64-w64-mingw32-clang" +CXX="$MOZ_FETCHES_DIR/clang/bin/x86_64-w64-mingw32-clang++" ac_add_options --with-clang-path="$CC" -ac_add_options --with-libclang-path="$TOOLTOOL_DIR/clang/lib" +ac_add_options --with-libclang-path="$MOZ_FETCHES_DIR/clang/lib" CXXFLAGS="-fms-extensions" AR=llvm-ar RANLIB=llvm-ranlib # For Stylo -BINDGEN_CFLAGS="-I$TOOLTOOL_DIR/clang/x86_64-w64-mingw32/include/c++/v1 -I$TOOLTOOL_DIR/clang/x86_64-w64-mingw32/include" +BINDGEN_CFLAGS="-I$MOZ_FETCHES_DIR/clang/x86_64-w64-mingw32/include/c++/v1 -I$MOZ_FETCHES_DIR/clang/x86_64-w64-mingw32/include" # We want to make sure we use binutils and other binaries in the tooltool # package. -mk_add_options "export PATH=$TOOLTOOL_DIR/clang/bin:$TOOLTOOL_DIR/mingw32/bin:$TOOLTOOL_DIR/wine/bin:$TOOLTOOL_DIR/upx/bin:$TOOLTOOL_DIR/fxc2/bin:$PATH" +mk_add_options "export PATH=$MOZ_FETCHES_DIR/clang/bin:$MOZ_FETCHES_DIR/mingw32/bin:$MOZ_FETCHES_DIR/wine/bin:$MOZ_FETCHES_DIR/upx/bin:$MOZ_FETCHES_DIR/fxc2/bin:$PATH" -LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$TOOLTOOL_DIR/mingw32/lib64:$TOOLTOOL_DIR/clang/lib +LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$MOZ_FETCHES_DIR/mingw32/lib64:$MOZ_FETCHES_DIR/clang/lib mk_add_options "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH" # Do not include the visual studio related mozconfigs of course diff --git a/browser/config/mozconfigs/win64/plain-opt b/browser/config/mozconfigs/win64/plain-opt index 7753e4687d..e1dd4148db 100644 --- a/browser/config/mozconfigs/win64/plain-opt +++ b/browser/config/mozconfigs/win64/plain-opt @@ -1,15 +1,15 @@ TOOLTOOL_DIR=${topsrcdir} export MAKECAB=$TOOLTOOL_DIR/makecab.exe -export LLVM_CONFIG="${TOOLTOOL_DIR}/clang/bin/llvm-config" +export LLVM_CONFIG="${MOZ_FETCHES_DIR}/clang/bin/llvm-config" -RUSTC="${TOOLTOOL_DIR}/rustc/bin/rustc" -CARGO="${TOOLTOOL_DIR}/rustc/bin/cargo" -RUSTDOC="${TOOLTOOL_DIR}/rustc/bin/rustdoc" -RUSTFMT="${TOOLTOOL_DIR}/rustc/bin/rustfmt" -CBINDGEN="${TOOLTOOL_DIR}/cbindgen/cbindgen" +RUSTC="${MOZ_FETCHES_DIR}/rustc/bin/rustc" +CARGO="${MOZ_FETCHES_DIR}/rustc/bin/cargo" +RUSTDOC="${MOZ_FETCHES_DIR}/rustc/bin/rustdoc" +RUSTFMT="${MOZ_FETCHES_DIR}/rustc/bin/rustfmt" +CBINDGEN="${MOZ_FETCHES_DIR}/cbindgen/cbindgen" -NASM="${TOOLTOOL_DIR}/nasm/nasm.exe" -NODEJS="${TOOLTOOL_DIR}/node/node.exe" +NASM="${MOZ_FETCHES_DIR}/nasm/nasm.exe" +NODEJS="${MOZ_FETCHES_DIR}/node/node.exe" ac_add_options --target=x86_64-pc-mingw32 diff --git a/browser/config/mozconfigs/win64/profile-generate b/browser/config/mozconfigs/win64/profile-generate index 6b9ad0795f..00a69c6ff7 100644 --- a/browser/config/mozconfigs/win64/profile-generate +++ b/browser/config/mozconfigs/win64/profile-generate @@ -1,6 +1,5 @@ . $topsrcdir/browser/config/mozconfigs/win64/nightly -mk_add_options "export MOZ_AUTOMATION_BUILD_SYMBOLS=0" mk_add_options "export MOZ_AUTOMATION_PACKAGE_TESTS=0" mk_add_options "export MOZ_AUTOMATION_PACKAGE_GENERATED_SOURCES=0" mk_add_options "export MOZ_AUTOMATION_L10N_CHECK=0" diff --git a/browser/config/mozconfigs/win64/release b/browser/config/mozconfigs/win64/release index 952fc7b55f..df6e68bef1 100644 --- a/browser/config/mozconfigs/win64/release +++ b/browser/config/mozconfigs/win64/release @@ -1,8 +1,6 @@ # This make file should be identical to the beta mozconfig, apart from the # safeguard below -export MOZ_PGO=1 - . "$topsrcdir/build/mozconfig.win-common" . "$topsrcdir/browser/config/mozconfigs/win64/common-win64" . "$topsrcdir/browser/config/mozconfigs/win64/common-opt" diff --git a/browser/config/version.txt b/browser/config/version.txt index 51b911d778..dfd2c37c92 100644 --- a/browser/config/version.txt +++ b/browser/config/version.txt @@ -1 +1 @@ -68.14.4 +68.14.5 diff --git a/browser/config/version_display.txt b/browser/config/version_display.txt index a43ba26b40..a772a330bf 100644 --- a/browser/config/version_display.txt +++ b/browser/config/version_display.txt @@ -1 +1 @@ -68.14.4b +68.14.5b diff --git a/browser/confvars.sh b/browser/confvars.sh index ac3f19f720..b9bd7f1ff5 100644 --- a/browser/confvars.sh +++ b/browser/confvars.sh @@ -3,10 +3,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -MOZ_APP_BASENAME=Mypal MOZ_APP_VENDOR=Theodor2 MOZ_UPDATER=1 -MOZ_PHOENIX=1 if test "$OS_ARCH" = "WINNT"; then if ! test "$HAVE_64BIT_BUILD"; then @@ -28,13 +26,10 @@ if test "$OS_ARCH" = "WINNT"; then fi fi -# Enable building ./signmar and running libmar signature tests -MOZ_ENABLE_SIGNMAR=1 - -if [ "${MOZ_BROWSER_XHTML}" = "1" ]; then - BROWSER_CHROME_URL=chrome://browser/content/browser.xhtml -else +if [ "${MOZ_BROWSER_XUL}" = "1" ]; then BROWSER_CHROME_URL=chrome://browser/content/browser.xul +else + BROWSER_CHROME_URL=chrome://browser/content/browser.xhtml fi # MOZ_APP_DISPLAYNAME will be set by branding/configure.sh @@ -45,22 +40,6 @@ fi # For the mozilla-aurora repository, use "aurora". MOZ_BRANDING_DIRECTORY=browser/branding/unofficial MOZ_APP_ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384} -# ACCEPTED_MAR_CHANNEL_IDS should usually be the same as the value MAR_CHANNEL_ID. -# If more than one ID is needed, then you should use a comma separated list -# of values. -# The MAR_CHANNEL_ID must not contain the following 3 characters: ",\t " -if test "$MOZ_UPDATE_CHANNEL" = "aurora"; then - ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-aurora - MAR_CHANNEL_ID=firefox-mozilla-aurora -else - ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-esr - MAR_CHANNEL_ID=firefox-mozilla-esr -fi -# ASan reporter builds should have different channel ids -if [ "${MOZ_ASAN_REPORTER}" = "1" ]; then - ACCEPTED_MAR_CHANNEL_IDS="${ACCEPTED_MAR_CHANNEL_IDS}-asan" - MAR_CHANNEL_ID="${MAR_CHANNEL_ID}-asan" -fi MOZ_PROFILE_MIGRATOR=1 diff --git a/browser/installer/Makefile.in b/browser/installer/Makefile.in index 8b99eed27e..e8af11801e 100644 --- a/browser/installer/Makefile.in +++ b/browser/installer/Makefile.in @@ -48,10 +48,6 @@ ifdef MOZ_SYSTEM_NSS DEFINES += -DMOZ_SYSTEM_NSS=1 endif -ifdef NSS_DISABLE_DBM -DEFINES += -DNSS_DISABLE_DBM=1 -endif - ifdef MOZ_ARTIFACT_BUILDS DEFINES += -DMOZ_ARTIFACT_BUILDS=1 endif diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 6bb9ad958f..968ed5f410 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -136,11 +136,9 @@ @RESPATH@/update-settings.ini #endif @RESPATH@/platform.ini -#ifndef MOZ_SYSTEM_SQLITE #ifndef MOZ_FOLD_LIBS @BINPATH@/@DLL_PREFIX@mozsqlite3@DLL_SUFFIX@ #endif -#endif @BINPATH@/@DLL_PREFIX@lgpllibs@DLL_SUFFIX@ #ifdef MOZ_FFVPX @BINPATH@/@DLL_PREFIX@mozavutil@DLL_SUFFIX@ @@ -185,6 +183,9 @@ @RESPATH@/components/Push.manifest +@RESPATH@/components/l10n-registry.manifest +@RESPATH@/browser/components/l10n-registry.manifest + ; CDP remote agent #ifdef ENABLE_REMOTE_AGENT @RESPATH@/chrome/remote@JAREXT@ @@ -354,9 +355,6 @@ #endif @BINPATH@/@DLL_PREFIX@nss3@DLL_SUFFIX@ @BINPATH@/@DLL_PREFIX@nssckbi@DLL_SUFFIX@ -#ifndef NSS_DISABLE_DBM -@BINPATH@/@DLL_PREFIX@nssdbm3@DLL_SUFFIX@ -#endif #ifndef MOZ_FOLD_LIBS @BINPATH@/@DLL_PREFIX@nssutil3@DLL_SUFFIX@ @BINPATH@/@DLL_PREFIX@smime3@DLL_SUFFIX@ @@ -417,10 +415,6 @@ bin/libfreebl_32int64_3.so #endif #endif -; [ Ping Sender ] -; -@BINPATH@/pingsender@BIN_SUFFIX@ - ; Shutdown Terminator @RESPATH@/components/terminator.manifest diff --git a/browser/installer/windows/nsis/shared.nsh b/browser/installer/windows/nsis/shared.nsh index cd9be47ad0..39c26ee662 100644 --- a/browser/installer/windows/nsis/shared.nsh +++ b/browser/installer/windows/nsis/shared.nsh @@ -1351,7 +1351,6 @@ Push "xpcom.dll" Push "crashreporter.exe" Push "minidump-analyzer.exe" - Push "pingsender.exe" Push "updater.exe" Push "${FileMainEXE}" !macroend diff --git a/browser/l10n-registry.manifest b/browser/l10n-registry.manifest new file mode 100644 index 0000000000..6b02008b80 --- /dev/null +++ b/browser/l10n-registry.manifest @@ -0,0 +1 @@ +category l10n-registry 5-browser resource://app/localization/{locale}/ diff --git a/browser/modules/moz.build b/browser/modules/moz.build index 51bb857bfe..73ee46593b 100644 --- a/browser/modules/moz.build +++ b/browser/modules/moz.build @@ -12,10 +12,10 @@ with Files("test/browser/*ContentSearch*"): BUG_COMPONENT = ("Firefox", "Search") with Files("test/browser/*PermissionUI*"): - BUG_COMPONENT = ("Firefox", "Site Identity and Permission Panels") + BUG_COMPONENT = ("Firefox", "Site Permissions") with Files("test/browser/*SitePermissions*"): - BUG_COMPONENT = ("Firefox", "Site Identity and Permission Panels") + BUG_COMPONENT = ("Firefox", "Site Permissions") with Files("test/browser/browser_UnsubmittedCrashHandler.js"): BUG_COMPONENT = ("Toolkit", "Crash Reporting") @@ -33,7 +33,7 @@ with Files("test/unit/test_LaterRun.js"): BUG_COMPONENT = ("Firefox", "Tours") with Files("test/unit/test_SitePermissions.js"): - BUG_COMPONENT = ("Firefox", "Site Identity and Permission Panels") + BUG_COMPONENT = ("Firefox", "Site Permissions") with Files("AboutNewTab.jsm"): BUG_COMPONENT = ("Firefox", "New Tab Page") @@ -75,7 +75,7 @@ with Files("OpenInTabsUtils.jsm"): BUG_COMPONENT = ("Firefox", "Tabbed Browser") with Files("PermissionUI.jsm"): - BUG_COMPONENT = ("Firefox", "Site Identity and Permission Panels") + BUG_COMPONENT = ("Firefox", "Site Permissions") with Files("ProcessHangMonitor.jsm"): BUG_COMPONENT = ("Core", "DOM: Content Processes") @@ -93,7 +93,7 @@ with Files("SiteDataManager.jsm"): BUG_COMPONENT = ("Firefox", "Preferences") with Files("SitePermissions.jsm"): - BUG_COMPONENT = ("Firefox", "Site Identity and Permission Panels") + BUG_COMPONENT = ("Firefox", "Site Permissions") with Files("TabsList.jsm"): BUG_COMPONENT = ("Firefox", "Tabbed Browser") @@ -114,7 +114,7 @@ with Files("WindowsPreviewPerTab.jsm"): BUG_COMPONENT = ("Core", "Widget: Win32") with Files("webrtcUI.jsm"): - BUG_COMPONENT = ("Firefox", "Device Permissions") + BUG_COMPONENT = ("Firefox", "Site Permissions") with Files("ZoomUI.jsm"): BUG_COMPONENT = ("Firefox", "Toolbars and Customization") diff --git a/browser/modules/test/unit/test_SiteDataManager.js b/browser/modules/test/unit/test_SiteDataManager.js index 9d4d2e3d84..5e2ec254b0 100644 --- a/browser/modules/test/unit/test_SiteDataManager.js +++ b/browser/modules/test/unit/test_SiteDataManager.js @@ -5,6 +5,7 @@ const EXAMPLE_ORIGIN = "https://www.example.com"; const EXAMPLE_ORIGIN_2 = "https://example.org"; +const EXAMPLE_ORIGIN_3 = "http://localhost:8000"; const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { SiteDataManager } = ChromeUtils.import( @@ -130,11 +131,18 @@ add_task(async function testRemove() { SiteDataTestUtils.addToCookies(EXAMPLE_ORIGIN_2, "foo", "bar"); await SiteDataTestUtils.addToIndexedDB(EXAMPLE_ORIGIN_2, 2048); await SiteDataTestUtils.persist(EXAMPLE_ORIGIN_2); + await SiteDataTestUtils.addToIndexedDB(EXAMPLE_ORIGIN_3, 2048); await SiteDataManager.updateSites(); let sites = await SiteDataManager.getSites(); + Assert.equal(sites.length, 3, "Has three sites."); + + await SiteDataManager.remove(["localhost"]); + + sites = await SiteDataManager.getSites(); + Assert.equal(sites.length, 2, "Has two sites."); await SiteDataManager.remove(["www.example.com"]); diff --git a/browser/moz.build b/browser/moz.build index b841379a5a..589245afec 100644 --- a/browser/moz.build +++ b/browser/moz.build @@ -9,6 +9,10 @@ SPHINX_TREES['browser'] = 'docs' with Files('docs/**'): SCHEDULES.exclusive = ['docs'] +EXTRA_COMPONENTS += [ + 'l10n-registry.manifest', +] + DIRS += [ 'actors', 'base', @@ -92,3 +96,6 @@ with Files("installer/**"): with Files("tools/**"): BUG_COMPONENT = ("Firefox", "General") + +with Files('l10n-registry.manifest'): + BUG_COMPONENT = ('Core', 'Localization') diff --git a/browser/themes/shared/browser.inc.css b/browser/themes/shared/browser.inc.css index e7336465d7..d5c467d01d 100644 --- a/browser/themes/shared/browser.inc.css +++ b/browser/themes/shared/browser.inc.css @@ -54,7 +54,7 @@ /* Bookmark toolbar */ #PersonalToolbar { - overflow: -moz-hidden-unscrollable; + overflow: clip; max-height: 4em; padding: 0 6px 2px; } diff --git a/browser/themes/shared/incontentprefs/preferences.inc.css b/browser/themes/shared/incontentprefs/preferences.inc.css index 126cdbb4db..46c1d1e66b 100644 --- a/browser/themes/shared/incontentprefs/preferences.inc.css +++ b/browser/themes/shared/incontentprefs/preferences.inc.css @@ -535,6 +535,8 @@ button > hbox > label { background: none !important; min-width: 0; min-height: auto; + padding-inline: 0; + margin-inline: 0 8px; } .dialogFrame { diff --git a/browser/themes/shared/urlbar-searchbar.inc.css b/browser/themes/shared/urlbar-searchbar.inc.css index f5fbd9ae91..989a13e2be 100644 --- a/browser/themes/shared/urlbar-searchbar.inc.css +++ b/browser/themes/shared/urlbar-searchbar.inc.css @@ -36,7 +36,7 @@ margin: 3px 5px; min-height: 30px; cursor: default; - overflow: -moz-hidden-unscrollable; + overflow: clip; } #urlbar:hover, diff --git a/browser/themes/windows/browser.css b/browser/themes/windows/browser.css index 972c88a1ac..498be2c626 100644 --- a/browser/themes/windows/browser.css +++ b/browser/themes/windows/browser.css @@ -255,7 +255,7 @@ /* Need to constrain the box shadow fade to avoid overlapping layers, see bug 886281. */ #main-window[tabsintitlebar]:not([sizemode=fullscreen]) #navigator-toolbox:not(:-moz-lwtheme) { - overflow: -moz-hidden-unscrollable; + overflow: clip; } #main-window[tabsintitlebar][sizemode="normal"] > #navigator-toolbox:-moz-lwtheme { diff --git a/browser/tools/mozscreenshots/browser_screenshots_cropping.js b/browser/tools/mozscreenshots/browser_screenshots_cropping.js index 45a6264af4..e80e46765c 100644 --- a/browser/tools/mozscreenshots/browser_screenshots_cropping.js +++ b/browser/tools/mozscreenshots/browser_screenshots_cropping.js @@ -53,7 +53,18 @@ async function compareImages(window, expected, test) { "The test and expected images must be the same size" ); - return window.windowUtils.compareCanvases(expectedCanvas, testCanvas, {}); + var maxDifference = {}; + var differences = window.windowUtils.compareCanvases( + expectedCanvas, + testCanvas, + maxDifference + ); + + // Fuzz for minor differences that can be caused by the encoder. + if (maxDifference.value > 1) { + return differences; + } + return 0; } async function cropAndCompare(window, src, expected, test, region, subregions) { diff --git a/browser/tools/mozscreenshots/moz.build b/browser/tools/mozscreenshots/moz.build index 459fc86679..89287ca92e 100644 --- a/browser/tools/mozscreenshots/moz.build +++ b/browser/tools/mozscreenshots/moz.build @@ -6,13 +6,13 @@ with Files("**"): BUG_COMPONENT = ("Firefox", "General") with Files("controlCenter/**"): - BUG_COMPONENT = ("Firefox", "Site Identity and Permission Panels") + BUG_COMPONENT = ("Firefox", "Site Identity") with Files("devtools/**"): BUG_COMPONENT = ("DevTools", "General") with Files("permissionPrompts/**"): - BUG_COMPONENT = ("Firefox", "Site Identity and Permission Panels") + BUG_COMPONENT = ("Firefox", "Site Permissions") with Files("preferences/**"): BUG_COMPONENT = ("Firefox", "Preferences") diff --git a/build.gradle b/build.gradle index 8b91888b5d..7498b81160 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,6 @@ allprojects { ANDROID_PACKAGE_NAME: mozconfig.substs.ANDROID_PACKAGE_NAME, ANDROID_TARGET_SDK: mozconfig.substs.ANDROID_TARGET_SDK, MOZ_ANDROID_MIN_SDK_VERSION: mozconfig.substs.MOZ_ANDROID_MIN_SDK_VERSION, - MOZ_ANDROID_SHARED_ID: "${mozconfig.substs.ANDROID_PACKAGE_NAME}.sharedID", ] } @@ -71,7 +70,7 @@ buildscript { } } - ext.kotlin_version = '1.2.41' + ext.kotlin_version = '1.3.41' ext.support_library_version = '28.0.0' ext.jacoco_version = '0.8.1' ext.lifecycle_library_version = '1.1.1' @@ -83,8 +82,8 @@ buildscript { } dependencies { - classpath 'org.mozilla.apilint:apilint:0.2.1' - classpath 'com.android.tools.build:gradle:3.1.4' + classpath 'org.mozilla.apilint:apilint:0.2.6' + classpath 'com.android.tools.build:gradle:3.4.2' classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2' classpath 'org.apache.commons:commons-exec:1.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" @@ -157,26 +156,6 @@ class MachExec extends Exec { } } -task machBuildGeneratedAndroidCodeAndResources(type: MachExec) { - onlyIf rootProject.ext.geckoBinariesOnlyIf - - workingDir "${topsrcdir}" - - commandLine mozconfig.substs.PYTHON - args "${topsrcdir}/mach" - args 'build' - args 'mobile/android/base/generated_android_code_and_resources' - - // Add `-v` if we're running under `--info` (or `--debug`). - if (project.logger.isEnabled(LogLevel.INFO)) { - args '-v' - } - - // `path` is like `:machBuildGeneratedAndroidCodeAndResources`. - standardOutput = new TaggedLogOutputStream("${path}>", logger) - errorOutput = standardOutput -} - // Why |mach build mobile/android/base/...| and |mach build faster|? |mach // build faster| generates dependentlibs.list, which in turn depends on compiled // code. That causes a circular dependency between Java compilation/JNI wrapper @@ -250,43 +229,21 @@ createMachStagePackageTask("machStagePackageForGeckoview").with { afterEvaluate { subprojects { project -> - if (project.name != 'thirdparty') { - tasks.withType(JavaCompile) { - // Add compiler args for all code except third-party code. - options.compilerArgs += [ - // Turn on all warnings, except... - "-Xlint:all", - // Deprecation, because we do use deprecated API for compatibility. - "-Xlint:-deprecation", - // Serial, because we don't use Java serialization. - "-Xlint:-serial", - // Classfile, because javac has a bug with MethodParameters attributes - // with Java 7. https://bugs.openjdk.java.net/browse/JDK-8190452 - "-Xlint:-classfile", - // Turn all remaining warnings into errors, - // unless marked by @SuppressWarnings. - "-Werror"] - } - if (project.name == 'app') { - tasks.withType(JavaCompile) { - // Turn off classfile warnings because upon updating to play services 15.0.0 - // a warning is being thrown from play-services-base which fails the build - // (com/google/android/gms/common/api/GoogleApiClient.class): - // warning: Cannot find annotation method 'value()' in type 'GuardedBy': - // class file for javax.annotation.concurrent.GuardedBy not found - options.compilerArgs += ["-Xlint:-classfile"] - } - } - } - - if (!hasProperty('android')) { - return - } - android.applicationVariants.all { - preBuild.dependsOn rootProject.machBuildGeneratedAndroidCodeAndResources - } - android.libraryVariants.all { - preBuild.dependsOn rootProject.machBuildGeneratedAndroidCodeAndResources + tasks.withType(JavaCompile) { + // Add compiler args for all code except third-party code. + options.compilerArgs += [ + // Turn on all warnings, except... + "-Xlint:all", + // Deprecation, because we do use deprecated API for compatibility. + "-Xlint:-deprecation", + // Serial, because we don't use Java serialization. + "-Xlint:-serial", + // Classfile, because javac has a bug with MethodParameters attributes + // with Java 7. https://bugs.openjdk.java.net/browse/JDK-8190452 + "-Xlint:-classfile", + // Turn all remaining warnings into errors, + // unless marked by @SuppressWarnings. + "-Werror"] } } } @@ -318,12 +275,5 @@ idea { excludeDirs += files(file(topobjdir).listFiles()) excludeDirs -= file("${topobjdir}/gradle") } - - if (!mozconfig.substs.MOZ_INSTALL_TRACKING) { - excludeDirs += file("${topsrcdir}/mobile/android/thirdparty/com/adjust") - } } } - -task wrapper(type: Wrapper) { -} diff --git a/build/autoconf/altoptions.m4 b/build/autoconf/altoptions.m4 index b6e365bdcb..ac016f4b91 100644 --- a/build/autoconf/altoptions.m4 +++ b/build/autoconf/altoptions.m4 @@ -73,5 +73,5 @@ define(MOZ_ARG_HEADER, [# $1]) dnl MOZ_READ_MYCONFIG() - Read in 'myconfig.sh' file AC_DEFUN([MOZ_READ_MOZCONFIG], [AC_REQUIRE([AC_INIT_BINSH])dnl -. ./old-configure.vars +. $OLD_CONFIGURE_VARS ]) diff --git a/build/autoconf/android.m4 b/build/autoconf/android.m4 index 6bba60e448..425def2023 100644 --- a/build/autoconf/android.m4 +++ b/build/autoconf/android.m4 @@ -23,11 +23,6 @@ case "$target" in ASFLAGS="$directory_include_args -DANDROID $ASFLAGS" LDFLAGS="-L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform $LDFLAGS" - ANDROID_PLATFORM="${android_platform}" - - AC_DEFINE(ANDROID) - AC_SUBST(ANDROID_PLATFORM) - ;; esac diff --git a/build/autoconf/clang-plugin.m4 b/build/autoconf/clang-plugin.m4 index a1e7b71edd..419ebf962c 100644 --- a/build/autoconf/clang-plugin.m4 +++ b/build/autoconf/clang-plugin.m4 @@ -175,16 +175,12 @@ if test -n "$ENABLE_MOZSEARCH_PLUGIN"; then AC_MSG_ERROR([Can't use mozsearch plugin without --enable-clang-plugin.]) fi - dnl We use this construct rather than $_objdir to avoid getting /js/src in the - dnl path when compiling JS code. - OBJDIR="$(dirname $(dirname $(dirname $CLANG_PLUGIN)))" - CLANG_PLUGIN_FLAGS="$CLANG_PLUGIN_FLAGS -Xclang -add-plugin -Xclang mozsearch-index" dnl Parameters are: srcdir, outdir (path where output JSON is stored), objdir. CLANG_PLUGIN_FLAGS="$CLANG_PLUGIN_FLAGS -Xclang -plugin-arg-mozsearch-index -Xclang $_topsrcdir" - CLANG_PLUGIN_FLAGS="$CLANG_PLUGIN_FLAGS -Xclang -plugin-arg-mozsearch-index -Xclang $OBJDIR/mozsearch_index" - CLANG_PLUGIN_FLAGS="$CLANG_PLUGIN_FLAGS -Xclang -plugin-arg-mozsearch-index -Xclang $OBJDIR" + CLANG_PLUGIN_FLAGS="$CLANG_PLUGIN_FLAGS -Xclang -plugin-arg-mozsearch-index -Xclang $_objdir/mozsearch_index" + CLANG_PLUGIN_FLAGS="$CLANG_PLUGIN_FLAGS -Xclang -plugin-arg-mozsearch-index -Xclang $_objdir" AC_DEFINE(MOZ_MOZSEARCH_PLUGIN) fi diff --git a/build/autoconf/compiler-opts.m4 b/build/autoconf/compiler-opts.m4 index 2ef0353ea5..15677cef2f 100644 --- a/build/autoconf/compiler-opts.m4 +++ b/build/autoconf/compiler-opts.m4 @@ -11,11 +11,6 @@ dnl the user the option of enabling it. dnl ============================================================================ AC_DEFUN([MOZ_RTTI], [ -MOZ_ARG_ENABLE_BOOL(cpp-rtti, -[ --enable-cpp-rtti Enable C++ RTTI ], -[ _MOZ_USE_RTTI=1 ], -[ _MOZ_USE_RTTI= ]) - if test -z "$_MOZ_USE_RTTI"; then if test "$GNU_CC"; then CXXFLAGS="$CXXFLAGS -fno-rtti" @@ -42,15 +37,6 @@ fi AC_SUBST(MOZ_NO_DEBUG_RTL) -MOZ_DEBUG_ENABLE_DEFS="DEBUG" -MOZ_ARG_WITH_STRING(debug-label, -[ --with-debug-label=LABELS - Define DEBUG_ for each comma-separated - value given.], -[ for option in `echo $withval | sed 's/,/ /g'`; do - MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS DEBUG_${option}" -done]) - if test -n "$MOZ_DEBUG"; then if test -n "$COMPILE_ENVIRONMENT"; then AC_MSG_CHECKING([for valid debug flags]) @@ -66,14 +52,7 @@ if test -n "$MOZ_DEBUG"; then fi CFLAGS=$_SAVE_CFLAGS fi - - MOZ_DEBUG_DEFINES="$MOZ_DEBUG_ENABLE_DEFS" -else - MOZ_DEBUG_DEFINES="NDEBUG TRIMMED" fi - -AC_SUBST_LIST(MOZ_DEBUG_DEFINES) - ]) dnl A high level macro for selecting compiler options. @@ -105,11 +84,6 @@ dnl ======================================================== dnl = Identical Code Folding dnl ======================================================== -MOZ_ARG_DISABLE_BOOL(icf, -[ --disable-icf Disable Identical Code Folding], - MOZ_DISABLE_ICF=1, - MOZ_DISABLE_ICF= ) - if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -a -z "$MOZ_DISABLE_ICF" -a -z "$DEVELOPER_OPTIONS"; then AC_CACHE_CHECK([whether the linker supports Identical Code Folding], LD_SUPPORTS_ICF, @@ -141,7 +115,7 @@ dnl ======================================================== dnl = Automatically remove dead symbols dnl ======================================================== -if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -a -z "$DEVELOPER_OPTIONS"; then +if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -a -z "$DEVELOPER_OPTIONS" -a -z "$MOZ_PROFILE_GENERATE"; then if test -n "$MOZ_DEBUG_FLAGS"; then dnl See bug 670659 AC_CACHE_CHECK([whether removing dead symbols breaks debugging], diff --git a/build/autoconf/config.status.m4 b/build/autoconf/config.status.m4 index 8e2b4d98d3..9be939b2b5 100644 --- a/build/autoconf/config.status.m4 +++ b/build/autoconf/config.status.m4 @@ -149,19 +149,6 @@ done cat >> $CONFIG_STATUS <<\EOF ] -dnl List of AC_DEFINEs that aren't to be exposed in ALLDEFINES -non_global_defines = [ -EOF - -if test -n "$_NON_GLOBAL_ACDEFINES"; then - for var in $_NON_GLOBAL_ACDEFINES; do - echo " '$var'," >> $CONFIG_STATUS - done -fi - -cat >> $CONFIG_STATUS <= 67.1) - CFLAGS="$CFLAGS $MOZ_ICU_CFLAGS" - CXXFLAGS="$CXXFLAGS $MOZ_ICU_CFLAGS" - AC_DEFINE(MOZ_SYSTEM_ICU) -fi - -AC_SUBST(MOZ_SYSTEM_ICU) - -MOZ_ARG_WITH_STRING(intl-api, -[ --with-intl-api, --without-intl-api - Determine the status of the ECMAScript Internationalization API. The first - (or lack of any of these) builds and exposes the API. The second doesn't - build ICU at all.], - _INTL_API=$withval) - -JS_HAS_INTL_API= -case "$_INTL_API" in -no) - ;; -yes) - JS_HAS_INTL_API=1 - ;; -*) - AC_MSG_ERROR([Invalid value passed to --with-intl-api: $_INTL_API]) - ;; -esac - -if test -n "$JS_HAS_INTL_API"; then - USE_ICU=1 -fi - -if test -n "$JS_HAS_INTL_API"; then - AC_DEFINE(JS_HAS_INTL_API) -fi - -dnl Settings for the implementation of the ECMAScript Internationalization API -if test -n "$USE_ICU"; then - icudir="$_topsrcdir/intl/icu/source" - if test ! -d "$icudir"; then - icudir="$_topsrcdir/../../intl/icu/source" - if test ! -d "$icudir"; then - AC_MSG_ERROR([Cannot find the ICU directory]) - fi - fi - - version=`sed -n 's/^[[[:space:]]]*#[[:space:]]*define[[:space:]][[:space:]]*U_ICU_VERSION_MAJOR_NUM[[:space:]][[:space:]]*\([0-9][0-9]*\)[[:space:]]*$/\1/p' "$icudir/common/unicode/uvernum.h"` - if test x"$version" = x; then - AC_MSG_ERROR([cannot determine icu version number from uvernum.h header file $lineno]) - fi - MOZ_ICU_VERSION="$version" - - # TODO: the l is actually endian-dependent - # We could make this set as 'l' or 'b' for little or big, respectively, - # but we'd need to check in a big-endian version of the file. - ICU_DATA_FILE="icudt${version}l.dat" -fi - -AC_SUBST(MOZ_ICU_VERSION) -AC_SUBST(JS_HAS_INTL_API) -AC_SUBST(USE_ICU) -AC_SUBST(ICU_DATA_FILE) - -if test -n "$USE_ICU"; then - dnl Source files that use ICU should have control over which parts of the ICU - dnl namespace they want to use. - AC_DEFINE(U_USING_ICU_NAMESPACE,0) - - if test -z "$MOZ_SYSTEM_ICU"; then - case "$OS_TARGET:$CPU_ARCH" in - WINNT:aarch64) - dnl we use non-yasm, non-GNU as solutions here. - ;; - *) - if test -z "$YASM" -a -z "$GNU_AS" -a "$COMPILE_ENVIRONMENT"; then - AC_MSG_ERROR([Building ICU requires either yasm or a GNU assembler. If you do not have either of those available for this platform you must use --without-intl-api]) - fi - ;; - esac - dnl We build ICU as a static library. - AC_DEFINE(U_STATIC_IMPLEMENTATION) - fi -fi -]) diff --git a/build/autoconf/ios.m4 b/build/autoconf/ios.m4 deleted file mode 100644 index eb4f3ec5c8..0000000000 --- a/build/autoconf/ios.m4 +++ /dev/null @@ -1,107 +0,0 @@ -dnl This Source Code Form is subject to the terms of the Mozilla Public -dnl License, v. 2.0. If a copy of the MPL was not distributed with this -dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. - -AC_DEFUN([MOZ_IOS_PATH_PROG], -[ -changequote({,}) -_prog_name=ifelse($2, {}, `echo $1 | tr "[:upper:]" "[:lower:]"`, $2) -changequote([,]) -AC_CACHE_CHECK([for $_prog_name in iOS SDK], -ac_cv_ios_path_$1, -[ -_path=`xcrun --sdk $ios_sdk --find $_prog_name 2>/dev/null` -_res=$? -if test $_res -ne 0; then - AC_MSG_ERROR([Could not find '$_prog_name' in the iOS SDK]) -fi -ac_cv_ios_path_$1=$_path -]) -$1="${ac_cv_ios_path_$1}$3" -]) - -AC_DEFUN([MOZ_IOS_SDK], -[ - -MOZ_ARG_WITH_STRING(ios-sdk, -[ --with-ios-sdk=TYPE - Type of iOS SDK to use (iphonesimulator, iphoneos) - and optionally version (like iphoneos8.2)], - ios_sdk=$withval) - -MOZ_ARG_ENABLE_STRING(ios-target, - [ --enable-ios-target=VER (default=8.0) - Set the minimum iOS version needed at runtime], - [_IOS_TARGET=$enableval]) -_IOS_TARGET_DEFAULT=8.0 - -case "$target" in -arm*-apple-darwin*) - if test -z "$ios_sdk" -o "$ios_sdk" = "yes"; then - ios_sdk=iphoneos - fi - case "$ios_sdk" in - iphoneos*) - ios_target_arg="-miphoneos-version-min" - ;; - *) - AC_MSG_ERROR([Only 'iphoneos' SDKs are valid when targeting iOS device, don't know what to do with '$ios_sdk'.]) - ;; - esac - ;; -*-apple-darwin*) - ios_target_arg="-mios-simulator-version-min" - case "$ios_sdk" in - # Empty SDK is okay, this might be an OS X desktop build. - ""|iphonesimulator*) - ;; - # Default to iphonesimulator - yes) - ios_sdk=iphonesimulator - ;; - *) - AC_MSG_ERROR([Only 'iphonesimulator' SDKs are valid when targeting iOS simulator.]) - ;; - esac - ;; -esac - - -if test -n "$ios_sdk"; then - if test -z "$_IOS_TARGET"; then - _IOS_TARGET=$_IOS_TARGET_DEFAULT - ios_target_arg="${ios_target_arg}=${_IOS_TARGET}" - fi - # Ensure that xcrun knows where this SDK is. - ios_sdk_path=`xcrun --sdk $ios_sdk --show-sdk-path 2>/dev/null` - _ret=$? - if test $_ret -ne 0; then - AC_MSG_ERROR([iOS SDK '$ios_sdk' could not be found.]) - fi - MOZ_IOS=1 - export HOST_CC=clang - export HOST_CXX=clang++ - # Add isysroot, arch, and ios target arguments - case "$target_cpu" in - arm*) - ARGS="-arch armv7" - ;; - *) - # Unfortunately simulator builds need this. - export CROSS_COMPILE=1 - ;; - esac - ARGS=" $ARGS -isysroot $ios_sdk_path $ios_target_arg" - # Now find our tools - MOZ_IOS_PATH_PROG(CC, clang, $ARGS) - MOZ_IOS_PATH_PROG(CXX, clang++, $ARGS) - export CPP="$CC -E" - MOZ_IOS_PATH_PROG(AR) - MOZ_IOS_PATH_PROG(AS, as, $ARGS) - MOZ_IOS_PATH_PROG(OTOOL) - MOZ_IOS_PATH_PROG(STRIP) - export PKG_CONFIG_PATH=${ios_sdk_path}/usr/lib/pkgconfig/ -fi - -AC_SUBST(MOZ_IOS) -]) diff --git a/build/autoconf/nspr-build.m4 b/build/autoconf/nspr-build.m4 deleted file mode 100644 index ab9747639a..0000000000 --- a/build/autoconf/nspr-build.m4 +++ /dev/null @@ -1,190 +0,0 @@ -dnl This Source Code Form is subject to the terms of the Mozilla Public -dnl License, v. 2.0. If a copy of the MPL was not distributed with this -dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. - -AC_DEFUN([MOZ_CONFIG_NSPR], [ - -ifelse([$1],,define(CONFIGURING_JS,yes)) - -dnl Possible ways this can be called: -dnl from toplevel configure: -dnl JS_STANDALONE= MOZ_BUILD_APP!=js -dnl from js/src/configure invoked by toplevel configure: -dnl JS_STANDALONE= MOZ_BUILD_APP=js -dnl from standalone js/src/configure: -dnl JS_STANDALONE=1 MOZ_BUILD_APP=js - -dnl ======================================================== -dnl = Find the right NSPR to use. -dnl ======================================================== -MOZ_ARG_WITH_STRING(nspr-cflags, -[ --with-nspr-cflags=FLAGS - Pass FLAGS to CC when building code that uses NSPR. - Use this when there's no accurate nspr-config - script available. This is the case when building - SpiderMonkey as part of the Mozilla tree: the - top-level configure script computes NSPR flags - that accomodate the quirks of that environment.], - NSPR_CFLAGS=$withval) -MOZ_ARG_WITH_STRING(nspr-libs, -[ --with-nspr-libs=LIBS Pass LIBS to LD when linking code that uses NSPR. - See --with-nspr-cflags for more details.], - NSPR_LIBS=$withval) - -ifdef([CONFIGURING_JS],[ - MOZ_ARG_ENABLE_BOOL(nspr-build, -[ --enable-nspr-build Build NSPR from source tree], - MOZ_BUILD_NSPR=1, - MOZ_BUILD_NSPR=) -]) - -if test "$MOZ_BUILD_APP" != js || test -n "$JS_STANDALONE"; then - _IS_OUTER_CONFIGURE=1 -fi - -MOZ_ARG_WITH_BOOL(system-nspr, -[ --with-system-nspr Use an NSPR that is already built and installed. - Use the 'nspr-config' script in the current path, - or look for the script in the directories given with - --with-nspr-exec-prefix or --with-nspr-prefix. - (Those flags are only checked if you specify - --with-system-nspr.)], - _USE_SYSTEM_NSPR=1 ) - -JS_WITHOUT_NSPR=unset -ifdef([CONFIGURING_JS],[ - if test -n "$JS_STANDALONE"; then - if test -z "$_HAS_NSPR"; then - JS_WITHOUT_NSPR_DEFAULT=1 - fi - fi -]) - -dnl Pass at most one of -dnl --with-system-nspr -dnl --with-nspr-cflags/libs -dnl --enable-nspr-build - -AC_MSG_CHECKING([NSPR selection]) -nspr_opts= -which_nspr=default -if test -n "$_USE_SYSTEM_NSPR"; then - nspr_opts="x$nspr_opts" - which_nspr="system" -fi -if test -n "$NSPR_CFLAGS" -o -n "$NSPR_LIBS"; then - nspr_opts="x$nspr_opts" - which_nspr="command-line" -fi -if test -n "$MOZ_BUILD_NSPR"; then - nspr_opts="x$nspr_opts" - which_nspr="source-tree" -fi -if test "$JS_WITHOUT_NSPR" = unset; then - JS_WITHOUT_NSPR= -else - nspr_opts="x$nspr_opts" - which_nspr="without-nspr" -fi - -if test -z "$nspr_opts"; then - if test "$MOZ_BUILD_APP" != js; then - dnl Toplevel configure defaults to using nsprpub from the source tree - MOZ_BUILD_NSPR=1 - which_nspr="source-tree" - else - dnl JS configure defaults to no NSPR, falling back to nsprpub. - JS_WITHOUT_NSPR="$JS_WITHOUT_NSPR_DEFAULT" - if test -z "$JS_WITHOUT_NSPR"; then - MOZ_BUILD_NSPR=1 - which_nspr="source-tree" - else - which_nspr="without-nspr" - fi - fi -fi - -if test -z "$nspr_opts" || test "$nspr_opts" = x; then - AC_MSG_RESULT($which_nspr) -else - AC_MSG_ERROR([only one way of using NSPR may be selected. See 'configure --help'.]) -fi - -AC_SUBST(MOZ_BUILD_NSPR) - -if test "$MOZ_BUILD_APP" = js; then - if test "$JS_WITHOUT_NSPR" = 1; then - AC_DEFINE(JS_WITHOUT_NSPR) - fi - AC_SUBST(JS_WITHOUT_NSPR) -fi - -# A (sub)configure invoked by the toplevel configure will always receive -# --with-nspr-libs on the command line. It will never need to figure out -# anything itself. -if test -n "$_IS_OUTER_CONFIGURE"; then - -if test -n "$_USE_SYSTEM_NSPR"; then - AM_PATH_NSPR($NSPR_MINVER, [MOZ_SYSTEM_NSPR=1], [AC_MSG_ERROR([you do not have NSPR installed or your version is older than $NSPR_MINVER.])]) -fi - -if test -n "$MOZ_SYSTEM_NSPR" -o -n "$NSPR_CFLAGS" -o -n "$NSPR_LIBS"; then - _SAVE_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS $NSPR_CFLAGS" - AC_TRY_COMPILE([#include "prtypes.h"], - [#ifndef PR_STATIC_ASSERT - #error PR_STATIC_ASSERT not defined or requires including prtypes.h - #endif], - , - AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT or including prtypes.h does not provide it])) - AC_TRY_COMPILE([#include "prtypes.h"], - [#ifndef PR_UINT64 - #error PR_UINT64 not defined or requires including prtypes.h - #endif], - , - AC_MSG_ERROR([system NSPR does not support PR_UINT64 or including prtypes.h does not provide it])) - CFLAGS=$_SAVE_CFLAGS - NSPR_INCLUDE_DIR=`echo ${NSPR_CFLAGS} | sed -e 's/.*-I\([[^ ]]*\).*/\1/'` - NSPR_LIB_DIR=`echo ${NSPR_LIBS} | sed -e 's/.*-L\([[^ ]]*\).*/\1/'` -elif test -z "$JS_WITHOUT_NSPR"; then - NSPR_INCLUDE_DIR="${DIST}/include/nspr" - NSPR_CFLAGS="-I${NSPR_INCLUDE_DIR}" - if test -n "$GNU_CC"; then - if test -n "$MOZ_FOLD_LIBS"; then - NSPR_LIB_DIR=${DIST}/lib - else - NSPR_LIB_DIR=${DIST}/bin - fi - NSPR_LIBS="-L${NSPR_LIB_DIR} -lnspr${NSPR_VERSION} -lplc${NSPR_VERSION} -lplds${NSPR_VERSION}" - else - # NSS needs actual static libs to link to, and this is where they are. - NSPR_LIBS="${DIST}/lib/nspr${NSPR_VERSION}.lib ${DIST}/lib/plc${NSPR_VERSION}.lib ${DIST}/lib/plds${NSPR_VERSION}.lib " - NSPR_LIB_DIR="${DIST}/lib" - fi -fi - -AC_SUBST_LIST(NSPR_CFLAGS) -AC_SUBST(NSPR_INCLUDE_DIR) -AC_SUBST(NSPR_LIB_DIR) - -PKGCONF_REQUIRES_PRIVATE="Requires.private: nspr" -if test -n "$MOZ_SYSTEM_NSPR"; then - _SAVE_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS $NSPR_CFLAGS" - AC_TRY_COMPILE([#include "prlog.h"], - [#ifndef PR_STATIC_ASSERT - #error PR_STATIC_ASSERT not defined - #endif], - , - AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT])) - CFLAGS=$_SAVE_CFLAGS - # piggy back on $MOZ_SYSTEM_NSPR to set a variable for the nspr check for js.pc - PKGCONF_REQUIRES_PRIVATE="Requires.private: nspr >= $NSPR_MINVER" -elif test -n "$JS_WITHOUT_NSPR"; then - PKGCONF_REQUIRES_PRIVATE= -fi -AC_SUBST([PKGCONF_REQUIRES_PRIVATE]) - -fi # _IS_OUTER_CONFIGURE - -]) diff --git a/build/autoconf/nspr.m4 b/build/autoconf/nspr.m4 deleted file mode 100644 index afd27bfdef..0000000000 --- a/build/autoconf/nspr.m4 +++ /dev/null @@ -1,109 +0,0 @@ -# Configure paths for NSPR -# Public domain - Chris Seawood 2001-04-05 -# Based upon gtk.m4 (also PD) by Owen Taylor - -dnl AM_PATH_NSPR([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) -dnl Test for NSPR, and define NSPR_CFLAGS and NSPR_LIBS -dnl -dnl If the nspr-config script is available, use it to find the -dnl appropriate CFLAGS and LIBS, and to check for the required -dnl version, and run ACTION-IF-FOUND. -dnl -dnl Otherwise, if NO_NSPR_CONFIG_SYSTEM_VERSION is set, we use it, -dnl NO_NSPR_CONFIG_SYSTEM_CFLAGS, and NO_NSPR_CONFIG_SYSTEM_LIBS to -dnl provide default values, and run ACTION-IF-FOUND. (Some systems -dnl ship NSPR without nspr-config, but can glean the appropriate flags -dnl and version.) -dnl -dnl Otherwise, run ACTION-IF-NOT-FOUND. -AC_DEFUN([AM_PATH_NSPR], -[dnl - -AC_ARG_WITH(nspr-prefix, - [ --with-nspr-prefix=PFX Prefix where NSPR is installed], - nspr_config_prefix="$withval", - nspr_config_prefix="") - -AC_ARG_WITH(nspr-exec-prefix, - [ --with-nspr-exec-prefix=PFX - Exec prefix where NSPR is installed], - nspr_config_exec_prefix="$withval", - nspr_config_exec_prefix="") - - if test -n "$nspr_config_exec_prefix"; then - nspr_config_args="$nspr_config_args --exec-prefix=$nspr_config_exec_prefix" - if test -z "$NSPR_CONFIG"; then - NSPR_CONFIG=$nspr_config_exec_prefix/bin/nspr-config - fi - fi - if test -n "$nspr_config_prefix"; then - nspr_config_args="$nspr_config_args --prefix=$nspr_config_prefix" - if test -z "$NSPR_CONFIG"; then - NSPR_CONFIG=$nspr_config_prefix/bin/nspr-config - fi - fi - - unset ac_cv_path_NSPR_CONFIG - AC_PATH_PROG(NSPR_CONFIG, nspr-config, no) - min_nspr_version=ifelse([$1], ,4.0.0,$1) - AC_MSG_CHECKING(for NSPR - version >= $min_nspr_version) - - no_nspr="" - if test "$NSPR_CONFIG" != "no"; then - NSPR_CFLAGS=`$NSPR_CONFIG $nspr_config_args --cflags` - NSPR_LIBS=`$NSPR_CONFIG $nspr_config_args --libs` - NSPR_VERSION_STRING=`$NSPR_CONFIG $nspr_config_args --version` - elif test -n "${NO_NSPR_CONFIG_SYSTEM_VERSION}"; then - NSPR_CFLAGS="${NO_NSPR_CONFIG_SYSTEM_CFLAGS}" - NSPR_LIBS="${NO_NSPR_CONFIG_SYSTEM_LDFLAGS}" - NSPR_VERSION_STRING="$NO_NSPR_CONFIG_SYSTEM_VERSION" - else - no_nspr="yes" - fi - - if test -z "$no_nspr"; then - nspr_config_major_version=`echo $NSPR_VERSION_STRING | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\(\.\([[0-9]]*\)\)\{0,1\}/\1/'` - nspr_config_minor_version=`echo $NSPR_VERSION_STRING | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\(\.\([[0-9]]*\)\)\{0,1\}/\2/'` - nspr_config_micro_version=`echo $NSPR_VERSION_STRING | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\(\.\([[0-9]]*\)\)\{0,1\}/\4/'` - if test -z "$nspr_config_micro_version"; then - nspr_config_micro_version="0" - fi - - min_nspr_major_version=`echo $min_nspr_version | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\(\.\([[0-9]]*\)\)\{0,1\}/\1/'` - min_nspr_minor_version=`echo $min_nspr_version | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\(\.\([[0-9]]*\)\)\{0,1\}/\2/'` - min_nspr_micro_version=`echo $min_nspr_version | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\(\.\([[0-9]]*\)\)\{0,1\}/\4/'` - if test -z "$min_nspr_micro_version"; then - min_nspr_micro_version="0" - fi - - if test "$nspr_config_major_version" -ne "$min_nspr_major_version"; then - no_nspr="yes" - elif test "$nspr_config_major_version" -eq "$min_nspr_major_version" && - test "$nspr_config_minor_version" -lt "$min_nspr_minor_version"; then - no_nspr="yes" - elif test "$nspr_config_major_version" -eq "$min_nspr_major_version" && - test "$nspr_config_minor_version" -eq "$min_nspr_minor_version" && - test "$nspr_config_micro_version" -lt "$min_nspr_micro_version"; then - no_nspr="yes" - fi - fi - - if test -z "$no_nspr"; then - AC_MSG_RESULT(yes) - ifelse([$2], , :, [$2]) - else - AC_MSG_RESULT(no) - ifelse([$3], , :, [$3]) - fi - - - AC_SUBST_LIST(NSPR_CFLAGS) - AC_SUBST_LIST(NSPR_LIBS) - -]) diff --git a/build/autoconf/nss.m4 b/build/autoconf/nss.m4 deleted file mode 100644 index 7924b16060..0000000000 --- a/build/autoconf/nss.m4 +++ /dev/null @@ -1,90 +0,0 @@ -# Configure paths for NSS -# Public domain - Chris Seawood 2001-04-05 -# Based upon gtk.m4 (also PD) by Owen Taylor - -dnl AM_PATH_NSS([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) -dnl Test for NSS, and define NSS_CFLAGS and NSS_LIBS -AC_DEFUN([AM_PATH_NSS], -[dnl - -AC_ARG_WITH(nss-prefix, - [ --with-nss-prefix=PFX Prefix where NSS is installed], - nss_config_prefix="$withval", - nss_config_prefix="") - -AC_ARG_WITH(nss-exec-prefix, - [ --with-nss-exec-prefix=PFX - Exec prefix where NSS is installed], - nss_config_exec_prefix="$withval", - nss_config_exec_prefix="") - - if test -n "$nss_config_exec_prefix"; then - nss_config_args="$nss_config_args --exec-prefix=$nss_config_exec_prefix" - if test -z "$NSS_CONFIG"; then - NSS_CONFIG=$nss_config_exec_prefix/bin/nss-config - fi - fi - if test -n "$nss_config_prefix"; then - nss_config_args="$nss_config_args --prefix=$nss_config_prefix" - if test -z "$NSS_CONFIG"; then - NSS_CONFIG=$nss_config_prefix/bin/nss-config - fi - fi - - unset ac_cv_path_NSS_CONFIG - AC_PATH_PROG(NSS_CONFIG, nss-config, no) - min_nss_version=ifelse([$1], ,3.0.0,$1) - AC_MSG_CHECKING(for NSS - version >= $min_nss_version) - - no_nss="" - if test "$NSS_CONFIG" = "no"; then - no_nss="yes" - else - NSS_CFLAGS=`$NSS_CONFIG $nss_config_args --cflags` - NSS_LIBS=`$NSS_CONFIG $nss_config_args --libs` - - nss_config_major_version=`$NSS_CONFIG $nss_config_args --version | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\(\.\([[0-9]]*\)\)\{0,1\}/\1/'` - nss_config_minor_version=`$NSS_CONFIG $nss_config_args --version | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\(\.\([[0-9]]*\)\)\{0,1\}/\2/'` - nss_config_micro_version=`$NSS_CONFIG $nss_config_args --version | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\(\.\([[0-9]]*\)\)\{0,1\}/\4/'` - if test -z "$nss_config_micro_version"; then - nss_config_micro_version="0" - fi - - min_nss_major_version=`echo $min_nss_version | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\(\.\([[0-9]]*\)\)\{0,1\}/\1/'` - min_nss_minor_version=`echo $min_nss_version | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\(\.\([[0-9]]*\)\)\{0,1\}/\2/'` - min_nss_micro_version=`echo $min_nss_version | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\(\.\([[0-9]]*\)\)\{0,1\}/\4/'` - if test -z "$min_nss_micro_version"; then - min_nss_micro_version="0" - fi - - if test "$nss_config_major_version" -lt "$min_nss_major_version"; then - no_nss="yes" - elif test "$nss_config_major_version" -eq "$min_nss_major_version" && - test "$nss_config_minor_version" -lt "$min_nss_minor_version"; then - no_nss="yes" - elif test "$nss_config_major_version" -eq "$min_nss_major_version" && - test "$nss_config_minor_version" -eq "$min_nss_minor_version" && - test "$nss_config_micro_version" -lt "$min_nss_micro_version"; then - no_nss="yes" - fi - fi - - if test -z "$no_nss"; then - AC_MSG_RESULT(yes) - ifelse([$2], , :, [$2]) - else - AC_MSG_RESULT(no) - ifelse([$3], , :, [$3]) - fi - - - AC_SUBST_LIST(NSS_CFLAGS) - AC_SUBST_LIST(NSS_LIBS) - -]) diff --git a/build/autoconf/zlib.m4 b/build/autoconf/zlib.m4 deleted file mode 100644 index 49a2ccc8bf..0000000000 --- a/build/autoconf/zlib.m4 +++ /dev/null @@ -1,54 +0,0 @@ -dnl This Source Code Form is subject to the terms of the Mozilla Public -dnl License, v. 2.0. If a copy of the MPL was not distributed with this -dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. - -dnl Usage: MOZ_ZLIB_CHECK([version]) - -AC_DEFUN([MOZ_ZLIB_CHECK], -[ - -MOZZLIB=$1 - -MOZ_ARG_WITH_STRING(system-zlib, -[ --with-system-zlib[=PFX] - Use system libz [installed at prefix PFX]], - ZLIB_DIR=$withval) - -if test -z "$MOZ_ZLIB_LIBS$MOZ_ZLIB_CFLAGS$SKIP_LIBRARY_CHECKS"; then - _SAVE_CFLAGS=$CFLAGS - _SAVE_LDFLAGS=$LDFLAGS - _SAVE_LIBS=$LIBS - - if test -n "${ZLIB_DIR}" -a "${ZLIB_DIR}" != "yes"; then - MOZ_ZLIB_CFLAGS="-I${ZLIB_DIR}/include" - MOZ_ZLIB_LIBS="-L${ZLIB_DIR}/lib" - CFLAGS="$MOZ_ZLIB_CFLAGS $CFLAGS" - LDFLAGS="$MOZ_ZLIB_LIBS $LDFLAGS" - fi - if test -z "$ZLIB_DIR" -o "$ZLIB_DIR" = no; then - MOZ_SYSTEM_ZLIB= - else - AC_CHECK_LIB(z, gzread, [MOZ_SYSTEM_ZLIB=1 MOZ_ZLIB_LIBS="$MOZ_ZLIB_LIBS -lz"], - [MOZ_SYSTEM_ZLIB=]) - if test "$MOZ_SYSTEM_ZLIB" = 1; then - MOZZLIBNUM=`echo $MOZZLIB | awk -F. changequote(<<, >>)'{printf "0x%x\n", (((<<$>>1 * 16 + <<$>>2) * 16) + <<$>>3) * 16 + <<$>>4}'changequote([, ])` - AC_TRY_COMPILE([ #include - #include - #include ], - [ #if ZLIB_VERNUM < $MOZZLIBNUM - #error "Insufficient zlib version ($MOZZLIBNUM required)." - #endif ], - MOZ_SYSTEM_ZLIB=1, - AC_MSG_ERROR([Insufficient zlib version for --with-system-zlib ($MOZZLIB required)])) - fi - fi - CFLAGS=$_SAVE_CFLAGS - LDFLAGS=$_SAVE_LDFLAGS - LIBS=$_SAVE_LIBS -fi - -AC_SUBST_LIST(MOZ_ZLIB_CFLAGS) -AC_SUBST_LIST(MOZ_ZLIB_LIBS) -AC_SUBST(MOZ_SYSTEM_ZLIB) - -]) diff --git a/build/build-clang/llvmorg-11-init-4265-g2dcbdba8540.patch b/build/build-clang/llvmorg-11-init-4265-g2dcbdba8540.patch new file mode 100644 index 0000000000..66432bccf4 --- /dev/null +++ b/build/build-clang/llvmorg-11-init-4265-g2dcbdba8540.patch @@ -0,0 +1,106 @@ +diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc +index 9a184c79798..733decfe52c 100644 +--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc ++++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc +@@ -1021,7 +1021,7 @@ TSAN_INTERCEPTOR(int, pthread_create, + + TSAN_INTERCEPTOR(int, pthread_join, void *th, void **ret) { + SCOPED_INTERCEPTOR_RAW(pthread_join, th, ret); +- int tid = ThreadTid(thr, pc, (uptr)th); ++ int tid = ThreadConsumeTid(thr, pc, (uptr)th); + ThreadIgnoreBegin(thr, pc); + int res = BLOCK_REAL(pthread_join)(th, ret); + ThreadIgnoreEnd(thr, pc); +@@ -1034,8 +1034,8 @@ TSAN_INTERCEPTOR(int, pthread_join, void *th, void **ret) { + DEFINE_REAL_PTHREAD_FUNCTIONS + + TSAN_INTERCEPTOR(int, pthread_detach, void *th) { +- SCOPED_TSAN_INTERCEPTOR(pthread_detach, th); +- int tid = ThreadTid(thr, pc, (uptr)th); ++ SCOPED_INTERCEPTOR_RAW(pthread_detach, th); ++ int tid = ThreadConsumeTid(thr, pc, (uptr)th); + int res = REAL(pthread_detach)(th); + if (res == 0) { + ThreadDetach(thr, pc, tid); +@@ -1055,8 +1055,8 @@ TSAN_INTERCEPTOR(void, pthread_exit, void *retval) { + + #if SANITIZER_LINUX + TSAN_INTERCEPTOR(int, pthread_tryjoin_np, void *th, void **ret) { +- SCOPED_TSAN_INTERCEPTOR(pthread_tryjoin_np, th, ret); +- int tid = ThreadTid(thr, pc, (uptr)th); ++ SCOPED_INTERCEPTOR_RAW(pthread_tryjoin_np, th, ret); ++ int tid = ThreadConsumeTid(thr, pc, (uptr)th); + ThreadIgnoreBegin(thr, pc); + int res = REAL(pthread_tryjoin_np)(th, ret); + ThreadIgnoreEnd(thr, pc); +@@ -1069,8 +1069,8 @@ TSAN_INTERCEPTOR(int, pthread_tryjoin_np, void *th, void **ret) { + + TSAN_INTERCEPTOR(int, pthread_timedjoin_np, void *th, void **ret, + const struct timespec *abstime) { +- SCOPED_TSAN_INTERCEPTOR(pthread_timedjoin_np, th, ret, abstime); +- int tid = ThreadTid(thr, pc, (uptr)th); ++ SCOPED_INTERCEPTOR_RAW(pthread_timedjoin_np, th, ret, abstime); ++ int tid = ThreadConsumeTid(thr, pc, (uptr)th); + ThreadIgnoreBegin(thr, pc); + int res = BLOCK_REAL(pthread_timedjoin_np)(th, ret, abstime); + ThreadIgnoreEnd(thr, pc); +diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h +index 3a8231bda9a..30e144fbd00 100644 +--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h ++++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h +@@ -772,7 +772,7 @@ int ThreadCreate(ThreadState *thr, uptr pc, uptr uid, bool detached); + void ThreadStart(ThreadState *thr, int tid, tid_t os_id, + ThreadType thread_type); + void ThreadFinish(ThreadState *thr); +-int ThreadTid(ThreadState *thr, uptr pc, uptr uid); ++int ThreadConsumeTid(ThreadState *thr, uptr pc, uptr uid); + void ThreadJoin(ThreadState *thr, uptr pc, int tid); + void ThreadDetach(ThreadState *thr, uptr pc, int tid); + void ThreadFinalize(ThreadState *thr); +diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc +index fd95cfed4f5..13e457bd770 100644 +--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc ++++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc +@@ -285,19 +285,34 @@ void ThreadFinish(ThreadState *thr) { + ctx->thread_registry->FinishThread(thr->tid); + } + +-static bool FindThreadByUid(ThreadContextBase *tctx, void *arg) { +- uptr uid = (uptr)arg; +- if (tctx->user_id == uid && tctx->status != ThreadStatusInvalid) { ++struct ConsumeThreadContext { ++ uptr uid; ++ ThreadContextBase* tctx; ++}; ++ ++static bool ConsumeThreadByUid(ThreadContextBase *tctx, void *arg) { ++ ConsumeThreadContext *findCtx = (ConsumeThreadContext*)arg; ++ if (tctx->user_id == findCtx->uid && tctx->status != ThreadStatusInvalid) { ++ if (findCtx->tctx) { ++ // Ensure that user_id is unique. If it's not the case we are screwed. ++ // Something went wrong before, but now there is no way to recover. ++ // Returning a wrong thread is not an option, it may lead to very hard ++ // to debug false positives (e.g. if we join a wrong thread). ++ Report("ThreadSanitizer: dup thread with used id 0x%zx\n", findCtx->uid); ++ Die(); ++ } ++ findCtx->tctx = tctx; + tctx->user_id = 0; +- return true; + } + return false; + } + +-int ThreadTid(ThreadState *thr, uptr pc, uptr uid) { +- int res = ctx->thread_registry->FindThread(FindThreadByUid, (void*)uid); +- DPrintf("#%d: ThreadTid uid=%zu tid=%d\n", thr->tid, uid, res); +- return res; ++int ThreadConsumeTid(ThreadState *thr, uptr pc, uptr uid) { ++ ConsumeThreadContext findCtx = {uid, nullptr}; ++ ctx->thread_registry->FindThread(ConsumeThreadByUid, &findCtx); ++ int tid = findCtx.tctx ? findCtx.tctx->tid : ThreadRegistry::kUnknownTid; ++ DPrintf("#%d: ThreadTid uid=%zu tid=%d\n", thr->tid, uid, tid); ++ return tid; + } + + void ThreadJoin(ThreadState *thr, uptr pc, int tid) { diff --git a/build/docs/mozinfo.rst b/build/docs/mozinfo.rst index 709ae87804..795ee3c219 100644 --- a/build/docs/mozinfo.rst +++ b/build/docs/mozinfo.rst @@ -167,3 +167,10 @@ topsrcdir The path to the source directory the build came from. Always defined. + +webrender + Whether or not WebRender is enabled as the Gecko compositor. + + Values are ``true`` and ``false``. + + Always defined. diff --git a/build/docs/pgo.rst b/build/docs/pgo.rst index ed714f8344..722056c727 100644 --- a/build/docs/pgo.rst +++ b/build/docs/pgo.rst @@ -23,17 +23,6 @@ Then:: This is roughly equivalent to:: -#. Perform a build with *MOZ_PROFILE_GENERATE=1* -#. Performing a run of the instrumented binaries -#. $ make maybe_clobber_profiledbuild -#. Perform a build with *MOZ_PROFILE_USE=1* - -Differences between toolchains -============================== - -There are some implementation differences depending on the compiler -toolchain being used. - -The *maybe_clobber_profiledbuild* step gets its name because of a -difference. On Windows, this step merely moves some *.pgc* files around. -Using GCC or Clang, it is equivalent to a *make clean*. +#. Perform a build with *--enable-profile-generate* in $topobjdir/instrumented +#. Perform a run of the instrumented binaries with build/pgo/profileserver.py +#. Perform a build with *--enable-profile-use* in $topobjdir diff --git a/build/docs/test_certificates.rst b/build/docs/test_certificates.rst index 32ab89fd62..c8394f7785 100644 --- a/build/docs/test_certificates.rst +++ b/build/docs/test_certificates.rst @@ -1,8 +1,8 @@ .. _test_certificates: -============== +=============================== Adding Certificates for Testing -============== +=============================== Sometimes we need to write tests for scenarios that require custom client, server or certificate authority (CA) certificates. For that purpose, you can generate such certificates using ``build/pgo/genpgocert.py``. diff --git a/build/mach_bootstrap.py b/build/mach_bootstrap.py index aa94db31cc..d3e5d21183 100644 --- a/build/mach_bootstrap.py +++ b/build/mach_bootstrap.py @@ -36,6 +36,7 @@ MACH_MODULES = [ 'build/valgrind/mach_commands.py', 'devtools/shared/css/generated/mach_commands.py', 'dom/bindings/mach_commands.py', + 'gfx/thebes/mach_commands.py', 'layout/tools/reftest/mach_commands.py', 'python/mach_commands.py', 'python/safety/mach_commands.py', @@ -43,7 +44,10 @@ MACH_MODULES = [ 'python/mach/mach/commands/settings.py', 'python/mozboot/mozboot/mach_commands.py', 'python/mozbuild/mozbuild/mach_commands.py', + 'python/mozbuild/mozbuild/artifact_commands.py', + 'python/mozbuild/mozbuild/build_commands.py', 'python/mozbuild/mozbuild/backend/mach_commands.py', + 'python/mozbuild/mozbuild/code-analysis/mach_commands.py', 'python/mozbuild/mozbuild/compilation/codecomplete.py', 'python/mozbuild/mozbuild/frontend/mach_commands.py', 'python/mozrelease/mozrelease/mach_commands.py', diff --git a/build/macosx/local-mozconfig.common b/build/macosx/local-mozconfig.common index be87140169..fbcc9171be 100644 --- a/build/macosx/local-mozconfig.common +++ b/build/macosx/local-mozconfig.common @@ -4,26 +4,16 @@ . "$topsrcdir/build/mozconfig.common" -if [ -d "$topsrcdir/clang" ]; then +if [ -d "$MOZ_FETCHES_DIR/clang" ]; then # mozilla-central based build - export CC=$topsrcdir/clang/bin/clang - export CXX=$topsrcdir/clang/bin/clang++ - export LLVMCONFIG=$topsrcdir/clang/bin/llvm-config - export DSYMUTIL=$topsrcdir/clang/bin/llvm-dsymutil + export CC=$MOZ_FETCHES_DIR/clang/bin/clang + export CXX=$MOZ_FETCHES_DIR/clang/bin/clang++ + export LLVMCONFIG=$MOZ_FETCHES_DIR/clang/bin/llvm-config + export DSYMUTIL=$MOZ_FETCHES_DIR/clang/bin/llvm-dsymutil # Use an updated linker. - ldflags="-B$topsrcdir/cctools/bin" - export AR=$topsrcdir/cctools/bin/ar - export RANLIB=$topsrcdir/cctools/bin/ranlib -elif [ -d "$topsrcdir/../clang" ]; then - # comm-central based build - export CC=$topsrcdir/../clang/bin/clang - export CXX=$topsrcdir/../clang/bin/clang++ - export LLVMCONFIG=$topsrcdir/../clang/bin/llvm-config - export DSYMUTIL=$topsrcdir/../clang/bin/llvm-dsymutil - # Use an updated linker. - ldflags="-B$topsrcdir/../cctools/bin" - export AR=$topsrcdir/../cctools/bin/ar - export RANLIB=$topsrcdir/../cctools/bin/ranlib + ldflags="-B$MOZ_FETCHES_DIR/cctools/bin" + export AR=$MOZ_FETCHES_DIR/cctools/bin/ar + export RANLIB=$MOZ_FETCHES_DIR/cctools/bin/ranlib fi # Ensure the updated linker doesn't generate things our older build tools diff --git a/build/merge_profdata.py b/build/merge_profdata.py deleted file mode 100644 index cf6a80ee82..0000000000 --- a/build/merge_profdata.py +++ /dev/null @@ -1,18 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -import glob -import subprocess -import sys -import buildconfig - - -def main(_, profile_dir): - profraw_files = glob.glob(profile_dir + '/*.profraw') - if not profraw_files: - print('Could not find any profraw files in ' + profile_dir) - sys.exit(1) - - subprocess.check_call([buildconfig.substs['LLVM_PROFDATA'], 'merge', - '-o', 'merged.profdata'] + profraw_files) diff --git a/build/moz-automation.mk b/build/moz-automation.mk index f6504b318c..22cd2320a8 100644 --- a/build/moz-automation.mk +++ b/build/moz-automation.mk @@ -8,6 +8,26 @@ ifndef ENABLE_TESTS MOZ_AUTOMATION_PACKAGE_TESTS = 0 endif +ifdef CROSS_COMPILE +# Narrow the definition of cross compilation to not include win32 builds +# on win64 and linux32 builds on linux64. +ifeq ($(HOST_OS_ARCH),$(OS_TARGET)) +ifneq (,$(filter x86%,$(CPU_ARCH))) +FUZZY_CROSS_COMPILE = +else +FUZZY_CROSS_COMPILE = 1 +endif +else +FUZZY_CROSS_COMPILE = 1 +endif +endif + +# Don't run make check when cross compiling, when doing artifact builds +# or when building instrumented builds for PGO. +ifneq (,$(USE_ARTIFACT)$(FUZZY_CROSS_COMPILE)$(MOZ_PROFILE_GENERATE)) +MOZ_AUTOMATION_CHECK := 0 +endif + ifneq (,$(filter automation/%,$(MAKECMDGOALS))) ifeq (4.0,$(firstword $(sort 4.0 $(MAKE_VERSION)))) MAKEFLAGS += --output-sync=target @@ -33,6 +53,7 @@ tier_MOZ_AUTOMATION_PACKAGE_TESTS = package-tests tier_MOZ_AUTOMATION_PACKAGE_GENERATED_SOURCES = package-generated-sources tier_MOZ_AUTOMATION_UPLOAD_SYMBOLS = uploadsymbols tier_MOZ_AUTOMATION_UPLOAD = upload +tier_MOZ_AUTOMATION_CHECK = check # Automation build steps. Everything in MOZ_AUTOMATION_TIERS also gets used in # TIERS for mach display. As such, the MOZ_AUTOMATION_TIERS are roughly sorted @@ -46,18 +67,22 @@ moz_automation_symbols = \ MOZ_AUTOMATION_PACKAGE_GENERATED_SOURCES \ MOZ_AUTOMATION_L10N_CHECK \ MOZ_AUTOMATION_UPLOAD \ + MOZ_AUTOMATION_CHECK \ $(NULL) MOZ_AUTOMATION_TIERS := $(foreach sym,$(moz_automation_symbols),$(if $(filter 1,$($(sym))),$(tier_$(sym)))) # Dependencies between automation build steps -automation/uploadsymbols: automation/buildsymbols +automation-start/uploadsymbols: automation/buildsymbols -automation/l10n-check: automation/package +automation-start/l10n-check: automation/package -automation/upload: automation/package -automation/upload: automation/package-tests -automation/upload: automation/buildsymbols -automation/upload: automation/package-generated-sources +automation-start/upload: automation/package +automation-start/upload: automation/package-tests +automation-start/upload: automation/buildsymbols +automation-start/upload: automation/package-generated-sources + +# Run the check tier after everything else. +automation-start/check: $(addprefix automation/,$(filter-out check,$(MOZ_AUTOMATION_TIERS))) automation/build: $(addprefix automation/,$(MOZ_AUTOMATION_TIERS)) @echo Automation steps completed. @@ -65,6 +90,9 @@ automation/build: $(addprefix automation/,$(MOZ_AUTOMATION_TIERS)) # Note: We have to force -j1 here, at least until bug 1036563 is fixed. AUTOMATION_EXTRA_CMDLINE-l10n-check = -j1 +# Run as many tests as possible, even in case of one of them failing. +AUTOMATION_EXTRA_CMDLINE-check = --keep-going + # The commands only run if the corresponding MOZ_AUTOMATION_* variable is # enabled. This means, for example, if we enable MOZ_AUTOMATION_UPLOAD, then # 'buildsymbols' will only run if MOZ_AUTOMATION_BUILD_SYMBOLS is also set. diff --git a/build/moz.configure/android-ndk.configure b/build/moz.configure/android-ndk.configure index 175445b24b..c7a40a878a 100644 --- a/build/moz.configure/android-ndk.configure +++ b/build/moz.configure/android-ndk.configure @@ -12,12 +12,12 @@ def default_android_ndk_root(mozbuild_state_path, _): return path -js_option('--with-android-ndk', nargs=1, - default=default_android_ndk_root, - help='location where the Android NDK can be found{|}') +option('--with-android-ndk', nargs=1, + default=default_android_ndk_root, + help='location where the Android NDK can be found{|}') -js_option('--with-android-toolchain', nargs=1, - help='location of the Android toolchain') +option('--with-android-toolchain', nargs=1, + help='location of the Android toolchain') option('--with-android-googlevr-sdk', nargs=1, help='location of the Android GoogleVR SDK') @@ -31,10 +31,10 @@ def min_android_version(target): return '16' -js_option('--with-android-version', - nargs=1, - help='android platform version{|}', - default=min_android_version) +option('--with-android-version', + nargs=1, + help='android platform version{|}', + default=min_android_version) @depends('--with-android-version', min_android_version) @@ -156,6 +156,7 @@ def android_platform(target, android_version, ndk): add_old_configure_assignment('android_platform', android_platform) +set_config('ANDROID_PLATFORM', android_platform) @depends(android_platform, ndk, target) @@ -256,9 +257,9 @@ def android_toolchain_prefix_base(target): return target.toolchain -js_option(env='STLPORT_CPPFLAGS', - nargs=1, - help='Options compiler should pass for standard C++ library') +option(env='STLPORT_CPPFLAGS', + nargs=1, + help='Options compiler should pass for standard C++ library') @depends('STLPORT_CPPFLAGS', ndk) diff --git a/build/moz.configure/android-sdk.configure b/build/moz.configure/android-sdk.configure index 342976b347..3aafacf46d 100644 --- a/build/moz.configure/android-sdk.configure +++ b/build/moz.configure/android-sdk.configure @@ -39,7 +39,7 @@ def android_sdk_root(value): @depends('--help') def android_sdk_version(_): - return namespace(build_tools_versions=['27.0.3'], target_sdk_version='28') + return namespace(build_tools_versions=['28.0.3'], target_sdk_version='28') @depends(android_sdk_root, android_sdk_version) diff --git a/build/moz.configure/arm.configure b/build/moz.configure/arm.configure index 0022916bda..0b8025d758 100644 --- a/build/moz.configure/arm.configure +++ b/build/moz.configure/arm.configure @@ -24,10 +24,10 @@ def arm_option_defaults(os, _): # default is always returned. The lint is fooled by this file being # conditional. If it weren't conditional, the lint wouldn't ask for '{|}' to # be there. -js_option('--with-arch', nargs=1, - default=arm_option_defaults.arch, - help='{Use specific CPU features (-march=type). Resets thumb, fpu, ' - 'float-abi, etc. defaults when set|}') +option('--with-arch', nargs=1, + default=arm_option_defaults.arch, + help='{Use specific CPU features (-march=type). Resets thumb, fpu, ' + 'float-abi, etc. defaults when set|}') @depends('--with-arch') @@ -38,9 +38,9 @@ def arch_option(value): return [] -js_option('--with-thumb', choices=('yes', 'no', 'toolchain-default'), - default=arm_option_defaults.thumb, - nargs='?', help='{Use Thumb instruction set (-mthumb)|}') +option('--with-thumb', choices=('yes', 'no', 'toolchain-default'), + default=arm_option_defaults.thumb, + nargs='?', help='{Use Thumb instruction set (-mthumb)|}') def normalize_arm_option(value): @@ -65,9 +65,9 @@ def thumb_option(value): return [] -js_option('--with-thumb-interwork', choices=('yes', 'no', 'toolchain-default'), - default='toolchain-default', - nargs='?', help='Use Thumb/ARM instuctions interwork (-mthumb-interwork)') +option('--with-thumb-interwork', choices=('yes', 'no', 'toolchain-default'), + default='toolchain-default', + nargs='?', help='Use Thumb/ARM instuctions interwork (-mthumb-interwork)') @depends('--with-thumb-interwork') @@ -80,9 +80,9 @@ def thumb_interwork_option(value): return [] -js_option('--with-fpu', nargs=1, - default=arm_option_defaults.fpu, - help='{Use specific FPU type (-mfpu=type)|}') +option('--with-fpu', nargs=1, + default=arm_option_defaults.fpu, + help='{Use specific FPU type (-mfpu=type)|}') @depends('--with-fpu') @@ -93,9 +93,9 @@ def fpu_option(value): return [] -js_option('--with-float-abi', nargs=1, - default=arm_option_defaults.float_abi, - help='{Use specific arm float ABI (-mfloat-abi=type)|}') +option('--with-float-abi', nargs=1, + default=arm_option_defaults.float_abi, + help='{Use specific arm float ABI (-mfloat-abi=type)|}') @depends('--with-float-abi') @@ -106,9 +106,9 @@ def float_abi_option(value): return [] -js_option('--with-soft-float', choices=('yes', 'no', 'toolchain-default'), - default='toolchain-default', - nargs='?', help='Use soft float library (-msoft-float)') +option('--with-soft-float', choices=('yes', 'no', 'toolchain-default'), + default='toolchain-default', + nargs='?', help='Use soft float library (-msoft-float)') @depends('--with-soft-float') diff --git a/build/moz.configure/bindgen.configure b/build/moz.configure/bindgen.configure index 5ed59dd797..5bf3479820 100644 --- a/build/moz.configure/bindgen.configure +++ b/build/moz.configure/bindgen.configure @@ -60,16 +60,16 @@ def cbindgen(cbindgen_override, toolchain_search_path): set_config('CBINDGEN', cbindgen) # Bindgen can use rustfmt to format Rust file, but it's not required. -js_option(env='RUSTFMT', nargs=1, help='Path to the rustfmt program') +option(env='RUSTFMT', nargs=1, help='Path to the rustfmt program') rustfmt = check_prog('RUSTFMT', ['rustfmt'], paths=toolchain_search_path, input='RUSTFMT', allow_missing=True) -js_option('--with-libclang-path', nargs=1, - help='Absolute path to a directory containing Clang/LLVM libraries for bindgen (version 3.9.x or above)') -js_option('--with-clang-path', nargs=1, - help='Absolute path to a Clang binary for bindgen (version 3.9.x or above)') +option('--with-libclang-path', nargs=1, + help='Absolute path to a directory containing Clang/LLVM libraries for bindgen (version 3.9.x or above)') +option('--with-clang-path', nargs=1, + help='Absolute path to a Clang binary for bindgen (version 3.9.x or above)') @depends('--with-clang-path', c_compiler, cxx_compiler, toolchain_search_path, @@ -278,9 +278,9 @@ def basic_bindgen_cflags(target, is_unix, compiler_info, android_cflags, return args + (clang_flags or []) -js_option(env='BINDGEN_CFLAGS', - nargs=1, - help='Options bindgen should pass to the C/C++ parser') +option(env='BINDGEN_CFLAGS', + nargs=1, + help='Options bindgen should pass to the C/C++ parser') @depends(basic_bindgen_cflags, 'BINDGEN_CFLAGS') diff --git a/build/moz.configure/headers.configure b/build/moz.configure/headers.configure index eda75ee9a8..b11fb09fa7 100644 --- a/build/moz.configure/headers.configure +++ b/build/moz.configure/headers.configure @@ -66,9 +66,9 @@ check_headers( have_perf_event_h = check_header('linux/perf_event.h', when=building_linux) -js_option('--with-linux-headers', - help='location where the Linux kernel headers can be found', - nargs=1) +option('--with-linux-headers', + help='location where the Linux kernel headers can be found', + nargs=1) passed_linux_header_flags = depends_if( '--with-linux-headers')(lambda v: ['-I%s' % v[0]]) diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure index fcfa4a47fd..a9a8eab4a4 100644 --- a/build/moz.configure/init.configure +++ b/build/moz.configure/init.configure @@ -112,15 +112,12 @@ def check_build_environment(help, dist): set_config('TOPSRCDIR', check_build_environment.topsrcdir) set_config('TOPOBJDIR', check_build_environment.topobjdir) -set_config('MOZ_BUILD_ROOT', check_build_environment.topobjdir) set_config('DIST', check_build_environment.dist) add_old_configure_assignment( '_topsrcdir', check_build_environment.topsrcdir) add_old_configure_assignment( '_objdir', check_build_environment.topobjdir) -add_old_configure_assignment( - 'MOZ_BUILD_ROOT', check_build_environment.topobjdir) add_old_configure_assignment( 'DIST', check_build_environment.dist) @@ -670,9 +667,6 @@ def split_triplet(triplet, allow_unknown=False): elif os.startswith('darwin'): canonical_kernel = 'Darwin' canonical_os = 'OSX' - elif os.startswith('ios'): - canonical_kernel = 'Darwin' - canonical_os = 'iOS' elif os.startswith('dragonfly'): canonical_os = canonical_kernel = 'DragonFly' elif os.startswith('freebsd'): @@ -916,26 +910,16 @@ set_config('HOST_MAJOR_VERSION', host_os_kernel_major_version) @depends(host) -def host_for_old_configure(host): +def host_for_sub_configure(host): return '--host=%s' % host.alias -add_old_configure_arg(host_for_old_configure) - - @depends(target) -def target_for_old_configure(target): +def target_for_sub_configure(target): target_alias = target.alias - # old-configure does plenty of tests against $target and $target_os - # and expects darwin for iOS, so make it happy. - if target.os == 'iOS': - target_alias = target_alias.replace('-ios', '-darwin') return '--target=%s' % target_alias -add_old_configure_arg(target_for_old_configure) - - # These variables are for compatibility with the current moz.builds and # old-configure. Eventually, we'll want to canonicalize better. @depends(target) @@ -1018,15 +1002,6 @@ def target_is_darwin(target): set_define('XP_DARWIN', target_is_darwin) -@depends(target) -def target_is_ios(target): - if target.kernel == 'Darwin' and target.os == 'iOS': - return True - - -set_define('XP_IOS', target_is_ios) - - @depends(target) def target_is_osx(target): if target.kernel == 'Darwin' and target.os == 'OSX': @@ -1045,6 +1020,15 @@ def target_is_linux(target): set_define('XP_LINUX', target_is_linux) +@depends(target) +def target_is_android(target): + if target.os == 'Android': + return True + + +set_define('ANDROID', target_is_android) + + @depends(target) def target_is_openbsd(target): if target.kernel == 'OpenBSD': @@ -1107,23 +1091,8 @@ set_define('MOZ_BUILD_APP', build_project) add_old_configure_assignment('MOZ_BUILD_APP', build_project) -# This is temporary until js/src/configure and configure are merged. -# Use instead of option() in js/moz.configure and more generally, for -# options that are shared between configure and js/src/configure. -@template -def js_option(*args, **kwargs): - opt = option(*args, **kwargs) - - @depends(opt.option, build_project, when=kwargs.get('when')) - def js_option(value, build_project): - if build_project != 'js': - return value.format(opt.option) - - add_old_configure_arg(js_option) - - -js_option(env='MOZILLA_OFFICIAL', - help='Build an official release') +option(env='MOZILLA_OFFICIAL', + help='Build an official release') @depends('MOZILLA_OFFICIAL') @@ -1268,9 +1237,9 @@ set_define('MOZ_UPDATE_CHANNEL', update_channel) add_old_configure_assignment('MOZ_UPDATE_CHANNEL', update_channel) -js_option(env='MOZBUILD_STATE_PATH', nargs=1, - help='Path to a persistent state directory for the build system ' - 'and related tools') +option(env='MOZBUILD_STATE_PATH', nargs=1, + help='Path to a persistent state directory for the build system ' + 'and related tools') @depends('MOZBUILD_STATE_PATH', '--help') @@ -1314,7 +1283,25 @@ def project_flag(env=None, set_for_old_configure=False, # milestone.is_nightly corresponds to cases NIGHTLY_BUILD is set. - @depends(milestone) def enabled_in_nightly(milestone): return milestone.is_nightly + +# Branding +# ============================================================== +option('--with-app-basename', env='MOZ_APP_BASENAME', nargs=1, + help='Typically stays consistent for multiple branded versions of a ' + 'given application (e.g. Aurora and Firefox both use "Firefox"), but ' + 'may vary for full rebrandings (e.g. Iceweasel). Used for ' + 'application.ini\'s "Name" field, which controls profile location in ' + 'the absence of a "Profile" field (see below), and various system ' + 'integration hooks (Unix remoting, Windows MessageWindow name, etc.') + +@depends('--with-app-basename', target_is_android) +def moz_app_basename(value, target_is_android): + if value: + return value[0] + return 'Mypal' + +set_config('MOZ_APP_BASENAME', moz_app_basename, + when=depends(build_project)(lambda p: p != 'js')) diff --git a/build/moz.configure/lto-pgo.configure b/build/moz.configure/lto-pgo.configure index 29e857126b..19f869a5eb 100644 --- a/build/moz.configure/lto-pgo.configure +++ b/build/moz.configure/lto-pgo.configure @@ -4,14 +4,71 @@ # PGO # ============================================================== -@depends(c_compiler, check_build_environment, target) -@imports('multiprocessing') -@imports(_from='__builtin__', _import='min') -def pgo_flags(compiler, build_env, target): +llvm_profdata = check_prog('LLVM_PROFDATA', ['llvm-profdata'], + allow_missing=True, + paths=toolchain_search_path) + +option('--enable-profile-generate', + env='MOZ_PROFILE_GENERATE', + nargs='?', + choices=('cross',), + help='Build a PGO instrumented binary') + +imply_option('MOZ_PGO', + depends_if('--enable-profile-generate')(lambda _: True)) + +set_config('MOZ_PROFILE_GENERATE', + depends_if('--enable-profile-generate')(lambda _: True)) + +set_define('MOZ_PROFILE_GENERATE', + depends_if('--enable-profile-generate')(lambda _: True)) + +add_old_configure_assignment('MOZ_PROFILE_GENERATE', 1, + when='--enable-profile-generate') + +option('--enable-profile-use', + env='MOZ_PROFILE_USE', + nargs='?', + choices=('cross',), + help='Use a generated profile during the build') + +option('--with-pgo-profile-path', + help='Path to the directory with unmerged profile data to use during the build', + nargs=1) + +imply_option('MOZ_PGO', + depends_if('--enable-profile-use')(lambda _: True)) + +set_config('MOZ_PROFILE_USE', + depends_if('--enable-profile-use')(lambda _: True)) + + +@depends('--with-pgo-profile-path', '--enable-profile-use', llvm_profdata, check_build_environment) +@imports('os') +def pgo_profile_path(path, pgo_use, profdata, build_env): topobjdir = build_env.topobjdir if topobjdir.endswith('/js/src'): topobjdir = topobjdir[:-7] + if not path: + return os.path.join(topobjdir, 'instrumented', 'merged.profdata') + if path and not pgo_use: + die('Pass --enable-profile-use to use --with-pgo-profile-path.') + if path and not profdata: + die('LLVM_PROFDATA must be set to process the pgo profile.') + if not os.path.isfile(path[0]): + die('Argument to --with-pgo-profile-path must be a file.') + if not os.path.isabs(path[0]): + die('Argument to --with-pgo-profile-path must be an absolute path.') + return path[0] + + +set_config('PGO_PROFILE_PATH', pgo_profile_path) + +@depends(c_compiler, target, pgo_profile_path) +@imports('multiprocessing') +@imports(_from='__builtin__', _import='min') +def pgo_flags(compiler, target, profdata): if compiler.type == 'gcc': return namespace( gen_cflags=['-fprofile-generate'], @@ -22,7 +79,6 @@ def pgo_flags(compiler, build_env, target): ) if compiler.type in ('clang-cl', 'clang'): - profdata = os.path.join(topobjdir, 'merged.profdata') prefix = '' if compiler.type == 'clang-cl': prefix = '/clang:' @@ -51,61 +107,6 @@ set_config('PROFILE_GEN_LDFLAGS', pgo_flags.gen_ldflags) set_config('PROFILE_USE_CFLAGS', pgo_flags.use_cflags) set_config('PROFILE_USE_LDFLAGS', pgo_flags.use_ldflags) -llvm_profdata = check_prog('LLVM_PROFDATA', ['llvm-profdata'], - allow_missing=True, - paths=toolchain_search_path) - -js_option('--enable-profile-generate', - nargs='?', - choices=('cross',), - help='Build a PGO instrumented binary') - -imply_option('MOZ_PGO', - depends_if('--enable-profile-generate')(lambda _: True)) - -set_config('MOZ_PROFILE_GENERATE', - depends_if('--enable-profile-generate')(lambda _: True)) - -set_define('MOZ_PROFILE_GENERATE', - depends_if('--enable-profile-generate')(lambda _: True)) - -js_option('--enable-profile-use', - nargs='?', - choices=('cross',), - help='Use a generated profile during the build') - -js_option('--with-pgo-profile-path', - help='Path to the directory with unmerged profile data to use during the build', - nargs=1) - -js_option('--enable-cross-pgo', - help='Enable PGO on Rust code') - -imply_option('MOZ_PGO', - depends_if('--enable-profile-use')(lambda _: True)) - -set_config('MOZ_PROFILE_USE', - depends_if('--enable-profile-use')(lambda _: True)) - - -@depends('--with-pgo-profile-path', '--enable-profile-use', llvm_profdata) -@imports('os') -def pgo_profile_path(path, pgo_use, profdata): - if not path: - return - if path and not pgo_use: - die('Pass --enable-profile-use to use --with-pgo-profile-path.') - if path and not profdata: - die('LLVM_PROFDATA must be set to process the pgo profile.') - if not os.path.isdir(path[0]): - die('Argument to --with-pgo-profile-path must be a directory.') - if not os.path.isabs(path[0]): - die('Argument to --with-pgo-profile-path must be an absolute path.') - return path[0] - - -set_config('PGO_PROFILE_PATH', pgo_profile_path) - option('--with-pgo-jarlog', help='Use the provided jarlog file when packaging during a profile-use ' 'build', @@ -147,27 +148,31 @@ set_config('MOZ_PGO_RUST', moz_pgo_rust) # LTO # ============================================================== -js_option('--enable-lto', - env='MOZ_LTO', - nargs='?', - choices=('full', 'thin', 'cross'), - help='Enable LTO') +option('--enable-lto', + env='MOZ_LTO', + nargs='?', + choices=('full', 'thin', 'cross'), + help='Enable LTO') -js_option(env='MOZ_LD64_KNOWN_GOOD', - nargs=1, - help='Indicate that ld64 is free of symbol aliasing bugs.') +option(env='MOZ_LD64_KNOWN_GOOD', + nargs=1, + help='Indicate that ld64 is free of symbol aliasing bugs.') imply_option('MOZ_LD64_KNOWN_GOOD', depends_if('MOZ_AUTOMATION')(lambda _: True)) -@depends('--enable-lto', c_compiler, 'MOZ_LD64_KNOWN_GOOD', target) +@depends('--enable-lto', c_compiler, 'MOZ_LD64_KNOWN_GOOD', target, '--enable-profile-generate') @imports('multiprocessing') -def lto(value, c_compiler, ld64_known_good, target): +def lto(value, c_compiler, ld64_known_good, target, instrumented_build): cflags = [] ldflags = [] enabled = None rust_lto = False if value: + if instrumented_build: + log.warning('Disabling LTO because --enable-profile-generate is specified') + return + enabled = True # `cross` implies `thin`, but with Rust code participating in LTO # as well. Make that a little more explicit. @@ -233,6 +238,17 @@ def lto(value, c_compiler, ld64_known_good, target): ldflags.append("-flto=%s" % num_cores) ldflags.append("-flifetime-dse=1") + # Tell LTO not to inline functions above a certain size, to mitigate + # binary size growth while still getting good performance. + # (For hot functions, PGO will put a multiplier on this limit.) + if target.os == 'WINNT': + ldflags.append('-mllvm:-import-instr-limit=10'); + elif target.os == 'OSX': + # Until OSX gets PGO, too small of a limit will cause slowdowns. + ldflags.append('-Wl,-mllvm,-import-instr-limit=40'); + elif c_compiler.type == 'clang': + ldflags.append('-Wl,-plugin-opt=-import-instr-limit=10'); + return namespace( enabled=enabled, cflags=cflags, diff --git a/build/moz.configure/memory.configure b/build/moz.configure/memory.configure index e408f71552..0fcfc59bef 100644 --- a/build/moz.configure/memory.configure +++ b/build/moz.configure/memory.configure @@ -8,8 +8,8 @@ def jemalloc_default(target): return target.kernel in ('Darwin', 'Linux', 'WINNT') -js_option('--enable-jemalloc', env='MOZ_MEMORY', default=jemalloc_default, - help='{Replace|Do not replace} memory allocator with jemalloc') +option('--enable-jemalloc', env='MOZ_MEMORY', default=jemalloc_default, + help='{Replace|Do not replace} memory allocator with jemalloc') set_config('MOZ_MEMORY', True, when='--enable-jemalloc') @@ -25,9 +25,9 @@ def replace_malloc_default(milestone, build_project): return True -js_option('--enable-replace-malloc', default=replace_malloc_default, - when='--enable-jemalloc', - help='{Enable|Disable} ability to dynamically replace the malloc implementation') +option('--enable-replace-malloc', default=replace_malloc_default, + when='--enable-jemalloc', + help='{Enable|Disable} ability to dynamically replace the malloc implementation') set_config('MOZ_REPLACE_MALLOC', True, when='--enable-replace-malloc') diff --git a/build/moz.configure/nspr.configure b/build/moz.configure/nspr.configure new file mode 100644 index 0000000000..c9d9f8e144 --- /dev/null +++ b/build/moz.configure/nspr.configure @@ -0,0 +1,98 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# Top-level configure defaults to building NSPR from source. Standalone JS +# doesn't. +option('--enable-nspr-build', when=js_standalone, + help='{Build|Do not build} NSPR from source tree') + +@depends('--enable-nspr-build', when=js_standalone) +def enable_nspr_build(enable): + if enable: + return enable + +option('--with-system-nspr', help='Use system NSPR') + +@depends(enable_nspr_build, '--with-system-nspr', js_standalone) +def build_nspr(nspr_build, system_nspr, js_standalone): + if nspr_build is not None and nspr_build.origin != 'default': + if nspr_build and system_nspr: + die('Cannot use both --enable-nspr-build and --with-system-nspr') + if js_standalone: + return nspr_build + return not system_nspr + +set_config('MOZ_BUILD_NSPR', True, when=build_nspr) +set_config('MOZ_SYSTEM_NSPR', True, when='--with-system-nspr') + +@depends(build_nspr, '--with-system-nspr', js_standalone) +def js_without_nspr(build_nspr, system_nspr, js_standalone): + if js_standalone: + return not build_nspr and not system_nspr + +set_config('JS_WITHOUT_NSPR', True, when=js_without_nspr) +set_define('JS_WITHOUT_NSPR', True, when=js_without_nspr) + +@depends(js_standalone) +def nspr_minver(js_standalone): + if js_standalone: + return 'nspr >= 4.10' + return 'nspr >= 4.25' + +nspr_pkg = pkg_check_modules('NSPR', nspr_minver, when='--with-system-nspr') + +@depends_if(nspr_pkg) +def nspr_pkg(nspr_pkg): + def extract(prefix, list): + for item in list: + if item.startswith(prefix): + return item[len(prefix):] + return '' + + include_dir = extract('-I', nspr_pkg.cflags) + lib_dir = extract('-L', nspr_pkg.libs) + return namespace( + cflags=nspr_pkg.cflags, + include_dir=include_dir, + libs=nspr_pkg.libs, + lib_dir=lib_dir, + ) + +@depends(nspr_minver, when='--with-system-nspr') +def pkgconf_requires_private(nspr_minver): + return 'Requires.private: %s' % nspr_minver + +set_config('PKGCONF_REQUIRES_PRIVATE', pkgconf_requires_private) + +# pkg_check_modules takes care of NSPR_CFLAGS and NSPR_LIBS when using --with-system-nspr. +@depends(check_build_environment, c_compiler, fold_libs, when=build_nspr) +def nspr_config(build_env, c_compiler, fold_libs): + libs = ['nspr4', 'plc4', 'plds4'] + if c_compiler.type == 'clang-cl': + lib_dir = os.path.join(build_env.dist, 'lib') + libs = [os.path.join(lib_dir, '%s.lib' % lib) for lib in libs] + else: + lib_dir = os.path.join(build_env.dist, 'lib' if fold_libs else 'bin') + libs = ['-L%s' % lib_dir] + ['-l%s' % lib for lib in libs] + + include_dir = os.path.join(build_env.dist, 'include', 'nspr') + return namespace( + cflags=['-I%s' % include_dir], + include_dir=include_dir, + libs=libs, + lib_dir=lib_dir, + ) + +set_config('NSPR_CFLAGS', nspr_config.cflags, when=nspr_config) +set_config('NSPR_LIBS', nspr_config.libs, when=nspr_config) + +set_config('NSPR_INCLUDE_DIR', nspr_config.include_dir, when=nspr_config) +set_config('NSPR_LIB_DIR', nspr_config.lib_dir, when=nspr_config) +set_config('NSPR_INCLUDE_DIR', nspr_pkg.include_dir, when=nspr_pkg) +set_config('NSPR_LIB_DIR', nspr_pkg.lib_dir, when=nspr_pkg) + +add_old_configure_assignment('NSPR_CFLAGS', nspr_config.cflags, when=nspr_config) +add_old_configure_assignment('NSPR_LIBS', nspr_config.libs, when=nspr_config) +add_old_configure_assignment('NSPR_CFLAGS', nspr_pkg.cflags, when=nspr_pkg) +add_old_configure_assignment('NSPR_LIBS', nspr_pkg.libs, when=nspr_pkg) diff --git a/build/moz.configure/old.configure b/build/moz.configure/old.configure index 930cbd362d..5b5020edc5 100644 --- a/build/moz.configure/old.configure +++ b/build/moz.configure/old.configure @@ -23,10 +23,19 @@ def autoconf(mozconfig, autoconf): make_extra = mozconfig['make_extra'] if make_extra: for assignment in make_extra: - m = re.match('(?:export\s+)?AUTOCONF\s*:?=\s*(.+)$', + m = re.match(r'(?:export\s+)?AUTOCONF\s*:?=\s*(.+)$', assignment) if m: mozconfig_autoconf = m.group(1) + # Check whether we've exported any known-broken variables. + m = re.match(r'(?:export\s+)?(?:CC|CXX)\s*:?=\s*(?:.+)$', + assignment) + if m: + die('Setting the value of CC or CXX with "mk_add_options" ' + 'can cause the build to fail unexpectedly. Please ' + 'change your mozconfig to instead use ' + '"ac_add_options", e.g. ac_add_options ' + 'CC=my-custom-cc".') autoconf = autoconf[0] if autoconf else None @@ -74,20 +83,8 @@ def prepare_mozconfig(mozconfig): return items -@depends('OLD_CONFIGURE', prepare_mozconfig, autoconf, check_build_environment, - shell, old_configure_assignments, build_project) -@imports(_from='__builtin__', _import='open') -@imports(_from='__builtin__', _import='print') -@imports(_from='__builtin__', _import='sorted') -@imports('glob') -@imports('itertools') -@imports('subprocess') -# Import getmtime without overwriting the sandbox os.path. -@imports(_from='os.path', _import='getmtime') -@imports(_from='os.path', _import='exists') -@imports(_from='mozbuild.shellutil', _import='quote') -def prepare_configure(old_configure, mozconfig, autoconf, build_env, shell, - old_configure_assignments, build_project): +@depends('OLD_CONFIGURE', build_project) +def old_configure(old_configure, build_project): # os.path.abspath in the sandbox will ensure forward slashes on Windows, # which is actually necessary because this path actually ends up literally # as $0, and backslashes there breaks autoconf's detection of the source @@ -98,39 +95,15 @@ def prepare_configure(old_configure, mozconfig, autoconf, build_env, shell, if not old_configure_dir.endswith('/js/src'): old_configure = os.path.join(old_configure_dir, 'js', 'src', os.path.basename(old_configure)) + return old_configure - refresh = True - if exists(old_configure): - mtime = getmtime(old_configure) - aclocal = os.path.join(build_env.topsrcdir, 'build', 'autoconf', - '*.m4') - for input in itertools.chain( - (old_configure + '.in', - os.path.join(os.path.dirname(old_configure), 'aclocal.m4')), - glob.iglob(aclocal), - ): - if getmtime(input) > mtime: - break - else: - refresh = False - if refresh: - log.info('Refreshing %s with %s', old_configure, autoconf) - script = subprocess.check_output([ - shell, autoconf, - '--localdir=%s' % os.path.dirname(old_configure), - old_configure + '.in']) - if not script: - die('Generated old-configure is empty! Check that your autoconf 2.13 program works!') - - # Make old-configure append to config.log, where we put our own log. - # This could be done with a m4 macro, but it's way easier this way - script = script.replace('>./config.log', '>>${CONFIG_LOG=./config.log}') - - with open(old_configure, 'wb') as fh: - fh.write(script) - - cmd = [shell, old_configure] +@depends(prepare_mozconfig, old_configure_assignments, autoconf) +@imports(_from='__builtin__', _import='open') +@imports(_from='__builtin__', _import='print') +@imports(_from='__builtin__', _import='sorted') +@imports(_from='mozbuild.shellutil', _import='quote') +def prepare_configure(mozconfig, old_configure_assignments, autoconf): with encoded_open('old-configure.vars', 'w') as out: log.debug('Injecting the following to old-configure:') @@ -156,8 +129,6 @@ def prepare_configure(old_configure, mozconfig, autoconf, build_env, shell, for k, v in old_configure_assignments: inject('%s=%s' % (k, quote(v))) - return cmd - @template def old_configure_options(*options): @@ -168,50 +139,27 @@ def old_configure_options(*options): def all_options(): return list(options) - return depends(extra_old_configure_args, all_options, *options) + return depends(host_for_sub_configure, target_for_sub_configure, all_options, *options) @old_configure_options( '--cache-file', '--datadir', - '--enable-content-sandbox', - '--enable-cookies', - '--enable-cpp-rtti', '--enable-crashreporter', '--enable-dbus', '--enable-debug-js-modules', - '--enable-directshow', - '--enable-dtrace', '--enable-dump-painting', '--enable-extensions', - '--enable-feeds', - '--enable-gconf', - '--enable-icf', - '--enable-install-strip', - '--enable-ios-target', - '--enable-libjpeg-turbo', '--enable-libproxy', - '--enable-llvm-hacks', '--enable-logrefcnt', - '--enable-mobile-optimize', '--enable-necko-wifi', '--enable-negotiateauth', - '--enable-nfc', - '--enable-nspr-build', '--enable-official-branding', '--enable-parental-controls', - '--enable-pref-extensions', - '--enable-readline', '--enable-sandbox', - '--enable-signmar', - '--enable-startup-notification', - '--enable-startupcache', - '--enable-strip', - '--enable-synth-pico', '--enable-system-cairo', '--enable-system-extension-dirs', '--enable-system-pixman', - '--enable-system-sqlite', '--enable-universalchardet', '--enable-updater', '--enable-webrender', @@ -223,40 +171,16 @@ def old_configure_options(*options): '--with-android-distribution-directory', '--with-android-max-sdk', '--with-android-min-sdk', - '--with-app-basename', - '--with-app-name', '--with-branding', - '--with-cross-lib', - '--with-debug-label', '--with-distribution-id', - '--with-doc-include-dirs', - '--with-doc-input-dirs', - '--with-doc-output-dir', - '--with-intl-api', - '--with-ios-sdk', - '--with-jitreport-granularity', '--with-macbundlename-prefix', - '--with-nspr-cflags', - '--with-nspr-exec-prefix', - '--with-nspr-libs', - '--with-nspr-prefix', - '--with-nss-exec-prefix', - '--with-nss-prefix', - '--with-qemu-exe', - '--with-sixgill', - '--with-system-bz2', - '--with-system-icu', '--with-system-libevent', - '--with-system-nspr', - '--with-system-nss', '--with-system-png', - '--with-system-zlib', - '--with-unify-dist', '--with-user-appdir', '--x-includes', '--x-libraries', ) -def prepare_configure_options(extra_old_configure_args, all_options, *options): +def prepare_configure_options(host, target, all_options, *options): # old-configure only supports the options listed in @old_configure_options # so we don't need to pass it every single option we've been passed. Only # the ones that are not supported by python configure need to. @@ -264,148 +188,183 @@ def prepare_configure_options(extra_old_configure_args, all_options, *options): value.format(name) for name, value in zip(all_options, options) if value.origin != 'default' - ] + ] + [host, target] - extra_env = {} + return namespace(options=options, all_options=all_options) - # We also pass it the options from js/moz.configure so that it can pass - # them down to js/src/configure. Note this list is empty when running - # js/src/configure, in which case we don't need to pass those options - # to old-configure since old-configure doesn't handle them anyways. - if extra_old_configure_args: - for arg in extra_old_configure_args: - if arg.startswith('-'): - options.append(arg) + +@template +def old_configure_for(old_configure_path, extra_env=None): + if extra_env is None: + extra_env = dependable(None) + + @depends(prepare_configure, prepare_configure_options, altered_path, extra_env, + check_build_environment, old_configure_path, 'MOZILLABUILD', autoconf, shell) + @imports(_from='__builtin__', _import='compile') + @imports(_from='__builtin__', _import='open') + @imports(_from='__builtin__', _import='OSError') + @imports('glob') + @imports('itertools') + @imports('logging') + @imports('os') + @imports('subprocess') + @imports('sys') + @imports('types') + @imports(_from='mozbuild.shellutil', _import='quote') + @imports(_from='mozbuild.shellutil', _import='split') + @imports(_from='mozbuild.util', _import='encode') + @imports(_from='tempfile', _import='NamedTemporaryFile') + @imports(_from='subprocess', _import='CalledProcessError') + def old_configure(prepare_configure, prepare_configure_options, altered_path, extra_env, + build_env, old_configure, mozillabuild, autoconf, shell): + # Use prepare_configure to make lint happy + prepare_configure + refresh = True + if os.path.exists(old_configure): + mtime = os.path.getmtime(old_configure) + aclocal = os.path.join(build_env.topsrcdir, 'build', 'autoconf', + '*.m4') + for input in itertools.chain( + (old_configure + '.in', + os.path.join(os.path.dirname(old_configure), 'aclocal.m4')), + glob.iglob(aclocal), + ): + if os.path.getmtime(input) > mtime: + break else: - k, v = arg.split('=', 1) - extra_env[k] = v + refresh = False - return namespace(options=options, extra_env=extra_env, all_options=all_options) + if refresh: + log.info('Refreshing %s with %s', old_configure, autoconf) + + try: + script = subprocess.check_output([ + shell, autoconf, + '--localdir=%s' % os.path.dirname(old_configure), + old_configure + '.in']) + except CalledProcessError as exc: + # Autoconf on win32 may break due to a bad $PATH. Let the user know + # their $PATH is suspect. + if mozillabuild: + mozillabuild_path = normsep(mozillabuild[0]) + sh_path = normsep(find_program('sh')) + if mozillabuild_path not in sh_path: + log.warning("The '{}msys/bin' directory is not first in $PATH. " + "This may cause autoconf to fail. ($PATH is currently " + "set to: {})".format(mozillabuild_path, os.environ[ + 'PATH'])) + die('autoconf exited with return code {}'.format(exc.returncode)) + + if not script: + die('Generated old-configure is empty! Check that your autoconf 2.13 program works!') + + # Make old-configure append to config.log, where we put our own log. + # This could be done with a m4 macro, but it's way easier this way + script = script.replace('>./config.log', '>>${CONFIG_LOG=./config.log}') + + with NamedTemporaryFile(mode='wb', prefix=os.path.basename(old_configure), + dir=os.path.dirname(old_configure), delete=False) as fh: + fh.write(script) + + try: + os.rename(fh.name, old_configure) + except OSError: + try: + # Likely the file already existed (on Windows). Retry after removing it. + os.remove(old_configure) + os.rename(fh.name, old_configure) + except OSError as e: + die('Failed re-creating old-configure: %s' % e.message) + + cmd = [shell, old_configure] + prepare_configure_options.options + + env = dict(os.environ) + + # For debugging purpose, in case it's not what we'd expect. + log.debug('Running %s', quote(*cmd)) + + # Our logging goes to config.log, the same file old.configure uses. + # We can't share the handle on the file, so close it. + logger = logging.getLogger('moz.configure') + config_log = None + for handler in logger.handlers: + if isinstance(handler, logging.FileHandler): + config_log = handler + config_log.close() + logger.removeHandler(config_log) + env['CONFIG_LOG'] = config_log.baseFilename + log_size = os.path.getsize(config_log.baseFilename) + break + + if altered_path: + env['PATH'] = altered_path + + if extra_env: + env.update(extra_env) + + env['OLD_CONFIGURE_VARS'] = os.path.join(build_env.topobjdir, 'old-configure.vars') + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + env=encode(env)) + while True: + line = proc.stdout.readline() + if not line: + break + log.info(line.rstrip()) + + ret = proc.wait() + if ret: + with log.queue_debug(): + if config_log: + with encoded_open(config_log.baseFilename, 'r') as fh: + fh.seek(log_size) + for line in fh: + log.debug(line.rstrip()) + log.error('old-configure failed') + sys.exit(ret) + + if config_log: + # Create a new handler in append mode + handler = logging.FileHandler(config_log.baseFilename, mode='a', delay=True) + handler.setFormatter(config_log.formatter) + logger.addHandler(handler) + + raw_config = { + 'split': split, + 'unique_list': unique_list, + } + with encoded_open('config.data', 'r') as fh: + code = compile(fh.read(), 'config.data', 'exec') + # Every variation of the exec() function I tried led to: + # SyntaxError: unqualified exec is not allowed in function 'main' it + # contains a nested function with free variables + exec code in raw_config # noqa + + # Ensure all the flags known to old-configure appear in the + # @old_configure_options above. + all_options = set(prepare_configure_options.all_options) + for flag in raw_config['flags']: + if flag not in all_options: + die('Missing option in `@old_configure_options` in %s: %s', + __file__, flag) + + # If the code execution above fails, we want to keep the file around for + # debugging. + os.remove('config.data') + + return namespace(**{ + c: [ + (k[1:-1], v[1:-1] if isinstance(v, types.StringTypes) else v) + for k, v in raw_config[c] + ] + for c in ('substs', 'defines') + }) + + return old_configure -@depends(prepare_configure, prepare_configure_options, altered_path) -@imports(_from='__builtin__', _import='compile') -@imports(_from='__builtin__', _import='open') -@imports('logging') -@imports('os') -@imports('subprocess') -@imports('sys') -@imports('types') -@imports(_from='mozbuild.shellutil', _import='quote') -@imports(_from='mozbuild.shellutil', _import='split') -@imports(_from='mozbuild.util', _import='encode') -def old_configure(prepare_configure, prepare_configure_options, altered_path): - cmd = prepare_configure + prepare_configure_options.options - extra_env = prepare_configure_options.extra_env - - env = dict(os.environ) - if extra_env: - env.update(extra_env) - - # For debugging purpose, in case it's not what we'd expect. - log.debug('Running %s', quote(*cmd)) - if extra_env: - log.debug('with extra environment: %s', - ' '.join('%s=%s' % pair for pair in extra_env.iteritems())) - - # Our logging goes to config.log, the same file old.configure uses. - # We can't share the handle on the file, so close it. - logger = logging.getLogger('moz.configure') - config_log = None - for handler in logger.handlers: - if isinstance(handler, logging.FileHandler): - config_log = handler - config_log.close() - logger.removeHandler(config_log) - env['CONFIG_LOG'] = config_log.baseFilename - log_size = os.path.getsize(config_log.baseFilename) - break - - if altered_path: - env['PATH'] = altered_path - - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - env=encode(env)) - while True: - line = proc.stdout.readline() - if not line: - break - log.info(line.rstrip()) - - ret = proc.wait() - if ret: - with log.queue_debug(): - if config_log: - with encoded_open(config_log.baseFilename, 'r') as fh: - fh.seek(log_size) - for line in fh: - log.debug(line.rstrip()) - log.error('old-configure failed') - sys.exit(ret) - - if config_log: - # Create a new handler in append mode - handler = logging.FileHandler(config_log.baseFilename, mode='a', delay=True) - handler.setFormatter(config_log.formatter) - logger.addHandler(handler) - - raw_config = { - 'split': split, - 'unique_list': unique_list, - } - with encoded_open('config.data', 'r') as fh: - code = compile(fh.read(), 'config.data', 'exec') - # Every variation of the exec() function I tried led to: - # SyntaxError: unqualified exec is not allowed in function 'main' it - # contains a nested function with free variables - exec code in raw_config # noqa - - # Ensure all the flags known to old-configure appear in the - # @old_configure_options above. - all_options = set(prepare_configure_options.all_options) - for flag in raw_config['flags']: - if flag not in all_options: - die('Missing option in `@old_configure_options` in %s: %s', - __file__, flag) - - # If the code execution above fails, we want to keep the file around for - # debugging. - os.remove('config.data') - - for c in ('substs', 'defines'): - raw_config[c] = [ - (k[1:-1], v[1:-1] if isinstance(v, types.StringTypes) else v) - for k, v in raw_config[c] - ] - - return raw_config - - -# set_config is only available in the global namespace, not directly in -# @depends functions, but we do need to enumerate the result of -# old_configure, so we cheat. -@imports('__sandbox__') -def set_old_configure_config(name, value): - __sandbox__.set_config_impl(name, value) - -# Same as set_old_configure_config, but for set_define. - - -@imports('__sandbox__') -def set_old_configure_define(name, value): - __sandbox__.set_define_impl(name, value) - - -@depends(old_configure) -def post_old_configure(raw_config): - for k, v in raw_config['substs']: - set_old_configure_config(k, v) - - for k, v in dict(raw_config['defines']).iteritems(): - set_old_configure_define(k, v) - - set_old_configure_config('non_global_defines', - raw_config['non_global_defines']) +old_configure = old_configure_for(old_configure) +set_config('OLD_CONFIGURE_SUBSTS', old_configure.substs) +set_config('OLD_CONFIGURE_DEFINES', old_configure.defines) # Assuming no other option is declared after this function, handle the diff --git a/build/moz.configure/pkg.configure b/build/moz.configure/pkg.configure index 3a28c3a07b..d779043439 100644 --- a/build/moz.configure/pkg.configure +++ b/build/moz.configure/pkg.configure @@ -14,7 +14,6 @@ pkg_config = check_prog('PKG_CONFIG', pkg_config, allow_missing=True) @depends_if(pkg_config) @checking('for pkg-config version') -@imports('subprocess') def pkg_config_version(pkg_config): return Version(check_cmd_output(pkg_config, '--version').rstrip()) @@ -34,7 +33,7 @@ def pkg_config_version(pkg_config): @template def pkg_check_modules(var, package_desc, when=always, - allow_missing=False): + allow_missing=False, config=True): if isinstance(package_desc, (tuple, list)): package_desc = ' '.join(package_desc) package_desc = dependable(package_desc) @@ -95,7 +94,8 @@ def pkg_check_modules(var, package_desc, when=always, def pkg_info(cflags, libs): return namespace(cflags=cflags, libs=libs) - set_config('%s_CFLAGS' % var, pkg_cflags) - set_config('%s_LIBS' % var, pkg_libs) + if config: + set_config('%s_CFLAGS' % var, pkg_cflags) + set_config('%s_LIBS' % var, pkg_libs) return pkg_info diff --git a/build/moz.configure/rust.configure b/build/moz.configure/rust.configure index a129f9a20b..654ebe4d87 100644 --- a/build/moz.configure/rust.configure +++ b/build/moz.configure/rust.configure @@ -5,8 +5,8 @@ # Rust is required by `rust_compiler` below. We allow_missing here # to propagate failures to the better error message there. -js_option(env='RUSTC', nargs=1, help='Path to the rust compiler') -js_option(env='CARGO', nargs=1, help='Path to the Cargo package manager') +option(env='RUSTC', nargs=1, help='Path to the rust compiler') +option(env='CARGO', nargs=1, help='Path to the Cargo package manager') rustc = check_prog('_RUSTC', ['rustc'], what='rustc', paths=toolchain_search_path, input='RUSTC', @@ -104,7 +104,7 @@ def rust_compiler(rustc_info, cargo_info, build_project): if build_project == 'tools/crashreporter': rustc_min_version = Version('1.31.0') else: - rustc_min_version = Version('1.35.0') + rustc_min_version = Version('1.36.0') cargo_min_version = rustc_min_version version = rustc_info.version @@ -188,7 +188,6 @@ def rust_triple_alias(host_or_target, host_or_target_c_compiler): rust_supported_targets, arm_target, when=rust_compiler) @checking('for rust %s triplet' % host_or_target_str) @imports('os') - @imports('subprocess') @imports(_from='mozbuild.configure.util', _import='LineIO') @imports(_from='mozbuild.shellutil', _import='quote') @imports(_from='tempfile', _import='mkstemp') @@ -381,7 +380,7 @@ set_config('RUST_HOST_TARGET', rust_host_triple) set_config('RUSTC_COMMIT', depends(rustc_info)(lambda i: i.commit)) # Rustdoc is required by Rust tests below. -js_option(env='RUSTDOC', nargs=1, help='Path to the rustdoc program') +option(env='RUSTDOC', nargs=1, help='Path to the rustdoc program') rustdoc = check_prog('RUSTDOC', ['rustdoc'], paths=toolchain_search_path, input='RUSTDOC', allow_missing=True) diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure index f1f975764c..2c2a313155 100644 --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -5,10 +5,10 @@ imply_option('--enable-release', mozilla_official) imply_option('--enable-release', depends_if('MOZ_AUTOMATION')(lambda x: True)) -js_option('--enable-release', - default=milestone.is_release_or_beta, - help='{Build|Do not build} with more conservative, release ' - 'engineering-oriented options.{ This may slow down builds.|}') +option('--enable-release', + default=milestone.is_release_or_beta, + help='{Build|Do not build} with more conservative, release ' + 'engineering-oriented options.{ This may slow down builds.|}') @depends('--enable-release') @@ -23,9 +23,9 @@ set_config('DEVELOPER_OPTIONS', developer_options) # Code optimization # ============================================================== -js_option('--disable-optimize', - nargs='?', - help='Disable optimizations via compiler flags') +option('--disable-optimize', + nargs='?', + help='Disable optimizations via compiler flags') @depends('--enable-optimize', '--help') @@ -131,7 +131,7 @@ def host_is_osx(host): with only_when(host_is_osx | target_is_osx): # MacOS SDK # ========= - js_option('--with-macos-sdk', env='MACOS_SDK_DIR', nargs=1, + option('--with-macos-sdk', env='MACOS_SDK_DIR', nargs=1, help='Location of platform SDK to use') @depends('--with-macos-sdk', host) @@ -202,62 +202,13 @@ with only_when(target_is_osx): set_config('MACOS_PRIVATE_FRAMEWORKS_DIR', macos_private_frameworks) -with only_when(host_is_osx): - # Xcode state - # =========== - js_option('--disable-xcode-checks', - help='Do not check that Xcode is installed and properly configured') - - - @depends(host, '--disable-xcode-checks') - def xcode_path(host, xcode_checks): - if host.kernel != 'Darwin' or not xcode_checks: - return - - # xcode-select -p prints the path to the installed Xcode. It - # should exit 0 and return non-empty result if Xcode is installed. - - def bad_xcode_select(): - die('Could not find installed Xcode; install Xcode from the App ' - 'Store, run it once to perform initial configuration, and then ' - 'try again; in the rare case you wish to build without Xcode ' - 'installed, add the --disable-xcode-checks configure flag') - - xcode_path = check_cmd_output('xcode-select', '--print-path', - onerror=bad_xcode_select).strip() - - if not xcode_path: - bad_xcode_select() - - # Now look for the Command Line Tools. - def no_cltools(): - die('Could not find installed Xcode Command Line Tools; ' - 'run `xcode-select --install` and follow the instructions ' - 'to install them then try again; if you wish to build without ' - 'Xcode Command Line Tools installed, ' - 'add the --disable-xcode-checks configure flag') - - check_cmd_output('pkgutil', '--pkg-info', - 'com.apple.pkg.CLTools_Executables', - onerror=no_cltools) - - return xcode_path - - - set_config('XCODE_PATH', xcode_path) - - # Compiler wrappers # ============================================================== -# Normally, we'd use js_option and automatically have those variables -# propagated to js/src, but things are complicated by possible additional -# wrappers in CC/CXX, and by other subconfigures that do not handle those -# options and do need CC/CXX altered. option('--with-compiler-wrapper', env='COMPILER_WRAPPER', nargs=1, help='Enable compiling with wrappers such as distcc and ccache') -js_option('--with-ccache', env='CCACHE', nargs='?', - help='Enable compiling with ccache') +option('--with-ccache', env='CCACHE', nargs='?', + help='Enable compiling with ccache') @depends_if('--with-ccache') @@ -271,9 +222,9 @@ def ccache(value): ccache = check_prog('CCACHE', progs=(), input=ccache) -js_option(env='CCACHE_PREFIX', - nargs=1, - help='Compiler prefix to use when using ccache') +option(env='CCACHE_PREFIX', + nargs=1, + help='Compiler prefix to use when using ccache') ccache_prefix = depends_if('CCACHE_PREFIX')(lambda prefix: prefix[0]) set_config('CCACHE_PREFIX', ccache_prefix) @@ -295,6 +246,33 @@ def using_ccache(ccache, ccache_is_sccache): def using_sccache(ccache, ccache_is_sccache): return ccache and ccache_is_sccache +option(env='RUSTC_WRAPPER', nargs=1, + help='Wrap rust compilation with given tool') + +@depends(ccache, ccache_is_sccache, 'RUSTC_WRAPPER') +@imports(_from='textwrap', _import='dedent') +@imports('os') +def check_sccache_version(ccache, ccache_is_sccache, rustc_wrapper): + sccache_min_version = Version('0.2.13') + + def check_version(path): + out = check_cmd_output(path, '--version') + version = Version(out.rstrip().split()[-1]) + if version < sccache_min_version: + die(dedent('''\ + sccache %s or later is required. sccache in use at %s has + version %s. + + Please upgrade or acquire a new version with |./mach bootstrap|. + '''), sccache_min_version, path, version) + + if ccache and ccache_is_sccache: + check_version(ccache) + + if (rustc_wrapper and + (os.path.splitext(os.path.basename(rustc_wrapper[0]))[0].lower() == + 'sccache')): + check_version(rustc_wrapper[0]) set_config('MOZ_USING_CCACHE', using_ccache) set_config('MOZ_USING_SCCACHE', using_sccache) @@ -356,8 +334,8 @@ set_config('MOZ_HAZARD', hazard_analysis) # Cross-compilation related things. # ============================================================== -js_option('--with-toolchain-prefix', env='TOOLCHAIN_PREFIX', nargs=1, - help='Prefix for the target toolchain') +option('--with-toolchain-prefix', env='TOOLCHAIN_PREFIX', nargs=1, + help='Prefix for the target toolchain') @depends('--with-toolchain-prefix', target, cross_compiling) @@ -631,9 +609,9 @@ def host_is_windows(host): return True -js_option('--with-visual-studio-version', nargs=1, - choices=('2017',), when=host_is_windows, - help='Select a specific Visual Studio version to use') +option('--with-visual-studio-version', nargs=1, + choices=('2017',), when=host_is_windows, + help='Select a specific Visual Studio version to use') @depends('--with-visual-studio-version', when=host_is_windows) @@ -642,8 +620,8 @@ def vs_major_version(value): return {'2017': 15}[value[0]] -js_option(env='VC_PATH', nargs=1, when=host_is_windows, - help='Path to the Microsoft Visual C/C++ compiler') +option(env='VC_PATH', nargs=1, when=host_is_windows, + help='Path to the Microsoft Visual C/C++ compiler') @depends(host, vs_major_version, check_build_environment, 'VC_PATH', @@ -881,12 +859,12 @@ def default_cxx_compilers(c_compiler, other_c_compiler=None, other_cxx_compiler= @template -def provided_program(env_var): +def provided_program(env_var, when=None): '''Template handling cases where a program can be specified either as a path or as a path with applicable arguments. ''' - @depends_if(env_var) + @depends_if(env_var, when=when) @imports(_from='itertools', _import='takewhile') @imports(_from='mozbuild.shellutil', _import='split', _as='shell_split') def provided(cmd): @@ -1256,9 +1234,9 @@ option(env='MOZ_DEBUG_FLAGS', imply_option('--enable-debug-symbols', depends_if('--enable-debug')(lambda v: v)) -js_option('--disable-debug-symbols', - nargs='?', - help='Disable debug symbols using the given compiler flags') +option('--disable-debug-symbols', + nargs='?', + help='Disable debug symbols using the given compiler flags') set_config('MOZ_DEBUG_SYMBOLS', depends_if('--enable-debug-symbols')(lambda _: True)) @@ -1420,12 +1398,12 @@ set_config('PREPROCESS_OPTION', preprocess_option) # We only want to include windows.configure when we are compiling on -# Windows, for Windows. +# Windows, or for Windows. @depends(target, host) def is_windows(target, host): - return host.kernel == 'WINNT' and target.kernel == 'WINNT' + return host.kernel == 'WINNT' or target.kernel == 'WINNT' include('windows.configure', when=is_windows) @@ -1433,7 +1411,7 @@ include('windows.configure', when=is_windows) # ASAN # ============================================================== -js_option('--enable-address-sanitizer', help='Enable Address Sanitizer') +option('--enable-address-sanitizer', help='Enable Address Sanitizer') @depends(when='--enable-address-sanitizer') @@ -1446,7 +1424,7 @@ add_old_configure_assignment('MOZ_ASAN', asan) # MSAN # ============================================================== -js_option('--enable-memory-sanitizer', help='Enable Memory Sanitizer') +option('--enable-memory-sanitizer', help='Enable Memory Sanitizer') @depends(when='--enable-memory-sanitizer') @@ -1459,7 +1437,7 @@ add_old_configure_assignment('MOZ_MSAN', msan) # TSAN # ============================================================== -js_option('--enable-thread-sanitizer', help='Enable Thread Sanitizer') +option('--enable-thread-sanitizer', help='Enable Thread Sanitizer') @depends(when='--enable-thread-sanitizer') @@ -1472,9 +1450,9 @@ add_old_configure_assignment('MOZ_TSAN', tsan) # UBSAN # ============================================================== -js_option('--enable-undefined-sanitizer', - nargs='*', - help='Enable UndefinedBehavior Sanitizer') +option('--enable-undefined-sanitizer', + nargs='*', + help='Enable UndefinedBehavior Sanitizer') @depends_if('--enable-undefined-sanitizer') def ubsan(options): @@ -1491,8 +1469,8 @@ def ubsan(options): add_old_configure_assignment('MOZ_UBSAN_CHECKS', ubsan) -js_option('--enable-signed-overflow-sanitizer', - help='Enable UndefinedBehavior Sanitizer (Signed Integer Overflow Parts)') +option('--enable-signed-overflow-sanitizer', + help='Enable UndefinedBehavior Sanitizer (Signed Integer Overflow Parts)') @depends(when='--enable-signed-overflow-sanitizer') @@ -1503,8 +1481,8 @@ def ub_signed_overflow_san(): add_old_configure_assignment('MOZ_SIGNED_OVERFLOW_SANITIZE', ub_signed_overflow_san) -js_option('--enable-unsigned-overflow-sanitizer', - help='Enable UndefinedBehavior Sanitizer (Unsigned Integer Overflow Parts)') +option('--enable-unsigned-overflow-sanitizer', + help='Enable UndefinedBehavior Sanitizer (Unsigned Integer Overflow Parts)') @depends(when='--enable-unsigned-overflow-sanitizer') @@ -1609,10 +1587,10 @@ def security_hardening_cflags(hardening_flag, asan, optimize, c_compiler, target ) -add_old_configure_assignment('MOZ_HARDENING_CFLAGS', security_hardening_cflags.flags) -add_old_configure_assignment('MOZ_HARDENING_LDFLAGS', security_hardening_cflags.ldflags) -add_old_configure_assignment('MOZ_HARDENING_CFLAGS_JS', security_hardening_cflags.js_flags) -add_old_configure_assignment('MOZ_HARDENING_LDFLAGS_JS', security_hardening_cflags.js_ldflags) +set_config('MOZ_HARDENING_CFLAGS', security_hardening_cflags.flags) +set_config('MOZ_HARDENING_LDFLAGS', security_hardening_cflags.ldflags) +set_config('MOZ_HARDENING_CFLAGS_JS', security_hardening_cflags.js_flags) +set_config('MOZ_HARDENING_LDFLAGS_JS', security_hardening_cflags.js_ldflags) # Frame pointers @@ -1638,8 +1616,8 @@ def frame_pointer_default(optimize, debug, target, msan, asan, ubsan): (target.os == 'WINNT' and target.cpu in ('x86', 'aarch64'))) -js_option('--enable-frame-pointers', default=frame_pointer_default, - help='{Enable|Disable} frame pointers') +option('--enable-frame-pointers', default=frame_pointer_default, + help='{Enable|Disable} frame pointers') @depends('--enable-frame-pointers', frame_pointer_flags) @@ -1722,24 +1700,11 @@ set_config('HAVE_YASM', have_yasm) add_old_configure_assignment('YASM', have_yasm) -# clang-cl integrated assembler support -# ============================================================== -@depends(target) -def clangcl_asflags(target): - asflags = None - if target.os == 'WINNT' and target.cpu == 'aarch64': - asflags = ['--target=aarch64-windows-msvc'] - return asflags - - -set_config('CLANGCL_ASFLAGS', clangcl_asflags) - - # Code Coverage # ============================================================== -js_option('--enable-coverage', env='MOZ_CODE_COVERAGE', - help='Enable code coverage') +option('--enable-coverage', env='MOZ_CODE_COVERAGE', + help='Enable code coverage') @depends('--enable-coverage') @@ -1798,9 +1763,9 @@ set_config('RUSTFLAGS', depends('RUSTFLAGS')(lambda flags: flags)) # Rust compiler flags # ============================================================== -js_option(env='RUSTC_OPT_LEVEL', - nargs=1, - help='Rust compiler optimization level (-C opt-level=%s)') +option(env='RUSTC_OPT_LEVEL', + nargs=1, + help='Rust compiler optimization level (-C opt-level=%s)') # --enable-release kicks in full optimizations. imply_option('RUSTC_OPT_LEVEL', '2', when='--enable-release') @@ -1861,13 +1826,15 @@ def rust_compile_flags(opt_level, debug_rust, debug_symbols, frame_pointers): # Rust incremental compilation # ============================================================== -js_option('--disable-cargo-incremental', - help='Disable incremental rust compilation.') + +option('--disable-cargo-incremental', + help='Disable incremental rust compilation.') @depends(rustc_opt_level, debug_rust, 'MOZ_AUTOMATION', code_coverage, - '--disable-cargo-incremental') + '--disable-cargo-incremental', using_sccache, 'RUSTC_WRAPPER') +@imports('os') def cargo_incremental(opt_level, debug_rust, automation, code_coverage, - enabled): + enabled, using_sccache, rustc_wrapper): """Return a value for the CARGO_INCREMENTAL environment variable.""" if not enabled: @@ -1884,6 +1851,15 @@ def cargo_incremental(opt_level, debug_rust, automation, code_coverage, if code_coverage: return '0' + # Incremental compilation doesn't work as well as it should, and if we're + # using sccache, it's better to use sccache than incremental compilation. + if not using_sccache and rustc_wrapper: + rustc_wrapper = os.path.basename(rustc_wrapper[0]) + if os.path.splitext(rustc_wrapper)[0].lower() == 'sccache': + using_sccache = True + if using_sccache: + return '0' + # Incremental compilation is automatically turned on for debug builds, so # we don't need to do anything special here. if debug_rust: @@ -1920,9 +1896,25 @@ option('--enable-gold', imply_option('--enable-linker', 'gold', when='--enable-gold') -js_option('--enable-linker', nargs=1, - help='Select the linker {bfd, gold, ld64, lld, lld-*}', - when=is_linker_option_enabled) +@depends(target, developer_options) +def enable_linker_default(target, developer_options): + # x86-64 gold has bugs in how it lays out .note.* sections. See bug 1573820. + # lld is faster, so prefer that for developer builds. + if target.os == 'Android' and target.cpu == 'x86_64': + return 'lld' if developer_options else 'bfd' + + +option('--enable-linker', nargs=1, + help='Select the linker {bfd, gold, ld64, lld, lld-*}{|}', + default=enable_linker_default, + when=is_linker_option_enabled) + + +# No-op to enable depending on --enable-linker from default_elfhack in +# toolkit/moz.configure. +@depends('--enable-linker', when=is_linker_option_enabled) +def enable_linker(linker): + return linker @depends('--enable-linker', c_compiler, developer_options, '--enable-gold', @@ -2064,14 +2056,14 @@ add_old_configure_assignment('GCC_USE_GNU_LD', gcc_use_gnu_ld) # Assembler detection # ============================================================== -js_option(env='AS', nargs=1, help='Path to the assembler') +option(env='AS', nargs=1, help='Path to the assembler') @depends(target, c_compiler) def as_info(target, c_compiler): if c_compiler.type == 'clang-cl': ml = { - 'x86': 'ml', - 'x86_64': 'ml64', + 'x86': 'ml.exe', + 'x86_64': 'ml64.exe', 'aarch64': 'armasm64.exe', }.get(target.cpu) return namespace( @@ -2166,14 +2158,14 @@ set_config('ASOUTOPTION', as_outoption) # clang plugin handling # ============================================================== -js_option('--enable-clang-plugin', env='ENABLE_CLANG_PLUGIN', - help="Enable building with the mozilla clang plugin") +option('--enable-clang-plugin', env='ENABLE_CLANG_PLUGIN', + help="Enable building with the Clang plugin (gecko specific static analyzers)") add_old_configure_assignment('ENABLE_CLANG_PLUGIN', depends_if('--enable-clang-plugin')(lambda _: True)) -js_option('--enable-mozsearch-plugin', env='ENABLE_MOZSEARCH_PLUGIN', - help="Enable building with the mozsearch indexer plugin") +option('--enable-mozsearch-plugin', env='ENABLE_MOZSEARCH_PLUGIN', + help="Enable building with the mozsearch indexer plugin") add_old_configure_assignment('ENABLE_MOZSEARCH_PLUGIN', depends_if('--enable-mozsearch-plugin')(lambda _: True)) @@ -2181,8 +2173,8 @@ add_old_configure_assignment('ENABLE_MOZSEARCH_PLUGIN', # Libstdc++ compatibility hacks # ============================================================== # -js_option('--enable-stdcxx-compat', env='MOZ_STDCXX_COMPAT', - help='Enable compatibility with older libstdc++') +option('--enable-stdcxx-compat', env='MOZ_STDCXX_COMPAT', + help='Enable compatibility with older libstdc++') @template @@ -2219,7 +2211,7 @@ add_gcc_flag( # Support various fuzzing options # ============================================================== -js_option('--enable-fuzzing', help='Enable fuzzing support') +option('--enable-fuzzing', help='Enable fuzzing support') @depends('--enable-fuzzing') def enable_fuzzing(value): @@ -2343,12 +2335,13 @@ def rc_names(c_compiler, toolchain_prefix): return ('rc',) -check_prog('RC', rc_names, paths=sdk_bin_path) +check_prog('RC', rc_names, paths=sdk_bin_path, when=target_is_windows) -@depends(link, toolchain_prefix) -def ar_config(link, toolchain_prefix): - if link: # if LINKER is set, it's either for lld-link or link +@depends(link, toolchain_prefix, c_compiler) +def ar_config(link, toolchain_prefix, c_compiler): + if c_compiler.type == 'clang-cl' and link: + # if LINKER is set, it's either for lld-link or link if 'lld-link' in link: return namespace( names=('llvm-lib',), @@ -2371,3 +2364,8 @@ ar = check_prog('AR', ar_config.names, paths=toolchain_search_path) add_old_configure_assignment('AR', ar) set_config('AR_FLAGS', ar_config.flags) + + +option('--enable-cpp-rtti', help='Enable C++ RTTI') + +add_old_configure_assignment('_MOZ_USE_RTTI', '1', when='--enable-cpp-rtti') diff --git a/build/moz.configure/util.configure b/build/moz.configure/util.configure index 47480bbc3c..7047baef34 100644 --- a/build/moz.configure/util.configure +++ b/build/moz.configure/util.configure @@ -214,7 +214,6 @@ def find_program(file, paths=None): @imports('os') -@imports('subprocess') @imports(_from='mozbuild.configure.util', _import='LineIO') @imports(_from='tempfile', _import='mkstemp') def try_invoke_compiler(compiler, language, source, flags=None, onerror=None): @@ -421,7 +420,9 @@ def dependable(obj): return obj if isfunction(obj): return depends(when=True)(obj) - return depends(when=True)(lambda: obj) + # Depend on --help to make lint happy if the dependable is used as an input + # to an option(). + return depends('--help', when=True)(lambda _: obj) always = dependable(True) @@ -470,11 +471,6 @@ def old_configure_assignments(): return [] -@dependable -def extra_old_configure_args(): - return [] - - @template def add_old_configure_assignment(var, value, when=None): var = dependable(var) @@ -493,11 +489,3 @@ def add_old_configure_assignment(var, value, when=None): if isinstance(value, (list, tuple)): value = quote(*value) assignments.append((var, str(value))) - - -@template -def add_old_configure_arg(arg): - @depends(extra_old_configure_args, arg) - def add_arg(args, arg): - if arg: - args.append(arg) diff --git a/build/moz.configure/warnings.configure b/build/moz.configure/warnings.configure index 3ccd1f7294..1f39ac1f54 100644 --- a/build/moz.configure/warnings.configure +++ b/build/moz.configure/warnings.configure @@ -2,13 +2,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -js_option('--enable-warnings-as-errors', env='MOZ_ENABLE_WARNINGS_AS_ERRORS', - default=depends('MOZ_AUTOMATION')(lambda x: bool(x)), - help='{Enable|Disable} treating warnings as errors') - -add_old_configure_assignment( - 'MOZ_ENABLE_WARNINGS_AS_ERRORS', - depends('--enable-warnings-as-errors')(lambda x: bool(x))) +option('--enable-warnings-as-errors', env='MOZ_ENABLE_WARNINGS_AS_ERRORS', + default=depends('MOZ_AUTOMATION')(lambda x: bool(x)), + help='{Enable|Disable} treating warnings as errors') @depends('--enable-warnings-as-errors') @@ -24,6 +20,22 @@ def rust_warning_flags(warnings_as_errors): return flags +c_warning_flag = dependable('-Werror') + + +@depends('--enable-warnings-as-errors', c_warning_flag) +def warnings_as_errors(warnings_as_errors, c_warning_flag): + if not warnings_as_errors: + return '' + + return c_warning_flag + +set_config('WARNINGS_AS_ERRORS', warnings_as_errors) +# We have a peculiar setup in old-configure.in where some compilation tests +# depend on enabling warnings-as-errors even if it's disabled for Firefox +# compilation. We therefore need this assignment. +add_old_configure_assignment('WARNINGS_AS_ERRORS', c_warning_flag) + # GCC/Clang warnings: # https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html @@ -200,6 +212,11 @@ check_and_add_gcc_warning('-Wno-noexcept-type', cxx_compiler, when=depends(build_project) (lambda build_project: build_project == 'js')) +# Disable broken missing-braces warning on old clang versions +check_and_add_gcc_warning( + '-Wno-missing-braces', + when=depends(c_compiler)(lambda c: c.type == 'clang' and c.version < '6.0')) + # Please keep these last in this file add_old_configure_assignment('_WARNINGS_CFLAGS', warnings_flags.cflags) diff --git a/build/moz.configure/windows.configure b/build/moz.configure/windows.configure index f7a19c7c89..46122bcf54 100644 --- a/build/moz.configure/windows.configure +++ b/build/moz.configure/windows.configure @@ -23,10 +23,11 @@ def valid_windows_version(value): option(env='WINDOWSSDKDIR', nargs=1, - help='Directory containing the Windows SDK') + help='Directory containing the Windows SDK', + when=host_is_windows) -@depends('WINDOWSSDKDIR', host) +@depends('WINDOWSSDKDIR', host, when=host_is_windows) def windows_sdk_dir(value, host): if value: return value @@ -92,7 +93,8 @@ def valid_windows_sdk_dir_result(value): return '0x%04x in %s' % (value.version, quote(value.path)) -@depends(c_compiler, windows_sdk_dir, valid_windows_version, 'WINDOWSSDKDIR') +@depends(c_compiler, windows_sdk_dir, valid_windows_version, 'WINDOWSSDKDIR', + when=host_is_windows) @checking('for Windows SDK', valid_windows_sdk_dir_result) @imports(_from='__builtin__', _import='sorted') @imports(_from='__builtin__', _import='Exception') @@ -161,7 +163,7 @@ def valid_ucrt_sdk_dir_result(value): return '%s in %s' % (value.version, quote(value.path)) -@depends(windows_sdk_dir, 'WINDOWSSDKDIR') +@depends(windows_sdk_dir, 'WINDOWSSDKDIR', when=host_is_windows) @checking('for Universal CRT SDK', valid_ucrt_sdk_dir_result) @imports('os') @imports(_from='__builtin__', _import='sorted') @@ -234,10 +236,10 @@ def valid_ucrt_sdk_dir(windows_sdk_dir, windows_sdk_dir_env): ) -@depends(c_compiler, toolchain_search_path) +@depends(c_compiler, host_c_compiler, toolchain_search_path) @imports('os') -def vc_path(c_compiler, toolchain_search_path): - if c_compiler.type != 'clang-cl': +def vc_path(c_compiler, host_c_compiler, toolchain_search_path): + if c_compiler.type != 'clang-cl' and host_c_compiler.type != 'clang-cl': return # In clang-cl builds, we need the headers and libraries from an MSVC installation. @@ -273,6 +275,8 @@ def dia_sdk_dir(vc_path, dia_sdk_path): # get_vc_paths works with, since 'DIA SDK' is relative to that. path = os.path.normpath(os.path.join( vc_path, r'..\..\..\..\DIA SDK')) + else: + return if os.path.exists(os.path.join(path, 'include', 'dia2.h')): return path @@ -383,7 +387,7 @@ def lib_path_for(host_or_target): return lib_path -@depends(lib_path_for(target)) +@depends_if(lib_path_for(target)) @imports('os') def lib_path(libs): # Set in the environment for old-configure @@ -397,13 +401,13 @@ set_config('LIB', lib_path) lib_path_for_host = lib_path_for(host) -@depends(lib_path_for_host) +@depends_if(lib_path_for_host) @imports(_from='mozbuild.shellutil', _import='quote') def host_linker_libpaths(libs): return ['-LIBPATH:%s' % quote(l) for l in libs] -@depends(lib_path_for_host) +@depends_if(lib_path_for_host) @imports(_from='mozbuild.shellutil', _import='quote') def host_linker_libpaths_bat(libs): # .bat files need a different style of quoting. Batch quoting is actually @@ -419,7 +423,11 @@ set_config('HOST_LINKER_LIBPATHS', host_linker_libpaths) set_config('HOST_LINKER_LIBPATHS_BAT', host_linker_libpaths_bat) -option(env='MT', nargs=1, help='Path to the Microsoft Manifest Tool') +# The when is technically wrong and should be removed and the code that +# @depends on the option will need to be adapted when actual support for +# clang-cl cross-builds emerge. +option(env='MT', nargs=1, help='Path to the Microsoft Manifest Tool', + when=host_is_windows) @depends(valid_windows_sdk_dir, valid_ucrt_sdk_dir) @@ -448,12 +456,12 @@ def sdk_bin_path(valid_windows_sdk_dir, valid_ucrt_sdk_dir): mt = check_prog('MT', ('mt.exe',), input='MT', - paths=sdk_bin_path) + paths=sdk_bin_path, when=host_is_windows) # Check that MT is not something unexpected like "magnetic tape manipulation # utility". -@depends(mt) +@depends_if(mt) @checking('whether MT is really Microsoft Manifest Tool', lambda x: bool(x)) @imports('subprocess') def valid_mt(path): @@ -470,17 +478,17 @@ def valid_mt(path): set_config('MSMANIFEST_TOOL', depends(valid_mt)(lambda x: bool(x))) -js_option(env='LINKER', nargs=1, help='Path to the linker') +option(env='LINKER', nargs=1, when=target_is_windows, help='Path to the linker') link = check_prog('LINKER', ('lld-link',), input='LINKER', - paths=toolchain_search_path) + when=target_is_windows, paths=toolchain_search_path) -js_option(env='HOST_LINKER', nargs=1, help='Path to the host linker') +option(env='HOST_LINKER', nargs=1, when=host_is_windows, help='Path to the host linker') host_link = check_prog('HOST_LINKER', ('lld-link',), input='HOST_LINKER', - paths=host_toolchain_search_path) + when=host_is_windows, paths=host_toolchain_search_path) add_old_configure_assignment('LINKER', link) -check_prog('MAKECAB', ('makecab.exe',)) +check_prog('MAKECAB', ('makecab.exe',), when=host_is_windows) diff --git a/build/mozconfig.automation b/build/mozconfig.automation index 293aa4d7ac..70d5960d1b 100644 --- a/build/mozconfig.automation +++ b/build/mozconfig.automation @@ -15,5 +15,6 @@ mk_add_options "export MOZ_AUTOMATION_PACKAGE=${MOZ_AUTOMATION_PACKAGE-1}" mk_add_options "export MOZ_AUTOMATION_PACKAGE_TESTS=${MOZ_AUTOMATION_PACKAGE_TESTS-1}" mk_add_options "export MOZ_AUTOMATION_PACKAGE_GENERATED_SOURCES=${MOZ_AUTOMATION_PACKAGE_GENERATED_SOURCES-1}" mk_add_options "export MOZ_AUTOMATION_UPLOAD=${MOZ_AUTOMATION_UPLOAD-1}" +mk_add_options "export MOZ_AUTOMATION_CHECK=${MOZ_AUTOMATION_CHECK-1}" export MOZ_AUTOMATION_MOZCONFIG=1 diff --git a/build/mozconfig.cache b/build/mozconfig.cache index fbea916672..4f944ba593 100644 --- a/build/mozconfig.cache +++ b/build/mozconfig.cache @@ -5,7 +5,7 @@ # Setup for build cache # builds where buildprops didn't have the data (eg: taskcluster) and without sccache disabled: -if test -z "$bucket" -a -z "$SCCACHE_DISABLE" -a -z "$MOZ_PGO"; then +if test -z "$bucket" -a -z "$SCCACHE_DISABLE"; then # prevent rerun if az is set, or wget is not available if test -z "$availability_zone" -a -x "$(command -v wget)"; then @@ -60,7 +60,7 @@ if test -n "$bucket"; then # instruct sccache to fetch the credentials from the Auth service's awsS3Credentials endpoint, via the Taskcluster proxy. mk_add_options "export AWS_IAM_CREDENTIALS_URL=http://taskcluster/auth/v1/aws/s3/read-write/${bucket}/?format=iam-role-compat" fi - export CCACHE="$topsrcdir/sccache2/sccache" + export CCACHE="$MOZ_FETCHES_DIR/sccache/sccache" export SCCACHE_VERBOSE_STATS=1 - mk_add_options MOZBUILD_MANAGE_SCCACHE_DAEMON=${topsrcdir}/sccache2/sccache + mk_add_options MOZBUILD_MANAGE_SCCACHE_DAEMON=${MOZ_FETCHES_DIR}/sccache/sccache fi diff --git a/build/mozconfig.clang-cl b/build/mozconfig.clang-cl index efaec52e1d..cfc7a2a8fc 100644 --- a/build/mozconfig.clang-cl +++ b/build/mozconfig.clang-cl @@ -1,9 +1,9 @@ -if test -d "$topsrcdir/clang/bin"; then - CLANG_DIR=`cd "$topsrcdir/clang/bin" ; pwd` +if test -d "$MOZ_FETCHES_DIR/clang/bin"; then + CLANG_DIR=`cd "$MOZ_FETCHES_DIR/clang/bin" ; pwd` export PATH="${CLANG_DIR}:${PATH}" - if $(cd $topsrcdir/clang/lib/clang/* && test -d lib/windows); then - CLANG_LIB_DIR="$(cd $topsrcdir/clang/lib/clang/* && cd lib/windows && pwd)" + if $(cd $MOZ_FETCHES_DIR/clang/lib/clang/* && test -d lib/windows); then + CLANG_LIB_DIR="$(cd $MOZ_FETCHES_DIR/clang/lib/clang/* && cd lib/windows && pwd)" export LIB=$LIB:$CLANG_LIB_DIR fi fi diff --git a/build/mozconfig.lld-link b/build/mozconfig.lld-link index 56f0878ec5..89f91930e7 100644 --- a/build/mozconfig.lld-link +++ b/build/mozconfig.lld-link @@ -1,5 +1,5 @@ -if test -d "$topsrcdir/clang/bin"; then - CLANG_DIR=`cd "$topsrcdir/clang/bin" ; pwd` +if test -d "$MOZ_FETCHES_DIR/clang/bin"; then + CLANG_DIR=`cd "$MOZ_FETCHES_DIR/clang/bin" ; pwd` export PATH="${CLANG_DIR}:${PATH}" fi diff --git a/build/mozconfig.nasm b/build/mozconfig.nasm index d1933e479a..055ec6cb7b 100644 --- a/build/mozconfig.nasm +++ b/build/mozconfig.nasm @@ -4,9 +4,9 @@ case "$(uname -s)" in MINGW*) - export NASM=$topsrcdir/nasm/nasm.exe + export NASM=$MOZ_FETCHES_DIR/nasm/nasm.exe ;; *) - export NASM=$topsrcdir/nasm/nasm + export NASM=$MOZ_FETCHES_DIR/nasm/nasm ;; esac diff --git a/build/mozconfig.node b/build/mozconfig.node index 399cf1e1c4..8a29161ece 100644 --- a/build/mozconfig.node +++ b/build/mozconfig.node @@ -4,9 +4,9 @@ case "$(uname -s)" in MINGW*) - export NODEJS=$topsrcdir/node/node.exe + export NODEJS=$MOZ_FETCHES_DIR/node/node.exe ;; *) - export NODEJS=$topsrcdir/node/bin/node + export NODEJS=$MOZ_FETCHES_DIR/node/bin/node ;; esac diff --git a/build/mozconfig.pgo b/build/mozconfig.pgo deleted file mode 100644 index 41444f7445..0000000000 --- a/build/mozconfig.pgo +++ /dev/null @@ -1,7 +0,0 @@ -case "$PERFHERDER_EXTRA_OPTIONS" in -base-toolchains*) - ;; -*) - export MOZ_PGO=1 - ;; -esac diff --git a/build/mozconfig.rust b/build/mozconfig.rust index 240c10fb1e..d12787f112 100644 --- a/build/mozconfig.rust +++ b/build/mozconfig.rust @@ -3,10 +3,10 @@ TOOLTOOL_DIR=${TOOLTOOL_DIR:-$topsrcdir} # Tell configure to use the tooltool rustc. -RUSTC="$TOOLTOOL_DIR/rustc/bin/rustc" -CARGO="$TOOLTOOL_DIR/rustc/bin/cargo" -RUSTDOC="$TOOLTOOL_DIR/rustc/bin/rustdoc" -RUSTFMT="$TOOLTOOL_DIR/rustc/bin/rustfmt" -CBINDGEN="$TOOLTOOL_DIR/cbindgen/cbindgen" +RUSTC="$MOZ_FETCHES_DIR/rustc/bin/rustc" +CARGO="$MOZ_FETCHES_DIR/rustc/bin/cargo" +RUSTDOC="$MOZ_FETCHES_DIR/rustc/bin/rustdoc" +RUSTFMT="$MOZ_FETCHES_DIR/rustc/bin/rustfmt" +CBINDGEN="$MOZ_FETCHES_DIR/cbindgen/cbindgen" ac_add_options --enable-rust-simd diff --git a/build/mozconfig.stylo b/build/mozconfig.stylo index 79384471e2..b8233a078b 100644 --- a/build/mozconfig.stylo +++ b/build/mozconfig.stylo @@ -1,2 +1,2 @@ # Tell the build system where to find llvm-config for builds on automation. -export LLVM_CONFIG="${TOOLTOOL_DIR:-$topsrcdir}/clang/bin/llvm-config" +export LLVM_CONFIG="${MOZ_FETCHES_DIR}/clang/bin/llvm-config" diff --git a/build/mozconfig.win-common b/build/mozconfig.win-common index 257b077c4f..17ede0d48c 100644 --- a/build/mozconfig.win-common +++ b/build/mozconfig.win-common @@ -6,10 +6,10 @@ TOOLTOOL_DIR=${TOOLTOOL_DIR:-$topsrcdir} export MAKECAB=$TOOLTOOL_DIR/makecab.exe if [ -z "$USE_ARTIFACT" ]; then - if [ -n "$MOZ_PGO_PROFILE_USE" ]; then + if [ -n "$TASKCLUSTER_PGO_PROFILE_USE" ]; then export MOZ_LTO=cross ac_add_options --enable-profile-use ac_add_options --with-pgo-jarlog="${WORKSPACE}/fetches/en-US.log" - ac_add_options --with-pgo-profile-path="${WORKSPACE}/fetches" + ac_add_options --with-pgo-profile-path="${WORKSPACE}/fetches/merged.profdata" fi fi diff --git a/build/pgo/index.html b/build/pgo/index.html index 12389a93a5..d61f5cbcad 100644 --- a/build/pgo/index.html +++ b/build/pgo/index.html @@ -7,11 +7,10 @@ var list = [ - "js-input/webkit/PerformanceTests/Speedometer/index.html", - "blueprint/sample.html", + "blueprint/elements.html", "blueprint/forms.html", "blueprint/grid.html", - "blueprint/elements.html", + "blueprint/sample.html", "js-input/3d-thingy.html", "js-input/crypto-otp.html", "js-input/sunspider/3d-cube.html", @@ -40,6 +39,37 @@ "js-input/sunspider/string-tagcloud.html", "js-input/sunspider/string-unpack-code.html", "js-input/sunspider/string-validate-input.html", + "talos/tests/perf-reftest-singletons/abspos-reflow-1.html", + "talos/tests/perf-reftest-singletons/bidi-resolution-1.html", + "talos/tests/perf-reftest-singletons/bloom-basic-2.html", + "talos/tests/perf-reftest-singletons/bloom-basic.html", + "talos/tests/perf-reftest-singletons/coalesce-1.html", + "talos/tests/perf-reftest-singletons/coalesce-2.html", + "talos/tests/perf-reftest-singletons/display-none-1.html", + "talos/tests/perf-reftest-singletons/external-string-pass.html", + "talos/tests/perf-reftest-singletons/getElementById-1.html", + "talos/tests/perf-reftest-singletons/id-getter-1.html", + "talos/tests/perf-reftest-singletons/id-getter-2.html", + "talos/tests/perf-reftest-singletons/id-getter-3.html", + "talos/tests/perf-reftest-singletons/id-getter-4.html", + "talos/tests/perf-reftest-singletons/id-getter-5.html", + "talos/tests/perf-reftest-singletons/id-getter-6.html", + "talos/tests/perf-reftest-singletons/id-getter-7.html", + "talos/tests/perf-reftest-singletons/inline-style-cache-1.html", + "talos/tests/perf-reftest-singletons/link-style-cache-1.html", + "talos/tests/perf-reftest-singletons/nth-index-1.html", + "talos/tests/perf-reftest-singletons/nth-index-2.html", + "talos/tests/perf-reftest-singletons/only-children-1.html", + "talos/tests/perf-reftest-singletons/parent-basic-singleton.html", + "talos/tests/perf-reftest-singletons/scrollbar-styles-1.html", + "talos/tests/perf-reftest-singletons/slow-selector-1.html", + "talos/tests/perf-reftest-singletons/slow-selector-2.html", + "talos/tests/perf-reftest-singletons/style-attr-1.html", + "talos/tests/perf-reftest-singletons/style-sharing-style-attr.html", + "talos/tests/perf-reftest-singletons/style-sharing.html", + "talos/tests/perf-reftest-singletons/tiny-traversal-singleton.html", + "talos/tests/perf-reftest-singletons/window-named-property-get.html", + "webkit/PerformanceTests/Speedometer/index.html", ]; var defaultInterval = 2000; var idx = 0; @@ -51,11 +81,16 @@ }; function loadURL() { var interval = defaultInterval; - if (idx == 0) { + var testURL = list[idx++]; + if (testURL.includes("webkit")) { interval = 90000; } w.close(); - w = window.open(list[idx++]); + w = window.open(testURL); + + // Prevent the perf-reftest-singletons from calling alert() + w.tpRecordTime = function() { }; + if (idx < list.length) { window.setTimeout(loadURL, interval); } else { diff --git a/build/pgo/profileserver.py b/build/pgo/profileserver.py index aacec93a8b..bb98209ab6 100644 --- a/build/pgo/profileserver.py +++ b/build/pgo/profileserver.py @@ -7,8 +7,10 @@ import json import os import sys +import glob +import subprocess -from buildconfig import substs +import mozcrash from mozbuild.base import MozbuildObject from mozfile import TemporaryDirectory from mozhttpd import MozHttpd @@ -20,10 +22,38 @@ from six import string_types PORT = 8888 PATH_MAPPINGS = { - '/js-input/webkit/PerformanceTests': 'third_party/webkit/PerformanceTests', + '/webkit/PerformanceTests': 'third_party/webkit/PerformanceTests', + # It is tempting to map to `testing/talos/talos/tests` instead, to avoid + # writing `tests/` in every path, but we can't do that because some files + # refer to scripts located in `../..`. + '/talos': 'testing/talos/talos', } +def get_crashreports(directory, name=None): + rc = 0 + upload_path = os.environ.get('UPLOAD_PATH') + if upload_path: + # For automation, log the minidumps with stackwalk and get them moved to + # the artifacts directory. + fetches_dir = os.environ.get('MOZ_FETCHES_DIR') + if not fetches_dir: + raise Exception("Unable to process minidump in automation because " + "$MOZ_FETCHES_DIR is not set in the environment") + stackwalk_binary = os.path.join(fetches_dir, 'minidump_stackwalk', 'minidump_stackwalk') + if sys.platform == 'win32': + stackwalk_binary += '.exe' + minidump_path = os.path.join(directory, "minidumps") + rc = mozcrash.check_for_crashes( + minidump_path, + symbols_path=fetches_dir, + stackwalk_binary=stackwalk_binary, + dump_save_path=upload_path, + test_name=name, + ) + return rc + + if __name__ == '__main__': cli = CLI() debug_args, interactive = cli.debugger_arguments() @@ -50,6 +80,10 @@ if __name__ == '__main__': port=PORT, options='primary,privileged') + old_profraw_files = glob.glob('*.profraw') + for f in old_profraw_files: + os.remove(f) + with TemporaryDirectory() as profilePath: # TODO: refactor this into mozprofile profile_data_dir = os.path.join(build.topsrcdir, 'testing', 'profiles') @@ -92,17 +126,6 @@ if __name__ == '__main__': # Ensure different pids write to different files env["LLVM_PROFILE_FILE"] = "default_%p_random_%m.profraw" - # For VC12+, make sure we can find the right bitness of pgort1x0.dll - if not substs.get('HAVE_64BIT_BUILD'): - for e in ('VS140COMNTOOLS', 'VS120COMNTOOLS'): - if e not in env: - continue - - vcdir = os.path.abspath(os.path.join(env[e], '../../VC/bin')) - if os.path.exists(vcdir): - env['PATH'] = '%s;%s' % (vcdir, env['PATH']) - break - # Write to an output file if we're running in automation process_args = {} if 'UPLOAD_PATH' in env: @@ -125,12 +148,15 @@ if __name__ == '__main__': with open(logfile) as f: print(f.read()) httpd.stop() + get_crashreports(profilePath, name='Profile initialization') sys.exit(ret) jarlog = os.getenv("JARLOG_FILE") if jarlog: env["MOZ_JAR_LOG_FILE"] = os.path.abspath(jarlog) print("jarlog: %s" % env["MOZ_JAR_LOG_FILE"]) + if os.path.exists(jarlog): + os.remove(jarlog) if 'UPLOAD_PATH' in env: process_args['logfile'] = os.path.join(env['UPLOAD_PATH'], 'profile-run-2.log') @@ -150,4 +176,30 @@ if __name__ == '__main__': print("Firefox output (%s):" % logfile) with open(logfile) as f: print(f.read()) + get_crashreports(profilePath, name='Profiling run') sys.exit(ret) + + # Try to move the crash reports to the artifacts even if Firefox appears + # to exit successfully, in case there's a crash that doesn't set the + # return code to non-zero for some reason. + if get_crashreports(profilePath, name='Firefox exited successfully?') != 0: + print("Firefox exited successfully, but produced a crashreport") + sys.exit(1) + + llvm_profdata = env.get('LLVM_PROFDATA') + if llvm_profdata: + profraw_files = glob.glob('*.profraw') + if not profraw_files: + print('Could not find profraw files in the current directory: %s' % os.getcwd()) + sys.exit(1) + merge_cmd = [ + llvm_profdata, + 'merge', + '-o', + 'merged.profdata', + ] + profraw_files + rc = subprocess.call(merge_cmd) + if rc != 0: + print('INFRA-ERROR: Failed to merge profile data. Corrupt profile?') + # exit with TBPL_RETRY + sys.exit(4) diff --git a/build/sanitizers/lsan_suppressions.txt b/build/sanitizers/lsan_suppressions.txt deleted file mode 100644 index 2ee52d926c..0000000000 --- a/build/sanitizers/lsan_suppressions.txt +++ /dev/null @@ -1,80 +0,0 @@ -### !!! Please do not add suppressions for new leaks in Gecko code, unless they are intentional !!! - -### -### Some of these leak in every test run. -### - -# LSan runs with a shallow stack depth and no debug symbols, so some small intentional -# leaks in system libraries show up with this. You do not want this enabled -# when running locally with a deep stack, as it can catch too much. -leak:libc.so - -# nsComponentManagerImpl intentionally leaks factory entries, and probably some other stuff. -leak:nsComponentManagerImpl -# These two variants are needed when fast unwind is disabled and stack depth is limited. -leak:mozJSComponentLoader::LoadModule -leak:nsNativeModuleLoader::LoadModule - -# Bug 981220 - Pixman fails to free TLS memory. -leak:pixman_implementation_lookup_composite - -# Bug 987918 - Font shutdown leaks when CLEANUP_MEMORY is not enabled. -leak:libfontconfig.so -leak:GI___strdup -# The symbol is really __GI___strdup, but if you have the leading _, it doesn't suppress it. - -# Bug 1078015 - If the process terminates during a PR_Sleep, LSAN detects a leak -leak:PR_Sleep - -# Bug 1363976 - Stylo holds some global data alive forever. -leak:style::global_style_data - -### -### Many leaks only affect some test suites. The suite annotations are not checked. -### - -# Bug 979928 - WebRTC leaks in different mochitest suites. -leak:NR_reg_init -# nr_reg_local_init should be redundant with NR_reg_init, but on Aurora -# we get fewer stack frames for some reason. -leak:nr_reg_local_init -leak:r_log_register -leak:nr_reg_set - -# This is a one-time leak in mochitest-bc, so it is probably okay to ignore. -leak:GlobalPrinters::InitializeGlobalPrinters -leak:nsPSPrinterList::GetPrinterList - -# Bug 1028456 - Various NSPR fd-related leaks in different mochitest suites. -leak:_PR_Getfd - -# Bug 1028483 - The XML parser sometimes leaks an object. Mostly happens in toolkit/components/thumbnails. -leak:processInternalEntity - -# Bug 1187421 - NSS does not always free the error stack in different mochitest suites. -leak:nss_ClearErrorStack - -### -### Leaks with system libraries in their stacks. These show up across a number of tests. -### Better symbols and disabling fast stackwalking may help diagnose these. -### - -leak:libcairo.so -leak:libdl.so -leak:libdricore.so -leak:libdricore9.2.1.so -leak:libGL.so -leak:libglib-2.0.so -leak:libglsl.so -leak:libp11-kit.so -leak:libpixman-1.so -leak:libpulse.so -# lubpulsecommon 1.1 is Ubuntu 12.04 -leak:libpulsecommon-1.1.so -# lubpulsecommon 1.1 is Ubuntu 16.04 -leak:libpulsecommon-8.0.so -leak:libresolv.so -leak:libstdc++.so -leak:libXrandr.so -leak:pthread_setspecific_internal -leak:swrast_dri.so diff --git a/build/sanitizers/tsan_suppressions.txt b/build/sanitizers/tsan_suppressions.txt deleted file mode 100644 index 3ea562e67c..0000000000 --- a/build/sanitizers/tsan_suppressions.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Bug 931149 -race:DoImageDataComplete - -# Bug 939786 -race:_pt_root - -# Bug 939788 -# Tracked by http://code.google.com/p/thread-sanitizer/issues/detail?id=40 -race:ELMCreationDetector - -# Bug 939790 -race:xpcom/components/nsComponentManager.h - -# Bug 939807 -race:ComputeUTCTime - -# Bug 939805 -race:g_variant_type_info_get - -# Bug 844759 -race:js::gc::ArenaLists::allocateFromArenaInline diff --git a/build/sanitizers/ubsan_suppressions.txt b/build/sanitizers/ubsan_suppressions.txt deleted file mode 100644 index 0d4c7becbd..0000000000 --- a/build/sanitizers/ubsan_suppressions.txt +++ /dev/null @@ -1,15 +0,0 @@ -# This list contains runtime suppression entries for any issues reported -# by UndefinedBehaviorSanitizer (UBSan). Unlike the compile-time blacklists, -# this list allows us to blacklist source code files and functions only for -# specific checks performed by UBSan. -# -# Example: -# -# signed-integer-overflow:file-with-known-overflow.cpp -# alignment:function_doing_unaligned_access -# vptr:shared_object_with_vptr_failures.so -# -# Since runtime suppressions are much more expensive than compile-time -# blacklisting, this list should not be used for frequent issues but rather -# only for sporadic warnings that have already been checked and confirmed -# to not be bugs. diff --git a/build/sparse-profiles/taskgraph b/build/sparse-profiles/taskgraph index 9a9d70ac9b..3df3d0b0b5 100644 --- a/build/sparse-profiles/taskgraph +++ b/build/sparse-profiles/taskgraph @@ -56,3 +56,10 @@ path:.cron.yml # for the wrench-deps toolchain task path:gfx/wr/Cargo.lock + +# for the mar-tools toolchain task +path:mfbt/ +path:modules/libmar/ +path:other-licenses/bsdiff/ +path:other-licenses/nsis/Contrib/CityHash/cityhash/ +path:toolkit/mozapps/update/updater diff --git a/build/unix/mozconfig.asan b/build/unix/mozconfig.asan index 16e7f8a08b..803f0275f8 100644 --- a/build/unix/mozconfig.asan +++ b/build/unix/mozconfig.asan @@ -2,7 +2,7 @@ MOZ_AUTOMATION_L10N_CHECK=0 . "$topsrcdir/build/unix/mozconfig.unix" -export LLVM_SYMBOLIZER="$topsrcdir/clang/bin/llvm-symbolizer" +export LLVM_SYMBOLIZER="$MOZ_FETCHES_DIR/clang/bin/llvm-symbolizer" # # Enable ASan specific code and build workarounds ac_add_options --enable-address-sanitizer diff --git a/build/unix/mozconfig.stdcxx b/build/unix/mozconfig.stdcxx index f86457c531..b1bb4e27db 100644 --- a/build/unix/mozconfig.stdcxx +++ b/build/unix/mozconfig.stdcxx @@ -6,14 +6,14 @@ TOOLTOOL_DIR=${TOOLTOOL_DIR:-$topsrcdir} # Depending whether GCC was built on a RedHat-based or a Debian-based system, # the directory containing 32-bits libraries can be either (respectively) # lib or lib32. The directory for 64-bits libraries is always lib64. -if [ -f "$TOOLTOOL_DIR/gcc/lib64/libstdc++.so" ]; then +if [ -f "$MOZ_FETCHES_DIR/gcc/lib64/libstdc++.so" ]; then # We put both 32-bits and 64-bits library path in LD_LIBRARY_PATH: ld.so # will prefer the files in the 32-bits path when loading 32-bits executables, # and the files in the 64-bits path when loading 64-bits executables. # We also put both possible 32-bits library paths. - LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$TOOLTOOL_DIR/gcc/lib64:$TOOLTOOL_DIR/gcc/lib32:$TOOLTOOL_DIR/gcc/lib -elif [ -f "$TOOLTOOL_DIR/clang/lib/libstdc++.so" ]; then - LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$TOOLTOOL_DIR/clang/lib:$TOOLTOOL_DIR/clang/lib32 + LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$MOZ_FETCHES_DIR/gcc/lib64:$MOZ_FETCHES_DIR/gcc/lib32:$MOZ_FETCHES_DIR/gcc/lib +elif [ -f "$MOZ_FETCHES_DIR/clang/lib/libstdc++.so" ]; then + LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$MOZ_FETCHES_DIR/clang/lib:$MOZ_FETCHES_DIR/clang/lib32 fi mk_add_options "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH" diff --git a/build/unix/mozconfig.tsan b/build/unix/mozconfig.tsan index 4f7faf443d..8fe913e15e 100644 --- a/build/unix/mozconfig.tsan +++ b/build/unix/mozconfig.tsan @@ -2,7 +2,7 @@ MOZ_AUTOMATION_L10N_CHECK=0 . "$topsrcdir/build/unix/mozconfig.unix" -export LLVM_SYMBOLIZER="$topsrcdir/clang/bin/llvm-symbolizer" +export LLVM_SYMBOLIZER="$MOZ_FETCHES_DIR/clang/bin/llvm-symbolizer" # Enable TSan specific code and build workarounds ac_add_options --enable-thread-sanitizer diff --git a/build/unix/mozconfig.unix b/build/unix/mozconfig.unix index ea860819ee..51753cf420 100644 --- a/build/unix/mozconfig.unix +++ b/build/unix/mozconfig.unix @@ -3,17 +3,22 @@ TOOLTOOL_DIR=${TOOLTOOL_DIR:-$topsrcdir} if [ -n "$FORCE_GCC" ]; then - CC="$TOOLTOOL_DIR/gcc/bin/gcc" - CXX="$TOOLTOOL_DIR/gcc/bin/g++" + CC="$MOZ_FETCHES_DIR/gcc/bin/gcc" + CXX="$MOZ_FETCHES_DIR/gcc/bin/g++" # We want to make sure we use binutils and other binaries in the tooltool # package. - mk_add_options "export PATH=$TOOLTOOL_DIR/gcc/bin:$PATH" - ac_add_options --with-clang-path=$TOOLTOOL_DIR/clang/bin/clang + mk_add_options "export PATH=$MOZ_FETCHES_DIR/gcc/bin:$PATH" + ac_add_options --with-clang-path=$MOZ_FETCHES_DIR/clang/bin/clang else - CC="$TOOLTOOL_DIR/clang/bin/clang" - CXX="$TOOLTOOL_DIR/clang/bin/clang++" - export ENABLE_CLANG_PLUGIN=1 + CC="$MOZ_FETCHES_DIR/clang/bin/clang" + CXX="$MOZ_FETCHES_DIR/clang/bin/clang++" + + # For some builds we don't want to have Clang based static-analysis activated + if [ -z "$DISABLE_CLANG_PLUGIN" ]; then + export ENABLE_CLANG_PLUGIN=1 + fi + case "$PERFHERDER_EXTRA_OPTIONS" in base-toolchains*) # Clang versions < 7.0 don't support the -fcrash-diagnostics-dir flag. @@ -24,22 +29,20 @@ else ;; esac - if [ -n "$MOZ_PGO" ]; then - if [ -z "$USE_ARTIFACT" ]; then + if [ -z "$USE_ARTIFACT" ]; then + if [ -n "$TASKCLUSTER_PGO_PROFILE_USE" ]; then export MOZ_LTO=cross - if [ -n "$MOZ_PGO_PROFILE_USE" ]; then - ac_add_options --enable-profile-use=cross - ac_add_options --with-pgo-jarlog=/builds/worker/fetches/en-US.log - ac_add_options --with-pgo-profile-path=/builds/worker/fetches - fi + ac_add_options --enable-profile-use=cross + ac_add_options --with-pgo-jarlog=/builds/worker/fetches/en-US.log + ac_add_options --with-pgo-profile-path=/builds/worker/fetches/merged.profdata + export LLVM_PROFDATA="$MOZ_FETCHES_DIR/clang/bin/llvm-profdata" + export AR="$MOZ_FETCHES_DIR/clang/bin/llvm-ar" + export NM="$MOZ_FETCHES_DIR/clang/bin/llvm-nm" + export RANLIB="$MOZ_FETCHES_DIR/clang/bin/llvm-ranlib" fi - export LLVM_PROFDATA="$TOOLTOOL_DIR/clang/bin/llvm-profdata" - export AR="$topsrcdir/clang/bin/llvm-ar" - export NM="$topsrcdir/clang/bin/llvm-nm" - export RANLIB="$topsrcdir/clang/bin/llvm-ranlib" fi - mk_add_options "export PATH=$TOOLTOOL_DIR/binutils/bin:$PATH" + mk_add_options "export PATH=$MOZ_FETCHES_DIR/binutils/bin:$PATH" fi . "$topsrcdir/build/unix/mozconfig.stdcxx" diff --git a/build/valgrind/x86_64-pc-linux-gnu.sup b/build/valgrind/x86_64-pc-linux-gnu.sup index 8a05c49a77..c400d66028 100644 --- a/build/valgrind/x86_64-pc-linux-gnu.sup +++ b/build/valgrind/x86_64-pc-linux-gnu.sup @@ -47,7 +47,6 @@ fun:FcDirCacheWrite fun:FcDirCacheScan fun:FcConfigAddDirList - fun:FcConfigAppFontAddDir ... } { @@ -58,7 +57,6 @@ fun:FcDirScanConfig fun:FcDirCacheScan fun:FcConfigAddDirList - fun:FcConfigAppFontAddDir ... } { @@ -70,7 +68,6 @@ fun:FcDirScanConfig fun:FcDirCacheScan fun:FcConfigAddDirList - fun:FcConfigAppFontAddDir ... } { @@ -82,7 +79,6 @@ obj:/usr/lib/x86_64-linux-gnu/libfontconfig.so.1.5.0 fun:FcDirCacheScan fun:FcConfigAddDirList - fun:FcConfigAppFontAddDir ... } # Leaks due to either Gtk+3 or cairo, but Gecko is not directly involved with diff --git a/build/win32/pgomerge.py b/build/win32/pgomerge.py deleted file mode 100644 index 754a2f6b3a..0000000000 --- a/build/win32/pgomerge.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/python -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -# Usage: pgomerge.py -# Gathers .pgc files from dist/bin and merges them into -# $PWD/$basename.pgd using pgomgr, then deletes them. -# No errors if any of these files don't exist. - -import sys -import os -import os.path -import subprocess -if not sys.platform == "win32": - raise Exception("This script was only meant for Windows.") - - -def MergePGOFiles(basename, pgddir, pgcdir): - """Merge pgc files produced from an instrumented binary - into the pgd file for the second pass of profile-guided optimization - with MSVC. |basename| is the name of the DLL or EXE without the - extension. |pgddir| is the path that contains .pgd - (should be the objdir it was built in). |pgcdir| is the path - containing basename!N.pgc files, which is probably dist/bin. - Calls pgomgr to merge each pgc file into the pgd, then deletes - the pgc files.""" - if not os.path.isdir(pgddir) or not os.path.isdir(pgcdir): - return - pgdfile = os.path.abspath(os.path.join(pgddir, basename + ".pgd")) - if not os.path.isfile(pgdfile): - return - for file in os.listdir(pgcdir): - if file.startswith(basename+"!") and file.endswith(".pgc"): - try: - pgcfile = os.path.normpath(os.path.join(pgcdir, file)) - subprocess.call(['pgomgr', '-merge', - pgcfile, - pgdfile]) - os.remove(pgcfile) - except OSError: - pass - - -if __name__ == '__main__': - if len(sys.argv) != 3: - print >>sys.stderr, "Usage: pgomerge.py " - sys.exit(1) - MergePGOFiles(sys.argv[1], os.getcwd(), sys.argv[2]) diff --git a/build/win64/mozconfig.asan b/build/win64/mozconfig.asan index c0872d2908..f2b568de80 100644 --- a/build/win64/mozconfig.asan +++ b/build/win64/mozconfig.asan @@ -1,13 +1,13 @@ . "$topsrcdir/browser/config/mozconfigs/win64/common-win64" -if [ -d "$topsrcdir/clang" ]; then - CLANG_LIB_DIR="$(cd $topsrcdir/clang/lib/clang/* && cd lib/windows && pwd)" +if [ -d "$MOZ_FETCHES_DIR/clang" ]; then + CLANG_LIB_DIR="$(cd $MOZ_FETCHES_DIR/clang/lib/clang/* && cd lib/windows && pwd)" export LIB=$LIB:$CLANG_LIB_DIR export LDFLAGS="clang_rt.asan_dynamic-x86_64.lib clang_rt.asan_dynamic_runtime_thunk-x86_64.lib" export MOZ_COPY_PDBS=1 - export LLVM_SYMBOLIZER="$topsrcdir/clang/bin/llvm-symbolizer.exe" + export LLVM_SYMBOLIZER="$MOZ_FETCHES_DIR/clang/bin/llvm-symbolizer.exe" export MOZ_CLANG_RT_ASAN_LIB_PATH="${CLANG_LIB_DIR}/clang_rt.asan_dynamic-x86_64.dll" fi @@ -16,7 +16,6 @@ ac_add_options --enable-address-sanitizer # Mandatory options required for ASan builds ac_add_options --enable-debug-symbols -ac_add_options --disable-install-strip ac_add_options --disable-jemalloc ac_add_options --disable-crashreporter ac_add_options --disable-profiling diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index 349d6aa875..0b3258cabb 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -70,7 +70,6 @@ using namespace mozilla; using namespace mozilla::dom; nsIIOService* nsScriptSecurityManager::sIOService = nullptr; -JSContext* nsScriptSecurityManager::sContext = nullptr; bool nsScriptSecurityManager::sStrictFileOriginPolicy = true; namespace { @@ -1330,22 +1329,29 @@ nsresult nsScriptSecurityManager::Init() { mSystemPrincipal = system; + return NS_OK; +} + +void nsScriptSecurityManager::InitJSCallbacks(JSContext* aCx) { //-- Register security check callback in the JS engine // Currently this is used to control access to function.caller - sContext = danger::GetJSContext(); static const JSSecurityCallbacks securityCallbacks = { ContentSecurityPolicyPermitsJSAction, JSPrincipalsSubsume, }; - MOZ_ASSERT(!JS_GetSecurityCallbacks(sContext)); - JS_SetSecurityCallbacks(sContext, &securityCallbacks); - JS_InitDestroyPrincipalsCallback(sContext, nsJSPrincipals::Destroy); + MOZ_ASSERT(!JS_GetSecurityCallbacks(aCx)); + JS_SetSecurityCallbacks(aCx, &securityCallbacks); + JS_InitDestroyPrincipalsCallback(aCx, nsJSPrincipals::Destroy); - JS_SetTrustedPrincipals(sContext, system); + JS_SetTrustedPrincipals(aCx, BasePrincipal::Cast(mSystemPrincipal)); +} - return NS_OK; +/* static */ +void nsScriptSecurityManager::ClearJSCallbacks(JSContext* aCx) { + JS_SetSecurityCallbacks(aCx, nullptr); + JS_SetTrustedPrincipals(aCx, nullptr); } static StaticRefPtr gScriptSecMan; @@ -1363,12 +1369,6 @@ nsScriptSecurityManager::~nsScriptSecurityManager(void) { } void nsScriptSecurityManager::Shutdown() { - if (sContext) { - JS_SetSecurityCallbacks(sContext, nullptr); - JS_SetTrustedPrincipals(sContext, nullptr); - sContext = nullptr; - } - NS_IF_RELEASE(sIOService); BundleHelper::Shutdown(); } diff --git a/caps/nsScriptSecurityManager.h b/caps/nsScriptSecurityManager.h index 0ceb3491a5..98af9d551f 100644 --- a/caps/nsScriptSecurityManager.h +++ b/caps/nsScriptSecurityManager.h @@ -49,6 +49,11 @@ class nsScriptSecurityManager final : public nsIScriptSecurityManager { // Invoked exactly once, by XPConnect. static void InitStatics(); + void InitJSCallbacks(JSContext* aCx); + + // This has to be static because it is called after gScriptSecMan is cleared. + static void ClearJSCallbacks(JSContext* aCx); + static already_AddRefed SystemPrincipalSingletonConstructor(); @@ -119,7 +124,6 @@ class nsScriptSecurityManager final : public nsIScriptSecurityManager { static nsIIOService* sIOService; static nsIStringBundle* sStrBundle; - static JSContext* sContext; }; #endif // nsScriptSecurityManager_h__ diff --git a/config/MozZipFile.py b/config/MozZipFile.py index d483614355..f8dc5cc7e4 100644 --- a/config/MozZipFile.py +++ b/config/MozZipFile.py @@ -2,6 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import absolute_import import os import time import zipfile @@ -47,7 +48,7 @@ class ZipFile(zipfile.ZipFile): date_time=time.localtime(time.time())) zinfo.compress_type = self.compression # Add some standard UNIX file access permissions (-rw-r--r--). - zinfo.external_attr = (0x81a4 & 0xFFFF) << 16L + zinfo.external_attr = (0x81a4 & 0xFFFF) << 16 else: zinfo = zinfo_or_arcname diff --git a/config/baseconfig.mk b/config/baseconfig.mk index 30582a6f05..532ccab776 100644 --- a/config/baseconfig.mk +++ b/config/baseconfig.mk @@ -43,7 +43,7 @@ ifndef INCLUDED_AUTOCONF_MK default:: else # All possible tiers -ALL_TIERS := artifact win32-artifact android-fat-aar-artifact pre-export export rust compile misc libs tools check +ALL_TIERS := artifact win32-artifact android-fat-aar-artifact pre-export export rust compile misc libs android-stage-package android-archive-geckoview tools check # All tiers that may be used manually via `mach build $tier` RUNNABLE_TIERS := $(ALL_TIERS) @@ -54,6 +54,10 @@ RUNNABLE_TIERS := $(filter-out win32-artifact,$(RUNNABLE_TIERS)) ifndef MOZ_ANDROID_FAT_AAR_ARCHITECTURES RUNNABLE_TIERS := $(filter-out android-fat-aar-artifact,$(RUNNABLE_TIERS)) endif +ifneq ($(MOZ_BUILD_APP),mobile/android) +RUNNABLE_TIERS := $(filter-out android-stage-package,$(RUNNABLE_TIERS)) +RUNNABLE_TIERS := $(filter-out android-archive-geckoview,$(RUNNABLE_TIERS)) +endif # All tiers that run automatically on `mach build` TIERS := $(filter-out check,$(RUNNABLE_TIERS)) diff --git a/config/check_js_msg_encoding.py b/config/check_js_msg_encoding.py index f875b4332d..35129964a4 100644 --- a/config/check_js_msg_encoding.py +++ b/config/check_js_msg_encoding.py @@ -8,6 +8,7 @@ # JSErrorFormatString.format member should be in ASCII encoding. # ---------------------------------------------------------------------------- +from __future__ import absolute_import from __future__ import print_function import os diff --git a/config/check_js_opcode.py b/config/check_js_opcode.py index e38acfc0e3..c6fd1b0336 100644 --- a/config/check_js_opcode.py +++ b/config/check_js_opcode.py @@ -6,6 +6,7 @@ # This script checks bytecode documentation in js/src/vm/Opcodes.h # ---------------------------------------------------------------------------- +from __future__ import absolute_import from __future__ import print_function import os diff --git a/config/check_macroassembler_style.py b/config/check_macroassembler_style.py index 1970f3a2e4..8d74014810 100644 --- a/config/check_macroassembler_style.py +++ b/config/check_macroassembler_style.py @@ -19,6 +19,7 @@ # proper methods annotations. # ---------------------------------------------------------------------------- +from __future__ import absolute_import from __future__ import print_function import difflib @@ -26,56 +27,56 @@ import os import re import sys -architecture_independent = set(['generic']) -all_unsupported_architectures_names = set(['mips32', 'mips64', 'mips_shared']) -all_architecture_names = set(['x86', 'x64', 'arm', 'arm64']) -all_shared_architecture_names = set(['x86_shared', 'arm', 'arm64']) +architecture_independent = set(["generic"]) +all_unsupported_architectures_names = set(["mips32", "mips64", "mips_shared"]) +all_architecture_names = set(["x86", "x64", "arm", "arm64"]) +all_shared_architecture_names = set(["x86_shared", "arm", "arm64"]) reBeforeArg = "(?<=[(,\s])" reArgType = "(?P[\w\s:*&]+)" reArgName = "(?P\s\w+)" reArgDefault = "(?P(?:\s=[^,)]+)?)" reAfterArg = "(?=[,)])" -reMatchArg = re.compile(reBeforeArg + reArgType + - reArgName + reArgDefault + reAfterArg) +reMatchArg = re.compile(reBeforeArg + reArgType + reArgName + reArgDefault + reAfterArg) def get_normalized_signatures(signature, fileAnnot=None): # Remove static - signature = signature.replace('static', '') + signature = signature.replace("static", "") # Remove semicolon. - signature = signature.replace(';', ' ') + signature = signature.replace(";", " ") # Normalize spaces. - signature = re.sub(r'\s+', ' ', signature).strip() + signature = re.sub(r"\s+", " ", signature).strip() # Remove new-line induced spaces after opening braces. - signature = re.sub(r'\(\s+', '(', signature).strip() + signature = re.sub(r"\(\s+", "(", signature).strip() # Match arguments, and keep only the type. - signature = reMatchArg.sub('\g', signature) + signature = reMatchArg.sub("\g", signature) # Remove class name - signature = signature.replace('MacroAssembler::', '') + signature = signature.replace("MacroAssembler::", "") # Extract list of architectures - archs = ['generic'] + archs = ["generic"] if fileAnnot: - archs = [fileAnnot['arch']] + archs = [fileAnnot["arch"]] - if 'DEFINED_ON(' in signature: + if "DEFINED_ON(" in signature: archs = re.sub( - r'.*DEFINED_ON\((?P[^()]*)\).*', '\g', signature).split(',') + r".*DEFINED_ON\((?P[^()]*)\).*", "\g", signature + ).split(",") archs = [a.strip() for a in archs] - signature = re.sub(r'\s+DEFINED_ON\([^()]*\)', '', signature) + signature = re.sub(r"\s+DEFINED_ON\([^()]*\)", "", signature) - elif 'PER_ARCH' in signature: + elif "PER_ARCH" in signature: archs = all_architecture_names - signature = re.sub(r'\s+PER_ARCH', '', signature) + signature = re.sub(r"\s+PER_ARCH", "", signature) - elif 'PER_SHARED_ARCH' in signature: + elif "PER_SHARED_ARCH" in signature: archs = all_shared_architecture_names - signature = re.sub(r'\s+PER_SHARED_ARCH', '', signature) + signature = re.sub(r"\s+PER_SHARED_ARCH", "", signature) - elif 'OOL_IN_HEADER' in signature: - assert archs == ['generic'] - signature = re.sub(r'\s+OOL_IN_HEADER', '', signature) + elif "OOL_IN_HEADER" in signature: + assert archs == ["generic"] + signature = re.sub(r"\s+OOL_IN_HEADER", "", signature) else: # No signature annotation, the list of architectures remains unchanged. @@ -84,58 +85,55 @@ def get_normalized_signatures(signature, fileAnnot=None): # Extract inline annotation inline = False if fileAnnot: - inline = fileAnnot['inline'] + inline = fileAnnot["inline"] - if 'inline ' in signature: - signature = re.sub(r'inline\s+', '', signature) + if "inline " in signature: + signature = re.sub(r"inline\s+", "", signature) inline = True - inlinePrefx = '' + inlinePrefx = "" if inline: - inlinePrefx = 'inline ' - signatures = [ - {'arch': a, 'sig': inlinePrefx + signature} - for a in archs - ] + inlinePrefx = "inline " + signatures = [{"arch": a, "sig": inlinePrefx + signature} for a in archs] return signatures -file_suffixes = set([ - a.replace('_', '-') for a in - all_architecture_names.union(all_shared_architecture_names) - .union(all_unsupported_architectures_names) -]) +file_suffixes = set( + [ + a.replace("_", "-") + for a in all_architecture_names.union(all_shared_architecture_names).union( + all_unsupported_architectures_names + ) + ] +) def get_file_annotation(filename): origFilename = filename - filename = filename.split('/')[-1] + filename = filename.split("/")[-1] inline = False - if filename.endswith('.cpp'): - filename = filename[:-len('.cpp')] - elif filename.endswith('-inl.h'): + if filename.endswith(".cpp"): + filename = filename[: -len(".cpp")] + elif filename.endswith("-inl.h"): inline = True - filename = filename[:-len('-inl.h')] - elif filename.endswith('.h'): + filename = filename[: -len("-inl.h")] + elif filename.endswith(".h"): # This allows the definitions block in MacroAssembler.h to be # style-checked. inline = True - filename = filename[:-len('.h')] + filename = filename[: -len(".h")] else: - raise Exception('unknown file name', origFilename) + raise Exception("unknown file name", origFilename) - arch = 'generic' + arch = "generic" for suffix in file_suffixes: - if filename == 'MacroAssembler-' + suffix: + if filename == "MacroAssembler-" + suffix: arch = suffix break - return { - 'inline': inline, - 'arch': arch.replace('-', '_') - } + return {"inline": inline, "arch": arch.replace("-", "_")} def get_macroassembler_definitions(filename): @@ -145,46 +143,45 @@ def get_macroassembler_definitions(filename): return [] style_section = False - lines = '' + lines = "" signatures = [] with open(filename) as f: for line in f: - if '//{{{ check_macroassembler_style' in line: + if "//{{{ check_macroassembler_style" in line: if style_section: - raise 'check_macroassembler_style section already opened.' + raise "check_macroassembler_style section already opened." style_section = True braces_depth = 0 - elif '//}}} check_macroassembler_style' in line: + elif "//}}} check_macroassembler_style" in line: style_section = False if not style_section: continue # Ignore preprocessor directives. - if line.startswith('#'): + if line.startswith("#"): continue # Remove comments from the processed line. - line = re.sub(r'//.*', '', line) + line = re.sub(r"//.*", "", line) # Locate and count curly braces. - open_curly_brace = line.find('{') + open_curly_brace = line.find("{") was_braces_depth = braces_depth - braces_depth = braces_depth + line.count('{') - line.count('}') + braces_depth = braces_depth + line.count("{") - line.count("}") # Raise an error if the check_macroassembler_style macro is used # across namespaces / classes scopes. if braces_depth < 0: - raise 'check_macroassembler_style annotations are not well scoped.' + raise "check_macroassembler_style annotations are not well scoped." # If the current line contains an opening curly brace, check if # this line combines with the previous one can be identified as a # MacroAssembler function signature. if open_curly_brace != -1 and was_braces_depth == 0: lines = lines + line[:open_curly_brace] - if 'MacroAssembler::' in lines: - signatures.extend( - get_normalized_signatures(lines, fileAnnot)) - lines = '' + if "MacroAssembler::" in lines: + signatures.extend(get_normalized_signatures(lines, fileAnnot)) + lines = "" continue # We do not aggregate any lines if we are scanning lines which are @@ -192,15 +189,15 @@ def get_macroassembler_definitions(filename): if braces_depth > 0: continue if was_braces_depth != 0: - line = line[line.rfind('}') + 1:] + line = line[line.rfind("}") + 1 :] # This logic is used to remove template instantiation, static # variable definitions and function declaration from the next # function definition. - last_semi_colon = line.rfind(';') + last_semi_colon = line.rfind(";") if last_semi_colon != -1: - lines = '' - line = line[last_semi_colon + 1:] + lines = "" + line = line[last_semi_colon + 1 :] # Aggregate lines of non-braced text, which corresponds to the space # where we are expecting to find function definitions. @@ -211,49 +208,49 @@ def get_macroassembler_definitions(filename): def get_macroassembler_declaration(filename): style_section = False - lines = '' + lines = "" signatures = [] with open(filename) as f: for line in f: - if '//{{{ check_macroassembler_decl_style' in line: + if "//{{{ check_macroassembler_decl_style" in line: style_section = True - elif '//}}} check_macroassembler_decl_style' in line: + elif "//}}} check_macroassembler_decl_style" in line: style_section = False if not style_section: continue # Ignore preprocessor directives. - if line.startswith('#'): + if line.startswith("#"): continue - line = re.sub(r'//.*', '', line) - if len(line.strip()) == 0 or 'public:' in line or 'private:' in line: - lines = '' + line = re.sub(r"//.*", "", line) + if len(line.strip()) == 0 or "public:" in line or "private:" in line: + lines = "" continue lines = lines + line # Continue until we have a complete declaration - if ';' not in lines: + if ";" not in lines: continue # Skip member declarations: which are lines ending with a # semi-colon without any list of arguments. - if ')' not in lines: - lines = '' + if ")" not in lines: + lines = "" continue signatures.extend(get_normalized_signatures(lines)) - lines = '' + lines = "" return signatures def append_signatures(d, sigs): for s in sigs: - if s['sig'] not in d: - d[s['sig']] = [] - d[s['sig']].append(s['arch']) + if s["sig"] not in d: + d[s["sig"]] = [] + d[s["sig"]].append(s["arch"]) return d @@ -263,65 +260,66 @@ def generate_file_content(signatures): archs = set(sorted(signatures[s])) archs -= all_unsupported_architectures_names if len(archs.symmetric_difference(architecture_independent)) == 0: - output.append(s + ';\n') - if s.startswith('inline'): + output.append(s + ";\n") + if s.startswith("inline"): # TODO, bug 1432600: This is mistaken for OOL_IN_HEADER # functions. (Such annotation is already removed by the time # this function sees the signature here.) - output.append(' is defined in MacroAssembler-inl.h\n') + output.append(" is defined in MacroAssembler-inl.h\n") else: - output.append(' is defined in MacroAssembler.cpp\n') + output.append(" is defined in MacroAssembler.cpp\n") else: if len(archs.symmetric_difference(all_architecture_names)) == 0: - output.append(s + ' PER_ARCH;\n') + output.append(s + " PER_ARCH;\n") elif len(archs.symmetric_difference(all_shared_architecture_names)) == 0: - output.append(s + ' PER_SHARED_ARCH;\n') + output.append(s + " PER_SHARED_ARCH;\n") else: - output.append( - s + ' DEFINED_ON(' + ', '.join(sorted(archs)) + ');\n') + output.append(s + " DEFINED_ON(" + ", ".join(sorted(archs)) + ");\n") for a in sorted(archs): - a = a.replace('_', '-') - masm = '%s/MacroAssembler-%s' % (a, a) - if s.startswith('inline'): - output.append(' is defined in %s-inl.h\n' % masm) + a = a.replace("_", "-") + masm = "%s/MacroAssembler-%s" % (a, a) + if s.startswith("inline"): + output.append(" is defined in %s-inl.h\n" % masm) else: - output.append(' is defined in %s.cpp\n' % masm) + output.append(" is defined in %s.cpp\n" % masm) return output def check_style(): # We read from the header file the signature of each function. - decls = dict() # type: dict(signature => ['x86', 'x64']) + decls = dict() # type: dict(signature => ['x86', 'x64']) # We infer from each file the signature of each MacroAssembler function. - defs = dict() # type: dict(signature => ['x86', 'x64']) + defs = dict() # type: dict(signature => ['x86', 'x64']) - root_dir = os.path.join('js', 'src', 'jit') + root_dir = os.path.join("js", "src", "jit") for dirpath, dirnames, filenames in os.walk(root_dir): for filename in filenames: - if 'MacroAssembler' not in filename: + if "MacroAssembler" not in filename: continue - filepath = os.path.join(dirpath, filename).replace('\\', '/') + filepath = os.path.join(dirpath, filename).replace("\\", "/") - if filepath.endswith('MacroAssembler.h'): + if filepath.endswith("MacroAssembler.h"): decls = append_signatures( - decls, get_macroassembler_declaration(filepath)) - defs = append_signatures( - defs, get_macroassembler_definitions(filepath)) + decls, get_macroassembler_declaration(filepath) + ) + defs = append_signatures(defs, get_macroassembler_definitions(filepath)) if not decls or not defs: raise Exception("Did not find any definitions or declarations") # Compare declarations and definitions output. - difflines = difflib.unified_diff(generate_file_content(decls), - generate_file_content(defs), - fromfile='check_macroassembler_style.py declared syntax', - tofile='check_macroassembler_style.py found definitions') + difflines = difflib.unified_diff( + generate_file_content(decls), + generate_file_content(defs), + fromfile="check_macroassembler_style.py declared syntax", + tofile="check_macroassembler_style.py found definitions", + ) ok = True for diffline in difflines: ok = False - print(diffline, end='') + print(diffline, end="") return ok @@ -330,12 +328,14 @@ def main(): ok = check_style() if ok: - print('TEST-PASS | check_macroassembler_style.py | ok') + print("TEST-PASS | check_macroassembler_style.py | ok") else: - print('TEST-UNEXPECTED-FAIL | check_macroassembler_style.py | actual output does not match expected output; diff is above') # noqa: E501 + print( + "TEST-UNEXPECTED-FAIL | check_macroassembler_style.py | actual output does not match expected output; diff is above" # noqa: E501 + ) sys.exit(0 if ok else 1) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/config/check_source_count.py b/config/check_source_count.py index 1c86b2d16b..df87c0689f 100644 --- a/config/check_source_count.py +++ b/config/check_source_count.py @@ -9,6 +9,7 @@ # not, an error message is printed, quoting ERROR_LOCATION, which should # probably be the filename and line number of the erroneous call to # check_source_count.py. +from __future__ import absolute_import from __future__ import print_function import sys import re diff --git a/config/check_spidermonkey_style.py b/config/check_spidermonkey_style.py index a609677dcd..2321847052 100644 --- a/config/check_spidermonkey_style.py +++ b/config/check_spidermonkey_style.py @@ -34,7 +34,7 @@ # isolation, but don't try to do any order checking between such blocks. # ---------------------------------------------------------------------------- -from __future__ import print_function +from __future__ import absolute_import, print_function import difflib import os diff --git a/config/check_vanilla_allocations.py b/config/check_vanilla_allocations.py index f6089df439..c1ebbf36b3 100644 --- a/config/check_vanilla_allocations.py +++ b/config/check_vanilla_allocations.py @@ -37,6 +37,7 @@ # mismatched alloc/free checking. # ---------------------------------------------------------------------------- +from __future__ import absolute_import from __future__ import print_function import argparse diff --git a/config/config.mk b/config/config.mk index c2918f9773..3660ffb38f 100644 --- a/config/config.mk +++ b/config/config.mk @@ -195,6 +195,10 @@ HOST_CXXFLAGS = $(COMPUTED_HOST_CXXFLAGS) $(_HOST_DEPEND_CFLAGS) HOST_C_LDFLAGS = $(COMPUTED_HOST_C_LDFLAGS) HOST_CXX_LDFLAGS = $(COMPUTED_HOST_CXX_LDFLAGS) +WASM_CFLAGS = $(COMPUTED_WASM_CFLAGS) $(PGO_CFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES) +WASM_CXXFLAGS = $(COMPUTED_WASM_CXXFLAGS) $(PGO_CFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES) +WASM_LDFLAGS = $(COMPUTED_WASM_LDFLAGS) + ifdef MOZ_LTO ifeq (Darwin,$(OS_TARGET)) # When linking on macOS, debug info is not linked along with the final binary, @@ -230,6 +234,9 @@ color_flags_vars := \ COMPILE_CMFLAGS \ COMPILE_CMMFLAGS \ LDFLAGS \ + WASM_LDFLAGS \ + WASM_CFLAGS \ + WASM_CXXFLAGS \ $(NULL) ifdef MACH_STDOUT_ISATTY @@ -428,23 +435,6 @@ endif # ! WINNT # this file OBJ_SUFFIX := $(_OBJ_SUFFIX) -OBJS_VAR_SUFFIX := OBJS - -# PGO builds with GCC and clang-cl build objects with instrumentation in -# a first pass, then objects optimized, without instrumentation, in a -# second pass. If we overwrite the objects from the first pass with -# those from the second, we end up not getting instrumentation data for -# better optimization on incremental builds. As a consequence, we use a -# different object suffix for the first pass. -ifdef MOZ_PROFILE_GENERATE -ifneq (,$(GNU_CC)$(CLANG_CL)) -OBJS_VAR_SUFFIX := PGO_OBJS -ifndef NO_PROFILE_GUIDED_OPTIMIZE -OBJ_SUFFIX := i_o -endif -endif -endif - PLY_INCLUDE = -I$(MOZILLA_DIR)/other-licenses/ply # Enable verbose logs when not using `make -s` diff --git a/config/external/ffi/subst_header.py b/config/external/ffi/subst_header.py index eb2a4921c6..48eb080a01 100644 --- a/config/external/ffi/subst_header.py +++ b/config/external/ffi/subst_header.py @@ -2,6 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distibuted with this # file, You can obtain one at http://mozilla.og/MPL/2.0/. +from __future__ import absolute_import import sys import buildconfig from mozbuild.preprocessor import Preprocessor diff --git a/config/external/icu/data/genicudata.py b/config/external/icu/data/genicudata.py deleted file mode 100644 index c94ebfd2f5..0000000000 --- a/config/external/icu/data/genicudata.py +++ /dev/null @@ -1,12 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - - -def main(output, data_file, data_symbol): - output.write(''' AREA |.rdata|,ALIGN=4,DATA,READONLY - EXPORT |{data_symbol}|[DATA] -|{data_symbol}| - INCBIN {data_file} - END -'''.format(data_file=data_file, data_symbol=data_symbol)) diff --git a/config/external/icu/data/icu_data.S b/config/external/icu/data/icu_data.S new file mode 100644 index 0000000000..95e2e359f9 --- /dev/null +++ b/config/external/icu/data/icu_data.S @@ -0,0 +1,24 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#if defined(_WIN32) && defined(__i386__) +// Mark the object as SAFESEH-enabled. +.def @feat.00; +.scl 3; +.type 0; +.endef +.global @feat.00 +.set @feat.00, 1 +#endif + +.global ICU_DATA_SYMBOL +#ifdef __APPLE__ +.data +.const +#else +.section .rodata +#endif +.balign 16 +ICU_DATA_SYMBOL: + .incbin ICU_DATA_FILE diff --git a/config/external/icu/data/icudata.s b/config/external/icu/data/icudata.s deleted file mode 100644 index a740f3260b..0000000000 --- a/config/external/icu/data/icudata.s +++ /dev/null @@ -1,31 +0,0 @@ -;; This Source Code Form is subject to the terms of the Mozilla Public -;; License, v. 2.0. If a copy of the MPL was not distributed with this -;; file, You can obtain one at http://mozilla.org/MPL/2.0/. - -%ifdef PREFIX - %define DATA_SYMBOL _ %+ ICU_DATA_SYMBOL -%else - %define DATA_SYMBOL ICU_DATA_SYMBOL -%endif - -%ifidn __OUTPUT_FORMAT__,elf - %define FORMAT_ELF 1 -%elifidn __OUTPUT_FORMAT__,elf32 - %define FORMAT_ELF 1 -%elifidn __OUTPUT_FORMAT__,elf64 - %define FORMAT_ELF 1 -%else - %define FORMAT_ELF 0 -%endif - -%if FORMAT_ELF - global DATA_SYMBOL:data hidden - ; This is needed for ELF, otherwise the GNU linker assumes the stack is executable by default. - [SECTION .note.GNU-stack noalloc noexec nowrite progbits] -%else - global DATA_SYMBOL -%endif - -SECTION .rodata align=16 -DATA_SYMBOL: - incbin ICU_DATA_FILE diff --git a/config/external/icu/data/icudt67l.dat b/config/external/icu/data/icudt67l.dat index b537282f7a..9bfd05117f 100644 Binary files a/config/external/icu/data/icudt67l.dat and b/config/external/icu/data/icudt67l.dat differ diff --git a/config/external/icu/data/moz.build b/config/external/icu/data/moz.build index a889b6a91e..aca1a1c693 100644 --- a/config/external/icu/data/moz.build +++ b/config/external/icu/data/moz.build @@ -6,29 +6,17 @@ # JSAPI consumers don't have to deal with setting ICU's data path. Library('icudata') -if CONFIG['OS_ARCH'] == 'WINNT': - if CONFIG['CPU_ARCH'] == 'x86': - ASFLAGS += ['-DPREFIX'] -elif CONFIG['OS_ARCH'] == 'Darwin': - ASFLAGS += ['-DPREFIX'] - -data_symbol = 'icudt%s_dat' % CONFIG['MOZ_ICU_VERSION'] -asflags = [ - '-I%s/config/external/icu/data/' % TOPSRCDIR, - '-DICU_DATA_FILE="%s"' % CONFIG['ICU_DATA_FILE'], - '-DICU_DATA_SYMBOL=%s' % data_symbol, -] LOCAL_INCLUDES += ['.'] -if CONFIG['OS_TARGET'] == 'WINNT' and CONFIG['CPU_ARCH'] == 'aarch64': - icudata = 'icudata.asm' - GeneratedFile(icudata, script='genicudata.py', - inputs=[CONFIG['ICU_DATA_FILE']], flags=[data_symbol]) - SOURCES += ['!%s' % icudata] -elif CONFIG['HAVE_YASM']: - USE_YASM = True - SOURCES += ['icudata.s'] - ASFLAGS += asflags -elif CONFIG['GNU_AS']: - SOURCES += ['icudata_gas.S'] - ASFLAGS += asflags +prefix = '' +if (CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['CPU_ARCH'] == 'x86') or CONFIG['OS_ARCH'] == 'Darwin': + prefix = '_' + +DEFINES['ICU_DATA_FILE'] = '"%s/icudt%sl.dat"' % (SRCDIR, CONFIG['MOZ_ICU_VERSION']) +DEFINES['ICU_DATA_SYMBOL'] = '%sicudt%s_dat' % (prefix, CONFIG['MOZ_ICU_VERSION']) +SOURCES += [ + 'icu_data.S', +] + +if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['CC_TYPE'] == 'clang-cl': + USE_INTEGRATED_CLANGCL_AS = True diff --git a/config/external/nspr/pr/moz.build b/config/external/nspr/pr/moz.build index 50f62c5ad7..485eb3f17d 100644 --- a/config/external/nspr/pr/moz.build +++ b/config/external/nspr/pr/moz.build @@ -59,8 +59,7 @@ elif CONFIG['OS_TARGET'] == 'Darwin': '/nsprpub/pr/src/md/unix/darwin.c', '/nsprpub/pr/src/md/unix/os_Darwin.s', ] - if not CONFIG['MOZ_IOS']: - DEFINES['HAVE_CRT_EXTERNS_H'] = True + DEFINES['HAVE_CRT_EXTERNS_H'] = True elif CONFIG['OS_TARGET'] == 'SunOS': DEFINES.update( HAVE_FCNTL_FILE_LOCKING=True, @@ -116,7 +115,6 @@ LOCAL_INCLUDES += [ SOURCES += [ '/nsprpub/pr/src/io/prpolevt.c', # conflicting definition of PRFilePrivate '/nsprpub/pr/src/misc/praton.c', # duplicate definition of index_hex - '/nsprpub/pr/src/misc/prcountr.c', # duplicate definition of QName, RName ] UNIFIED_SOURCES += [ @@ -136,9 +134,7 @@ UNIFIED_SOURCES += [ '/nsprpub/pr/src/malloc/prmem.c', '/nsprpub/pr/src/md/prosdep.c', '/nsprpub/pr/src/memory/prseg.c', - '/nsprpub/pr/src/memory/prshm.c', '/nsprpub/pr/src/memory/prshma.c', - '/nsprpub/pr/src/misc/pralarm.c', '/nsprpub/pr/src/misc/pratom.c', '/nsprpub/pr/src/misc/prdtoa.c', '/nsprpub/pr/src/misc/prenv.c', @@ -149,15 +145,11 @@ UNIFIED_SOURCES += [ '/nsprpub/pr/src/misc/prinrval.c', '/nsprpub/pr/src/misc/pripc.c', '/nsprpub/pr/src/misc/prlog2.c', - '/nsprpub/pr/src/misc/prlong.c', '/nsprpub/pr/src/misc/prnetdb.c', - '/nsprpub/pr/src/misc/prolock.c', '/nsprpub/pr/src/misc/prrng.c', '/nsprpub/pr/src/misc/prsystem.c', - '/nsprpub/pr/src/misc/prthinfo.c', '/nsprpub/pr/src/misc/prtime.c', '/nsprpub/pr/src/misc/prtpool.c', - '/nsprpub/pr/src/misc/prtrace.c', '/nsprpub/pr/src/threads/prcmon.c', '/nsprpub/pr/src/threads/prrwlock.c', '/nsprpub/pr/src/threads/prtpd.c', @@ -171,7 +163,6 @@ if CONFIG['OS_TARGET'] != 'WINNT': '/nsprpub/pr/src/md/unix/uxproces.c', '/nsprpub/pr/src/md/unix/uxrng.c', '/nsprpub/pr/src/md/unix/uxshm.c', - '/nsprpub/pr/src/md/unix/uxwrap.c', '/nsprpub/pr/src/pthreads/ptio.c', '/nsprpub/pr/src/pthreads/ptmisc.c', '/nsprpub/pr/src/pthreads/ptsynch.c', @@ -221,7 +212,6 @@ EXPORTS.nspr += [ '/nsprpub/pr/include/prbit.h', '/nsprpub/pr/include/prclist.h', '/nsprpub/pr/include/prcmon.h', - '/nsprpub/pr/include/prcountr.h', '/nsprpub/pr/include/prcvar.h', '/nsprpub/pr/include/prdtoa.h', '/nsprpub/pr/include/prenv.h', @@ -240,7 +230,6 @@ EXPORTS.nspr += [ '/nsprpub/pr/include/prmon.h', '/nsprpub/pr/include/prmwait.h', '/nsprpub/pr/include/prnetdb.h', - '/nsprpub/pr/include/prolock.h', '/nsprpub/pr/include/prpdce.h', '/nsprpub/pr/include/prprf.h', '/nsprpub/pr/include/prproces.h', diff --git a/config/external/sqlite/moz.build b/config/external/sqlite/moz.build index 076f7be18f..1e68e38eb8 100644 --- a/config/external/sqlite/moz.build +++ b/config/external/sqlite/moz.build @@ -2,19 +2,15 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -if CONFIG['MOZ_SYSTEM_SQLITE']: +DIRS += ['../../../third_party/sqlite3/src'] +if CONFIG['MOZ_FOLD_LIBS']: Library('sqlite') - OS_LIBS += CONFIG['SQLITE_LIBS'] + # When folding libraries, sqlite is actually in the nss library. + USE_LIBS += [ + 'nss', + ] else: - DIRS += ['../../../third_party/sqlite3/src'] - if CONFIG['MOZ_FOLD_LIBS']: - Library('sqlite') - # When folding libraries, sqlite is actually in the nss library. - USE_LIBS += [ - 'nss', - ] - else: - SharedLibrary('sqlite') - SHARED_LIBRARY_NAME = 'mozsqlite3' + SharedLibrary('sqlite') + SHARED_LIBRARY_NAME = 'mozsqlite3' - SYMBOLS_FILE = '/third_party/sqlite3/src/sqlite.symbols' + SYMBOLS_FILE = '/third_party/sqlite3/src/sqlite.symbols' diff --git a/config/make-stl-wrappers.py b/config/make-stl-wrappers.py index 7e6da5150b..803b15fc1a 100644 --- a/config/make-stl-wrappers.py +++ b/config/make-stl-wrappers.py @@ -1,6 +1,7 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import absolute_import from __future__ import print_function import os import string diff --git a/config/make-system-wrappers.py b/config/make-system-wrappers.py index 78c1454863..8636e244e8 100644 --- a/config/make-system-wrappers.py +++ b/config/make-system-wrappers.py @@ -1,6 +1,7 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import absolute_import from __future__ import print_function import os from mozbuild.util import FileAvoidWrite diff --git a/config/make-windows-h-wrapper.py b/config/make-windows-h-wrapper.py index fca3597e99..cda38dce66 100644 --- a/config/make-windows-h-wrapper.py +++ b/config/make-windows-h-wrapper.py @@ -2,6 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import absolute_import import re import textwrap import string diff --git a/config/makefiles/debugmake.mk b/config/makefiles/debugmake.mk index 0a04dfb3bf..3244781148 100644 --- a/config/makefiles/debugmake.mk +++ b/config/makefiles/debugmake.mk @@ -58,7 +58,6 @@ showbuild showhost: _DEPEND_CFLAGS= showbuild showhost: COMPILE_PDB_FLAG= showbuild: $(call print_vars,\ - MOZ_BUILD_ROOT \ MOZ_WIDGET_TOOLKIT \ CC \ CXX \ diff --git a/config/makefiles/rust.mk b/config/makefiles/rust.mk index a2064f84af..8ac1e9b818 100644 --- a/config/makefiles/rust.mk +++ b/config/makefiles/rust.mk @@ -141,7 +141,7 @@ target_rust_ltoable := force-cargo-library-build target_rust_nonltoable := force-cargo-test-run force-cargo-library-check $(foreach b,build check,force-cargo-program-$(b)) ifdef MOZ_PGO_RUST -rust_pgo_flags := $(if $(MOZ_PROFILE_GENERATE),-C profile-generate=$(topobjdir)) $(if $(MOZ_PROFILE_USE),-C profile-use=$(topobjdir)/merged.profdata) +rust_pgo_flags := $(if $(MOZ_PROFILE_GENERATE),-C profile-generate=$(topobjdir)) $(if $(MOZ_PROFILE_USE),-C profile-use=$(PGO_PROFILE_PATH)) endif $(target_rust_ltoable): RUSTFLAGS:=$(rustflags_override) $(RUSTFLAGS) $(if $(MOZ_LTO_RUST),-Clinker-plugin-lto) $(rust_pgo_flags) diff --git a/config/milestone.txt b/config/milestone.txt index 3f220a13cb..1776b4c61d 100644 --- a/config/milestone.txt +++ b/config/milestone.txt @@ -10,4 +10,4 @@ # hardcoded milestones in the tree from these two files. #-------------------------------------------------------- -68.14.4 +68.14.5 diff --git a/config/mozunit/mozunit/mozunit.py b/config/mozunit/mozunit/mozunit.py index 9619e58872..828c7e7a02 100644 --- a/config/mozunit/mozunit/mozunit.py +++ b/config/mozunit/mozunit/mozunit.py @@ -164,6 +164,7 @@ class MockedOpen(object): f.write('foo') self.assertRaises(Exception,f.open('foo', 'r')) ''' + def __init__(self, files={}): self.files = {} for name, content in files.items(): diff --git a/config/nsinstall.py b/config/nsinstall.py index 1ea0087048..adf03164cc 100644 --- a/config/nsinstall.py +++ b/config/nsinstall.py @@ -9,6 +9,7 @@ # a full build environment set up. # The basic limitation is, it doesn't even try to link and ignores # all related options. +from __future__ import absolute_import from __future__ import print_function from optparse import OptionParser import mozfile diff --git a/config/printconfigsetting.py b/config/printconfigsetting.py index c85f3ff4bc..e8e99ae947 100644 --- a/config/printconfigsetting.py +++ b/config/printconfigsetting.py @@ -2,6 +2,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import absolute_import +from __future__ import print_function import configobj import sys import re diff --git a/config/printprereleasesuffix.py b/config/printprereleasesuffix.py index 9ae050b5d1..cf8be72e45 100644 --- a/config/printprereleasesuffix.py +++ b/config/printprereleasesuffix.py @@ -9,6 +9,7 @@ # 2.1a3pre > "" # 3.2b4 > " 3.2 Beta 4" # 3.2b4pre > "" +from __future__ import absolute_import from __future__ import print_function import sys diff --git a/config/pythonpath.py b/config/pythonpath.py index b02cd44243..9c7878727d 100644 --- a/config/pythonpath.py +++ b/config/pythonpath.py @@ -2,6 +2,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import absolute_import +from __future__ import print_function """ Run a python script, adding extra directories to the python path. """ diff --git a/config/rebuild_check.py b/config/rebuild_check.py index ba17f7444a..c957bebcde 100644 --- a/config/rebuild_check.py +++ b/config/rebuild_check.py @@ -2,6 +2,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import absolute_import +from __future__ import print_function import os import errno diff --git a/config/recurse.mk b/config/recurse.mk index d45af11a48..cfac86fbcf 100644 --- a/config/recurse.mk +++ b/config/recurse.mk @@ -171,8 +171,7 @@ accessible/xpcom/export: xpcom/xpidl/export widget/android/bindings/export: mobile/android/base/export # The widget JNI wrapper generator code needs to build the GeckoView -# and Fennec source code in order to find JNI wrapper annotations. -widget/android/fennec/export: mobile/android/base/export +# source code in order to find JNI wrapper annotations. widget/android/export: mobile/android/base/export # .xpt generation needs the xpidl lex/yacc files diff --git a/config/rules.mk b/config/rules.mk index e266a1a298..3634114e21 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -175,20 +175,22 @@ endif ifdef COMPILE_ENVIRONMENT ifndef TARGETS -TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(HOST_SHARED_LIBRARY) +TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(HOST_SHARED_LIBRARY) $(WASM_LIBRARY) endif COBJS = $(notdir $(CSRCS:.c=.$(OBJ_SUFFIX))) +CWASMOBJS = $(notdir $(WASM_CSRCS:.c=.$(WASM_OBJ_SUFFIX))) SOBJS = $(notdir $(SSRCS:.S=.$(OBJ_SUFFIX))) # CPPSRCS can have different extensions (eg: .cpp, .cc) CPPOBJS = $(notdir $(addsuffix .$(OBJ_SUFFIX),$(basename $(CPPSRCS)))) +CPPWASMOBJS = $(notdir $(addsuffix .$(WASM_OBJ_SUFFIX),$(basename $(WASM_CPPSRCS)))) CMOBJS = $(notdir $(CMSRCS:.m=.$(OBJ_SUFFIX))) CMMOBJS = $(notdir $(CMMSRCS:.mm=.$(OBJ_SUFFIX))) # ASFILES can have different extensions (.s, .asm) ASOBJS = $(notdir $(addsuffix .$(OBJ_SUFFIX),$(basename $(ASFILES)))) RS_STATICLIB_CRATE_OBJ = $(addprefix lib,$(notdir $(RS_STATICLIB_CRATE_SRC:.rs=.$(LIB_SUFFIX)))) ifndef OBJS -_OBJS = $(COBJS) $(SOBJS) $(CPPOBJS) $(CMOBJS) $(CMMOBJS) $(ASOBJS) +_OBJS = $(COBJS) $(SOBJS) $(CPPOBJS) $(CMOBJS) $(CMMOBJS) $(ASOBJS) $(CWASMOBJS) $(CPPWASMOBJS) OBJS = $(strip $(_OBJS)) endif @@ -211,8 +213,11 @@ SIMPLE_PROGRAMS := HOST_SHARED_LIBRARY := HOST_PROGRAM := HOST_SIMPLE_PROGRAMS := +WASM_LIBRARY := endif +WASM_ARCHIVE = $(addsuffix .$(WASM_OBJ_SUFFIX),$(WASM_LIBRARY)) + ALL_TRASH = \ $(GARBAGE) $(TARGETS) $(OBJS) $(PROGOBJS) LOGS TAGS a.out \ $(filter-out $(ASFILES),$(OBJS:.$(OBJ_SUFFIX)=.s)) $(OBJS:.$(OBJ_SUFFIX)=.ii) \ @@ -224,7 +229,7 @@ ALL_TRASH = \ $(PROGRAM:$(BIN_SUFFIX)=.exp) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.exp) \ $(PROGRAM:$(BIN_SUFFIX)=.lib) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.lib) \ $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.$(OBJ_SUFFIX)) \ - $(wildcard gts_tmp_*) $(LIBRARY:%.a=.%.timestamp) + $(WASM_ARCHIVE) $(wildcard gts_tmp_*) $(LIBRARY:%.a=.%.timestamp) ALL_TRASH_DIRS = \ $(GARBAGE_DIRS) /no-such-file @@ -299,11 +304,7 @@ endif ifeq ($(OS_ARCH),Darwin) ifdef SHARED_LIBRARY -ifdef MOZ_IOS -_LOADER_PATH := @rpath -else _LOADER_PATH := @executable_path -endif EXTRA_DSO_LDOPTS += -dynamiclib -install_name $(_LOADER_PATH)/$(SHARED_LIBRARY) -compatibility_version 1 -current_version 1 -single_module endif endif @@ -403,13 +404,11 @@ GLOBAL_DEPS += Makefile $(addprefix $(DEPTH)/config/,$(INCLUDED_AUTOCONF_MK)) $( ############################################## ifdef COMPILE_ENVIRONMENT -OBJ_TARGETS = $(OBJS) $(PROGOBJS) $(HOST_OBJS) $(HOST_PROGOBJS) - compile:: host target host:: $(HOST_OBJS) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(HOST_RUST_PROGRAMS) $(HOST_RUST_LIBRARY_FILE) $(HOST_SHARED_LIBRARY) -target:: $(filter-out $(MOZBUILD_NON_DEFAULT_TARGETS),$(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(RUST_LIBRARY_FILE) $(RUST_PROGRAMS)) +target:: $(filter-out $(MOZBUILD_NON_DEFAULT_TARGETS),$(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(RUST_LIBRARY_FILE) $(RUST_PROGRAMS) $(WASM_LIBRARY)) ifndef LIBRARY ifdef OBJS @@ -425,64 +424,6 @@ syms:: include $(MOZILLA_DIR)/config/makefiles/target_binaries.mk endif -############################################## -ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE)) -ifdef MOZ_1TIER_PGO -ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_) -# When building with PGO, we have to make sure to re-link -# in the MOZ_PROFILE_USE phase if we linked in the -# MOZ_PROFILE_GENERATE phase. We'll touch this pgo.relink -# file in the link rule in the GENERATE phase to indicate -# that we need a relink. -ifdef SHARED_LIBRARY -$(SHARED_LIBRARY): pgo.relink -endif -ifdef PROGRAM -$(PROGRAM): pgo.relink -endif - -# In the second pass, we need to merge the pgc files into the pgd file. -# The compiler would do this for us automatically if they were in the right -# place, but they're in dist/bin. -ifneq (,$(SHARED_LIBRARY)$(PROGRAM)) -export:: -ifdef PROGRAM - $(PYTHON) $(MOZILLA_DIR)/build/win32/pgomerge.py \ - $(PROGRAM:$(BIN_SUFFIX)=) $(DIST)/bin -endif -ifdef SHARED_LIBRARY - $(PYTHON) $(MOZILLA_DIR)/build/win32/pgomerge.py \ - $(patsubst $(DLL_PREFIX)%$(DLL_SUFFIX),%,$(SHARED_LIBRARY)) $(DIST)/bin -endif -endif # SHARED_LIBRARY || PROGRAM -endif # WINNT_ -endif # MOZ_PROFILE_USE -ifdef MOZ_PROFILE_GENERATE -# Clean up profiling data during PROFILE_GENERATE phase -export:: -ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_) - $(foreach pgd,$(wildcard *.pgd),pgomgr -clear $(pgd);) -else -ifdef GNU_CC - -$(RM) *.gcda -endif -endif -endif - -ifneq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE)) -ifneq (,$(filter target,$(MAKECMDGOALS))) -ifdef GNU_CC -# Force rebuilding libraries and programs in both passes because each -# pass uses different object files. -$(PROGRAM) $(SHARED_LIBRARY) $(LIBRARY): FORCE -endif -endif -endif - -endif # NO_PROFILE_GUIDED_OPTIMIZE - -############################################## - clean clobber realclean clobber_all:: -$(RM) $(ALL_TRASH) -$(RM) -r $(ALL_TRASH_DIRS) @@ -514,7 +455,7 @@ $(PROGRAM): $(PROGOBJS) $(STATIC_LIBS) $(EXTRA_DEPS) $(RESFILE) $(GLOBAL_DEPS) $ $(REPORT_BUILD) @$(RM) $@.manifest ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH)) - $(LINKER) -NOLOGO -OUT:$@ -PDB:$(LINK_PDBFILE) -IMPLIB:$(basename $(@F)).lib $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_PROGRAM_LDFLAGS) $($(notdir $@)_$(OBJS_VAR_SUFFIX)) $(RESFILE) $(STATIC_LIBS) $(SHARED_LIBS) $(OS_LIBS) + $(LINKER) -NOLOGO -OUT:$@ -PDB:$(LINK_PDBFILE) -IMPLIB:$(basename $(@F)).lib $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_PROGRAM_LDFLAGS) $($(notdir $@)_OBJS) $(RESFILE) $(STATIC_LIBS) $(SHARED_LIBS) $(OS_LIBS) ifdef MSMANIFEST_TOOL @if test -f $@.manifest; then \ if test -f '$(srcdir)/$@.manifest'; then \ @@ -529,13 +470,8 @@ ifdef MSMANIFEST_TOOL $(MT) -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' -OUTPUTRESOURCE:$@\;1; \ fi endif # MSVC with manifest tool -ifdef MOZ_PROFILE_GENERATE -# touch it a few seconds into the future to work around FAT's -# 2-second granularity - touch -t `date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink -endif else # !WINNT || GNU_CC - $(call EXPAND_CC_OR_CXX,$@) -o $@ $(COMPUTED_CXX_LDFLAGS) $(PGO_CFLAGS) $($(notdir $@)_$(OBJS_VAR_SUFFIX)) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(OS_LIBS) + $(call EXPAND_CC_OR_CXX,$@) -o $@ $(COMPUTED_CXX_LDFLAGS) $(PGO_CFLAGS) $($(notdir $@)_OBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(OS_LIBS) $(call py_action,check_binary,--target $@) endif # WINNT && !GNU_CC @@ -586,7 +522,7 @@ endif $(SIMPLE_PROGRAMS): %$(BIN_SUFFIX): %.$(OBJ_SUFFIX) $(STATIC_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS) $(REPORT_BUILD) ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH)) - $(LINKER) -nologo -out:$@ -pdb:$(LINK_PDBFILE) $($@_$(OBJS_VAR_SUFFIX)) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_PROGRAM_LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(OS_LIBS) + $(LINKER) -nologo -out:$@ -pdb:$(LINK_PDBFILE) $($@_OBJS) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_PROGRAM_LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(OS_LIBS) ifdef MSMANIFEST_TOOL @if test -f $@.manifest; then \ $(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \ @@ -596,7 +532,7 @@ ifdef MSMANIFEST_TOOL fi endif # MSVC with manifest tool else - $(call EXPAND_CC_OR_CXX,$@) $(COMPUTED_CXX_LDFLAGS) $(PGO_CFLAGS) -o $@ $($@_$(OBJS_VAR_SUFFIX)) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(OS_LIBS) + $(call EXPAND_CC_OR_CXX,$@) $(COMPUTED_CXX_LDFLAGS) $(PGO_CFLAGS) -o $@ $($@_OBJS) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(OS_LIBS) $(call py_action,check_binary,--target $@) endif # WINNT && !GNU_CC @@ -625,7 +561,16 @@ endif $(LIBRARY): $(OBJS) $(STATIC_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS) $(REPORT_BUILD) $(RM) $(REAL_LIBRARY) - $(AR) $(AR_FLAGS) $($@_$(OBJS_VAR_SUFFIX)) + $(AR) $(AR_FLAGS) $($@_OBJS) + +$(WASM_ARCHIVE): $(CWASMOBJS) $(CPPWASMOBJS) $(STATIC_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS) + $(REPORT_BUILD_VERBOSE) + $(RM) $(WASM_LIBRARY).$(WASM_OBJ_SUFFIX) + $(WASM_CXX) $(OUTOPTION)$@ -Wl,--export-all $(WASM_LDFLAGS) $(CWASMOBJS) $(CPPWASMOBJS) +$(WASM_LIBRARY): $(WASM_LIBRARY).$(WASM_OBJ_SUFFIX) + $(REPORT_BUILD) + $(RM) $(WASM_LIBRARY) + $(LUCETC) --bindings $(topsrcdir)/third_party/rust/lucet-wasi/bindings.json $(WASM_LIBRARY).$(WASM_OBJ_SUFFIX) --opt-level 2 -o $(WASM_LIBRARY) ifeq ($(OS_ARCH),WINNT) # Import libraries are created by the rules creating shared libraries. @@ -657,7 +602,7 @@ $(SHARED_LIBRARY): $(OBJS) $(RESFILE) $(STATIC_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS ifndef INCREMENTAL_LINKER $(RM) $@ endif - $(MKSHLIB) $($@_$(OBJS_VAR_SUFFIX)) $(RESFILE) $(LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS) + $(MKSHLIB) $($@_OBJS) $(RESFILE) $(LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS) $(call py_action,check_binary,--target $@) ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH)) @@ -677,9 +622,6 @@ ifdef EMBED_MANIFEST_AT fi endif # EMBED_MANIFEST_AT endif # MSVC with manifest tool -ifdef MOZ_PROFILE_GENERATE - touch -t `date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink -endif endif # WINNT && !GCC chmod +x $@ ifdef ENABLE_STRIP @@ -696,6 +638,7 @@ $(basename $3$(notdir $1)).$2: $1 $$(call mkdir_deps,$$(MDDEPDIR)) endef $(foreach f,$(CSRCS) $(SSRCS) $(CPPSRCS) $(CMSRCS) $(CMMSRCS) $(ASFILES),$(eval $(call src_objdep,$(f),$(OBJ_SUFFIX)))) $(foreach f,$(HOST_CSRCS) $(HOST_CPPSRCS) $(HOST_CMSRCS) $(HOST_CMMSRCS),$(eval $(call src_objdep,$(f),$(_OBJ_SUFFIX),host_))) +$(foreach f,$(WASM_CSRCS) $(WASM_CPPSRCS),$(eval $(call src_objdep,$(f),wasm))) # The Rust compiler only outputs library objects, and so we need different # mangling to generate dependency rules for it. @@ -727,6 +670,10 @@ $(COBJS): $(REPORT_BUILD_VERBOSE) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $< +$(CWASMOBJS): + $(REPORT_BUILD_VERBOSE) + $(WASM_CC) $(OUTOPTION)$@ -c $(WASM_CFLAGS) $($(notdir $<)_FLAGS) $< + ifdef ASFILES # The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept # a '-c' flag. @@ -743,11 +690,9 @@ ifdef MOZ_CRASHREPORTER endif endef -ifndef MOZ_PROFILE_GENERATE ifneq (,$(filter $(DIST)/bin%,$(FINAL_TARGET))) DUMP_SYMS_TARGETS := $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) endif -endif ifdef MOZ_AUTOMATION ifeq (,$(filter 1,$(MOZ_AUTOMATION_BUILD_SYMBOLS))) @@ -785,6 +730,11 @@ $(CPPOBJS): $(call BUILDSTATUS,OBJECT_FILE $@) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $< +$(CPPWASMOBJS): + $(REPORT_BUILD_VERBOSE) + $(call BUILDSTATUS,OBJECT_FILE $@) + $(WASM_CXX) $(OUTOPTION)$@ -c $(WASM_CXXFLAGS) $($(notdir $<)_FLAGS) $< + $(CMMOBJS): $(REPORT_BUILD_VERBOSE) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $($(notdir $<)_FLAGS) $< @@ -1273,6 +1223,7 @@ FREEZE_VARIABLES = \ EXPORTS \ DIRS \ LIBRARY \ + WASM_LIBRARY \ MODULE \ $(NULL) diff --git a/config/run_spidermonkey_checks.py b/config/run_spidermonkey_checks.py index 1aed5ce913..9323fdf126 100644 --- a/config/run_spidermonkey_checks.py +++ b/config/run_spidermonkey_checks.py @@ -2,6 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import absolute_import import buildconfig import subprocess import sys diff --git a/config/system-headers.mozbuild b/config/system-headers.mozbuild index 9a00f9cde5..154d5119b5 100644 --- a/config/system-headers.mozbuild +++ b/config/system-headers.mozbuild @@ -1266,16 +1266,6 @@ if CONFIG['MOZ_SYSTEM_ZLIB']: 'zlib.h', ] -if CONFIG['MOZ_ENABLE_STARTUP_NOTIFICATION']: - system_headers += [ - 'libsn/sn-common.h', - 'libsn/sn.h', - 'libsn/sn-launchee.h', - 'libsn/sn-launcher.h', - 'libsn/sn-monitor.h', - 'libsn/sn-util.h', - ] - if CONFIG['MOZ_SYSTEM_LIBEVENT']: system_headers += [ 'event2/event_compat.h', @@ -1359,3 +1349,6 @@ if CONFIG['OS_TARGET'] == 'Linux' and CONFIG['CPU_ARCH'].startswith('mips'): system_headers += [ 'sys/cachectl.h', ] + +if CONFIG['MOZ_APP_SYSTEM_HEADERS']: + include("../" + CONFIG['MOZ_BUILD_APP'] + "/app-system-headers.mozbuild") diff --git a/config/system_header_util.py b/config/system_header_util.py index 6e7b30318f..a623c48ad4 100644 --- a/config/system_header_util.py +++ b/config/system_header_util.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import os diff --git a/config/tests/test_mozbuild_reading.py b/config/tests/test_mozbuild_reading.py index b95d3e3fc2..6bacf5d799 100644 --- a/config/tests/test_mozbuild_reading.py +++ b/config/tests/test_mozbuild_reading.py @@ -2,6 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import absolute_import from __future__ import unicode_literals import os @@ -77,7 +78,7 @@ class TestMozbuildReading(unittest.TestCase): try: config = mb.config_environment except Exception as e: - if e.message == 'config.status not available. Run configure.': + if str(e) == 'config.status not available. Run configure.': raise unittest.SkipTest('failing without config.status') raise diff --git a/config/tests/unit-mozunit.py b/config/tests/unit-mozunit.py index c217373732..90fd2bc705 100644 --- a/config/tests/unit-mozunit.py +++ b/config/tests/unit-mozunit.py @@ -2,6 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import absolute_import import os from mozunit import main, MockedOpen import unittest diff --git a/config/tests/unit-nsinstall.py b/config/tests/unit-nsinstall.py index cf3db6e18e..172d68a291 100644 --- a/config/tests/unit-nsinstall.py +++ b/config/tests/unit-nsinstall.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import unittest import os diff --git a/config/tests/unit-printprereleasesuffix.py b/config/tests/unit-printprereleasesuffix.py index ba76ce68c7..4a2382ece0 100644 --- a/config/tests/unit-printprereleasesuffix.py +++ b/config/tests/unit-printprereleasesuffix.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import unittest import mozunit diff --git a/config/tests/unitMozZipFile.py b/config/tests/unitMozZipFile.py index ecfb69ad95..e1765a2ab3 100644 --- a/config/tests/unitMozZipFile.py +++ b/config/tests/unitMozZipFile.py @@ -2,6 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import absolute_import import unittest import shutil diff --git a/configure.py b/configure.py index 5c83a7d0a7..4bb9e1349b 100644 --- a/configure.py +++ b/configure.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, print_function, unicode_literals import codecs +import errno import itertools import logging import os @@ -40,10 +41,35 @@ def main(argv): if sandbox._help: return 0 + logging.getLogger('moz.configure').info('Creating config.status') + + old_js_configure_substs = config.pop('OLD_JS_CONFIGURE_SUBSTS', None) + old_js_configure_defines = config.pop('OLD_JS_CONFIGURE_DEFINES', None) + if old_js_configure_substs or old_js_configure_defines: + js_config = config.copy() + pwd = os.getcwd() + try: + try: + os.makedirs('js/src') + except OSError as e: + if e.errno != errno.EEXIST: + raise + + os.chdir('js/src') + js_config['OLD_CONFIGURE_SUBSTS'] = old_js_configure_substs + js_config['OLD_CONFIGURE_DEFINES'] = old_js_configure_defines + # The build system frontend expects $objdir/js/src/config.status + # to have $objdir/js/src as topobjdir. + # We want forward slashes on all platforms. + js_config['TOPOBJDIR'] += '/js/src' + config_status(js_config, execute=False) + finally: + os.chdir(pwd) + return config_status(config) -def config_status(config): +def config_status(config, execute=True): # Sanitize config data to feed config.status # Ideally, all the backend and frontend code would handle the booleans, but # there are so many things involved, that it's easier to keep config.status @@ -58,13 +84,16 @@ def config_status(config): sanitized_config = {} sanitized_config['substs'] = { k: sanitized_bools(v) for k, v in config.iteritems() - if k not in ('DEFINES', 'non_global_defines', 'TOPSRCDIR', 'TOPOBJDIR', - 'CONFIG_STATUS_DEPS') + if k not in ('DEFINES', 'TOPSRCDIR', 'TOPOBJDIR', 'CONFIG_STATUS_DEPS', + 'OLD_CONFIGURE_SUBSTS', 'OLD_CONFIGURE_DEFINES') } + for k, v in config['OLD_CONFIGURE_SUBSTS']: + sanitized_config['substs'][k] = sanitized_bools(v) sanitized_config['defines'] = { k: sanitized_bools(v) for k, v in config['DEFINES'].iteritems() } - sanitized_config['non_global_defines'] = config['non_global_defines'] + for k, v in config['OLD_CONFIGURE_DEFINES']: + sanitized_config['defines'][k] = sanitized_bools(v) sanitized_config['topsrcdir'] = config['TOPSRCDIR'] sanitized_config['topobjdir'] = config['TOPOBJDIR'] sanitized_config['mozconfig'] = config.get('MOZCONFIG') @@ -72,7 +101,6 @@ def config_status(config): # Create config.status. Eventually, we'll want to just do the work it does # here, when we're able to skip configure tests/use cached results/not rely # on autoconf. - logging.getLogger('moz.configure').info('Creating config.status') encoding = 'mbcs' if sys.platform == 'win32' else 'utf-8' with codecs.open('config.status', 'w', encoding) as fh: fh.write(textwrap.dedent('''\ @@ -87,9 +115,9 @@ def config_status(config): for k, v in sanitized_config.iteritems(): fh.write('%s = encode(%s, encoding)\n' % (k, indented_repr(v))) fh.write("__all__ = ['topobjdir', 'topsrcdir', 'defines', " - "'non_global_defines', 'substs', 'mozconfig']") + "'substs', 'mozconfig']") - if config.get('MOZ_BUILD_APP') != 'js' or config.get('JS_STANDALONE'): + if execute: fh.write(textwrap.dedent(''' if __name__ == '__main__': from mozbuild.util import patch_main @@ -113,7 +141,7 @@ def config_status(config): # Other things than us are going to run this file, so we need to give it # executable permissions. os.chmod('config.status', 0o755) - if config.get('MOZ_BUILD_APP') != 'js' or config.get('JS_STANDALONE'): + if execute: from mozbuild.config_status import config_status # Some values in sanitized_config also have more complex types, such as diff --git a/devtools/client/aboutdebugging/src/actions/runtimes.js b/devtools/client/aboutdebugging/src/actions/runtimes.js index a0e133b897..bbc6cdcedc 100644 --- a/devtools/client/aboutdebugging/src/actions/runtimes.js +++ b/devtools/client/aboutdebugging/src/actions/runtimes.js @@ -56,23 +56,6 @@ const { const CONNECTION_TIMING_OUT_DELAY = 3000; const CONNECTION_CANCEL_DELAY = 13000; -async function getRuntimeIcon(runtime, channel) { - if (runtime.isFenix) { - switch (channel) { - case "release": - case "beta": - return "chrome://devtools/skin/images/aboutdebugging-fenix.svg"; - case "aurora": - default: - return "chrome://devtools/skin/images/aboutdebugging-fenix-nightly.svg"; - } - } - - return channel === "release" || channel === "beta" || channel === "aurora" - ? `chrome://devtools/skin/images/aboutdebugging-firefox-${channel}.svg` - : "chrome://devtools/skin/images/aboutdebugging-firefox-nightly.svg"; -} - function onRemoteDebuggerClientClosed() { window.AboutDebugging.onNetworkLocationsUpdated(); window.AboutDebugging.onUSBRuntimesUpdated(); @@ -121,7 +104,7 @@ function connectRuntime(id) { const deviceDescription = await clientWrapper.getDeviceDescription(); const compatibilityReport = await clientWrapper.checkVersionCompatibility(); - const icon = await getRuntimeIcon(runtime, deviceDescription.channel); + //const icon = "chrome://devtools/skin/images/aboutdebugging.svg" const { CONNECTION_PROMPT, @@ -165,7 +148,7 @@ function connectRuntime(id) { connectionPromptEnabled, info: { deviceName: deviceDescription.deviceName, - icon, + //icon, name: runtimeName, os: deviceDescription.os, type: runtime.type, diff --git a/devtools/client/aboutdebugging/src/components/sidebar/Sidebar.js b/devtools/client/aboutdebugging/src/components/sidebar/Sidebar.js index 8c4eee6ef1..8463327198 100644 --- a/devtools/client/aboutdebugging/src/components/sidebar/Sidebar.js +++ b/devtools/client/aboutdebugging/src/components/sidebar/Sidebar.js @@ -28,8 +28,8 @@ const SidebarItem = createFactory(require("./SidebarItem")); const SidebarFixedItem = createFactory(require("./SidebarFixedItem")); const SidebarRuntimeItem = createFactory(require("./SidebarRuntimeItem")); const RefreshDevicesButton = createFactory(require("./RefreshDevicesButton")); -const FIREFOX_ICON = - "chrome://devtools/skin/images/aboutdebugging-firefox-logo.svg"; +//const FIREFOX_ICON = +// "chrome://devtools/skin/images/aboutdebugging-firefox-logo.svg"; const CONNECT_ICON = "chrome://devtools/skin/images/settings.svg"; const GLOBE_ICON = "chrome://devtools/skin/images/aboutdebugging-globe-icon.svg"; @@ -213,7 +213,7 @@ class Sidebar extends PureComponent { Localized( { id: "about-debugging-sidebar-this-firefox", attrs: { name: true } }, SidebarFixedItem({ - icon: FIREFOX_ICON, + //icon: FIREFOX_ICON, isSelected: PAGE_TYPES.RUNTIME === selectedPage && selectedRuntimeId === RUNTIMES.THIS_FIREFOX, diff --git a/devtools/client/framework/test/browser.ini b/devtools/client/framework/test/browser.ini index d99ac7da5c..2de962275b 100644 --- a/devtools/client/framework/test/browser.ini +++ b/devtools/client/framework/test/browser.ini @@ -147,7 +147,6 @@ run-if = e10s [browser_toolbox_view_source_03.js] [browser_toolbox_view_source_04.js] [browser_toolbox_window_reload_target.js] -skip-if = os == 'win' && os_version == '6.1' && !debug # bug 1522720 [browser_toolbox_window_shortcuts.js] [browser_toolbox_window_title_changes.js] [browser_toolbox_window_title_frame_select.js] diff --git a/devtools/client/framework/test/browser_toolbox_window_reload_target.js b/devtools/client/framework/test/browser_toolbox_window_reload_target.js index 356e70441e..1e3314a4df 100644 --- a/devtools/client/framework/test/browser_toolbox_window_reload_target.js +++ b/devtools/client/framework/test/browser_toolbox_window_reload_target.js @@ -104,13 +104,30 @@ function testReload(shortcut, toolbox, toolID) { const mm = gBrowser.selectedBrowser.messageManager; return new Promise(resolve => { - // The inspector needs some special care. - const toolUpdated = - toolID === "inspector" - ? toolbox.getPanel("inspector").once("new-root") - : Promise.resolve(); + const observer = { + _isDocumentUnloaded: false, + _isNewRooted: false, + onMutation(mutations) { + for (const { type } of mutations) { + if (type === "documentUnload") { + this._isDocumentUnloaded = true; + } else if (type === "newRoot") { + this._isNewRooted = true; + } + } + }, + isReady() { + return this._isDocumentUnloaded && this._isNewRooted; + }, + }; + + if (toolbox.walker) { + observer.onMutation = observer.onMutation.bind(observer); + toolbox.walker.on("mutations", observer.onMutation); + } else { + observer.isReady = () => true; + } - const complete = () => { // If we have a jsdebugger panel, wait for it to complete its reload const jsdebugger = toolbox.getPanel("jsdebugger"); let onReloaded = Promise.resolve; @@ -118,9 +135,15 @@ function testReload(shortcut, toolbox, toolID) { onReloaded = jsdebugger.once("reloaded"); } + const complete = async () => { mm.removeMessageListener("devtools:test:load", complete); - toolUpdated.then(resolve); + // Wait for the documentUnload and newRoot were fired. + await waitUntil(() => observer.isReady()); + if (toolbox.walker) { + toolbox.walker.off("mutations", observer.onMutation); + } await onReloaded; + resolve(); }; mm.addMessageListener("devtools:test:load", complete); diff --git a/devtools/client/inspector/rules/test/browser.ini b/devtools/client/inspector/rules/test/browser.ini index 04cd3ab69f..2811c089b0 100644 --- a/devtools/client/inspector/rules/test/browser.ini +++ b/devtools/client/inspector/rules/test/browser.ini @@ -234,10 +234,13 @@ skip-if = os == 'linux' # focusEditableField times out consistently on linux. [browser_rules_multiple_properties_02.js] [browser_rules_non_ascii.js] [browser_rules_original-source-link.js] +skip-if = ccov #Bug 1432176 [browser_rules_original-source-link2.js] +skip-if = ccov #Bug 1432176 [browser_rules_preview-tooltips-sizes.js] [browser_rules_pseudo-element_01.js] [browser_rules_pseudo-element_02.js] +[browser_rules_pseudo-visited.js] [browser_rules_pseudo_lock_options.js] [browser_rules_refresh-no-flicker.js] [browser_rules_refresh-on-attribute-change_01.js] diff --git a/devtools/client/inspector/rules/test/browser_rules_pseudo-visited.js b/devtools/client/inspector/rules/test/browser_rules_pseudo-visited.js new file mode 100644 index 0000000000..f7f891ade7 --- /dev/null +++ b/devtools/client/inspector/rules/test/browser_rules_pseudo-visited.js @@ -0,0 +1,44 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Tests for visited/unvisited rule. + +const VISISTED_URI = URL_ROOT + "doc_variables_1.html"; + +const TEST_URI = ` + + visited link + unvisited link +`; + +add_task(async () => { + info("Open a particular url to make a visited link"); + const tab = await addTab(VISISTED_URI); + + info("Open tested page in the same tab"); + await BrowserTestUtils.loadURI( + tab.linkedBrowser, + "data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI) + ); + + info("Open the inspector"); + const { inspector, view } = await openRuleView(); + + info("Check whether the rule view is shown correctly for visited element"); + await selectNode("#visited", inspector); + ok(getRuleViewRule(view, "a:visited"), "Rule of a:visited is shown"); + ok(!getRuleViewRule(view, "a:link"), "Rule of a:link is not shown"); + ok(getRuleViewRule(view, "a"), "Rule of a is shown"); + + info("Check whether the rule view is shown correctly for unvisited element"); + await selectNode("#unvisited", inspector); + ok(!getRuleViewRule(view, "a:visited"), "Rule of a:visited is not shown"); + ok(getRuleViewRule(view, "a:link"), "Rule of a:link is shown"); + ok(getRuleViewRule(view, "a"), "Rule of a is shown"); +}); diff --git a/devtools/client/inspector/rules/test/browser_rules_pseudo_lock_options.js b/devtools/client/inspector/rules/test/browser_rules_pseudo_lock_options.js index f1e5630d55..a219b63464 100644 --- a/devtools/client/inspector/rules/test/browser_rules_pseudo_lock_options.js +++ b/devtools/client/inspector/rules/test/browser_rules_pseudo_lock_options.js @@ -23,6 +23,9 @@ const TEST_URI = ` div:focus-within { color: papayawhip; } + div:visited { + color: orange; + }
test div
`; diff --git a/devtools/client/jar.mn b/devtools/client/jar.mn index b5b407a529..5a2475e31d 100644 --- a/devtools/client/jar.mn +++ b/devtools/client/jar.mn @@ -88,13 +88,8 @@ devtools.jar: skin/images/filter-swatch.svg (themes/images/filter-swatch.svg) skin/images/aboutdebugging-connect-icon.svg (themes/images/aboutdebugging-connect-icon.svg) skin/images/aboutdebugging-error.svg (themes/images/aboutdebugging-error.svg) - skin/images/aboutdebugging-fenix-nightly.svg (themes/images/aboutdebugging-fenix-nightly.svg) - skin/images/aboutdebugging-fenix.svg (themes/images/aboutdebugging-fenix.svg) - skin/images/aboutdebugging-firefox-aurora.svg (themes/images/aboutdebugging-firefox-aurora.svg) - skin/images/aboutdebugging-firefox-beta.svg (themes/images/aboutdebugging-firefox-beta.svg) - skin/images/aboutdebugging-firefox-logo.svg (themes/images/aboutdebugging-firefox-logo.svg) - skin/images/aboutdebugging-firefox-nightly.svg (themes/images/aboutdebugging-firefox-nightly.svg) - skin/images/aboutdebugging-firefox-release.svg (themes/images/aboutdebugging-firefox-release.svg) +# skin/images/aboutdebugging-firefox-logo.svg (themes/images/aboutdebugging-firefox-logo.svg) +# skin/images/aboutdebugging-firefox-release.svg (themes/images/aboutdebugging-firefox-release.svg) skin/images/aboutdebugging-globe-icon.svg (themes/images/aboutdebugging-globe-icon.svg) skin/images/aboutdebugging-information.svg (themes/images/aboutdebugging-information.svg) skin/images/aboutdebugging-process-icon.svg (themes/images/aboutdebugging-process-icon.svg) diff --git a/devtools/client/locales/en-US/markers.properties b/devtools/client/locales/en-US/markers.properties index 030082ad04..23d5a73df9 100644 --- a/devtools/client/locales/en-US/markers.properties +++ b/devtools/client/locales/en-US/markers.properties @@ -118,7 +118,7 @@ marker.gcreason.label.PERIODIC_FULL_GC=Periodic Full GC marker.gcreason.label.INCREMENTAL_TOO_SLOW=Allocations Rate Too Fast marker.gcreason.label.COMPONENT_UTILS=Cu.forceGC marker.gcreason.label.MEM_PRESSURE=Low Memory -marker.gcreason.label.CC_WAITING=Forced by Cycle Collection +marker.gcreason.label.CC_FINISHED=Cycle Collection Finished marker.gcreason.label.CC_FORCED=Forced by Cycle Collection marker.gcreason.label.LOAD_END=Page Load Finished marker.gcreason.label.PAGE_HIDE=Moved to Background diff --git a/devtools/client/responsive/browser/tunnel.js b/devtools/client/responsive/browser/tunnel.js index 8eff13e9f5..e6401b8726 100644 --- a/devtools/client/responsive/browser/tunnel.js +++ b/devtools/client/responsive/browser/tunnel.js @@ -30,7 +30,6 @@ const SWAPPED_BROWSER_STATE = [ "_contentTitle", "_characterSet", "_contentPrincipal", - "_imageDocument", "_isSyntheticDocument", "_innerWindowID", ]; @@ -107,7 +106,6 @@ function tunnelToInnerBrowser(outer, inner) { inner._documentContentType = outer._documentContentType; inner._contentTitle = outer._contentTitle; inner._characterSet = outer._characterSet; - inner._imageDocument = outer._imageDocument; inner._isSyntheticDocument = outer._isSyntheticDocument; inner._innerWindowID = outer._innerWindowID; inner._remoteWebNavigationImpl._currentURI = @@ -482,7 +480,6 @@ MessageManagerTunnel.prototype = { "PageStyle:StyleSheets", // Messages sent to browser.js "DOMTitleChanged", - "ImageDocumentLoaded", "Forms:ShowDropDown", "Forms:HideDropDown", "InPermitUnload", diff --git a/devtools/client/themes/images/aboutdebugging-fenix-nightly.svg b/devtools/client/themes/images/aboutdebugging-fenix-nightly.svg deleted file mode 100644 index c87c2988a1..0000000000 --- a/devtools/client/themes/images/aboutdebugging-fenix-nightly.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/devtools/client/themes/images/aboutdebugging-fenix.svg b/devtools/client/themes/images/aboutdebugging-fenix.svg deleted file mode 100644 index 2a145d5013..0000000000 --- a/devtools/client/themes/images/aboutdebugging-fenix.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/devtools/client/themes/images/aboutdebugging-firefox-aurora.svg b/devtools/client/themes/images/aboutdebugging-firefox-aurora.svg deleted file mode 100644 index 7346d54b94..0000000000 --- a/devtools/client/themes/images/aboutdebugging-firefox-aurora.svg +++ /dev/null @@ -1,4 +0,0 @@ - -firefox-logo-developer-edition diff --git a/devtools/client/themes/images/aboutdebugging-firefox-beta.svg b/devtools/client/themes/images/aboutdebugging-firefox-beta.svg deleted file mode 100644 index 6cdc237fa9..0000000000 --- a/devtools/client/themes/images/aboutdebugging-firefox-beta.svg +++ /dev/null @@ -1,4 +0,0 @@ - -firefox-logo-beta diff --git a/devtools/client/themes/images/aboutdebugging-firefox-logo.svg b/devtools/client/themes/images/aboutdebugging-firefox-logo.svg deleted file mode 100644 index 7e9522a3be..0000000000 --- a/devtools/client/themes/images/aboutdebugging-firefox-logo.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/devtools/client/themes/images/aboutdebugging-firefox-nightly.svg b/devtools/client/themes/images/aboutdebugging-firefox-nightly.svg deleted file mode 100644 index bfed2982bc..0000000000 --- a/devtools/client/themes/images/aboutdebugging-firefox-nightly.svg +++ /dev/null @@ -1,4 +0,0 @@ - -firefox-logo-nightly diff --git a/devtools/client/themes/images/aboutdebugging-firefox-release.svg b/devtools/client/themes/images/aboutdebugging-firefox-release.svg deleted file mode 100644 index 46f2a42421..0000000000 --- a/devtools/client/themes/images/aboutdebugging-firefox-release.svg +++ /dev/null @@ -1,4 +0,0 @@ - -firefox-logo diff --git a/devtools/server/actors/animation-type-longhand.js b/devtools/server/actors/animation-type-longhand.js index 22217f4cb0..89bc990cf1 100644 --- a/devtools/server/actors/animation-type-longhand.js +++ b/devtools/server/actors/animation-type-longhand.js @@ -36,7 +36,6 @@ exports.ANIMATION_TYPE_FOR_LONGHANDS = [ "-moz-box-orient", "-moz-box-pack", "box-sizing", - "-moz-button-appearance", "caption-side", "clear", "clip-rule", diff --git a/devtools/server/actors/breakpoint.js b/devtools/server/actors/breakpoint.js index 1c2f5b9a5a..8ea43d5937 100644 --- a/devtools/server/actors/breakpoint.js +++ b/devtools/server/actors/breakpoint.js @@ -169,7 +169,7 @@ BreakpointActor.prototype = { * @param frame Debugger.Frame * The stack frame that contained the breakpoint. */ - /* eslint-disable complexity */ + // eslint-disable-next-line complexity hit: function(frame) { // Don't pause if we are currently stepping (in or over) or the frame is // black-boxed. @@ -231,7 +231,6 @@ BreakpointActor.prototype = { return this.threadActor._pauseAndRespond(frame, reason); }, - /* eslint-enable complexity */ delete: function() { // Remove from the breakpoint store. diff --git a/devtools/server/actors/highlighters/flexbox.js b/devtools/server/actors/highlighters/flexbox.js index 99b1096efd..ebee53aaf9 100644 --- a/devtools/server/actors/highlighters/flexbox.js +++ b/devtools/server/actors/highlighters/flexbox.js @@ -943,10 +943,7 @@ function getRectFromFlexItemValues(item, container) { domRect.x -= paddingLeft + scrollX; domRect.y -= paddingTop + scrollY; - if ( - style.overflow === "visible" || - style.overflow === "-moz-hidden-unscrollable" - ) { + if (style.overflow === "visible" || style.overflow === "clip") { domRect.x -= borderLeftWidth; domRect.y -= borderTopWidth; } diff --git a/devtools/server/actors/storage.js b/devtools/server/actors/storage.js index 39c1879b0e..9351c5b293 100644 --- a/devtools/server/actors/storage.js +++ b/devtools/server/actors/storage.js @@ -589,7 +589,7 @@ StorageActors.createActor( case cookie.SAMESITE_STRICT: return COOKIE_SAMESITE.STRICT; } - // cookie.SAMESITE_UNSET + // cookie.SAMESITE_NONE return COOKIE_SAMESITE.UNSET; }, diff --git a/devtools/server/actors/styles.js b/devtools/server/actors/styles.js index 3cb4a016a5..6bd0dee94c 100644 --- a/devtools/server/actors/styles.js +++ b/devtools/server/actors/styles.js @@ -101,6 +101,8 @@ const BOLD_FONT_WEIGHT = 700; // Offset (in px) to avoid cutting off text edges of italic fonts. const FONT_PREVIEW_OFFSET = 4; +const NS_EVENT_STATE_VISITED = 1 << 24; + /** * The PageStyle actor lets the client look at the styles on a page, as * they are applied to a given node. @@ -770,7 +772,12 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, { * @returns Array */ _getElementRules: function(node, pseudo, inherited, options) { - const domRules = InspectorUtils.getCSSStyleRules(node, pseudo); + const domRules = InspectorUtils.getCSSStyleRules( + node, + pseudo, + _hasVisitedState(node) + ); + if (!domRules) { return []; } @@ -802,6 +809,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, { } const ruleActor = this._styleRef(domRule); + rules.push({ rule: ruleActor, inherited: inherited, @@ -885,14 +893,17 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, { const { bindingElement, pseudo } = CssLogic.getBindingElementAndPseudo( element ); + const relevantLinkVisited = _hasVisitedState(bindingElement); entry.matchedSelectors = []; + for (let i = 0; i < selectors.length; i++) { if ( InspectorUtils.selectorMatchesElement( bindingElement, domRule, i, - pseudo + pseudo, + relevantLinkVisited ) ) { entry.matchedSelectors.push(selectors[i]); @@ -2231,3 +2242,10 @@ function getTextAtLineColumn(text, line, column) { } exports.getTextAtLineColumn = getTextAtLineColumn; + +function _hasVisitedState(node) { + return ( + !!(InspectorUtils.getContentState(node) & NS_EVENT_STATE_VISITED) || + InspectorUtils.hasPseudoClassLock(node, ":visited") + ); +} diff --git a/devtools/shared/css/constants.js b/devtools/shared/css/constants.js index e3879971c5..58974742fc 100644 --- a/devtools/shared/css/constants.js +++ b/devtools/shared/css/constants.js @@ -27,6 +27,11 @@ exports.CSS_TYPES = { /** * Supported pseudo-class locks in the order in which they appear in the pseudo-class * panel in the Rules sidebar panel of the Inspector. - * FIXME: add ":visited" and ":link" after bug 713106 is fixed */ -exports.PSEUDO_CLASSES = [":hover", ":active", ":focus", ":focus-within"]; +exports.PSEUDO_CLASSES = [ + ":hover", + ":active", + ":focus", + ":focus-within", + ":visited", +]; diff --git a/devtools/shared/css/generated/properties-db.js b/devtools/shared/css/generated/properties-db.js index 1b33f253cc..d792a63630 100644 --- a/devtools/shared/css/generated/properties-db.js +++ b/devtools/shared/css/generated/properties-db.js @@ -8481,6 +8481,7 @@ exports.CSS_PROPERTIES = { "values": [ "-moz-hidden-unscrollable", "auto", + "clip", "hidden", "inherit", "initial", @@ -8514,6 +8515,7 @@ exports.CSS_PROPERTIES = { "values": [ "-moz-hidden-unscrollable", "auto", + "clip", "hidden", "inherit", "initial", @@ -8532,6 +8534,7 @@ exports.CSS_PROPERTIES = { "values": [ "-moz-hidden-unscrollable", "auto", + "clip", "hidden", "inherit", "initial", @@ -8566,6 +8569,7 @@ exports.CSS_PROPERTIES = { "values": [ "-moz-hidden-unscrollable", "auto", + "clip", "hidden", "inherit", "initial", @@ -8584,6 +8588,7 @@ exports.CSS_PROPERTIES = { "values": [ "-moz-hidden-unscrollable", "auto", + "clip", "hidden", "inherit", "initial", diff --git a/docshell/base/BrowsingContext.h b/docshell/base/BrowsingContext.h index aa321d0ff4..fa3ddb3e98 100644 --- a/docshell/base/BrowsingContext.h +++ b/docshell/base/BrowsingContext.h @@ -222,7 +222,6 @@ class BrowsingContext : public nsWrapperCache, public BrowsingContextBase { mWindowProxy = aWindowProxy; } - MOZ_DECLARE_WEAKREFERENCE_TYPENAME(BrowsingContext) NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(BrowsingContext) NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(BrowsingContext) diff --git a/docshell/base/moz.build b/docshell/base/moz.build index d6fa2f47de..068ec34e72 100644 --- a/docshell/base/moz.build +++ b/docshell/base/moz.build @@ -3,13 +3,13 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. with Files('**'): - BUG_COMPONENT = ('Core', 'Document Navigation') + BUG_COMPONENT = ('Core', 'DOM: Navigation') with Files('crashtests/430628*'): - BUG_COMPONENT = ('Core', 'Editor') + BUG_COMPONENT = ('Core', 'DOM: Editor') with Files('crashtests/432114*'): - BUG_COMPONENT = ('Core', 'Editor') + BUG_COMPONENT = ('Core', 'DOM: Editor') with Files('crashtests/500328*'): BUG_COMPONENT = ('Firefox', 'Bookmarks & History') diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 4ac2f27d0f..bc86134b6c 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -119,7 +119,7 @@ class nsDocShell final : public nsDocLoader, public nsIDOMStorageManager, public nsINetworkInterceptController, public nsIDeprecationWarner, - public mozilla::SupportsWeakPtr { + public mozilla::SupportsWeakPtr { public: enum InternalLoad : uint32_t { INTERNAL_LOAD_FLAGS_NONE = 0x0, @@ -174,11 +174,10 @@ class nsDocShell final : public nsDocLoader, private: virtual ~InterfaceRequestorProxy(); - InterfaceRequestorProxy() {} + InterfaceRequestorProxy() = default; nsWeakPtr mWeakPtr; }; - MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsDocShell) NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDocShell, nsDocLoader) NS_DECL_NSIDOCSHELL diff --git a/docshell/moz.build b/docshell/moz.build index 1586a5ad74..feca60ee87 100644 --- a/docshell/moz.build +++ b/docshell/moz.build @@ -3,7 +3,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. with Files('**'): - BUG_COMPONENT = ('Core', 'Document Navigation') + BUG_COMPONENT = ('Core', 'DOM: Navigation') DIRS += [ 'base', diff --git a/docshell/test/moz.build b/docshell/test/moz.build index fdb49cb198..a02cd1c405 100644 --- a/docshell/test/moz.build +++ b/docshell/test/moz.build @@ -1,5 +1,5 @@ with Files('**'): - BUG_COMPONENT = ('Core', 'Document Navigation') + BUG_COMPONENT = ('Core', 'DOM: Navigation') with Files('browser/*_bug234628*'): BUG_COMPONENT = ('Core', 'Internationalization') @@ -58,10 +58,6 @@ with Files('chrome/*690056*'): with Files('chrome/*92598*'): BUG_COMPONENT = ('Core', 'Networking: HTTP') -with Files('chrome/*private_hidden_window*'): - BUG_COMPONENT = ('Firefox', 'Private Browsing') - - with Files('iframesandbox/**'): BUG_COMPONENT = ('Core', 'Security') @@ -113,13 +109,13 @@ with Files('navigation/*13871.html'): BUG_COMPONENT = ('Core', 'Security') with Files('navigation/*386782*'): - BUG_COMPONENT = ('Core', 'Editor') + BUG_COMPONENT = ('Core', 'DOM: Editor') with Files('navigation/*430624*'): - BUG_COMPONENT = ('Core', 'Editor') + BUG_COMPONENT = ('Core', 'DOM: Editor') with Files('navigation/*430723*'): - BUG_COMPONENT = ('Core', 'User events and focus handling') + BUG_COMPONENT = ('Core', 'DOM: UI Events & Focus Handling') with Files('navigation/*child*'): BUG_COMPONENT = ('Core', 'Security') diff --git a/editor/libeditor/CompositionTransaction.h b/editor/libeditor/CompositionTransaction.h index 3621eebdb9..80a977defc 100644 --- a/editor/libeditor/CompositionTransaction.h +++ b/editor/libeditor/CompositionTransaction.h @@ -28,9 +28,8 @@ class Text; * composition string, modifying the composition string or its IME selection * ranges and commit or cancel the composition. */ -class CompositionTransaction final - : public EditTransactionBase, - public SupportsWeakPtr { +class CompositionTransaction final : public EditTransactionBase, + public SupportsWeakPtr { protected: CompositionTransaction(EditorBase& aEditorBase, const nsAString& aStringToInsert, @@ -53,8 +52,6 @@ class CompositionTransaction final EditorBase& aEditorBase, const nsAString& aStringToInsert, const EditorDOMPointInText& aPointToInsert); - MOZ_DECLARE_WEAKREFERENCE_TYPENAME(CompositionTransaction) - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CompositionTransaction, EditTransactionBase) diff --git a/editor/libeditor/EditorEventListener.cpp b/editor/libeditor/EditorEventListener.cpp index 8410d351b1..de2877cb99 100644 --- a/editor/libeditor/EditorEventListener.cpp +++ b/editor/libeditor/EditorEventListener.cpp @@ -443,7 +443,7 @@ NS_IMETHODIMP EditorEventListener::HandleEvent(Event* aEvent) { case eMouseClick: { WidgetMouseEvent* widgetMouseEvent = internalEvent->AsMouseEvent(); // Don't handle non-primary click events - if (widgetMouseEvent->mButton != MouseButton::eLeft) { + if (widgetMouseEvent->mButton != MouseButton::ePrimary) { return NS_OK; } [[fallthrough]]; diff --git a/editor/libeditor/HTMLEditor.h b/editor/libeditor/HTMLEditor.h index 1774ab6e8a..801a8e45fe 100644 --- a/editor/libeditor/HTMLEditor.h +++ b/editor/libeditor/HTMLEditor.h @@ -3242,10 +3242,11 @@ class HTMLEditor final : public TextEditor, * @param aRv Returns error if layout information is not * available or given element is not a table cell. */ - CellIndexes(Element& aCellElement, ErrorResult& aRv) + MOZ_CAN_RUN_SCRIPT CellIndexes(Element& aCellElement, PresShell* aPresShell, + ErrorResult& aRv) : mRow(-1), mColumn(-1) { MOZ_ASSERT(!aRv.Failed()); - Update(aCellElement, aRv); + Update(aCellElement, aPresShell, aRv); } /** @@ -3253,7 +3254,8 @@ class HTMLEditor final : public TextEditor, * * @param See above. */ - void Update(Element& aCellElement, ErrorResult& aRv); + MOZ_CAN_RUN_SCRIPT void Update(Element& aCellElement, PresShell* aPresShell, + ErrorResult& aRv); /** * This constructor initializes mRowIndex and mColumnIndex with indexes of @@ -3265,8 +3267,8 @@ class HTMLEditor final : public TextEditor, * which contains anchor of Selection, or layout * information is not available. */ - CellIndexes(HTMLEditor& aHTMLEditor, Selection& aSelection, - ErrorResult& aRv) + MOZ_CAN_RUN_SCRIPT CellIndexes(HTMLEditor& aHTMLEditor, + Selection& aSelection, ErrorResult& aRv) : mRow(-1), mColumn(-1) { Update(aHTMLEditor, aSelection, aRv); } @@ -3277,8 +3279,8 @@ class HTMLEditor final : public TextEditor, * * @param See above. */ - void Update(HTMLEditor& aHTMLEditor, Selection& aSelection, - ErrorResult& aRv); + MOZ_CAN_RUN_SCRIPT void Update(HTMLEditor& aHTMLEditor, + Selection& aSelection, ErrorResult& aRv); bool operator==(const CellIndexes& aOther) const { return mRow == aOther.mRow && mColumn == aOther.mColumn; @@ -3304,8 +3306,8 @@ class HTMLEditor final : public TextEditor, * first range is in the cell element, this does not treat it as the * cell element is selected. */ - CellAndIndexes(HTMLEditor& aHTMLEditor, Selection& aSelection, - ErrorResult& aRv) { + MOZ_CAN_RUN_SCRIPT CellAndIndexes(HTMLEditor& aHTMLEditor, + Selection& aSelection, ErrorResult& aRv) { Update(aHTMLEditor, aSelection, aRv); } @@ -3315,8 +3317,8 @@ class HTMLEditor final : public TextEditor, * in the cell element, this does not treat it as the cell element is * selected. */ - void Update(HTMLEditor& aHTMLEditor, Selection& aSelection, - ErrorResult& aRv); + MOZ_CAN_RUN_SCRIPT void Update(HTMLEditor& aHTMLEditor, + Selection& aSelection, ErrorResult& aRv); }; struct MOZ_STACK_CLASS CellData final { @@ -4100,9 +4102,11 @@ class HTMLEditor final : public TextEditor, * Returns NS_EDITOR_ELEMENT_NOT_FOUND if cell is not found even if aCell is * null. */ - nsresult GetCellContext(Element** aTable, Element** aCell, - nsINode** aCellParent, int32_t* aCellOffset, - int32_t* aRowIndex, int32_t* aColIndex); + MOZ_CAN_RUN_SCRIPT nsresult GetCellContext(Element** aTable, Element** aCell, + nsINode** aCellParent, + int32_t* aCellOffset, + int32_t* aRowIndex, + int32_t* aColIndex); nsresult GetCellSpansAt(Element* aTable, int32_t aRowIndex, int32_t aColIndex, int32_t& aActualRowSpan, int32_t& aActualColSpan); diff --git a/editor/libeditor/HTMLTableEditor.cpp b/editor/libeditor/HTMLTableEditor.cpp index 56c468aa2e..c720141772 100644 --- a/editor/libeditor/HTMLTableEditor.cpp +++ b/editor/libeditor/HTMLTableEditor.cpp @@ -1131,7 +1131,8 @@ nsresult HTMLEditor::DeleteTableCellWithTransaction( // When 2 or more cells are selected, ignore aNumberOfCellsToRemove and // remove all selected cells. - CellIndexes firstCellIndexes(*firstSelectedCellElement, error); + const RefPtr presShell{GetPresShell()}; + CellIndexes firstCellIndexes(*firstSelectedCellElement, presShell, error); if (error.Failed()) { NS_WARNING("CellIndexes failed"); return error.StealNSResult(); @@ -1166,7 +1167,7 @@ nsresult HTMLEditor::DeleteTableCellWithTransaction( if (!cell) { break; } - CellIndexes nextSelectedCellIndexes(*cell, error); + CellIndexes nextSelectedCellIndexes(*cell, presShell, error); if (error.Failed()) { NS_WARNING("CellIndexes failed"); return error.StealNSResult(); @@ -1223,7 +1224,7 @@ nsresult HTMLEditor::DeleteTableCellWithTransaction( if (!cell) { break; } - CellIndexes nextSelectedCellIndexes(*cell, error); + CellIndexes nextSelectedCellIndexes(*cell, presShell, error); if (error.Failed()) { NS_WARNING("CellIndexes failed"); return error.StealNSResult(); @@ -1273,7 +1274,7 @@ nsresult HTMLEditor::DeleteTableCellWithTransaction( return NS_OK; } - CellIndexes nextCellIndexes(*nextCell, error); + CellIndexes nextCellIndexes(*nextCell, presShell, error); if (error.Failed()) { NS_WARNING("CellIndexes failed"); return error.StealNSResult(); @@ -1351,7 +1352,8 @@ nsresult HTMLEditor::DeleteTableCellContentsWithTransaction() { } if (firstSelectedCellElement) { - CellIndexes firstCellIndexes(*firstSelectedCellElement, error); + const RefPtr presShell{GetPresShell()}; + CellIndexes firstCellIndexes(*firstSelectedCellElement, presShell, error); if (error.Failed()) { NS_WARNING("CellIndexes failed"); return error.StealNSResult(); @@ -1464,7 +1466,8 @@ nsresult HTMLEditor::DeleteSelectedTableColumnsWithTransaction( MOZ_ASSERT(SelectionRefPtr()->RangeCount()); if (firstSelectedCellElement && SelectionRefPtr()->RangeCount() > 1) { - CellIndexes firstCellIndexes(*firstSelectedCellElement, error); + const RefPtr presShell{GetPresShell()}; + CellIndexes firstCellIndexes(*firstSelectedCellElement, presShell, error); if (error.Failed()) { NS_WARNING("CellIndexes failed"); return error.StealNSResult(); @@ -1494,9 +1497,10 @@ nsresult HTMLEditor::DeleteSelectedTableColumnsWithTransaction( // If 2 or more cells are selected, remove all columns which contain selected // cells. I.e., we ignore aNumberOfColumnsToDelete in this case. + const RefPtr presShell{GetPresShell()}; for (cell = firstSelectedCellElement; cell;) { if (cell != firstSelectedCellElement) { - CellIndexes cellIndexes(*cell, error); + CellIndexes cellIndexes(*cell, presShell, error); if (error.Failed()) { NS_WARNING("CellIndexes failed"); return error.StealNSResult(); @@ -1516,7 +1520,7 @@ nsresult HTMLEditor::DeleteSelectedTableColumnsWithTransaction( if (!cell) { break; } - CellIndexes cellIndexes(*cell, error); + CellIndexes cellIndexes(*cell, presShell, error); if (error.Failed()) { NS_WARNING("CellIndexes failed"); return error.StealNSResult(); @@ -1721,7 +1725,8 @@ nsresult HTMLEditor::DeleteSelectedTableRowsWithTransaction( if (firstSelectedCellElement && SelectionRefPtr()->RangeCount() > 1) { // Fetch indexes again - may be different for selected cells - CellIndexes firstCellIndexes(*firstSelectedCellElement, error); + const RefPtr presShell{GetPresShell()}; + CellIndexes firstCellIndexes(*firstSelectedCellElement, presShell, error); if (error.Failed()) { NS_WARNING("CellIndexes failed"); return error.StealNSResult(); @@ -1765,9 +1770,10 @@ nsresult HTMLEditor::DeleteSelectedTableRowsWithTransaction( // If 2 or more cells are selected, remove all rows which contain selected // cells. I.e., we ignore aNumberOfRowsToDelete in this case. + const RefPtr presShell{GetPresShell()}; for (cell = firstSelectedCellElement; cell;) { if (cell != firstSelectedCellElement) { - CellIndexes cellIndexes(*cell, error); + CellIndexes cellIndexes(*cell, presShell, error); if (error.Failed()) { NS_WARNING("CellIndexes failed"); return error.StealNSResult(); @@ -1787,7 +1793,7 @@ nsresult HTMLEditor::DeleteSelectedTableRowsWithTransaction( if (!cell) { break; } - CellIndexes cellIndexes(*cell, error); + CellIndexes cellIndexes(*cell, presShell, error); if (error.Failed()) { NS_WARNING("CellIndexes failed"); return error.StealNSResult(); @@ -2671,7 +2677,8 @@ NS_IMETHODIMP HTMLEditor::JoinTableCells(bool aMergeNonContiguousContents) { // as well as the "non-contiguous" cells, so user can see what happened. ErrorResult error; - CellAndIndexes firstSelectedCell(*this, *SelectionRefPtr(), error); + CellAndIndexes firstSelectedCell(*this, MOZ_KnownLive(*SelectionRefPtr()), + error); if (error.Failed()) { NS_WARNING("CellAndIndexes failed"); return EditorBase::ToGenericNSResult(error.StealNSResult()); @@ -3432,7 +3439,7 @@ NS_IMETHODIMP HTMLEditor::GetCellIndexes(Element* aCellElement, // Use cell element which contains anchor of Selection when aCellElement is // nullptr. ErrorResult error; - CellIndexes cellIndexes(*this, *SelectionRefPtr(), error); + CellIndexes cellIndexes(*this, MOZ_KnownLive(*SelectionRefPtr()), error); if (error.Failed()) { return EditorBase::ToGenericNSResult(error.StealNSResult()); } @@ -3442,7 +3449,8 @@ NS_IMETHODIMP HTMLEditor::GetCellIndexes(Element* aCellElement, } ErrorResult error; - CellIndexes cellIndexes(*aCellElement, error); + const RefPtr presShell{GetPresShell()}; + CellIndexes cellIndexes(*aCellElement, presShell, error); if (error.Failed()) { NS_WARNING("CellIndexes failed"); return EditorBase::ToGenericNSResult(error.StealNSResult()); @@ -3467,16 +3475,26 @@ void HTMLEditor::CellIndexes::Update(HTMLEditor& aHTMLEditor, aRv.Throw(NS_ERROR_FAILURE); return; } - Update(*cellElement, aRv); + + RefPtr presShell{aHTMLEditor.GetPresShell()}; + Update(*cellElement, presShell, aRv); NS_WARNING_ASSERTION(!aRv.Failed(), "CellIndexes::Update() failed"); } -void HTMLEditor::CellIndexes::Update(Element& aCellElement, ErrorResult& aRv) { +void HTMLEditor::CellIndexes::Update(Element& aCellElement, + PresShell* aPresShell, ErrorResult& aRv) { MOZ_ASSERT(!aRv.Failed()); - // XXX If the table cell is created immediately before this call, e.g., - // using innerHTML, frames have not been created yet. In such case, - // shouldn't we flush pending layout? + // If the table cell is created immediately before this call, e.g., using + // innerHTML, frames have not been created yet. Hence, flush layout to create + // them. + if (NS_WARN_IF(!aPresShell)) { + aRv.Throw(NS_ERROR_INVALID_ARG); + return; + } + + aPresShell->FlushPendingNotifications(FlushType::Frames); + nsIFrame* frameOfCell = aCellElement.GetPrimaryFrame(); if (!frameOfCell) { NS_WARNING("There was no layout information of aCellElement"); @@ -3856,7 +3874,8 @@ nsresult HTMLEditor::GetCellContext(Element** aTable, Element** aCell, // Get the rest of the related data only if requested if (aRowIndex || aColumnIndex) { ErrorResult error; - CellIndexes cellIndexes(*cell, error); + const RefPtr presShell{GetPresShell()}; + CellIndexes cellIndexes(*cell, presShell, error); if (error.Failed()) { NS_WARNING("CellIndexes failed"); return error.StealNSResult(); @@ -4056,7 +4075,7 @@ NS_IMETHODIMP HTMLEditor::GetFirstSelectedCellInTable(int32_t* aRowIndex, *aCellElement = nullptr; ErrorResult error; - CellAndIndexes result(*this, *SelectionRefPtr(), error); + CellAndIndexes result(*this, MOZ_KnownLive(*SelectionRefPtr()), error); if (error.Failed()) { NS_WARNING("CellAndIndexes failed"); return EditorBase::ToGenericNSResult(error.StealNSResult()); @@ -4084,7 +4103,9 @@ void HTMLEditor::CellAndIndexes::Update(HTMLEditor& aHTMLEditor, return; } - mIndexes.Update(*mElement, aRv); + const RefPtr presShell{aHTMLEditor.GetPresShell()}; + const RefPtr element{mElement}; + mIndexes.Update(*element, presShell, aRv); NS_WARNING_ASSERTION(!aRv.Failed(), "CellIndexes::Update() failed"); } @@ -4356,11 +4377,12 @@ NS_IMETHODIMP HTMLEditor::GetSelectedCellsType(Element* aElement, // Store indexes of each row/col to avoid duplication of searches nsTArray indexArray; + const RefPtr presShell{GetPresShell()}; bool allCellsInRowAreSelected = false; bool allCellsInColAreSelected = false; IgnoredErrorResult ignoredError; while (selectedCell) { - CellIndexes selectedCellIndexes(*selectedCell, error); + CellIndexes selectedCellIndexes(*selectedCell, presShell, error); if (error.Failed()) { NS_WARNING("CellIndexes failed"); return EditorBase::ToGenericNSResult(error.StealNSResult()); @@ -4398,7 +4420,7 @@ NS_IMETHODIMP HTMLEditor::GetSelectedCellsType(Element* aElement, ignoredError.SuppressException(); while (selectedCell) { - CellIndexes selectedCellIndexes(*selectedCell, error); + CellIndexes selectedCellIndexes(*selectedCell, presShell, error); if (error.Failed()) { NS_WARNING("CellIndexes failed"); return EditorBase::ToGenericNSResult(error.StealNSResult()); diff --git a/editor/libeditor/PlaceholderTransaction.h b/editor/libeditor/PlaceholderTransaction.h index 418e13b780..8a45315589 100644 --- a/editor/libeditor/PlaceholderTransaction.h +++ b/editor/libeditor/PlaceholderTransaction.h @@ -21,9 +21,8 @@ class EditorBase; * transactions it has absorbed. */ -class PlaceholderTransaction final - : public EditAggregateTransaction, - public SupportsWeakPtr { +class PlaceholderTransaction final : public EditAggregateTransaction, + public SupportsWeakPtr { protected: PlaceholderTransaction(EditorBase& aEditorBase, nsStaticAtom& aName, Maybe&& aSelState); @@ -47,8 +46,6 @@ class PlaceholderTransaction final return transaction.forget(); } - MOZ_DECLARE_WEAKREFERENCE_TYPENAME(PlaceholderTransaction) - NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PlaceholderTransaction, diff --git a/editor/libeditor/moz.build b/editor/libeditor/moz.build index 046d53bcaa..8806f9c123 100644 --- a/editor/libeditor/moz.build +++ b/editor/libeditor/moz.build @@ -89,3 +89,6 @@ FINAL_LIBRARY = 'xul' if CONFIG['CC_TYPE'] in ('clang', 'gcc'): CXXFLAGS += ['-Wno-error=shadow'] + +with Files("tests/*1151186*"): + BUG_COMPONENT = ("Core", "DOM: UI Events & Focus Handling") diff --git a/editor/moz.build b/editor/moz.build index e8397bc2c7..be2cccc22d 100644 --- a/editor/moz.build +++ b/editor/moz.build @@ -29,5 +29,5 @@ TESTING_JS_MODULES += [ 'AsyncSpellCheckTestHelper.jsm', ] -with Files('**'): - BUG_COMPONENT = ('Core', 'Editor') +with Files('**'): + BUG_COMPONENT = ('Core', 'DOM: Editor') diff --git a/editor/nsITableEditor.idl b/editor/nsITableEditor.idl index 38360ceb97..a89a41bd2c 100644 --- a/editor/nsITableEditor.idl +++ b/editor/nsITableEditor.idl @@ -239,6 +239,7 @@ interface nsITableEditor : nsISupports * column. If colspan is set to 2 or more, the * start column index is used. */ + [can_run_script] void getCellIndexes(in Element aCellElement, out long aRowIndex, out long aColumnIndex); @@ -414,6 +415,7 @@ interface nsITableEditor : nsISupports * TableSelectionMode::Column All cells are in 1 or more columns * and in each column, all cells are selected */ + [can_run_script] uint32_t getSelectedCellsType(in Element aElement); /** @@ -451,6 +453,7 @@ interface nsITableEditor : nsISupports * range of Selection. Even if this is not found, * this returns null, not throwing exception. */ + [can_run_script] Element getFirstSelectedCellInTable(out long aRowIndex, out long aColIndex); /** diff --git a/extensions/auth/nsHttpNegotiateAuth.cpp b/extensions/auth/nsHttpNegotiateAuth.cpp index a8b5ddb551..7d3e0ed7b6 100644 --- a/extensions/auth/nsHttpNegotiateAuth.cpp +++ b/extensions/auth/nsHttpNegotiateAuth.cpp @@ -21,6 +21,7 @@ #include "nsIHttpAuthenticableChannel.h" #include "nsIAuthModule.h" #include "nsIPrefBranch.h" +#include "nsIPrefService.h" #include "nsIProxyInfo.h" #include "nsIURI.h" #include "nsCOMPtr.h" diff --git a/extensions/permissions/PermissionDelegateHandler.cpp b/extensions/permissions/PermissionDelegateHandler.cpp index 38c7ac44c0..d6a0d8fc38 100644 --- a/extensions/permissions/PermissionDelegateHandler.cpp +++ b/extensions/permissions/PermissionDelegateHandler.cpp @@ -9,6 +9,7 @@ #include "nsIPrincipal.h" #include "nsContentPermissionHelper.h" +#include "mozilla/StaticPrefs_dom.h" #include "mozilla/StaticPrefs_permissions.h" #include "mozilla/dom/Document.h" #include "mozilla/dom/FeaturePolicyUtils.h" diff --git a/extensions/permissions/nsPermissionManager.cpp b/extensions/permissions/nsPermissionManager.cpp index b37fb29497..707e8d7394 100644 --- a/extensions/permissions/nsPermissionManager.cpp +++ b/extensions/permissions/nsPermissionManager.cpp @@ -29,9 +29,6 @@ #include "nsContentUtils.h" #include "nsPIDOMWindow.h" #include "mozilla/dom/Document.h" -#ifdef ANDROID -# include "mozilla/jni/Utils.h" // for jni::IsFennec -#endif #include "mozilla/net/NeckoMessageUtils.h" #include "mozilla/Preferences.h" #include "nsReadLine.h" @@ -1028,7 +1025,6 @@ nsresult nsPermissionManager::Init() { observerService->AddObserver(this, "profile-do-change", true); observerService->AddObserver(this, "testonly-reload-permissions-from-disk", true); - observerService->AddObserver(this, "clear-origin-attributes-data", true); } // ignore failure here, since it's non-fatal (we can run fine without @@ -2648,8 +2644,6 @@ NS_IMETHODIMP nsPermissionManager::Observe(nsISupports* aSubject, RemoveAllFromMemory(); CloseDB(false); InitDB(false); - } else if (!nsCRT::strcmp(aTopic, "clear-origin-attributes-data")) { - return RemovePermissionsWithAttributes(nsDependentString(someData)); } return NS_OK; @@ -2665,7 +2659,8 @@ nsresult nsPermissionManager::RemoveAllModifiedSince( }); } -nsresult nsPermissionManager::RemovePermissionsWithAttributes( +NS_IMETHODIMP +nsPermissionManager::RemovePermissionsWithAttributes( const nsAString& aPattern) { ENSURE_NOT_CHILD_PROCESS; mozilla::OriginAttributesPattern pattern; diff --git a/extensions/permissions/nsPermissionManager.h b/extensions/permissions/nsPermissionManager.h index a400d4146c..bbb659908c 100644 --- a/extensions/permissions/nsPermissionManager.h +++ b/extensions/permissions/nsPermissionManager.h @@ -207,6 +207,9 @@ class nsPermissionManager final : public nsIPermissionManager, */ static void Startup(); + nsresult RemovePermissionsWithAttributes( + mozilla::OriginAttributesPattern& aAttrs); + /** * See `nsIPermissionManager::GetPermissionsWithKey` for more info on * permission keys. @@ -282,6 +285,15 @@ class nsPermissionManager final : public nsIPermissionManager, // From ContentChild. nsresult RemoveAllFromIPC(); + /** + * Returns false if this permission manager wouldn't have the permission + * requested available. + * + * If aType is empty, checks that the permission manager would have all + * permissions available for the given principal. + */ + bool PermissionAvailable(nsIPrincipal* aPrincipal, const nsACString& aType); + /** * The content process doesn't have access to every permission. Instead, when * LOAD_DOCUMENT_URI channels for http://, https://, and ftp:// URIs are @@ -580,19 +592,6 @@ class nsPermissionManager final : public nsIPermissionManager, template nsresult RemovePermissionEntries(T aCondition); - nsresult RemovePermissionsWithAttributes(const nsAString& aPattern); - nsresult RemovePermissionsWithAttributes( - mozilla::OriginAttributesPattern& aAttrs); - - /** - * Returns false if this permission manager wouldn't have the permission - * requested available. - * - * If aType is nullptr, checks that the permission manager would have all - * permissions available for the given principal. - */ - bool PermissionAvailable(nsIPrincipal* aPrincipal, const nsACString& aType); - nsRefPtrHashtable mPermissionKeyPromiseMap; diff --git a/extensions/permissions/test/PermissionTestUtils.jsm b/extensions/permissions/test/PermissionTestUtils.jsm index 31b5277e75..7183252dd0 100644 --- a/extensions/permissions/test/PermissionTestUtils.jsm +++ b/extensions/permissions/test/PermissionTestUtils.jsm @@ -8,13 +8,11 @@ "use strict"; -let pm = Cc["@mozilla.org/permissionmanager;1"].getService( - Ci.nsIPermissionManager -); +const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); -let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService( - Ci.nsIScriptSecurityManager -); +let pm = Services.perms; + +let secMan = Services.scriptSecurityManager; const EXPORTED_SYMBOLS = ["PermissionTestUtils"]; diff --git a/extensions/permissions/test/unit/test_permmanager_cleardata.js b/extensions/permissions/test/unit/test_permmanager_cleardata.js index 0dc002a8b0..4abf67daa2 100644 --- a/extensions/permissions/test/unit/test_permmanager_cleardata.js +++ b/extensions/permissions/test/unit/test_permmanager_cleardata.js @@ -11,22 +11,21 @@ function createPrincipal(aOrigin, aOriginAttributes) { ); } -// Return the data required by 'clear-origin-attributes-data' notification. function getData(aPattern) { return JSON.stringify(aPattern); } // Use aEntries to create principals, add permissions to them and check that they have them. -// Then, it is notifying 'clear-origin-attributes-data' with the given aData and check if the permissions +// Then, it is removing origin attributes with the given aData and check if the permissions // of principals[i] matches the permission in aResults[i]. function test(aEntries, aData, aResults) { let principals = []; - for (entry of aEntries) { + for (const entry of aEntries) { principals.push(createPrincipal(entry.origin, entry.originAttributes)); } - for (principal of principals) { + for (const principal of principals) { Assert.equal( pm.testPermissionFromPrincipal(principal, "test/clear-origin"), pm.UNKNOWN_ACTION @@ -44,7 +43,9 @@ function test(aEntries, aData, aResults) { ); } - Services.obs.notifyObservers(null, "clear-origin-attributes-data", aData); + // `clear-origin-attributes-data` notification is removed from permission + // manager + pm.removePermissionsWithAttributes(aData); var length = aEntries.length; for (let i = 0; i < length; ++i) { @@ -63,9 +64,7 @@ function test(aEntries, aData, aResults) { function run_test() { do_get_profile(); - pm = Cc["@mozilla.org/permissionmanager;1"].getService( - Ci.nsIPermissionManager - ); + pm = Services.perms; let entries = [ { origin: "http://example.com", originAttributes: {} }, diff --git a/extensions/permissions/test/unit/test_permmanager_matches.js b/extensions/permissions/test/unit/test_permmanager_matches.js index 099fb48142..32d7adf45f 100644 --- a/extensions/permissions/test/unit/test_permmanager_matches.js +++ b/extensions/permissions/test/unit/test_permmanager_matches.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +var attrs; + function matches_always(perm, principals) { principals.forEach(principal => { Assert.ok( @@ -42,13 +44,9 @@ function matches_never(perm, principals) { function run_test() { // initialize the permission manager service - let pm = Cc["@mozilla.org/permissionmanager;1"].getService( - Ci.nsIPermissionManager - ); + let pm = Services.perms; - let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService( - Ci.nsIScriptSecurityManager - ); + let secMan = Services.scriptSecurityManager; // Add some permissions let uri0 = NetUtil.newURI("http://google.com/search?q=foo#hashtag"); diff --git a/extensions/permissions/test/unit/test_permmanager_migrate_4-7.js b/extensions/permissions/test/unit/test_permmanager_migrate_4-7.js index e7836cbc9d..fcd07d145d 100644 --- a/extensions/permissions/test/unit/test_permmanager_migrate_4-7.js +++ b/extensions/permissions/test/unit/test_permmanager_migrate_4-7.js @@ -91,6 +91,7 @@ add_task(async function test() { } // Add some rows to the database + // eslint-disable-next-line no-unused-vars let created = [ insertHost("foo.com", "A", 1, 0, 0, 0, 0, false), insertHost("foo.com", "C", 1, 0, 0, 0, 0, false), diff --git a/extensions/permissions/test/unit/test_permmanager_migrate_4-7_no_history.js b/extensions/permissions/test/unit/test_permmanager_migrate_4-7_no_history.js index af0752fa69..a3330f2e53 100644 --- a/extensions/permissions/test/unit/test_permmanager_migrate_4-7_no_history.js +++ b/extensions/permissions/test/unit/test_permmanager_migrate_4-7_no_history.js @@ -131,6 +131,7 @@ add_task(function test() { } // Add some rows to the database + // eslint-disable-next-line no-unused-vars let created = [ insertHost("foo.com", "A", 1, 0, 0, 0, 0, false), insertHost("foo.com", "C", 1, 0, 0, 0, 0, false), diff --git a/extensions/permissions/test/unit/test_permmanager_migrate_5-7a.js b/extensions/permissions/test/unit/test_permmanager_migrate_5-7a.js index ab75c3848d..38c2293fb1 100644 --- a/extensions/permissions/test/unit/test_permmanager_migrate_5-7a.js +++ b/extensions/permissions/test/unit/test_permmanager_migrate_5-7a.js @@ -109,7 +109,6 @@ add_task(async function test() { modificationTime, }; } - function insertHost( host, type, @@ -158,6 +157,7 @@ add_task(async function test() { ]; // Add some rows to the database + // eslint-disable-next-line no-unused-vars let created = [ insertHost("foo.com", "A", 1, 0, 0, 0, 0, false), insertHost("foo.com", "C", 1, 0, 0, 0, 0, false), diff --git a/extensions/permissions/test/unit/test_permmanager_migrate_5-7b.js b/extensions/permissions/test/unit/test_permmanager_migrate_5-7b.js index 70d242fad2..796f58a132 100644 --- a/extensions/permissions/test/unit/test_permmanager_migrate_5-7b.js +++ b/extensions/permissions/test/unit/test_permmanager_migrate_5-7b.js @@ -49,7 +49,6 @@ add_task(function test() { ); let id = 0; - function insertOrigin( origin, type, @@ -85,6 +84,7 @@ add_task(function test() { }; } + // eslint-disable-next-line no-unused-vars let created5 = [ insertOrigin("https://foo.com", "A", 2, 0, 0, 0), insertOrigin("http://foo.com", "A", 2, 0, 0, 0), diff --git a/extensions/permissions/test/unit/test_permmanager_migrate_6-7a.js b/extensions/permissions/test/unit/test_permmanager_migrate_6-7a.js index 1c68126330..fef13ba062 100644 --- a/extensions/permissions/test/unit/test_permmanager_migrate_6-7a.js +++ b/extensions/permissions/test/unit/test_permmanager_migrate_6-7a.js @@ -158,6 +158,7 @@ add_task(async function test() { ]; // Add some rows to the database + // eslint-disable-next-line no-unused-vars let created = [ insertHost("foo.com", "A", 1, 0, 0, 0, 0, false), insertHost("foo.com", "C", 1, 0, 0, 0, 0, false), diff --git a/extensions/permissions/test/unit/test_permmanager_migrate_6-7b.js b/extensions/permissions/test/unit/test_permmanager_migrate_6-7b.js index 6181d30aaa..97feb673cd 100644 --- a/extensions/permissions/test/unit/test_permmanager_migrate_6-7b.js +++ b/extensions/permissions/test/unit/test_permmanager_migrate_6-7b.js @@ -49,7 +49,6 @@ add_task(function test() { ); let id = 0; - function insertOrigin( origin, type, @@ -85,6 +84,7 @@ add_task(function test() { }; } + // eslint-disable-next-line no-unused-vars let created6 = [ insertOrigin("https://foo.com", "A", 2, 0, 0, 0), insertOrigin("http://foo.com", "A", 2, 0, 0, 0), diff --git a/extensions/permissions/test/unit/test_permmanager_migrate_7-8.js b/extensions/permissions/test/unit/test_permmanager_migrate_7-8.js index 37525b45fd..14c812e453 100644 --- a/extensions/permissions/test/unit/test_permmanager_migrate_7-8.js +++ b/extensions/permissions/test/unit/test_permmanager_migrate_7-8.js @@ -157,7 +157,7 @@ add_task(async function test() { isInBrowserElement, }; } - + // eslint-disable-next-line no-unused-vars let created7 = [ insertOrigin("https://foo.com", "A", 2, 0, 0, 0), insertOrigin("http://foo.com", "A", 2, 0, 0, 0), @@ -166,6 +166,7 @@ add_task(async function test() { ]; // Add some rows to the database + // eslint-disable-next-line no-unused-vars let created = [ insertHost("foo.com", "A", 1, 0, 0, 0, 0, false), insertHost("foo.com", "C", 1, 0, 0, 0, 0, false), diff --git a/extensions/permissions/test/unit/test_permmanager_migrate_9-10.js b/extensions/permissions/test/unit/test_permmanager_migrate_9-10.js index edd1897861..d03f24038f 100644 --- a/extensions/permissions/test/unit/test_permmanager_migrate_9-10.js +++ b/extensions/permissions/test/unit/test_permmanager_migrate_9-10.js @@ -144,7 +144,7 @@ add_task(async function test() { isInBrowserElement, }; } - + // eslint-disable-next-line no-unused-vars let created7 = [ insertOrigin("https://foo.com", "A", 2, 0, 0, 0), insertOrigin("http://foo.com", "A", 2, 0, 0, 0), @@ -152,6 +152,7 @@ add_task(async function test() { ]; // Add some rows to the database + // eslint-disable-next-line no-unused-vars let created = [ insertHost("foo.com", "A", 1, 0, 0, 0, 0, false), insertHost("foo.com", "B", 1, 0, 0, 0, 1000, false), diff --git a/extensions/permissions/test/unit/test_permmanager_removeall.js b/extensions/permissions/test/unit/test_permmanager_removeall.js index 607e811b91..1c688cd514 100644 --- a/extensions/permissions/test/unit/test_permmanager_removeall.js +++ b/extensions/permissions/test/unit/test_permmanager_removeall.js @@ -6,9 +6,7 @@ function run_test() { var dir = do_get_profile(); // initialize the permission manager service - var pm = Cc["@mozilla.org/permissionmanager;1"].getService( - Ci.nsIPermissionManager - ); + var pm = Services.perms; // get the db file var file = dir.clone(); diff --git a/extensions/pref/autoconfig/src/nsAutoConfig.cpp b/extensions/pref/autoconfig/src/nsAutoConfig.cpp index 7fcd4f0cfc..51af896fe3 100644 --- a/extensions/pref/autoconfig/src/nsAutoConfig.cpp +++ b/extensions/pref/autoconfig/src/nsAutoConfig.cpp @@ -12,6 +12,7 @@ #include "nsAppDirectoryServiceDefs.h" #include "nsIObserverService.h" #include "nsLiteralString.h" +#include "nsIPrefService.h" #include "nsIPromptService.h" #include "nsIInputStream.h" #include "nsIOutputStream.h" diff --git a/extensions/spellcheck/hunspell/tests/unit/test_hunspell.js b/extensions/spellcheck/hunspell/tests/unit/test_hunspell.js index 3a93ed4fa0..77ff1635e8 100644 --- a/extensions/spellcheck/hunspell/tests/unit/test_hunspell.js +++ b/extensions/spellcheck/hunspell/tests/unit/test_hunspell.js @@ -151,9 +151,10 @@ const tests = [ ["warn", "iso-8859-1"], ]; +// eslint-disable-next-line no-shadow function* do_get_file_by_line(file, charset) { dump("getting file by line for file " + file.path + "\n"); - dump("using charset " + charset + "\n"); + dump("using charset1" + charset + "\n"); let fis = Cc["@mozilla.org/network/file-input-stream;1"].createInstance( Ci.nsIFileInputStream ); @@ -165,7 +166,7 @@ function* do_get_file_by_line(file, charset) { lis.init(fis, charset, 1024, 0); lis.QueryInterface(Ci.nsIUnicharLineInputStream); - var val = {}; + let val = {}; while (lis.readLine(val)) { yield val.value; val = {}; @@ -191,7 +192,7 @@ function do_run_test(checker, name, charset, todo_good, todo_bad) { if (good.exists()) { var good_counter = 0; - for (val of do_get_file_by_line(good, charset)) { + for (const val of do_get_file_by_line(good, charset)) { let todo = false; good_counter++; if (todo_good && todo_good[good_counter]) { @@ -210,7 +211,7 @@ function do_run_test(checker, name, charset, todo_good, todo_bad) { if (bad.exists()) { var bad_counter = 0; - for (val of do_get_file_by_line(bad, charset)) { + for (const val of do_get_file_by_line(bad, charset)) { let todo = false; bad_counter++; if (todo_bad && todo_bad[bad_counter]) { @@ -241,7 +242,7 @@ function run_test() { spellChecker.loadDictionariesFromDir(testdir); function do_run_test_closure(test) { - [name, charset, todo_good, todo_bad] = test; + let [name, charset, todo_good, todo_bad] = test; do_run_test(spellChecker, name, charset, todo_good, todo_bad); } diff --git a/extensions/spellcheck/hunspell/tests/unit/test_hunspell_unicode_paths.js b/extensions/spellcheck/hunspell/tests/unit/test_hunspell_unicode_paths.js index 6c9719d4ee..019f854291 100644 --- a/extensions/spellcheck/hunspell/tests/unit/test_hunspell_unicode_paths.js +++ b/extensions/spellcheck/hunspell/tests/unit/test_hunspell_unicode_paths.js @@ -5,8 +5,6 @@ const { XPCOMUtils } = ChromeUtils.import( ); const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm"); -Cu.importGlobalProperties(["TextEncoder"]); - XPCOMUtils.defineLazyServiceGetter( this, "spellCheck", diff --git a/extensions/spellcheck/tests/mochitest/helper_bug1170484.js b/extensions/spellcheck/tests/mochitest/helper_bug1170484.js index 53bb34d465..be6505bb44 100644 --- a/extensions/spellcheck/tests/mochitest/helper_bug1170484.js +++ b/extensions/spellcheck/tests/mochitest/helper_bug1170484.js @@ -1,10 +1,12 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); +/* eslint-env mozilla/frame-script */ + // Chrome scripts are run with synchronous messages, so make sure we're completely // decoupled from the content process before doing this work. Cu.dispatch(function() { let chromeWin = Services.ww.activeWindow; - contextMenu = chromeWin.document.getElementById("contentAreaContextMenu"); + let contextMenu = chromeWin.document.getElementById("contentAreaContextMenu"); var suggestion = contextMenu.querySelector(".spell-suggestion"); suggestion.doCommand(); contextMenu.hidePopup(); diff --git a/extensions/spellcheck/tests/mochitest/test_bug1170484.html b/extensions/spellcheck/tests/mochitest/test_bug1170484.html index 8201557afa..e32fcf4c3c 100644 --- a/extensions/spellcheck/tests/mochitest/test_bug1170484.html +++ b/extensions/spellcheck/tests/mochitest/test_bug1170484.html @@ -14,6 +14,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1170484 /** Test for Bug 1170484 **/ SimpleTest.waitForExplicitFinish(); + /* global onSpellCheck */ SpecialPowers.Cu.import( "resource://testing-common/AsyncSpellCheckTestHelper.jsm", window); diff --git a/extensions/spellcheck/tests/mochitest/test_bug1272623.html b/extensions/spellcheck/tests/mochitest/test_bug1272623.html index fadc8c8264..ed3fa3dfdb 100644 --- a/extensions/spellcheck/tests/mochitest/test_bug1272623.html +++ b/extensions/spellcheck/tests/mochitest/test_bug1272623.html @@ -23,6 +23,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1272623 - Mozilla Bug 431054

-
 
diff --git a/widget/tests/test_mouse_event_with_control_on_mac.html b/widget/tests/test_mouse_event_with_control_on_mac.html
new file mode 100644
index 0000000000..516eafc861
--- /dev/null
+++ b/widget/tests/test_mouse_event_with_control_on_mac.html
@@ -0,0 +1,114 @@
+
+
+  Test control+click on Mac
+  
+  
+  
+  
+  
+
+
+
+ + + diff --git a/widget/uikit/nsWindow.mm b/widget/uikit/nsWindow.mm index 7cad5d9d7a..c09ed4857a 100644 --- a/widget/uikit/nsWindow.mm +++ b/widget/uikit/nsWindow.mm @@ -134,7 +134,7 @@ class nsAutoRetainUIKitObject { event.mRefPoint = aPoint; event.mClickCount = 1; - event.button = MouseButton::eLeft; + event.button = MouseButton::ePrimary; event.mTime = PR_IntervalNow(); event.inputSource = MouseEvent_Binding::MOZ_SOURCE_UNKNOWN; diff --git a/widget/windows/IMMHandler.cpp b/widget/windows/IMMHandler.cpp index 97657b2d86..088ddcab98 100644 --- a/widget/windows/IMMHandler.cpp +++ b/widget/windows/IMMHandler.cpp @@ -2469,13 +2469,13 @@ nsresult IMMHandler::OnMouseButtonEvent( BYTE button; switch (aIMENotification.mMouseButtonEventData.mButton) { - case MouseButton::eLeft: + case MouseButton::ePrimary: button = IMEMOUSE_LDOWN; break; case MouseButton::eMiddle: button = IMEMOUSE_MDOWN; break; - case MouseButton::eRight: + case MouseButton::eSecondary: button = IMEMOUSE_RDOWN; break; default: diff --git a/widget/windows/KeyboardLayout.cpp b/widget/windows/KeyboardLayout.cpp index 83a68c80be..1326f04197 100644 --- a/widget/windows/KeyboardLayout.cpp +++ b/widget/windows/KeyboardLayout.cpp @@ -917,10 +917,10 @@ void ModifierKeyState::InitMouseEvent(WidgetInputEvent& aMouseEvent) const { WidgetMouseEventBase& mouseEvent = *aMouseEvent.AsMouseEventBase(); mouseEvent.mButtons = 0; if (::GetKeyState(VK_LBUTTON) < 0) { - mouseEvent.mButtons |= MouseButtonsFlag::eLeftFlag; + mouseEvent.mButtons |= MouseButtonsFlag::ePrimaryFlag; } if (::GetKeyState(VK_RBUTTON) < 0) { - mouseEvent.mButtons |= MouseButtonsFlag::eRightFlag; + mouseEvent.mButtons |= MouseButtonsFlag::eSecondaryFlag; } if (::GetKeyState(VK_MBUTTON) < 0) { mouseEvent.mButtons |= MouseButtonsFlag::eMiddleFlag; diff --git a/widget/windows/TSFTextStore.cpp b/widget/windows/TSFTextStore.cpp index 9894a18801..5470ceb11d 100644 --- a/widget/windows/TSFTextStore.cpp +++ b/widget/windows/TSFTextStore.cpp @@ -529,11 +529,11 @@ static nsCString GetDisplayAttrStr(const TF_DISPLAYATTRIBUTE& aDispAttr) { static const char* GetMouseButtonName(int16_t aButton) { switch (aButton) { - case MouseButton::eLeft: + case MouseButton::ePrimary: return "LeftButton"; case MouseButton::eMiddle: return "MiddleButton"; - case MouseButton::eRight: + case MouseButton::eSecondary: return "RightButton"; default: return "UnknownButton"; @@ -550,10 +550,10 @@ static nsCString GetMouseButtonsName(int16_t aButtons) { return NS_LITERAL_CSTRING("no buttons"); } nsCString names; - if (aButtons & MouseButtonsFlag::eLeftFlag) { + if (aButtons & MouseButtonsFlag::ePrimaryFlag) { names = "LeftButton"; } - if (aButtons & MouseButtonsFlag::eRightFlag) { + if (aButtons & MouseButtonsFlag::eSecondaryFlag) { ADD_SEPARATOR_IF_NECESSARY(names); names += "RightButton"; } @@ -6438,13 +6438,13 @@ nsresult TSFTextStore::OnMouseButtonEventInternal( aIMENotification.mMouseButtonEventData.mEventMessage == eMouseUp; if (!isMouseUp) { switch (aIMENotification.mMouseButtonEventData.mButton) { - case MouseButton::eLeft: + case MouseButton::ePrimary: buttonStatus = MK_LBUTTON; break; case MouseButton::eMiddle: buttonStatus = MK_MBUTTON; break; - case MouseButton::eRight: + case MouseButton::eSecondary: buttonStatus = MK_RBUTTON; break; } diff --git a/widget/windows/WinHeaderOnlyUtils.h b/widget/windows/WinHeaderOnlyUtils.h index 13d69ba54a..8226e94626 100644 --- a/widget/windows/WinHeaderOnlyUtils.h +++ b/widget/windows/WinHeaderOnlyUtils.h @@ -11,15 +11,23 @@ #include #include +#include + #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/DynamicallyLinkedFunctionPtr.h" #include "mozilla/Maybe.h" -#include "mozilla/Result.h" +#include "mozilla/ResultVariant.h" +#include "mozilla/Tuple.h" #include "mozilla/UniquePtr.h" #include "mozilla/WindowsVersion.h" #include "nsWindowsHelpers.h" +#if defined(MOZILLA_INTERNAL_API) +# include "nsIFile.h" +# include "nsString.h" +#endif // defined(MOZILLA_INTERNAL_API) + /** * This header is intended for self-contained, header-only, utility code for * Win32. It may be used outside of xul.dll, in places such as firefox.exe or @@ -401,6 +409,128 @@ class MOZ_RAII AutoVirtualProtect final { WindowsError mError; }; +inline UniquePtr GetFullModulePath(HMODULE aModule) { + DWORD bufLen = MAX_PATH; + mozilla::UniquePtr buf; + DWORD retLen; + + while (true) { + buf = mozilla::MakeUnique(bufLen); + retLen = ::GetModuleFileNameW(aModule, buf.get(), bufLen); + if (!retLen) { + return nullptr; + } + + if (retLen == bufLen && ::GetLastError() == ERROR_INSUFFICIENT_BUFFER) { + bufLen *= 2; + continue; + } + + break; + } + + // Upon success, retLen *excludes* the null character + ++retLen; + + // Since we're likely to have a bunch of unused space in buf, let's reallocate + // a string to the actual size of the file name. + auto result = mozilla::MakeUnique(retLen); + if (wcscpy_s(result.get(), retLen, buf.get())) { + return nullptr; + } + + return result; +} + +inline UniquePtr GetFullBinaryPath() { + return GetFullModulePath(nullptr); +} + +class ModuleVersion final { + public: + explicit ModuleVersion(const VS_FIXEDFILEINFO& aFixedInfo) + : mVersion((static_cast(aFixedInfo.dwFileVersionMS) << 32) | + static_cast(aFixedInfo.dwFileVersionLS)) {} + + explicit ModuleVersion(const uint64_t aVersion) : mVersion(aVersion) {} + + ModuleVersion(const ModuleVersion& aOther) : mVersion(aOther.mVersion) {} + + uint64_t AsInteger() const { return mVersion; } + + operator uint64_t() const { return AsInteger(); } + + Tuple AsTuple() const { + uint16_t major = static_cast((mVersion >> 48) & 0xFFFFU); + uint16_t minor = static_cast((mVersion >> 32) & 0xFFFFU); + uint16_t patch = static_cast((mVersion >> 16) & 0xFFFFU); + uint16_t build = static_cast(mVersion & 0xFFFFU); + + return MakeTuple(major, minor, patch, build); + } + + explicit operator bool() const { return !!mVersion; } + + bool operator<(const ModuleVersion& aOther) const { + return mVersion < aOther.mVersion; + } + + bool operator<(const uint64_t& aOther) const { return mVersion < aOther; } + + private: + const uint64_t mVersion; +}; + +inline WindowsErrorResult GetModuleVersion( + const wchar_t* aModuleFullPath) { + DWORD verInfoLen = ::GetFileVersionInfoSizeW(aModuleFullPath, nullptr); + if (!verInfoLen) { + return Err(WindowsError::FromLastError()); + } + + auto verInfoBuf = MakeUnique(verInfoLen); + if (!::GetFileVersionInfoW(aModuleFullPath, 0, verInfoLen, + verInfoBuf.get())) { + return Err(WindowsError::FromLastError()); + } + + UINT fixedInfoLen; + VS_FIXEDFILEINFO* fixedInfo = nullptr; + if (!::VerQueryValueW(verInfoBuf.get(), L"\\", + reinterpret_cast(&fixedInfo), &fixedInfoLen)) { + // VerQueryValue may fail if the resource does not exist. This is not an + // error; we'll return 0 in this case. + return ModuleVersion(0ULL); + } + + return ModuleVersion(*fixedInfo); +} + +inline WindowsErrorResult GetModuleVersion(HMODULE aModule) { + UniquePtr fullPath(GetFullModulePath(aModule)); + if (!fullPath) { + return Err(WindowsError::CreateGeneric()); + } + + return GetModuleVersion(fullPath.get()); +} + +#if defined(MOZILLA_INTERNAL_API) +inline WindowsErrorResult GetModuleVersion(nsIFile* aFile) { + if (!aFile) { + return Err(WindowsError::FromHResult(E_INVALIDARG)); + } + + nsAutoString fullPath; + nsresult rv = aFile->GetPath(fullPath); + if (NS_FAILED(rv)) { + return Err(WindowsError::CreateGeneric()); + } + + return GetModuleVersion(fullPath.get()); +} +#endif // defined(MOZILLA_INTERNAL_API) + struct CoTaskMemFreeDeleter { void operator()(void* aPtr) { ::CoTaskMemFree(aPtr); } }; diff --git a/widget/windows/WindowsUIUtils.cpp b/widget/windows/WindowsUIUtils.cpp index 5aa3475d6a..7009c32e3c 100644 --- a/widget/windows/WindowsUIUtils.cpp +++ b/widget/windows/WindowsUIUtils.cpp @@ -13,6 +13,7 @@ #include "nsIObserverService.h" #include "nsIAppShellService.h" #include "nsAppShellCID.h" +#include "mozilla/ResultVariant.h" #include "mozilla/Services.h" #include "mozilla/WidgetUtils.h" #include "mozilla/WindowsVersion.h" diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 6c5ea53d4a..e587809a62 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -123,6 +123,7 @@ #include "WinTaskbar.h" #include "WidgetUtils.h" #include "nsIWidgetListener.h" +#include "mozilla/dom/Document.h" #include "mozilla/dom/MouseEventBinding.h" #include "mozilla/dom/Touch.h" #include "mozilla/gfx/2D.h" @@ -139,6 +140,7 @@ #include "InProcessWinCompositorWidget.h" #include "InputDeviceUtils.h" #include "ScreenHelperWin.h" +#include "mozilla/StaticPrefs_dom.h" #include "mozilla/StaticPrefs_layout.h" #include "nsIGfxInfo.h" @@ -1930,7 +1932,7 @@ nsresult nsWindow::BeginResizeDrag(WidgetGUIEvent* aEvent, int32_t aHorizontal, return NS_ERROR_INVALID_ARG; } - if (aEvent->AsMouseEvent()->mButton != MouseButton::eLeft) { + if (aEvent->AsMouseEvent()->mButton != MouseButton::ePrimary) { // you can only begin a resize drag with the left mouse button return NS_ERROR_INVALID_ARG; } @@ -4286,13 +4288,13 @@ bool nsWindow::DispatchMouseEvent(EventMessage aEventMessage, WPARAM wParam, BYTE eventButton; switch (aButton) { - case MouseButton::eLeft: + case MouseButton::ePrimary: eventButton = VK_LBUTTON; break; case MouseButton::eMiddle: eventButton = VK_MBUTTON; break; - case MouseButton::eRight: + case MouseButton::eSecondary: eventButton = VK_RBUTTON; break; default: @@ -4353,13 +4355,13 @@ bool nsWindow::DispatchMouseEvent(EventMessage aEventMessage, WPARAM wParam, switch (aEventMessage) { case eMouseDown: switch (aButton) { - case MouseButton::eLeft: + case MouseButton::ePrimary: pluginEvent.event = WM_LBUTTONDOWN; break; case MouseButton::eMiddle: pluginEvent.event = WM_MBUTTONDOWN; break; - case MouseButton::eRight: + case MouseButton::eSecondary: pluginEvent.event = WM_RBUTTONDOWN; break; default: @@ -4368,13 +4370,13 @@ bool nsWindow::DispatchMouseEvent(EventMessage aEventMessage, WPARAM wParam, break; case eMouseUp: switch (aButton) { - case MouseButton::eLeft: + case MouseButton::ePrimary: pluginEvent.event = WM_LBUTTONUP; break; case MouseButton::eMiddle: pluginEvent.event = WM_MBUTTONUP; break; - case MouseButton::eRight: + case MouseButton::eSecondary: pluginEvent.event = WM_RBUTTONUP; break; default: @@ -4383,13 +4385,13 @@ bool nsWindow::DispatchMouseEvent(EventMessage aEventMessage, WPARAM wParam, break; case eMouseDoubleClick: switch (aButton) { - case MouseButton::eLeft: + case MouseButton::ePrimary: pluginEvent.event = WM_LBUTTONDBLCLK; break; case MouseButton::eMiddle: pluginEvent.event = WM_MBUTTONDBLCLK; break; - case MouseButton::eRight: + case MouseButton::eSecondary: pluginEvent.event = WM_RBUTTONDBLCLK; break; default: @@ -4422,16 +4424,16 @@ bool nsWindow::DispatchMouseEvent(EventMessage aEventMessage, WPARAM wParam, if (sCurrentWindow == nullptr || sCurrentWindow != this) { if ((nullptr != sCurrentWindow) && (!sCurrentWindow->mInDtor)) { LPARAM pos = sCurrentWindow->lParamToClient(lParamToScreen(lParam)); - sCurrentWindow->DispatchMouseEvent(eMouseExitFromWidget, wParam, - pos, false, MouseButton::eLeft, - aInputSource, aPointerInfo); + sCurrentWindow->DispatchMouseEvent( + eMouseExitFromWidget, wParam, pos, false, MouseButton::ePrimary, + aInputSource, aPointerInfo); } sCurrentWindow = this; if (!mInDtor) { LPARAM pos = sCurrentWindow->lParamToClient(lParamToScreen(lParam)); - sCurrentWindow->DispatchMouseEvent(eMouseEnterIntoWidget, wParam, - pos, false, MouseButton::eLeft, - aInputSource, aPointerInfo); + sCurrentWindow->DispatchMouseEvent( + eMouseEnterIntoWidget, wParam, pos, false, + MouseButton::ePrimary, aInputSource, aPointerInfo); } } } @@ -5357,7 +5359,7 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, result = DispatchMouseEvent(eMouseMove, wParam, lParam, false, - MouseButton::eLeft, MOUSE_INPUT_SOURCE(), + MouseButton::ePrimary, MOUSE_INPUT_SOURCE(), mPointerEvents.GetCachedPointerInfo(msg, wParam)); if (userMovedMouse) { DispatchPendingEvents(); @@ -5374,7 +5376,7 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, case WM_LBUTTONDOWN: { result = DispatchMouseEvent(eMouseDown, wParam, lParam, false, - MouseButton::eLeft, MOUSE_INPUT_SOURCE(), + MouseButton::ePrimary, MOUSE_INPUT_SOURCE(), mPointerEvents.GetCachedPointerInfo(msg, wParam)); DispatchPendingEvents(); } break; @@ -5382,7 +5384,7 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, case WM_LBUTTONUP: { result = DispatchMouseEvent(eMouseUp, wParam, lParam, false, - MouseButton::eLeft, MOUSE_INPUT_SOURCE(), + MouseButton::ePrimary, MOUSE_INPUT_SOURCE(), mPointerEvents.GetCachedPointerInfo(msg, wParam)); DispatchPendingEvents(); } break; @@ -5408,7 +5410,7 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, // WM_MOUSELEAVE. LPARAM pos = lParamToClient(::GetMessagePos()); DispatchMouseEvent(eMouseExitFromWidget, mouseState, pos, false, - MouseButton::eLeft, MOUSE_INPUT_SOURCE()); + MouseButton::ePrimary, MOUSE_INPUT_SOURCE()); } break; case MOZ_WM_PEN_LEAVES_HOVER_OF_DIGITIZER: { @@ -5419,7 +5421,7 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, WinPointerInfo pointerInfo; pointerInfo.pointerId = pointerId; DispatchMouseEvent(eMouseExitFromWidget, wParam, pos, false, - MouseButton::eLeft, + MouseButton::ePrimary, MouseEvent_Binding::MOZ_SOURCE_PEN, &pointerInfo); InkCollector::sInkCollector->ClearTarget(); InkCollector::sInkCollector->ClearPointerId(); @@ -5450,7 +5452,7 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, result = DispatchMouseEvent( eContextMenu, wParam, pos, contextMenukey, - contextMenukey ? MouseButton::eLeft : MouseButton::eRight, + contextMenukey ? MouseButton::ePrimary : MouseButton::eSecondary, MOUSE_INPUT_SOURCE()); if (lParam != -1 && !result && mCustomNonClient && mDraggableRegion.Contains(GET_X_LPARAM(pos), GET_Y_LPARAM(pos))) { @@ -5473,7 +5475,7 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, case WM_LBUTTONDBLCLK: result = DispatchMouseEvent(eMouseDoubleClick, wParam, lParam, false, - MouseButton::eLeft, MOUSE_INPUT_SOURCE()); + MouseButton::ePrimary, MOUSE_INPUT_SOURCE()); DispatchPendingEvents(); break; @@ -5517,7 +5519,7 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, case WM_RBUTTONDOWN: result = DispatchMouseEvent(eMouseDown, wParam, lParam, false, - MouseButton::eRight, MOUSE_INPUT_SOURCE(), + MouseButton::eSecondary, MOUSE_INPUT_SOURCE(), mPointerEvents.GetCachedPointerInfo(msg, wParam)); DispatchPendingEvents(); break; @@ -5525,33 +5527,36 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, case WM_RBUTTONUP: result = DispatchMouseEvent(eMouseUp, wParam, lParam, false, - MouseButton::eRight, MOUSE_INPUT_SOURCE(), + MouseButton::eSecondary, MOUSE_INPUT_SOURCE(), mPointerEvents.GetCachedPointerInfo(msg, wParam)); DispatchPendingEvents(); break; case WM_RBUTTONDBLCLK: - result = DispatchMouseEvent(eMouseDoubleClick, wParam, lParam, false, - MouseButton::eRight, MOUSE_INPUT_SOURCE()); + result = + DispatchMouseEvent(eMouseDoubleClick, wParam, lParam, false, + MouseButton::eSecondary, MOUSE_INPUT_SOURCE()); DispatchPendingEvents(); break; case WM_NCRBUTTONDOWN: - result = DispatchMouseEvent(eMouseDown, 0, lParamToClient(lParam), false, - MouseButton::eRight, MOUSE_INPUT_SOURCE()); + result = + DispatchMouseEvent(eMouseDown, 0, lParamToClient(lParam), false, + MouseButton::eSecondary, MOUSE_INPUT_SOURCE()); DispatchPendingEvents(); break; case WM_NCRBUTTONUP: - result = DispatchMouseEvent(eMouseUp, 0, lParamToClient(lParam), false, - MouseButton::eRight, MOUSE_INPUT_SOURCE()); + result = + DispatchMouseEvent(eMouseUp, 0, lParamToClient(lParam), false, + MouseButton::eSecondary, MOUSE_INPUT_SOURCE()); DispatchPendingEvents(); break; case WM_NCRBUTTONDBLCLK: - result = - DispatchMouseEvent(eMouseDoubleClick, 0, lParamToClient(lParam), - false, MouseButton::eRight, MOUSE_INPUT_SOURCE()); + result = DispatchMouseEvent(eMouseDoubleClick, 0, lParamToClient(lParam), + false, MouseButton::eSecondary, + MOUSE_INPUT_SOURCE()); DispatchPendingEvents(); break; @@ -5682,9 +5687,9 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, case WM_NCLBUTTONDBLCLK: DispatchMouseEvent(eMouseDoubleClick, 0, lParamToClient(lParam), false, - MouseButton::eLeft, MOUSE_INPUT_SOURCE()); + MouseButton::ePrimary, MOUSE_INPUT_SOURCE()); result = DispatchMouseEvent(eMouseUp, 0, lParamToClient(lParam), false, - MouseButton::eLeft, MOUSE_INPUT_SOURCE()); + MouseButton::ePrimary, MOUSE_INPUT_SOURCE()); DispatchPendingEvents(); break; @@ -8149,11 +8154,11 @@ bool nsWindow::OnPointerEvents(UINT msg, WPARAM aWParam, LPARAM aLParam) { // We don't support chorded buttons for pen. Keep the button at // WM_POINTERDOWN. - static mozilla::MouseButton sLastPenDownButton = MouseButton::eLeft; + static mozilla::MouseButton sLastPenDownButton = MouseButton::ePrimary; static bool sPointerDown = false; EventMessage message; - mozilla::MouseButton button = MouseButton::eLeft; + mozilla::MouseButton button = MouseButton::ePrimary; switch (msg) { case WM_POINTERDOWN: { LayoutDeviceIntPoint eventPoint(GET_X_LPARAM(aLParam), @@ -8161,15 +8166,15 @@ bool nsWindow::OnPointerEvents(UINT msg, WPARAM aWParam, LPARAM aLParam) { sLastPointerDownPoint.x = eventPoint.x; sLastPointerDownPoint.y = eventPoint.y; message = eMouseDown; - button = IS_POINTER_SECONDBUTTON_WPARAM(aWParam) ? MouseButton::eRight - : MouseButton::eLeft; + button = IS_POINTER_SECONDBUTTON_WPARAM(aWParam) ? MouseButton::eSecondary + : MouseButton::ePrimary; sLastPenDownButton = button; sPointerDown = true; } break; case WM_POINTERUP: message = eMouseUp; MOZ_ASSERT(sPointerDown, "receive WM_POINTERUP w/o WM_POINTERDOWN"); - button = sPointerDown ? sLastPenDownButton : MouseButton::eLeft; + button = sPointerDown ? sLastPenDownButton : MouseButton::ePrimary; sPointerDown = false; break; case WM_POINTERUPDATE: @@ -8208,9 +8213,9 @@ bool nsWindow::OnPointerEvents(UINT msg, WPARAM aWParam, LPARAM aLParam) { // Windows defines the pen pressure is normalized to a range between 0 and // 1024. Convert it to float. float pressure = penInfo.pressure ? (float)penInfo.pressure / 1024 : 0; - int16_t buttons = sPointerDown ? button == MouseButton::eLeft - ? MouseButtonsFlag::eLeftFlag - : MouseButtonsFlag::eRightFlag + int16_t buttons = sPointerDown ? button == MouseButton::ePrimary + ? MouseButtonsFlag::ePrimaryFlag + : MouseButtonsFlag::eSecondaryFlag : MouseButtonsFlag::eNoButtons; WinPointerInfo pointerInfo(pointerId, penInfo.tiltX, penInfo.tiltY, pressure, buttons); diff --git a/widget/windows/nsWindow.h b/widget/windows/nsWindow.h index 1a54365e20..920f79033f 100644 --- a/widget/windows/nsWindow.h +++ b/widget/windows/nsWindow.h @@ -238,7 +238,7 @@ class nsWindow final : public nsWindowBase { virtual bool DispatchMouseEvent( mozilla::EventMessage aEventMessage, WPARAM wParam, LPARAM lParam, bool aIsContextMenuKey = false, - int16_t aButton = mozilla::MouseButton::eLeft, + int16_t aButton = mozilla::MouseButton::ePrimary, uint16_t aInputSource = mozilla::dom::MouseEvent_Binding::MOZ_SOURCE_MOUSE, WinPointerInfo* aPointerInfo = nullptr); diff --git a/xpcom/base/ClearOnShutdown.cpp b/xpcom/base/ClearOnShutdown.cpp index df4a198521..8f767942a6 100644 --- a/xpcom/base/ClearOnShutdown.cpp +++ b/xpcom/base/ClearOnShutdown.cpp @@ -12,6 +12,21 @@ Array, sShutdownObservers; ShutdownPhase sCurrentShutdownPhase = ShutdownPhase::NotInShutdown; +void InsertIntoShutdownList(ShutdownObserver* aObserver, ShutdownPhase aPhase) { + // Adding a ClearOnShutdown for a "past" phase is an error. + if (PastShutdownPhase(aPhase)) { + MOZ_ASSERT(false, "ClearOnShutdown for phase that already was cleared"); + aObserver->Shutdown(); + delete aObserver; + return; + } + + if (!(sShutdownObservers[static_cast(aPhase)])) { + sShutdownObservers[static_cast(aPhase)] = new ShutdownList(); + } + sShutdownObservers[static_cast(aPhase)]->insertBack(aObserver); +} + } // namespace ClearOnShutdown_Internal // Called when XPCOM is shutting down, after all shutdown notifications have @@ -21,8 +36,11 @@ void KillClearOnShutdown(ShutdownPhase aPhase) { MOZ_ASSERT(NS_IsMainThread()); // Shutdown only goes one direction... - MOZ_ASSERT(static_cast(sCurrentShutdownPhase) < - static_cast(aPhase)); + MOZ_ASSERT(!PastShutdownPhase(aPhase)); + + // Set the phase before notifying observers to make sure that they can't run + // any code which isn't allowed to run after the start of this phase. + sCurrentShutdownPhase = aPhase; // It's impossible to add an entry for a "past" phase; this is blocked in // ClearOnShutdown, but clear them out anyways in case there are phases diff --git a/xpcom/base/ClearOnShutdown.h b/xpcom/base/ClearOnShutdown.h index c499e2cca9..d2119a06a7 100644 --- a/xpcom/base/ClearOnShutdown.h +++ b/xpcom/base/ClearOnShutdown.h @@ -10,8 +10,10 @@ #include "mozilla/Array.h" #include "MainThreadUtils.h" +#include + /* - * This header exports one public method in the mozilla namespace: + * This header exports two public methods in the mozilla namespace: * * template * void ClearOnShutdown(SmartPtr *aPtr, aPhase=ShutdownPhase::ShutdownFinal) @@ -33,9 +35,18 @@ * know will live until the program shuts down. In practice, these are likely * global variables, which should be Static{Ref,Auto}Ptr. * - * ClearOnShutdown is currently main-thread only because we don't want to - * accidentally free an object from a different thread than the one it was - * created on. + * template + * void RunOnShutdown(CallableT&& aCallable, + * aPhase = ShutdownPhase::ShutdownFinal) + * + * This function takes a callable and executes it upon shutdown at the start of + * the specified phase. If the phase has already occurred when RunOnShutdown() + * is called, it will cause a MOZ_ASSERT. In case a phase is not explicitly + * cleared, we will clear it on the next phase that occurs. + * + * ClearOnShutdown and RunOnShutdown are both currently main-thread only because + * we don't want to accidentally free an object from a different thread than the + * one it was created on. */ namespace mozilla { @@ -77,6 +88,27 @@ class PointerClearer : public ShutdownObserver { SmartPtr* mPtr; }; +class FunctionInvoker : public ShutdownObserver { + public: + template + explicit FunctionInvoker(CallableT&& aCallable) + : mCallable(std::forward(aCallable)) {} + + virtual void Shutdown() override { + if (!mCallable) { + return; + } + + mCallable(); + } + + private: + std::function mCallable; +}; + +void InsertIntoShutdownList(ShutdownObserver* aShutdownObserver, + ShutdownPhase aPhase); + typedef LinkedList ShutdownList; extern Array, static_cast(ShutdownPhase::ShutdownPhase_Length)> @@ -93,19 +125,26 @@ inline void ClearOnShutdown( MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aPhase != ShutdownPhase::ShutdownPhase_Length); - // Adding a ClearOnShutdown for a "past" phase is an error. - if (!(static_cast(sCurrentShutdownPhase) < - static_cast(aPhase))) { - MOZ_ASSERT(false, "ClearOnShutdown for phase that already was cleared"); - *aPtr = nullptr; - return; - } + InsertIntoShutdownList(new PointerClearer(aPtr), aPhase); +} - if (!(sShutdownObservers[static_cast(aPhase)])) { - sShutdownObservers[static_cast(aPhase)] = new ShutdownList(); - } - sShutdownObservers[static_cast(aPhase)]->insertBack( - new PointerClearer(aPtr)); +template +inline void RunOnShutdown(CallableT&& aCallable, + ShutdownPhase aPhase = ShutdownPhase::ShutdownFinal) { + using namespace ClearOnShutdown_Internal; + + MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(aPhase != ShutdownPhase::ShutdownPhase_Length); + + InsertIntoShutdownList( + new FunctionInvoker(std::forward(aCallable)), aPhase); +} + +inline bool PastShutdownPhase(ShutdownPhase aPhase) { + MOZ_ASSERT(NS_IsMainThread()); + + return size_t(ClearOnShutdown_Internal::sCurrentShutdownPhase) >= + size_t(aPhase); } // Called when XPCOM is shutting down, after all shutdown notifications have diff --git a/xpcom/base/CycleCollectedJSContext.cpp b/xpcom/base/CycleCollectedJSContext.cpp index 1ed8a78766..dfa0d88bda 100644 --- a/xpcom/base/CycleCollectedJSContext.cpp +++ b/xpcom/base/CycleCollectedJSContext.cpp @@ -352,8 +352,8 @@ void CycleCollectedJSContext::PromiseRejectionTrackerCallback( init.mReason = JS::GetPromiseResult(aPromise); RefPtr event = - PromiseRejectionEvent::Constructor( - owner, NS_LITERAL_STRING("rejectionhandled"), init); + PromiseRejectionEvent::Constructor(owner, u"rejectionhandled"_ns, + init); RefPtr asyncDispatcher = new AsyncEventDispatcher(owner, event); @@ -499,8 +499,6 @@ void CycleCollectedJSContext::IsIdleGCTaskNeeded() const { } return NS_OK; } - - nsresult Cancel() override { return NS_OK; } }; if (Runtime()->IsIdleGCTaskNeeded()) { @@ -701,8 +699,8 @@ NS_IMETHODIMP CycleCollectedJSContext::NotifyUnhandledRejections::Run() { init.mCancelable = true; RefPtr event = - PromiseRejectionEvent::Constructor( - target, NS_LITERAL_STRING("unhandledrejection"), init); + PromiseRejectionEvent::Constructor(target, u"unhandledrejection"_ns, + init); // We don't use the result of dispatching event here to check whether to // report the Promise to console. target->DispatchEvent(*event); @@ -736,15 +734,16 @@ nsresult CycleCollectedJSContext::NotifyUnhandledRejections::Cancel() { return NS_OK; } -class FinalizationRegistryCleanup::CleanupRunnable : public CancelableRunnable { +class FinalizationRegistryCleanup::CleanupRunnable + : public DiscardableRunnable { public: explicit CleanupRunnable(FinalizationRegistryCleanup* aCleanupWork) - : CancelableRunnable("CleanupRunnable"), mCleanupWork(aCleanupWork) {} + : DiscardableRunnable("CleanupRunnable"), mCleanupWork(aCleanupWork) {} // MOZ_CAN_RUN_SCRIPT_BOUNDARY until Runnable::Run is MOZ_CAN_RUN_SCRIPT. See // bug 1535398. MOZ_CAN_RUN_SCRIPT_BOUNDARY - NS_IMETHODIMP Run() { + NS_IMETHOD Run() override { mCleanupWork->DoCleanup(); return NS_OK; } diff --git a/xpcom/base/CycleCollectedJSRuntime.cpp b/xpcom/base/CycleCollectedJSRuntime.cpp index f8c3e5cdaa..8ae687d62f 100644 --- a/xpcom/base/CycleCollectedJSRuntime.cpp +++ b/xpcom/base/CycleCollectedJSRuntime.cpp @@ -120,7 +120,7 @@ struct DeferredFinalizeFunctionHolder { void* data; }; -class IncrementalFinalizeRunnable : public CancelableRunnable { +class IncrementalFinalizeRunnable : public DiscardableRunnable { typedef AutoTArray DeferredFinalizeArray; typedef CycleCollectedJSRuntime::DeferredFinalizerTable DeferredFinalizerTable; @@ -699,6 +699,8 @@ CycleCollectedJSRuntime::CycleCollectedJSRuntime(JSContext* aCx) #ifdef MOZ_JS_DEV_ERROR_INTERCEPTOR JS_SetErrorInterceptorCallback(mJSRuntime, &mErrorInterceptor); #endif // MOZ_JS_DEV_ERROR_INTERCEPTOR + + JS_SetDestroyZoneCallback(aCx, OnZoneDestroyed); } #ifdef NS_BUILD_REFCNT_LOGGING @@ -733,11 +735,14 @@ void CycleCollectedJSRuntime::Shutdown(JSContext* cx) { #ifdef DEBUG mShutdownCalled = true; #endif + + JS_SetDestroyZoneCallback(cx, nullptr); } CycleCollectedJSRuntime::~CycleCollectedJSRuntime() { MOZ_COUNT_DTOR(CycleCollectedJSRuntime); MOZ_ASSERT(!mDeferredFinalizerTable.Count()); + MOZ_ASSERT(!mFinalizeRunnable); MOZ_ASSERT(mShutdownCalled); } @@ -1506,7 +1511,7 @@ void CycleCollectedJSRuntime::DumpJSHeap(FILE* aFile) { IncrementalFinalizeRunnable::IncrementalFinalizeRunnable( CycleCollectedJSRuntime* aRt, DeferredFinalizerTable& aFinalizers) - : CancelableRunnable("IncrementalFinalizeRunnable"), + : DiscardableRunnable("IncrementalFinalizeRunnable"), mRuntime(aRt), mFinalizeFunctionToRun(0), mReleasing(false) { @@ -1521,10 +1526,12 @@ IncrementalFinalizeRunnable::IncrementalFinalizeRunnable( iter.Remove(); } + MOZ_ASSERT(mDeferredFinalizeFunctions.Length()); } IncrementalFinalizeRunnable::~IncrementalFinalizeRunnable() { - MOZ_ASSERT(this != mRuntime->mFinalizeRunnable); + MOZ_ASSERT(!mDeferredFinalizeFunctions.Length()); + MOZ_ASSERT(!mRuntime); } void IncrementalFinalizeRunnable::ReleaseNow(bool aLimited) { @@ -1573,8 +1580,10 @@ void IncrementalFinalizeRunnable::ReleaseNow(bool aLimited) { if (mFinalizeFunctionToRun == mDeferredFinalizeFunctions.Length()) { MOZ_ASSERT(mRuntime->mFinalizeRunnable == this); mDeferredFinalizeFunctions.Clear(); + CycleCollectedJSRuntime* runtime = mRuntime; + mRuntime = nullptr; // NB: This may delete this! - mRuntime->mFinalizeRunnable = nullptr; + runtime->mFinalizeRunnable = nullptr; } } @@ -1582,12 +1591,13 @@ NS_IMETHODIMP IncrementalFinalizeRunnable::Run() { AUTO_PROFILER_LABEL("IncrementalFinalizeRunnable::Run", GCCC); - if (mRuntime->mFinalizeRunnable != this) { + if (!mDeferredFinalizeFunctions.Length()) { /* These items were already processed synchronously in JSGC_END. */ - MOZ_ASSERT(!mDeferredFinalizeFunctions.Length()); + MOZ_ASSERT(!mRuntime); return NS_OK; } + MOZ_ASSERT(mRuntime->mFinalizeRunnable == this); TimeStamp start = TimeStamp::Now(); ReleaseNow(true); @@ -1596,6 +1606,8 @@ IncrementalFinalizeRunnable::Run() { if (NS_FAILED(rv)) { ReleaseNow(false); } + } else { + MOZ_ASSERT(!mRuntime); } uint32_t duration = (uint32_t)((TimeStamp::Now() - start).ToMilliseconds()); @@ -1735,12 +1747,21 @@ void CycleCollectedJSRuntime::PrepareWaitingZonesForGC() { JS::PrepareForFullGC(cx); } else { for (auto iter = mZonesWaitingForGC.Iter(); !iter.Done(); iter.Next()) { - JS::PrepareZoneForGC(iter.Get()->GetKey()); + JS::PrepareZoneForGC(cx, iter.Get()->GetKey()); } mZonesWaitingForGC.Clear(); } } +/* static */ +void CycleCollectedJSRuntime::OnZoneDestroyed(JSFreeOp* aFop, JS::Zone* aZone) { + // Remove the zone from the set of zones waiting for GC, if present. This can + // happen if a zone is added to the set during an incremental GC in which it + // is later destroyed. + CycleCollectedJSRuntime* runtime = Get(); + runtime->mZonesWaitingForGC.RemoveEntry(aZone); +} + void CycleCollectedJSRuntime::EnvironmentPreparer::invoke( JS::HandleObject global, js::ScriptEnvironmentPreparer::Closure& closure) { MOZ_ASSERT(JS_IsGlobalObject(global)); diff --git a/xpcom/base/CycleCollectedJSRuntime.h b/xpcom/base/CycleCollectedJSRuntime.h index 17874abc36..3d6e2402ee 100644 --- a/xpcom/base/CycleCollectedJSRuntime.h +++ b/xpcom/base/CycleCollectedJSRuntime.h @@ -334,6 +334,8 @@ class CycleCollectedJSRuntime { mZonesWaitingForGC.PutEntry(aZone); } + static void OnZoneDestroyed(JSFreeOp* aFop, JS::Zone* aZone); + // Prepare any zones for GC that have been passed to AddZoneWaitingForGC() // since the last GC or since the last call to PrepareWaitingZonesForGC(), // whichever was most recent. If there were no such zones, prepare for a diff --git a/xpcom/base/LogCommandLineHandler.cpp b/xpcom/base/LogCommandLineHandler.cpp index 5518b15a5c..bf9ed2400a 100644 --- a/xpcom/base/LogCommandLineHandler.cpp +++ b/xpcom/base/LogCommandLineHandler.cpp @@ -17,8 +17,7 @@ void LoggingHandleCommandLineArgs( // Used for the `-MOZ_LOG ` form of argument. nsAutoCString env; - auto const names = {NS_LITERAL_CSTRING("MOZ_LOG"), - NS_LITERAL_CSTRING("MOZ_LOG_FILE")}; + auto const names = {"MOZ_LOG"_ns, "MOZ_LOG_FILE"_ns}; for (int arg = 1; arg < argc; ++arg) { Tokenizer p(argv[arg]); diff --git a/xpcom/base/moz.build b/xpcom/base/moz.build index e47f67497b..3bf381313c 100644 --- a/xpcom/base/moz.build +++ b/xpcom/base/moz.build @@ -84,7 +84,6 @@ EXPORTS += [ 'nsQueryObject.h', 'nsSystemInfo.h', 'nsTraceRefcnt.h', - 'nsTWeakRef.h', 'nsVersionComparator.h', 'nsWeakReference.h', ] diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index c50e18919f..8c0ad1b26b 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -1329,10 +1329,10 @@ struct CCGraphDescriber : public LinkedListElement { Type mType; }; -class LogStringMessageAsync : public CancelableRunnable { +class LogStringMessageAsync : public DiscardableRunnable { public: explicit LogStringMessageAsync(const nsAString& aMsg) - : mozilla::CancelableRunnable("LogStringMessageAsync"), mMsg(aMsg) {} + : mozilla::DiscardableRunnable("LogStringMessageAsync"), mMsg(aMsg) {} NS_IMETHOD Run() override { nsCOMPtr cs = @@ -1408,7 +1408,7 @@ class nsCycleCollectorLogSinkToFile final : public nsICycleCollectorLogSink { if (!mGCLog.mStream) { return NS_ERROR_UNEXPECTED; } - CloseLog(&mGCLog, NS_LITERAL_STRING("Garbage")); + CloseLog(&mGCLog, u"Garbage"_ns); return NS_OK; } @@ -1416,7 +1416,7 @@ class nsCycleCollectorLogSinkToFile final : public nsICycleCollectorLogSink { if (!mCCLog.mStream) { return NS_ERROR_UNEXPECTED; } - CloseLog(&mCCLog, NS_LITERAL_STRING("Cycle")); + CloseLog(&mCCLog, u"Cycle"_ns); return NS_OK; } @@ -1466,8 +1466,8 @@ class nsCycleCollectorLogSinkToFile final : public nsICycleCollectorLogSink { // aFilename under a memory-reporting-specific folder // (/data/local/tmp/memory-reports). Otherwise, it will open a // file named aFilename under "NS_OS_TEMP_DIR". - nsresult rv = nsDumpUtils::OpenTempFile( - filename, &logFile, NS_LITERAL_CSTRING("memory-reports")); + nsresult rv = + nsDumpUtils::OpenTempFile(filename, &logFile, "memory-reports"_ns); if (NS_FAILED(rv)) { NS_IF_RELEASE(logFile); return nullptr; @@ -1528,8 +1528,8 @@ class nsCycleCollectorLogSinkToFile final : public nsICycleCollectorLogSink { // Log to the error console. nsAutoString logPath; logFileFinalDestination->GetPath(logPath); - nsAutoString msg = aCollectorKind + - NS_LITERAL_STRING(" Collector log dumped to ") + logPath; + nsAutoString msg = + aCollectorKind + u" Collector log dumped to "_ns + logPath; // We don't want any JS to run between ScanRoots and CollectWhite calls, // and since ScanRoots calls this method, better to log the message @@ -2038,7 +2038,8 @@ void CCGraphBuilder::DoneAddingRoots() { MOZ_NEVER_INLINE bool CCGraphBuilder::BuildGraph(SliceBudget& aBudget) { const intptr_t kNumNodesBetweenTimeChecks = 1000; - const intptr_t kStep = SliceBudget::CounterReset / kNumNodesBetweenTimeChecks; + const intptr_t kStep = + SliceBudget::StepsPerTimeCheck / kNumNodesBetweenTimeChecks; MOZ_ASSERT(mCurrNode); @@ -3430,7 +3431,7 @@ bool nsCycleCollector::Collect(ccType aCCType, SliceBudget& aBudget, } if (continueSlice) { // Force SliceBudget::isOverBudget to check the time. - aBudget.step(SliceBudget::CounterReset); + aBudget.step(SliceBudget::StepsPerTimeCheck); continueSlice = !aBudget.isOverBudget(); } } while (continueSlice); diff --git a/xpcom/base/nsCycleCollectorTraceJSHelpers.cpp b/xpcom/base/nsCycleCollectorTraceJSHelpers.cpp index 3fdc9bc5e6..1ff9641233 100644 --- a/xpcom/base/nsCycleCollectorTraceJSHelpers.cpp +++ b/xpcom/base/nsCycleCollectorTraceJSHelpers.cpp @@ -30,7 +30,7 @@ void nsCycleCollectionParticipant::NoteJSChild(JS::GCCellPtr aGCThing, void TraceCallbackFunc::Trace(JS::Heap* aPtr, const char* aName, void* aClosure) const { if (aPtr->unbarrieredGet().isGCThing()) { - mCallback(JS::GCCellPtr(aPtr->unbarrieredGet()), aName, aClosure); + mCallback(aPtr->unbarrieredGet().toGCCellPtr(), aName, aClosure); } } diff --git a/xpcom/base/nsDumpUtils.cpp b/xpcom/base/nsDumpUtils.cpp index da126a9e83..63eb942bb9 100644 --- a/xpcom/base/nsDumpUtils.cpp +++ b/xpcom/base/nsDumpUtils.cpp @@ -289,7 +289,7 @@ int FifoWatcher::OpenFd() { } } - rv = file->AppendNative(NS_LITERAL_CSTRING("debug_info_trigger")); + rv = file->AppendNative("debug_info_trigger"_ns); if (NS_WARN_IF(NS_FAILED(rv))) { return -1; } diff --git a/xpcom/base/nsIMemoryReporter.idl b/xpcom/base/nsIMemoryReporter.idl index 5df883e448..90ca6a0cbc 100644 --- a/xpcom/base/nsIMemoryReporter.idl +++ b/xpcom/base/nsIMemoryReporter.idl @@ -609,8 +609,8 @@ nsresult RegisterNonJSSizeOfTab(NonJSSizeOfTabFn aSizeOfTabFn); // variables. The (void) is there because we should always ignore the return // value of the callback, because callback failures aren't fatal. #define MOZ_COLLECT_REPORT(path, kind, units, amount, description) \ - (void)aHandleReport->Callback(EmptyCString(), NS_LITERAL_CSTRING(path), \ + (void)aHandleReport->Callback(EmptyCString(), nsLiteralCString(path), \ kind, units, amount, \ - NS_LITERAL_CSTRING(description), aData) + nsLiteralCString(description), aData) %} diff --git a/xpcom/base/nsMacUtilsImpl.cpp b/xpcom/base/nsMacUtilsImpl.cpp index 8d36c79f74..46fca11633 100644 --- a/xpcom/base/nsMacUtilsImpl.cpp +++ b/xpcom/base/nsMacUtilsImpl.cpp @@ -169,7 +169,7 @@ bool nsMacUtilsImpl::GetAppPath(nsCString& aAppPath) { // The binary path resides within the .app dir in Contents/MacOS, // e.g., Firefox.app/Contents/MacOS/firefox. Search backwards in // the binary path for the end of .app path. - auto pattern = NS_LITERAL_CSTRING("/Contents/MacOS/"); + auto pattern = "/Contents/MacOS/"_ns; nsAutoCString::const_iterator start, end; appBinaryPath.BeginReading(start); appBinaryPath.EndReading(end); @@ -415,12 +415,14 @@ nsresult nsMacUtilsImpl::GetRepoDir(nsIFile** aRepoDir) { #if defined(MOZ_SANDBOX) MOZ_ASSERT(mozilla::IsDevelopmentBuild()); #endif - return GetDirFromBundlePlist(NS_LITERAL_STRING(MAC_DEV_REPO_KEY), aRepoDir); + return GetDirFromBundlePlist(NS_LITERAL_STRING_FROM_CSTRING(MAC_DEV_REPO_KEY), + aRepoDir); } nsresult nsMacUtilsImpl::GetObjDir(nsIFile** aObjDir) { #if defined(MOZ_SANDBOX) MOZ_ASSERT(mozilla::IsDevelopmentBuild()); #endif - return GetDirFromBundlePlist(NS_LITERAL_STRING(MAC_DEV_OBJ_KEY), aObjDir); + return GetDirFromBundlePlist(NS_LITERAL_STRING_FROM_CSTRING(MAC_DEV_OBJ_KEY), + aObjDir); } diff --git a/xpcom/base/nsMemoryInfoDumper.cpp b/xpcom/base/nsMemoryInfoDumper.cpp index 2ad959ec4e..2835d47f38 100644 --- a/xpcom/base/nsMemoryInfoDumper.cpp +++ b/xpcom/base/nsMemoryInfoDumper.cpp @@ -212,12 +212,11 @@ bool SetupFifo() { FifoWatcher* fw = FifoWatcher::GetSingleton(); // Dump our memory reports (but run this on the main thread!). - fw->RegisterCallback(NS_LITERAL_CSTRING("memory report"), doMemoryReport); - fw->RegisterCallback(NS_LITERAL_CSTRING("minimize memory report"), - doMemoryReport); + fw->RegisterCallback("memory report"_ns, doMemoryReport); + fw->RegisterCallback("minimize memory report"_ns, doMemoryReport); // Dump GC and CC logs (from the main thread). - fw->RegisterCallback(NS_LITERAL_CSTRING("gc log"), doGCCCDump); - fw->RegisterCallback(NS_LITERAL_CSTRING("abbreviated gc log"), doGCCCDump); + fw->RegisterCallback("gc log"_ns, doGCCCDump); + fw->RegisterCallback("abbreviated gc log"_ns, doGCCCDump); # ifdef DEBUG fifoCallbacksRegistered = true; @@ -510,7 +509,7 @@ class TempDirFinishCallback final : public nsIFinishDumpingCallback { } #ifdef ANDROID - rv = reportsFinalFile->AppendNative(NS_LITERAL_CSTRING("memory-reports")); + rv = reportsFinalFile->AppendNative("memory-reports"_ns); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -551,7 +550,7 @@ class TempDirFinishCallback final : public nsIFinishDumpingCallback { return rv; } - nsString msg = NS_LITERAL_STRING("nsIMemoryInfoDumper dumped reports to "); + nsString msg = u"nsIMemoryInfoDumper dumped reports to "_ns; msg.Append(path); return cs->LogStringMessage(msg.get()); } @@ -672,9 +671,9 @@ nsMemoryInfoDumper::DumpMemoryInfoToTempDir(const nsAString& aIdentifier, // In Android case, this function will open a file named aFilename under // specific folder (/data/local/tmp/memory-reports). Otherwise, it will // open a file named aFilename under "NS_OS_TEMP_DIR". - rv = nsDumpUtils::OpenTempFile( - NS_LITERAL_CSTRING("incomplete-") + reportsFinalFilename, - getter_AddRefs(reportsTmpFile), NS_LITERAL_CSTRING("memory-reports")); + rv = nsDumpUtils::OpenTempFile("incomplete-"_ns + reportsFinalFilename, + getter_AddRefs(reportsTmpFile), + "memory-reports"_ns); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -709,7 +708,7 @@ nsresult nsMemoryInfoDumper::OpenDMDFile(const nsAString& aIdentifier, int aPid, nsresult rv; nsCOMPtr dmdFile; rv = nsDumpUtils::OpenTempFile(dmdFilename, getter_AddRefs(dmdFile), - NS_LITERAL_CSTRING("memory-reports")); + "memory-reports"_ns); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index 887f33d4f9..457fe65f7a 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -904,9 +904,9 @@ class WindowsAddressSpaceReporter final : public nsIMemoryReporter { // Append the segment count. path.AppendPrintf("(segments=%u)", entry->mCount); - aHandleReport->Callback( - EmptyCString(), path, KIND_OTHER, UNITS_BYTES, entry->mSize, - NS_LITERAL_CSTRING("From MEMORY_BASIC_INFORMATION."), aData); + aHandleReport->Callback(EmptyCString(), path, KIND_OTHER, UNITS_BYTES, + entry->mSize, "From MEMORY_BASIC_INFORMATION."_ns, + aData); } return NS_OK; @@ -1433,8 +1433,8 @@ class ThreadsReporter final : public nsIMemoryReporter { aHandleReport->Callback( EmptyCString(), path, KIND_NONHEAP, UNITS_BYTES, thread.mPrivateSize, - NS_LITERAL_CSTRING("The sizes of thread stacks which have been " - "committed to memory."), + nsLiteralCString("The sizes of thread stacks which have been " + "committed to memory."), aData); } diff --git a/xpcom/base/nsMessageLoop.cpp b/xpcom/base/nsMessageLoop.cpp index 5cd79c1959..6b74324260 100644 --- a/xpcom/base/nsMessageLoop.cpp +++ b/xpcom/base/nsMessageLoop.cpp @@ -25,10 +25,8 @@ namespace { * Note that the MessageLoop owns this object and will delete it after it calls * Run(). Tread lightly. */ -class MessageLoopIdleTask : public Runnable, - public SupportsWeakPtr { +class MessageLoopIdleTask : public Runnable, public SupportsWeakPtr { public: - MOZ_DECLARE_WEAKREFERENCE_TYPENAME(MessageLoopIdleTask) MessageLoopIdleTask(nsIRunnable* aTask, uint32_t aEnsureRunsAfterMS); NS_IMETHOD Run() override; diff --git a/xpcom/base/nsTWeakRef.h b/xpcom/base/nsTWeakRef.h deleted file mode 100644 index 70f6282b9b..0000000000 --- a/xpcom/base/nsTWeakRef.h +++ /dev/null @@ -1,157 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsTWeakRef_h__ -#define nsTWeakRef_h__ - -#ifndef nsDebug_h___ -# include "nsDebug.h" -#endif - -/** - * A weak reference class for use with generic C++ objects. NOT THREADSAFE! - * - * Example usage: - * - * class A { - * public: - * A() : mWeakSelf(this) { - * } - * ~A() { - * mWeakSelf.forget(); - * } - * void Bar() { printf("Bar!\n"); } - * const nsTWeakRef &AsWeakRef() const { return mWeakSelf; } - * private: - * nsTWeakRef mWeakSelf; - * }; - * - * class B { - * public: - * void SetA(const nsTWeakRef &a) { - * mA = a; - * } - * void Foo() { - * if (mA) - * mA->Bar(); - * } - * private: - * nsTWeakRef mA; - * }; - * - * void Test() { - * B b; - * { - * A a; - * b.SetA(a.AsWeakRef()); - * b.Foo(); // prints "Bar!" - * } - * b.Foo(); // prints nothing because |a| has already been destroyed - * } - * - * One can imagine much more complex examples, especially when asynchronous - * event processing is involved. - * - * Keep in mind that you should only ever need a class like this when you have - * multiple instances of B, such that it is not possible for A and B to simply - * have pointers to one another. - */ -template -class nsTWeakRef { - public: - ~nsTWeakRef() {} - - /** - * Construct from an object pointer (may be null). - */ - explicit nsTWeakRef(Type* aObj = nullptr) { - if (aObj) { - mRef = new Inner(aObj); - } else { - mRef = nullptr; - } - } - - /** - * Construct from another weak reference object. - */ - explicit nsTWeakRef(const nsTWeakRef& aOther) : mRef(aOther.mRef) {} - - /** - * Assign from an object pointer. - */ - nsTWeakRef& operator=(Type* aObj) { - if (aObj) { - mRef = new Inner(aObj); - } else { - mRef = nullptr; - } - return *this; - } - - /** - * Assign from another weak reference object. - */ - nsTWeakRef& operator=(const nsTWeakRef& aOther) { - mRef = aOther.mRef; - return *this; - } - - /** - * Get the referenced object. This method may return null if the reference - * has been cleared or if an out-of-memory error occurred at assignment. - */ - Type* get() const { return mRef ? mRef->mObj : nullptr; } - - /** - * Called to "null out" the weak reference. Typically, the object referenced - * by this weak reference calls this method when it is being destroyed. - * @returns The former referenced object. - */ - Type* forget() { - Type* obj; - if (mRef) { - obj = mRef->mObj; - mRef->mObj = nullptr; - mRef = nullptr; - } else { - obj = nullptr; - } - return obj; - } - - /** - * Allow |*this| to be treated as a |Type*| for convenience. - */ - operator Type*() const { return get(); } - - /** - * Allow |*this| to be treated as a |Type*| for convenience. Use with - * caution since this method will crash if the referenced object is null. - */ - Type* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN { - NS_ASSERTION( - mRef && mRef->mObj, - "You can't dereference a null weak reference with operator->()."); - return get(); - } - - private: - struct Inner { - int mCnt; - Type* mObj; - - explicit Inner(Type* aObj) : mCnt(1), mObj(aObj) {} - void AddRef() { ++mCnt; } - void Release() { - if (--mCnt == 0) { - delete this; - } - } - }; - - RefPtr mRef; -}; - -#endif // nsTWeakRef_h__ diff --git a/xpcom/base/nscore.h b/xpcom/base/nscore.h index f08fe35c2a..c649ee9e43 100644 --- a/xpcom/base/nscore.h +++ b/xpcom/base/nscore.h @@ -222,8 +222,6 @@ struct UnusedZero { static constexpr bool value = true; static constexpr StorageType nullValue = NS_OK; - static constexpr StorageType GetDefaultValue() { return NS_ERROR_FAILURE; } - static constexpr void AssertValid(StorageType aValue) {} static constexpr const nsresult& Inspect(const StorageType& aValue) { return aValue; diff --git a/xpcom/build/IOInterposer.cpp b/xpcom/build/IOInterposer.cpp index a69d045e25..6ef41ea086 100644 --- a/xpcom/build/IOInterposer.cpp +++ b/xpcom/build/IOInterposer.cpp @@ -22,8 +22,6 @@ #include "PoisonIOInterposer.h" #include "prenv.h" -using namespace mozilla; - namespace { /** Find if a vector contains a specific element */ @@ -62,13 +60,13 @@ struct ObserverLists { // These are implemented as vectors since they are allowed to survive gecko, // without reporting leaks. This is necessary for the IOInterposer to be used // for late-write checks. - std::vector mCreateObservers; - std::vector mReadObservers; - std::vector mWriteObservers; - std::vector mFSyncObservers; - std::vector mStatObservers; - std::vector mCloseObservers; - std::vector mStageObservers; + std::vector mCreateObservers; + std::vector mReadObservers; + std::vector mWriteObservers; + std::vector mFSyncObservers; + std::vector mStatObservers; + std::vector mCloseObservers; + std::vector mStageObservers; }; class PerThreadData { @@ -82,7 +80,7 @@ class PerThreadData { ~PerThreadData() { MOZ_COUNT_DTOR(PerThreadData); } - void CallObservers(IOInterposeObserver::Observation& aObservation) { + void CallObservers(mozilla::IOInterposeObserver::Observation& aObservation) { // Prevent recursive reporting. if (mIsHandlingObservation) { return; @@ -90,27 +88,27 @@ class PerThreadData { mIsHandlingObservation = true; // Decide which list of observers to inform - std::vector* observers = nullptr; + std::vector* observers = nullptr; switch (aObservation.ObservedOperation()) { - case IOInterposeObserver::OpCreateOrOpen: + case mozilla::IOInterposeObserver::OpCreateOrOpen: observers = &mObserverLists->mCreateObservers; break; - case IOInterposeObserver::OpRead: + case mozilla::IOInterposeObserver::OpRead: observers = &mObserverLists->mReadObservers; break; - case IOInterposeObserver::OpWrite: + case mozilla::IOInterposeObserver::OpWrite: observers = &mObserverLists->mWriteObservers; break; - case IOInterposeObserver::OpFSync: + case mozilla::IOInterposeObserver::OpFSync: observers = &mObserverLists->mFSyncObservers; break; - case IOInterposeObserver::OpStat: + case mozilla::IOInterposeObserver::OpStat: observers = &mObserverLists->mStatObservers; break; - case IOInterposeObserver::OpClose: + case mozilla::IOInterposeObserver::OpClose: observers = &mObserverLists->mCloseObservers; break; - case IOInterposeObserver::OpNextStage: + case mozilla::IOInterposeObserver::OpNextStage: observers = &mObserverLists->mStageObservers; break; default: { @@ -157,7 +155,8 @@ class PerThreadData { class MasterList { public: MasterList() - : mObservedOperations(IOInterposeObserver::OpNone), mIsEnabled(true) { + : mObservedOperations(mozilla::IOInterposeObserver::OpNone), + mIsEnabled(true) { MOZ_COUNT_CTOR(MasterList); } @@ -166,9 +165,9 @@ class MasterList { inline void Disable() { mIsEnabled = false; } inline void Enable() { mIsEnabled = true; } - void Register(IOInterposeObserver::Operation aOp, - IOInterposeObserver* aObserver) { - IOInterposer::AutoLock lock(mLock); + void Register(mozilla::IOInterposeObserver::Operation aOp, + mozilla::IOInterposeObserver* aObserver) { + mozilla::IOInterposer::AutoLock lock(mLock); ObserverLists* newLists = nullptr; if (mObserverLists) { @@ -178,44 +177,44 @@ class MasterList { } // You can register to observe multiple types of observations // but you'll never be registered twice for the same observations. - if (aOp & IOInterposeObserver::OpCreateOrOpen && + if (aOp & mozilla::IOInterposeObserver::OpCreateOrOpen && !VectorContains(newLists->mCreateObservers, aObserver)) { newLists->mCreateObservers.push_back(aObserver); } - if (aOp & IOInterposeObserver::OpRead && + if (aOp & mozilla::IOInterposeObserver::OpRead && !VectorContains(newLists->mReadObservers, aObserver)) { newLists->mReadObservers.push_back(aObserver); } - if (aOp & IOInterposeObserver::OpWrite && + if (aOp & mozilla::IOInterposeObserver::OpWrite && !VectorContains(newLists->mWriteObservers, aObserver)) { newLists->mWriteObservers.push_back(aObserver); } - if (aOp & IOInterposeObserver::OpFSync && + if (aOp & mozilla::IOInterposeObserver::OpFSync && !VectorContains(newLists->mFSyncObservers, aObserver)) { newLists->mFSyncObservers.push_back(aObserver); } - if (aOp & IOInterposeObserver::OpStat && + if (aOp & mozilla::IOInterposeObserver::OpStat && !VectorContains(newLists->mStatObservers, aObserver)) { newLists->mStatObservers.push_back(aObserver); } - if (aOp & IOInterposeObserver::OpClose && + if (aOp & mozilla::IOInterposeObserver::OpClose && !VectorContains(newLists->mCloseObservers, aObserver)) { newLists->mCloseObservers.push_back(aObserver); } - if (aOp & IOInterposeObserver::OpNextStage && + if (aOp & mozilla::IOInterposeObserver::OpNextStage && !VectorContains(newLists->mStageObservers, aObserver)) { newLists->mStageObservers.push_back(aObserver); } mObserverLists = newLists; mObservedOperations = - (IOInterposeObserver::Operation)(mObservedOperations | aOp); + (mozilla::IOInterposeObserver::Operation)(mObservedOperations | aOp); mCurrentGeneration++; } - void Unregister(IOInterposeObserver::Operation aOp, - IOInterposeObserver* aObserver) { - IOInterposer::AutoLock lock(mLock); + void Unregister(mozilla::IOInterposeObserver::Operation aOp, + mozilla::IOInterposeObserver* aObserver) { + mozilla::IOInterposer::AutoLock lock(mLock); ObserverLists* newLists = nullptr; if (mObserverLists) { @@ -224,53 +223,54 @@ class MasterList { newLists = new ObserverLists(); } - if (aOp & IOInterposeObserver::OpCreateOrOpen) { + if (aOp & mozilla::IOInterposeObserver::OpCreateOrOpen) { VectorRemove(newLists->mCreateObservers, aObserver); if (newLists->mCreateObservers.empty()) { - mObservedOperations = (IOInterposeObserver::Operation)( - mObservedOperations & ~IOInterposeObserver::OpCreateOrOpen); + mObservedOperations = (mozilla::IOInterposeObserver::Operation)( + mObservedOperations & + ~mozilla::IOInterposeObserver::OpCreateOrOpen); } } - if (aOp & IOInterposeObserver::OpRead) { + if (aOp & mozilla::IOInterposeObserver::OpRead) { VectorRemove(newLists->mReadObservers, aObserver); if (newLists->mReadObservers.empty()) { - mObservedOperations = (IOInterposeObserver::Operation)( - mObservedOperations & ~IOInterposeObserver::OpRead); + mObservedOperations = (mozilla::IOInterposeObserver::Operation)( + mObservedOperations & ~mozilla::IOInterposeObserver::OpRead); } } - if (aOp & IOInterposeObserver::OpWrite) { + if (aOp & mozilla::IOInterposeObserver::OpWrite) { VectorRemove(newLists->mWriteObservers, aObserver); if (newLists->mWriteObservers.empty()) { - mObservedOperations = (IOInterposeObserver::Operation)( - mObservedOperations & ~IOInterposeObserver::OpWrite); + mObservedOperations = (mozilla::IOInterposeObserver::Operation)( + mObservedOperations & ~mozilla::IOInterposeObserver::OpWrite); } } - if (aOp & IOInterposeObserver::OpFSync) { + if (aOp & mozilla::IOInterposeObserver::OpFSync) { VectorRemove(newLists->mFSyncObservers, aObserver); if (newLists->mFSyncObservers.empty()) { - mObservedOperations = (IOInterposeObserver::Operation)( - mObservedOperations & ~IOInterposeObserver::OpFSync); + mObservedOperations = (mozilla::IOInterposeObserver::Operation)( + mObservedOperations & ~mozilla::IOInterposeObserver::OpFSync); } } - if (aOp & IOInterposeObserver::OpStat) { + if (aOp & mozilla::IOInterposeObserver::OpStat) { VectorRemove(newLists->mStatObservers, aObserver); if (newLists->mStatObservers.empty()) { - mObservedOperations = (IOInterposeObserver::Operation)( - mObservedOperations & ~IOInterposeObserver::OpStat); + mObservedOperations = (mozilla::IOInterposeObserver::Operation)( + mObservedOperations & ~mozilla::IOInterposeObserver::OpStat); } } - if (aOp & IOInterposeObserver::OpClose) { + if (aOp & mozilla::IOInterposeObserver::OpClose) { VectorRemove(newLists->mCloseObservers, aObserver); if (newLists->mCloseObservers.empty()) { - mObservedOperations = (IOInterposeObserver::Operation)( - mObservedOperations & ~IOInterposeObserver::OpClose); + mObservedOperations = (mozilla::IOInterposeObserver::Operation)( + mObservedOperations & ~mozilla::IOInterposeObserver::OpClose); } } - if (aOp & IOInterposeObserver::OpNextStage) { + if (aOp & mozilla::IOInterposeObserver::OpNextStage) { VectorRemove(newLists->mStageObservers, aObserver); if (newLists->mStageObservers.empty()) { - mObservedOperations = (IOInterposeObserver::Operation)( - mObservedOperations & ~IOInterposeObserver::OpNextStage); + mObservedOperations = (mozilla::IOInterposeObserver::Operation)( + mObservedOperations & ~mozilla::IOInterposeObserver::OpNextStage); } } mObserverLists = newLists; @@ -283,11 +283,11 @@ class MasterList { } // If the generation counts don't match then we need to update the current // thread's observer list with the new master list. - IOInterposer::AutoLock lock(mLock); + mozilla::IOInterposer::AutoLock lock(mLock); aPtd.SetObserverLists(mCurrentGeneration, mObserverLists); } - inline bool IsObservedOperation(IOInterposeObserver::Operation aOp) { + inline bool IsObservedOperation(mozilla::IOInterposeObserver::Operation aOp) { // The quick reader may observe that no locks are being employed here, // hence the result of the operations is truly undefined. However, most // computers will usually return either true or false, which is good enough. @@ -303,31 +303,34 @@ class MasterList { // unregister observers during shutdown an OffTheBooksMutex is not an option // either, as its base calls into sDeadlockDetector which may be nullptr // during shutdown. - IOInterposer::Mutex mLock; + mozilla::IOInterposer::Mutex mLock; // Flags tracking which operations are being observed - IOInterposeObserver::Operation mObservedOperations; + mozilla::IOInterposeObserver::Operation mObservedOperations; // Used for quickly disabling everything by IOInterposer::Disable() - Atomic mIsEnabled; + mozilla::Atomic mIsEnabled; // Used to inform threads that the master observer list has changed - Atomic mCurrentGeneration; + mozilla::Atomic mCurrentGeneration; }; // Special observation used by IOInterposer::EnteringNextStage() -class NextStageObservation : public IOInterposeObserver::Observation { +class NextStageObservation : public mozilla::IOInterposeObserver::Observation { public: NextStageObservation() - : IOInterposeObserver::Observation(IOInterposeObserver::OpNextStage, - "IOInterposer", false) { - mStart = TimeStamp::Now(); + : mozilla::IOInterposeObserver::Observation( + mozilla::IOInterposeObserver::OpNextStage, "IOInterposer", false) { + mStart = mozilla::TimeStamp::Now(); mEnd = mStart; } }; // List of observers registered -static StaticAutoPtr sMasterList; +static mozilla::StaticAutoPtr sMasterList; static MOZ_THREAD_LOCAL(PerThreadData*) sThreadLocalData; static bool sThreadLocalDataInitialized; -} // namespace + +} // anonymous namespace + +namespace mozilla { IOInterposeObserver::Observation::Observation(Operation aOperation, const char* aReference, @@ -520,3 +523,5 @@ void IOInterposer::EnteringNextStage() { NextStageObservation observation; Report(observation); } + +} // namespace mozilla diff --git a/xpcom/build/LateWriteChecks.cpp b/xpcom/build/LateWriteChecks.cpp index 09a4a89d9a..289b5b70fc 100644 --- a/xpcom/build/LateWriteChecks.cpp +++ b/xpcom/build/LateWriteChecks.cpp @@ -34,8 +34,6 @@ #include "LateWriteChecks.h" -using namespace mozilla; - /*************************** Auxiliary Declarations ***************************/ // This a wrapper over a file descriptor that provides a Printf method and @@ -54,9 +52,9 @@ class SHA1Stream { str.AppendPrintf(aFormat, list); va_end(list); mSHA1.update(str.get(), str.Length()); - Unused << fwrite(str.get(), 1, str.Length(), mFile); + mozilla::Unused << fwrite(str.get(), 1, str.Length(), mFile); } - void Finish(SHA1Sum::Hash& aHash) { + void Finish(mozilla::SHA1Sum::Hash& aHash) { int fd = fileno(mFile); fflush(mFile); //MozillaUnRegisterDebugFD(fd); @@ -67,7 +65,7 @@ class SHA1Stream { private: FILE* mFile; - SHA1Sum mSHA1; + mozilla::SHA1Sum mSHA1; }; static void RecordStackWalker(uint32_t aFrameNumber, void* aPC, void* aSP, @@ -83,8 +81,8 @@ static void RecordStackWalker(uint32_t aFrameNumber, void* aPC, void* aSP, * An implementation of IOInterposeObserver to be registered with IOInterposer. * This observer logs all writes as late writes. */ -class LateWriteObserver final : public IOInterposeObserver { - using char_type = filesystem::Path::value_type; +class LateWriteObserver final : public mozilla::IOInterposeObserver { + using char_type = mozilla::filesystem::Path::value_type; public: explicit LateWriteObserver(const char_type* aProfileDirectory) @@ -94,20 +92,23 @@ class LateWriteObserver final : public IOInterposeObserver { mProfileDirectory = nullptr; } - void Observe(IOInterposeObserver::Observation& aObservation) override; + void Observe( + mozilla::IOInterposeObserver::Observation& aObservation) override; private: char_type* mProfileDirectory; }; -void LateWriteObserver::Observe(IOInterposeObserver::Observation& aOb) { +void LateWriteObserver::Observe( + mozilla::IOInterposeObserver::Observation& aOb) { // Crash if that is the shutdown check mode - if (gShutdownChecks == SCM_CRASH) { + if (mozilla::gShutdownChecks == mozilla::SCM_CRASH) { MOZ_CRASH(); } - // If we have shutdown mode SCM_NOTHING or we can't record then abort - if (gShutdownChecks == SCM_NOTHING || !Telemetry::CanRecordExtended()) { + // If we have shutdown mode mozilla::SCM_NOTHING or we can't record then abort + if (mozilla::gShutdownChecks == mozilla::SCM_NOTHING || + !mozilla::Telemetry::CanRecordExtended()) { return; } @@ -117,7 +118,8 @@ void LateWriteObserver::Observe(IOInterposeObserver::Observation& aOb) { MozStackWalk(RecordStackWalker, /* skipFrames */ 0, /* maxFrames */ 0, &rawStack); - Telemetry::ProcessedStack stack = Telemetry::GetStackAndModules(rawStack); + mozilla::Telemetry::ProcessedStack stack = + mozilla::Telemetry::GetStackAndModules(rawStack); nsTAutoString nameAux(mProfileDirectory); nameAux.AppendLiteral(NS_SLASH "Telemetry.LateWriteTmpXXXXXX"); @@ -159,7 +161,7 @@ void LateWriteObserver::Observe(IOInterposeObserver::Observation& aOb) { size_t numModules = stack.GetNumModules(); sha1Stream.Printf("%u\n", (unsigned)numModules); for (size_t i = 0; i < numModules; ++i) { - Telemetry::ProcessedStack::Module module = stack.GetModule(i); + mozilla::Telemetry::ProcessedStack::Module module = stack.GetModule(i); sha1Stream.Printf("%s %s\n", module.mBreakpadId.get(), NS_ConvertUTF16toUTF8(module.mName).get()); } @@ -167,7 +169,7 @@ void LateWriteObserver::Observe(IOInterposeObserver::Observation& aOb) { size_t numFrames = stack.GetStackSize(); sha1Stream.Printf("%u\n", (unsigned)numFrames); for (size_t i = 0; i < numFrames; ++i) { - const Telemetry::ProcessedStack::Frame& frame = stack.GetFrame(i); + const mozilla::Telemetry::ProcessedStack::Frame& frame = stack.GetFrame(i); // NOTE: We write the offsets, while the atos tool expects a value with // the virtual address added. For example, running otool -l on the the // firefox binary shows @@ -180,7 +182,7 @@ void LateWriteObserver::Observe(IOInterposeObserver::Observation& aOb) { sha1Stream.Printf("%d %x\n", frame.mModIndex, (unsigned)frame.mOffset); } - SHA1Sum::Hash sha1; + mozilla::SHA1Sum::Hash sha1; sha1Stream.Finish(sha1); // Note: These files should be deleted by telemetry once it reads them. If @@ -190,7 +192,7 @@ void LateWriteObserver::Observe(IOInterposeObserver::Observation& aOb) { // We append the sha1 of the contents to the file name. This provides a simple // client side deduplication. - nsAutoString finalName(NS_LITERAL_STRING("Telemetry.LateWriteFinal-")); + nsAutoString finalName(u"Telemetry.LateWriteFinal-"_ns); for (int i = 0; i < 20; ++i) { finalName.AppendPrintf("%02x", sha1[i]); } @@ -200,7 +202,7 @@ void LateWriteObserver::Observe(IOInterposeObserver::Observation& aOb) { /******************************* Setup/Teardown *******************************/ -static StaticAutoPtr sLateWriteObserver; +static mozilla::StaticAutoPtr sLateWriteObserver; namespace mozilla { diff --git a/xpcom/build/MainThreadIOLogger.cpp b/xpcom/build/MainThreadIOLogger.cpp index fced3ccc75..6685adcf94 100644 --- a/xpcom/build/MainThreadIOLogger.cpp +++ b/xpcom/build/MainThreadIOLogger.cpp @@ -61,15 +61,15 @@ class MainThreadIOLoggerImpl final : public mozilla::IOInterposeObserver { static void sIOThreadFunc(void* aArg); void IOThreadFunc(); - TimeStamp mLogStartTime; + mozilla::TimeStamp mLogStartTime; const char* mFileName; PRThread* mIOThread; - IOInterposer::Monitor mMonitor; + mozilla::IOInterposer::Monitor mMonitor; bool mShutdownRequired; std::vector mObservations; }; -static StaticAutoPtr sImpl; +static mozilla::StaticAutoPtr sImpl; MainThreadIOLoggerImpl::MainThreadIOLoggerImpl() : mFileName(nullptr), mIOThread(nullptr), mShutdownRequired(false) {} @@ -80,7 +80,7 @@ MainThreadIOLoggerImpl::~MainThreadIOLoggerImpl() { } { // Scope for lock - IOInterposer::MonitorAutoLock lock(mMonitor); + mozilla::IOInterposer::MonitorAutoLock lock(mMonitor); mShutdownRequired = true; lock.Notify(); } @@ -120,15 +120,15 @@ void MainThreadIOLoggerImpl::IOThreadFunc() { PRFileDesc* fd = PR_Open(mFileName, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, PR_IRUSR | PR_IWUSR | PR_IRGRP); if (!fd) { - IOInterposer::MonitorAutoLock lock(mMonitor); + mozilla::IOInterposer::MonitorAutoLock lock(mMonitor); mShutdownRequired = true; std::vector().swap(mObservations); return; } - mLogStartTime = TimeStamp::Now(); + mLogStartTime = mozilla::TimeStamp::Now(); { // Scope for lock - IOInterposer::MonitorAutoLock lock(mMonitor); + mozilla::IOInterposer::MonitorAutoLock lock(mMonitor); while (true) { while (!mShutdownRequired && mObservations.empty()) { lock.Wait(); @@ -141,14 +141,15 @@ void MainThreadIOLoggerImpl::IOThreadFunc() { observationsToWrite.swap(mObservations); // Release the lock so that we're not holding anybody up during I/O - IOInterposer::MonitorAutoUnlock unlock(mMonitor); + mozilla::IOInterposer::MonitorAutoUnlock unlock(mMonitor); // Now write the events. for (auto i = observationsToWrite.begin(), e = observationsToWrite.end(); i != e; ++i) { if (i->mObservation.ObservedOperation() == OpNextStage) { - PR_fprintf(fd, "%f,NEXT-STAGE\n", - (TimeStamp::Now() - mLogStartTime).ToMilliseconds()); + PR_fprintf( + fd, "%f,NEXT-STAGE\n", + (mozilla::TimeStamp::Now() - mLogStartTime).ToMilliseconds()); continue; } double durationMs = i->mObservation.Duration().ToMilliseconds(); @@ -185,7 +186,7 @@ void MainThreadIOLoggerImpl::Observe(Observation& aObservation) { if (!mFileName || !IsMainThread()) { return; } - IOInterposer::MonitorAutoLock lock(mMonitor); + mozilla::IOInterposer::MonitorAutoLock lock(mMonitor); if (mShutdownRequired) { // The writer thread isn't running. Don't enqueue any more data. return; diff --git a/xpcom/build/NSPRInterposer.cpp b/xpcom/build/NSPRInterposer.cpp index bad0a8e643..5f7b4f581a 100644 --- a/xpcom/build/NSPRInterposer.cpp +++ b/xpcom/build/NSPRInterposer.cpp @@ -20,8 +20,6 @@ namespace { -using namespace mozilla; - /* Original IO methods */ PRCloseFN sCloseFn = nullptr; PRReadFN sReadFn = nullptr; @@ -54,13 +52,13 @@ static int32_t GetPathFromFd(int32_t aFd, char* aBuf, size_t aBufSize) { /** * RAII class for timing the duration of an NSPR I/O call and reporting the - * result to the IOInterposeObserver API. + * result to the mozilla::IOInterposeObserver API. */ -class NSPRIOAutoObservation : public IOInterposeObserver::Observation { +class NSPRIOAutoObservation : public mozilla::IOInterposeObserver::Observation { public: - explicit NSPRIOAutoObservation(IOInterposeObserver::Operation aOp, + explicit NSPRIOAutoObservation(mozilla::IOInterposeObserver::Operation aOp, PRFileDesc* aFd) - : IOInterposeObserver::Observation(aOp, "NSPRIOInterposer") { + : mozilla::IOInterposeObserver::Observation(aOp, "NSPRIOInterposer") { char filename[MAXPATHLEN]; if (mShouldReport && aFd && GetPathFromFd(PR_FileDesc2NativeHandle(aFd), filename, @@ -83,7 +81,7 @@ PRStatus PR_CALLBACK interposedClose(PRFileDesc* aFd) { // If we don't have a valid original function pointer something is very wrong. NS_ASSERTION(sCloseFn, "NSPR IO Interposing: sCloseFn is NULL"); - NSPRIOAutoObservation timer(IOInterposeObserver::OpClose, aFd); + NSPRIOAutoObservation timer(mozilla::IOInterposeObserver::OpClose, aFd); return sCloseFn(aFd); } @@ -91,7 +89,7 @@ int32_t PR_CALLBACK interposedRead(PRFileDesc* aFd, void* aBuf, int32_t aAmt) { // If we don't have a valid original function pointer something is very wrong. NS_ASSERTION(sReadFn, "NSPR IO Interposing: sReadFn is NULL"); - NSPRIOAutoObservation timer(IOInterposeObserver::OpRead, aFd); + NSPRIOAutoObservation timer(mozilla::IOInterposeObserver::OpRead, aFd); return sReadFn(aFd, aBuf, aAmt); } @@ -100,7 +98,7 @@ int32_t PR_CALLBACK interposedWrite(PRFileDesc* aFd, const void* aBuf, // If we don't have a valid original function pointer something is very wrong. NS_ASSERTION(sWriteFn, "NSPR IO Interposing: sWriteFn is NULL"); - NSPRIOAutoObservation timer(IOInterposeObserver::OpWrite, aFd); + NSPRIOAutoObservation timer(mozilla::IOInterposeObserver::OpWrite, aFd); return sWriteFn(aFd, aBuf, aAmt); } @@ -108,7 +106,7 @@ PRStatus PR_CALLBACK interposedFSync(PRFileDesc* aFd) { // If we don't have a valid original function pointer something is very wrong. NS_ASSERTION(sFSyncFn, "NSPR IO Interposing: sFSyncFn is NULL"); - NSPRIOAutoObservation timer(IOInterposeObserver::OpFSync, aFd); + NSPRIOAutoObservation timer(mozilla::IOInterposeObserver::OpFSync, aFd); return sFSyncFn(aFd); } @@ -116,7 +114,7 @@ PRStatus PR_CALLBACK interposedFileInfo(PRFileDesc* aFd, PRFileInfo* aInfo) { // If we don't have a valid original function pointer something is very wrong. NS_ASSERTION(sFileInfoFn, "NSPR IO Interposing: sFileInfoFn is NULL"); - NSPRIOAutoObservation timer(IOInterposeObserver::OpStat, aFd); + NSPRIOAutoObservation timer(mozilla::IOInterposeObserver::OpStat, aFd); return sFileInfoFn(aFd, aInfo); } @@ -125,7 +123,7 @@ PRStatus PR_CALLBACK interposedFileInfo64(PRFileDesc* aFd, // If we don't have a valid original function pointer something is very wrong. NS_ASSERTION(sFileInfo64Fn, "NSPR IO Interposing: sFileInfo64Fn is NULL"); - NSPRIOAutoObservation timer(IOInterposeObserver::OpStat, aFd); + NSPRIOAutoObservation timer(mozilla::IOInterposeObserver::OpStat, aFd); return sFileInfo64Fn(aFd, aInfo); } diff --git a/xpcom/build/PoisonIOInterposerBase.cpp b/xpcom/build/PoisonIOInterposerBase.cpp index fbb50731b0..5ae3880d98 100644 --- a/xpcom/build/PoisonIOInterposerBase.cpp +++ b/xpcom/build/PoisonIOInterposerBase.cpp @@ -34,8 +34,6 @@ inline mozilla::Maybe FileDescriptorToHandle(int aFd) { } #endif /* if not XP_WIN */ -using namespace mozilla; - namespace { struct DebugFilesAutoLockTraits { @@ -45,7 +43,7 @@ struct DebugFilesAutoLockTraits { static void release(type aL) { PR_Unlock(aL); } }; -class DebugFilesAutoLock : public Scoped { +class DebugFilesAutoLock : public mozilla::Scoped { static PRLock* Lock; public: @@ -66,7 +64,7 @@ class DebugFilesAutoLock : public Scoped { } DebugFilesAutoLock() - : Scoped(getDebugFileIDsLock()) { + : mozilla::Scoped(getDebugFileIDsLock()) { PR_Lock(get()); } }; @@ -216,7 +214,7 @@ void MozillaRegisterDebugHandle(intptr_t aHandle) { } void MozillaRegisterDebugFD(int aFd) { - Maybe handle = FileDescriptorToHandle(aFd); + mozilla::Maybe handle = FileDescriptorToHandle(aFd); if (!handle.isSome()) { return; } @@ -239,7 +237,7 @@ void MozillaUnRegisterDebugHandle(intptr_t aHandle) { } void MozillaUnRegisterDebugFD(int aFd) { - Maybe handle = FileDescriptorToHandle(aFd); + mozilla::Maybe handle = FileDescriptorToHandle(aFd); if (!handle.isSome()) { return; } @@ -258,11 +256,11 @@ void MozillaUnRegisterDebugFILE(FILE* aFile) { } // extern "C" #ifdef MOZ_REPLACE_MALLOC -void DebugFdRegistry::RegisterHandle(intptr_t aHandle) { +void mozilla::DebugFdRegistry::RegisterHandle(intptr_t aHandle) { MozillaRegisterDebugHandle(aHandle); } -void DebugFdRegistry::UnRegisterHandle(intptr_t aHandle) { +void mozilla::DebugFdRegistry::UnRegisterHandle(intptr_t aHandle) { MozillaUnRegisterDebugHandle(aHandle); } #endif diff --git a/xpcom/build/PoisonIOInterposerMac.cpp b/xpcom/build/PoisonIOInterposerMac.cpp index 8003c77be6..d56ec133e3 100644 --- a/xpcom/build/PoisonIOInterposerMac.cpp +++ b/xpcom/build/PoisonIOInterposerMac.cpp @@ -37,8 +37,6 @@ namespace { -using namespace mozilla; - // Bit tracking if poisoned writes are enabled static bool sIsEnabled = false; @@ -53,25 +51,27 @@ bool IsIPCWrite(int aFd, const struct stat& aBuf); /** * RAII class for timing the duration of an I/O call and reporting the result - * to the IOInterposeObserver API. + * to the mozilla::IOInterposeObserver API. */ -class MacIOAutoObservation : public IOInterposeObserver::Observation { +class MacIOAutoObservation : public mozilla::IOInterposeObserver::Observation { public: - MacIOAutoObservation(IOInterposeObserver::Operation aOp, int aFd) - : IOInterposeObserver::Observation(aOp, sReference, - sIsEnabled && !IsDebugFile(aFd)), + MacIOAutoObservation(mozilla::IOInterposeObserver::Operation aOp, int aFd) + : mozilla::IOInterposeObserver::Observation( + aOp, sReference, sIsEnabled && !mozilla::IsDebugFile(aFd)), mFd(aFd), mHasQueriedFilename(false) {} - MacIOAutoObservation(IOInterposeObserver::Operation aOp, int aFd, + MacIOAutoObservation(mozilla::IOInterposeObserver::Operation aOp, int aFd, const void* aBuf, size_t aCount) - : IOInterposeObserver::Observation( + : mozilla::IOInterposeObserver::Observation( aOp, sReference, - sIsEnabled && !IsDebugFile(aFd) && IsValidWrite(aFd, aBuf, aCount)), + sIsEnabled && !mozilla::IsDebugFile(aFd) && + IsValidWrite(aFd, aBuf, aCount)), mFd(aFd), mHasQueriedFilename(false) {} - // Custom implementation of IOInterposeObserver::Observation::Filename + // Custom implementation of + // mozilla::IOInterposeObserver::Observation::Filename void Filename(nsAString& aFilename) override; ~MacIOAutoObservation() { Report(); } @@ -160,7 +160,7 @@ bool IsValidWrite(int aFd, const void* aWbuf, size_t aCount) { // content. This is needed because dbm doesn't keep track of dirty bits // and can end up writing the same data to disk twice. Once when the // user (nss) asks it to sync and once when closing the database. - auto wbuf2 = MakeUniqueFallible(aCount); + auto wbuf2 = mozilla::MakeUniqueFallible(aCount); if (!wbuf2) { return true; } @@ -201,7 +201,8 @@ typedef ssize_t (*aio_write_t)(struct aiocb* aAioCbp); ssize_t wrap_aio_write(struct aiocb* aAioCbp); FuncData aio_write_data = {0, (void*)wrap_aio_write, (void*)aio_write}; ssize_t wrap_aio_write(struct aiocb* aAioCbp) { - MacIOAutoObservation timer(IOInterposeObserver::OpWrite, aAioCbp->aio_fildes); + MacIOAutoObservation timer(mozilla::IOInterposeObserver::OpWrite, + aAioCbp->aio_fildes); aio_write_t old_write = (aio_write_t)aio_write_data.Buffer; return old_write(aAioCbp); @@ -214,7 +215,7 @@ typedef ssize_t (*pwrite_t)(int aFd, const void* buf, size_t aNumBytes, template ssize_t wrap_pwrite_temp(int aFd, const void* aBuf, size_t aNumBytes, off_t aOffset) { - MacIOAutoObservation timer(IOInterposeObserver::OpWrite, aFd); + MacIOAutoObservation timer(mozilla::IOInterposeObserver::OpWrite, aFd); pwrite_t old_write = (pwrite_t)foo.Buffer; return old_write(aFd, aBuf, aNumBytes, aOffset); } @@ -234,8 +235,8 @@ DEFINE_PWRITE_DATA(pwrite_NOCANCEL, "pwrite$NOCANCEL"); typedef ssize_t (*writev_t)(int aFd, const struct iovec* aIov, int aIovCount); template ssize_t wrap_writev_temp(int aFd, const struct iovec* aIov, int aIovCount) { - MacIOAutoObservation timer(IOInterposeObserver::OpWrite, aFd, nullptr, - aIovCount); + MacIOAutoObservation timer(mozilla::IOInterposeObserver::OpWrite, aFd, + nullptr, aIovCount); writev_t old_write = (writev_t)foo.Buffer; return old_write(aFd, aIov, aIovCount); } @@ -255,7 +256,8 @@ DEFINE_WRITEV_DATA(writev_NOCANCEL, "writev$NOCANCEL"); typedef ssize_t (*write_t)(int aFd, const void* aBuf, size_t aCount); template ssize_t wrap_write_temp(int aFd, const void* aBuf, size_t aCount) { - MacIOAutoObservation timer(IOInterposeObserver::OpWrite, aFd, aBuf, aCount); + MacIOAutoObservation timer(mozilla::IOInterposeObserver::OpWrite, aFd, aBuf, + aCount); write_t old_write = (write_t)foo.Buffer; return old_write(aFd, aBuf, aCount); } @@ -283,7 +285,7 @@ FuncData* Functions[] = {&aio_write_data, &writev_data, &writev_NOCANCEL_UNIX2003_data, &writev_UNIX2003_data, &writev_NOCANCEL_data}; -const int NumFunctions = ArrayLength(Functions); +const int NumFunctions = mozilla::ArrayLength(Functions); } // namespace diff --git a/xpcom/build/PoisonIOInterposerWin.cpp b/xpcom/build/PoisonIOInterposerWin.cpp index c3483348a4..6548a097ab 100644 --- a/xpcom/build/PoisonIOInterposerWin.cpp +++ b/xpcom/build/PoisonIOInterposerWin.cpp @@ -25,8 +25,6 @@ # include "replace_malloc_bridge.h" #endif -using namespace mozilla; - namespace { // Keep track of poisoned state. Notice that there is no reason to lock access @@ -107,15 +105,15 @@ typedef NTSTATUS(NTAPI* NtQueryFullAttributesFileFn)( /** * RAII class for timing the duration of an I/O call and reporting the result - * to the IOInterposeObserver API. + * to the mozilla::IOInterposeObserver API. */ -class WinIOAutoObservation : public IOInterposeObserver::Observation { +class WinIOAutoObservation : public mozilla::IOInterposeObserver::Observation { public: - WinIOAutoObservation(IOInterposeObserver::Operation aOp, HANDLE aFileHandle, - const LARGE_INTEGER* aOffset) - : IOInterposeObserver::Observation( + WinIOAutoObservation(mozilla::IOInterposeObserver::Operation aOp, + HANDLE aFileHandle, const LARGE_INTEGER* aOffset) + : mozilla::IOInterposeObserver::Observation( aOp, sReference, - !IsDebugFile(reinterpret_cast(aFileHandle))), + !mozilla::IsDebugFile(reinterpret_cast(aFileHandle))), mFileHandle(aFileHandle), mHasQueriedFilename(false) { if (mShouldReport) { @@ -123,13 +121,14 @@ class WinIOAutoObservation : public IOInterposeObserver::Observation { } } - WinIOAutoObservation(IOInterposeObserver::Operation aOp, nsAString& aFilename) - : IOInterposeObserver::Observation(aOp, sReference), + WinIOAutoObservation(mozilla::IOInterposeObserver::Operation aOp, + nsAString& aFilename) + : mozilla::IOInterposeObserver::Observation(aOp, sReference), mFileHandle(nullptr), mHasQueriedFilename(false) { if (mShouldReport) { nsAutoString dosPath; - if (NtPathToDosPath(aFilename, dosPath)) { + if (mozilla::NtPathToDosPath(aFilename, dosPath)) { mFilename = dosPath; } else { // If we can't get a dosPath, what we have is better than nothing. @@ -140,7 +139,8 @@ class WinIOAutoObservation : public IOInterposeObserver::Observation { } } - // Custom implementation of IOInterposeObserver::Observation::Filename + // Custom implementation of + // mozilla::IOInterposeObserver::Observation::Filename void Filename(nsAString& aFilename) override; ~WinIOAutoObservation() { Report(); } @@ -165,7 +165,8 @@ void WinIOAutoObservation::Filename(nsAString& aFilename) { } nsAutoString filename; - if (mFileHandle && HandleToFilename(mFileHandle, mOffset, filename)) { + if (mFileHandle && + mozilla::HandleToFilename(mFileHandle, mOffset, filename)) { mFilename = filename; } mHasQueriedFilename = true; @@ -176,17 +177,19 @@ void WinIOAutoObservation::Filename(nsAString& aFilename) { /*************************** IO Interposing Methods ***************************/ // Function pointers to original functions -static WindowsDllInterceptor::FuncHookType +static mozilla::WindowsDllInterceptor::FuncHookType gOriginalNtCreateFile; -static WindowsDllInterceptor::FuncHookType gOriginalNtReadFile; -static WindowsDllInterceptor::FuncHookType +static mozilla::WindowsDllInterceptor::FuncHookType + gOriginalNtReadFile; +static mozilla::WindowsDllInterceptor::FuncHookType gOriginalNtReadFileScatter; -static WindowsDllInterceptor::FuncHookType gOriginalNtWriteFile; -static WindowsDllInterceptor::FuncHookType +static mozilla::WindowsDllInterceptor::FuncHookType + gOriginalNtWriteFile; +static mozilla::WindowsDllInterceptor::FuncHookType gOriginalNtWriteFileGather; -static WindowsDllInterceptor::FuncHookType +static mozilla::WindowsDllInterceptor::FuncHookType gOriginalNtFlushBuffersFile; -static WindowsDllInterceptor::FuncHookType +static mozilla::WindowsDllInterceptor::FuncHookType gOriginalNtQueryFullAttributesFile; static NTSTATUS NTAPI InterposedNtCreateFile( @@ -202,7 +205,8 @@ static NTSTATUS NTAPI InterposedNtCreateFile( ? aObjectAttributes->ObjectName->Length / sizeof(WCHAR) : 0; nsDependentSubstring filename(buf, len); - WinIOAutoObservation timer(IOInterposeObserver::OpCreateOrOpen, filename); + WinIOAutoObservation timer(mozilla::IOInterposeObserver::OpCreateOrOpen, + filename); // Something is badly wrong if this function is undefined MOZ_ASSERT(gOriginalNtCreateFile); @@ -221,7 +225,8 @@ static NTSTATUS NTAPI InterposedNtReadFile(HANDLE aFileHandle, HANDLE aEvent, PLARGE_INTEGER aOffset, PULONG aKey) { // Report IO - WinIOAutoObservation timer(IOInterposeObserver::OpRead, aFileHandle, aOffset); + WinIOAutoObservation timer(mozilla::IOInterposeObserver::OpRead, aFileHandle, + aOffset); // Something is badly wrong if this function is undefined MOZ_ASSERT(gOriginalNtReadFile); @@ -236,7 +241,8 @@ static NTSTATUS NTAPI InterposedNtReadFileScatter( PIO_STATUS_BLOCK aIoStatus, FILE_SEGMENT_ELEMENT* aSegments, ULONG aLength, PLARGE_INTEGER aOffset, PULONG aKey) { // Report IO - WinIOAutoObservation timer(IOInterposeObserver::OpRead, aFileHandle, aOffset); + WinIOAutoObservation timer(mozilla::IOInterposeObserver::OpRead, aFileHandle, + aOffset); // Something is badly wrong if this function is undefined MOZ_ASSERT(gOriginalNtReadFileScatter); @@ -255,7 +261,7 @@ static NTSTATUS NTAPI InterposedNtWriteFile(HANDLE aFileHandle, HANDLE aEvent, PLARGE_INTEGER aOffset, PULONG aKey) { // Report IO - WinIOAutoObservation timer(IOInterposeObserver::OpWrite, aFileHandle, + WinIOAutoObservation timer(mozilla::IOInterposeObserver::OpWrite, aFileHandle, aOffset); // Something is badly wrong if this function is undefined @@ -272,7 +278,7 @@ static NTSTATUS NTAPI InterposedNtWriteFileGather( PIO_STATUS_BLOCK aIoStatus, FILE_SEGMENT_ELEMENT* aSegments, ULONG aLength, PLARGE_INTEGER aOffset, PULONG aKey) { // Report IO - WinIOAutoObservation timer(IOInterposeObserver::OpWrite, aFileHandle, + WinIOAutoObservation timer(mozilla::IOInterposeObserver::OpWrite, aFileHandle, aOffset); // Something is badly wrong if this function is undefined @@ -287,7 +293,7 @@ static NTSTATUS NTAPI InterposedNtWriteFileGather( static NTSTATUS NTAPI InterposedNtFlushBuffersFile( HANDLE aFileHandle, PIO_STATUS_BLOCK aIoStatusBlock) { // Report IO - WinIOAutoObservation timer(IOInterposeObserver::OpFSync, aFileHandle, + WinIOAutoObservation timer(mozilla::IOInterposeObserver::OpFSync, aFileHandle, nullptr); // Something is badly wrong if this function is undefined @@ -307,7 +313,7 @@ static NTSTATUS NTAPI InterposedNtQueryFullAttributesFile( ? aObjectAttributes->ObjectName->Length / sizeof(WCHAR) : 0; nsDependentSubstring filename(buf, len); - WinIOAutoObservation timer(IOInterposeObserver::OpStat, filename); + WinIOAutoObservation timer(mozilla::IOInterposeObserver::OpStat, filename); // Something is badly wrong if this function is undefined MOZ_ASSERT(gOriginalNtQueryFullAttributesFile); @@ -322,7 +328,7 @@ static NTSTATUS NTAPI InterposedNtQueryFullAttributesFile( /******************************** IO Poisoning ********************************/ // Windows DLL interceptor -static WindowsDllInterceptor sNtDllInterceptor; +static mozilla::WindowsDllInterceptor sNtDllInterceptor; namespace mozilla { diff --git a/xpcom/build/XPCOM.h b/xpcom/build/XPCOM.h index 0f04f9c0c0..024869c9c9 100644 --- a/xpcom/build/XPCOM.h +++ b/xpcom/build/XPCOM.h @@ -32,7 +32,6 @@ #include "nsISupports.h" #include "nsTArray.h" -#include "nsTWeakRef.h" #include "nsCOMPtr.h" #include "nsCOMArray.h" diff --git a/xpcom/build/XPCOMInit.cpp b/xpcom/build/XPCOMInit.cpp index 29f176f1c1..cec15d15e1 100644 --- a/xpcom/build/XPCOMInit.cpp +++ b/xpcom/build/XPCOMInit.cpp @@ -100,7 +100,6 @@ #include "gfxPlatform.h" -using namespace mozilla; using base::AtExitManager; using mozilla::ipc::BrowserProcessSubThread; @@ -114,7 +113,7 @@ static AtExitManager* sExitManager; static MessageLoop* sMessageLoop; static bool sCommandLineWasInitialized; static BrowserProcessSubThread* sIOThread; -static BackgroundHangMonitor* sMainHangMonitor; +static mozilla::BackgroundHangMonitor* sMainHangMonitor; } /* anonymous namespace */ @@ -173,7 +172,7 @@ const mozilla::Module kXPCOMModule = { nullptr, nullptr, nullptr, - Module::ALLOW_IN_GPU_RDD_VR_AND_SOCKET_PROCESS}; + mozilla::Module::ALLOW_IN_GPU_RDD_VR_AND_SOCKET_PROCESS}; // gDebug will be freed during shutdown. static nsIDebug2* gDebug = nullptr; @@ -184,7 +183,7 @@ NS_GetDebug(nsIDebug2** aResult) { } class ICUReporter final : public nsIMemoryReporter, - public CountingAllocatorBase { + public mozilla::CountingAllocatorBase { public: NS_DECL_ISUPPORTS @@ -215,11 +214,11 @@ class ICUReporter final : public nsIMemoryReporter, NS_IMPL_ISUPPORTS(ICUReporter, nsIMemoryReporter) /* static */ template <> -CountingAllocatorBase::AmountType - CountingAllocatorBase::sAmount(0); +mozilla::CountingAllocatorBase::AmountType + mozilla::CountingAllocatorBase::sAmount(0); class OggReporter final : public nsIMemoryReporter, - public CountingAllocatorBase { + public mozilla::CountingAllocatorBase { public: NS_DECL_ISUPPORTS @@ -241,15 +240,16 @@ class OggReporter final : public nsIMemoryReporter, NS_IMPL_ISUPPORTS(OggReporter, nsIMemoryReporter) /* static */ template <> -CountingAllocatorBase::AmountType - CountingAllocatorBase::sAmount(0); +mozilla::CountingAllocatorBase::AmountType + mozilla::CountingAllocatorBase::sAmount(0); static bool sInitializedJS = false; // Note that on OSX, aBinDirectory will point to .app/Contents/Resources/browser EXPORT_XPCOM_API(nsresult) NS_InitXPCOM(nsIServiceManager** aResult, nsIFile* aBinDirectory, - nsIDirectoryServiceProvider* aAppFileLocationProvider) { + nsIDirectoryServiceProvider* aAppFileLocationProvider, + bool aInitJSContext) { static bool sInitialized = false; if (sInitialized) { return NS_ERROR_FAILURE; @@ -307,8 +307,9 @@ NS_InitXPCOM(nsIServiceManager** aResult, nsIFile* aBinDirectory, if (XRE_IsParentProcess() && !BrowserProcessSubThread::GetMessageLoop(BrowserProcessSubThread::IO)) { - UniquePtr ioThread = - MakeUnique(BrowserProcessSubThread::IO); + mozilla::UniquePtr ioThread = + mozilla::MakeUnique( + BrowserProcessSubThread::IO); base::Thread::Options options; options.message_loop_type = MessageLoop::TYPE_IO; @@ -326,8 +327,8 @@ NS_InitXPCOM(nsIServiceManager** aResult, nsIFile* aBinDirectory, } AUTO_PROFILER_INIT2; - // Init the SystemGroup for dispatching main thread runnables. - SystemGroup::InitStatic(); + // Init the mozilla::SystemGroup for dispatching main thread runnables. + mozilla::SystemGroup::InitStatic(); // Set up the timer globals/timer thread rv = nsTimerImpl::Startup(); @@ -351,8 +352,7 @@ NS_InitXPCOM(nsIServiceManager** aResult, nsIFile* aBinDirectory, rv = aBinDirectory->IsDirectory(&value); if (NS_SUCCEEDED(rv) && value) { - nsDirectoryService::gService->Set(NS_XPCOM_INIT_CURRENT_PROCESS_DIR, - aBinDirectory); + nsDirectoryService::gService->SetCurrentProcessDirectory(aBinDirectory); } } @@ -393,7 +393,7 @@ NS_InitXPCOM(nsIServiceManager** aResult, nsIFile* aBinDirectory, return NS_ERROR_FAILURE; } - rv = binaryFile->AppendNative(NS_LITERAL_CSTRING("nonexistent-executable")); + rv = binaryFile->AppendNative("nonexistent-executable"_ns); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -459,10 +459,9 @@ NS_InitXPCOM(nsIServiceManager** aResult, nsIFile* aBinDirectory, // to the directory service. nsDirectoryService::gService->RegisterCategoryProviders(); - // Init SharedThreadPool (which needs the service manager). - SharedThreadPool::InitStatics(); + // Init mozilla::SharedThreadPool (which needs the service manager). + mozilla::SharedThreadPool::InitStatics(); - mozilla::ScriptPreloader::GetSingleton(); mozilla::scache::StartupCache::GetSingleton(); mozilla::AvailableMemoryTracker::Init(); @@ -488,6 +487,10 @@ NS_InitXPCOM(nsIServiceManager** aResult, nsIFile* aBinDirectory, mozilla::dom::JSExecutionManager::Initialize(); + if (aInitJSContext) { + xpc::InitializeJSContext(); + } + return NS_OK; } @@ -511,8 +514,8 @@ NS_InitMinimalXPCOM() { return rv; } - // Init the SystemGroup for dispatching main thread runnables. - SystemGroup::InitStatic(); + // Init the mozilla::SystemGroup for dispatching main thread runnables. + mozilla::SystemGroup::InitStatic(); // Set up the timer globals/timer thread. rv = nsTimerImpl::Startup(); @@ -535,7 +538,7 @@ NS_InitMinimalXPCOM() { return NS_ERROR_UNEXPECTED; } - SharedThreadPool::InitStatics(); + mozilla::SharedThreadPool::InitStatics(); mozilla::Telemetry::Init(); mozilla::BackgroundHangMonitor::Startup(); diff --git a/xpcom/build/nsXPCOM.h b/xpcom/build/nsXPCOM.h index e377df504f..b3e0dd330a 100644 --- a/xpcom/build/nsXPCOM.h +++ b/xpcom/build/nsXPCOM.h @@ -62,6 +62,9 @@ struct Module; * component registry preferences and so on; or use * nullptr for the default behaviour. * + * @param aInitJSContext Whether the nsXPCJSContext should be initialized at + * this point. + * * @see NS_NewLocalFile * @see nsIFile * @see nsIDirectoryServiceProvider @@ -74,7 +77,8 @@ struct Module; */ XPCOM_API(nsresult) NS_InitXPCOM(nsIServiceManager** aResult, nsIFile* aBinDirectory, - nsIDirectoryServiceProvider* aAppFileLocationProvider); + nsIDirectoryServiceProvider* aAppFileLocationProvider, + bool aInitJSContext = true); /** * Initialize only minimal components of XPCOM. This ensures nsThreadManager, diff --git a/xpcom/components/ManifestParser.cpp b/xpcom/components/ManifestParser.cpp index dce301027c..6b9cc70f3c 100644 --- a/xpcom/components/ManifestParser.cpp +++ b/xpcom/components/ManifestParser.cpp @@ -267,8 +267,7 @@ static bool CheckOsFlag(const nsAString& aFlag, const nsAString& aData, bool result = CheckStringFlag(aFlag, aData, aValue, aResult); #if defined(XP_UNIX) && !defined(XP_DARWIN) && !defined(ANDROID) if (result && aResult == eBad) { - result = - CheckStringFlag(aFlag, aData, NS_LITERAL_STRING("likeunix"), aResult); + result = CheckStringFlag(aFlag, aData, u"likeunix"_ns, aResult); } #endif return result; diff --git a/xpcom/components/gen_static_components.py b/xpcom/components/gen_static_components.py index 1571091921..1dbe471c9c 100644 --- a/xpcom/components/gen_static_components.py +++ b/xpcom/components/gen_static_components.py @@ -355,7 +355,7 @@ class ModuleEntry(object): if self.jsm: res += ( ' nsCOMPtr inst;\n' - ' MOZ_TRY(ConstructJSMComponent(NS_LITERAL_CSTRING(%s),\n' + ' MOZ_TRY(ConstructJSMComponent(nsLiteralCString(%s),\n' ' %s,\n' ' getter_AddRefs(inst)));' '\n' % (json.dumps(self.jsm), json.dumps(self.constructor))) diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index baff9917d6..96269075ff 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -199,8 +199,8 @@ class MOZ_STACK_CLASS EntryWrapper final { nsCString ModuleDescription() { MATCH(nsCString, return entry->mModule ? entry->mModule->Description() - : NS_LITERAL_CSTRING(""), - return NS_LITERAL_CSTRING("")); + : ""_ns, + return ""_ns); } private: @@ -310,9 +310,6 @@ extern const mozilla::Module kLayoutModule; extern const mozilla::Module kKeyValueModule; extern const mozilla::Module kXREModule; extern const mozilla::Module kEmbeddingModule; -#if defined(MOZ_WIDGET_ANDROID) -extern const mozilla::Module kBrowserModule; -#endif static nsTArray* sExtraStaticModules; @@ -398,9 +395,6 @@ nsresult nsComponentManagerImpl::Init() { RegisterModule(&kKeyValueModule); RegisterModule(&kXREModule); RegisterModule(&kEmbeddingModule); -#if defined(MOZ_WIDGET_ANDROID) - RegisterModule(&kBrowserModule); -#endif for (uint32_t i = 0; i < sExtraStaticModules->Length(); ++i) { RegisterModule((*sExtraStaticModules)[i]); @@ -457,8 +451,7 @@ nsresult nsComponentManagerImpl::Init() { if (greOmnijar) { cl->location.Init(greOmnijar, "chrome.manifest"); } else { - nsCOMPtr lf = - CloneAndAppend(greDir, NS_LITERAL_CSTRING("chrome.manifest")); + nsCOMPtr lf = CloneAndAppend(greDir, "chrome.manifest"_ns); cl->location.Init(lf); } @@ -474,8 +467,7 @@ nsresult nsComponentManagerImpl::Init() { if (!equals) { cl = sModuleLocations->AppendElement(); cl->type = NS_APP_LOCATION; - nsCOMPtr lf = - CloneAndAppend(appDir, NS_LITERAL_CSTRING("chrome.manifest")); + nsCOMPtr lf = CloneAndAppend(appDir, "chrome.manifest"_ns); cl->location.Init(lf); } } @@ -1089,10 +1081,8 @@ nsComponentManagerImpl::CreateInstance(const nsCID& aClass, #ifdef SHOW_CI_ON_EXISTING_SERVICE if (entry->ServiceInstance()) { nsAutoCString message; - message = - NS_LITERAL_CSTRING("You are calling CreateInstance \"") + - AutoIDString(aClass) + - NS_LITERAL_CSTRING("\" when a service for this CID already exists!"); + message = "You are calling CreateInstance \""_ns + AutoIDString(aClass) + + "\" when a service for this CID already exists!"_ns; NS_ERROR(message.get()); } #endif @@ -1172,9 +1162,9 @@ nsComponentManagerImpl::CreateInstanceByContractID(const char* aContractID, if (entry->ServiceInstance()) { nsAutoCString message; message = - NS_LITERAL_CSTRING("You are calling CreateInstance \"") + + "You are calling CreateInstance \""_ns + nsDependentCString(aContractID) + - NS_LITERAL_CSTRING( + nsLiteralCString( "\" when a service for this CID already exists! " "Add it to abusedContracts to track down the service consumer."); NS_ERROR(message.get()); @@ -1884,8 +1874,7 @@ nsComponentManagerImpl::AddBootstrappedManifestLocation(nsIFile* aLocation) { return XRE_AddJarManifestLocation(NS_BOOTSTRAPPED_LOCATION, aLocation); } - nsCOMPtr manifest = - CloneAndAppend(aLocation, NS_LITERAL_CSTRING("chrome.manifest")); + nsCOMPtr manifest = CloneAndAppend(aLocation, "chrome.manifest"_ns); return XRE_AddManifestLocation(NS_BOOTSTRAPPED_LOCATION, manifest); } @@ -1911,8 +1900,7 @@ nsComponentManagerImpl::RemoveBootstrappedManifestLocation(nsIFile* aLocation) { if (Substring(path, path.Length() - 4).EqualsLiteral(".xpi")) { elem.location.Init(aLocation, "chrome.manifest"); } else { - nsCOMPtr lf = - CloneAndAppend(aLocation, NS_LITERAL_CSTRING("chrome.manifest")); + nsCOMPtr lf = CloneAndAppend(aLocation, "chrome.manifest"_ns); elem.location.Init(lf); } diff --git a/xpcom/components/nsComponentManager.h b/xpcom/components/nsComponentManager.h index 77c5699f36..dc118238f8 100644 --- a/xpcom/components/nsComponentManager.h +++ b/xpcom/components/nsComponentManager.h @@ -7,7 +7,6 @@ #include "nsXPCOM.h" -#include "xpcom-private.h" #include "nsIComponentManager.h" #include "nsIComponentRegistrar.h" #include "nsIMemoryReporter.h" diff --git a/xpcom/ds/AtomArray.h b/xpcom/ds/AtomArray.h index d09eed5f00..bded74bf24 100644 --- a/xpcom/ds/AtomArray.h +++ b/xpcom/ds/AtomArray.h @@ -11,7 +11,7 @@ class nsAtom; namespace mozilla { -typedef nsTArray> AtomArray; +typedef AutoTArray, 4> AtomArray; } #endif // mozilla_AtomArray_h diff --git a/xpcom/ds/StaticAtoms.py b/xpcom/ds/StaticAtoms.py index ce35a37200..c9aa0f70dc 100644 --- a/xpcom/ds/StaticAtoms.py +++ b/xpcom/ds/StaticAtoms.py @@ -405,6 +405,7 @@ STATIC_ATOMS = [ Atom("enctype", "enctype"), Atom("end", "end"), Atom("endEvent", "endEvent"), + Atom("enterkeyhint", "enterkeyhint"), Atom("equalsize", "equalsize"), Atom("error", "error"), Atom("ethiopic_numeric", "ethiopic-numeric"), @@ -1894,6 +1895,58 @@ STATIC_ATOMS = [ Atom("onmozvisualresize", "onmozvisualresize"), Atom("onmozvisualscroll", "onmozvisualscroll"), + # Miscellaneous events included for memory usage optimization (see bug 1542885) + Atom("onDOMAutoComplete", "onDOMAutoComplete"), + Atom("onDOMContentLoaded", "onDOMContentLoaded"), + Atom("onDOMDocElementInserted", "onDOMDocElementInserted"), + Atom("onDOMFormBeforeSubmit", "onDOMFormBeforeSubmit"), + Atom("onDOMFormHasPassword", "onDOMFormHasPassword"), + Atom("onDOMFrameContentLoaded", "onDOMFrameContentLoaded"), + Atom("onDOMHeadElementParsed", "onDOMHeadElementParsed"), + Atom("onDOMInputPasswordAdded", "onDOMInputPasswordAdded"), + Atom("onDOMLinkAdded", "onDOMLinkAdded"), + Atom("onDOMLinkChanged", "onDOMLinkChanged"), + Atom("onDOMMetaAdded", "onDOMMetaAdded"), + Atom("onDOMMetaChanged", "onDOMMetaChanged"), + Atom("onDOMMetaRemoved", "onDOMMetaRemoved"), + Atom("onDOMPopupBlocked", "onDOMPopupBlocked"), + Atom("onDOMTitleChanged", "onDOMTitleChanged"), + Atom("onDOMWindowClose", "onDOMWindowClose"), + Atom("onDOMWindowCreated", "onDOMWindowCreated"), + Atom("onDOMWindowFocus", "onDOMWindowFocus"), + Atom("onFullZoomChange", "onFullZoomChange"), + Atom("onGloballyAutoplayBlocked", "onGloballyAutoplayBlocked"), + Atom("onHiddenPlugin", "onHiddenPlugin"), + Atom("onMozApplicationManifest", "onMozApplicationManifest"), + Atom("onMozDOMFullscreen_Entered", "onMozDOMFullscreen:Entered"), + Atom("onMozDOMFullscreen_Exit", "onMozDOMFullscreen:Exit"), + Atom("onMozDOMFullscreen_Exited", "onMozDOMFullscreen:Exited"), + Atom("onMozDOMFullscreen_NewOrigin", "onMozDOMFullscreen:NewOrigin"), + Atom("onMozDOMFullscreen_Request", "onMozDOMFullscreen:Request"), + Atom("onMozDOMPointerLock_Entered", "onMozDOMPointerLock:Entered"), + Atom("onMozDOMPointerLock_Exited", "onMozDOMPointerLock:Exited"), + Atom("onMozInvalidForm", "onMozInvalidForm"), + Atom("onMozLocalStorageChanged", "onMozLocalStorageChanged"), + Atom("onMozOpenDateTimePicker", "onMozOpenDateTimePicker"), + Atom("onMozSessionStorageChanged", "onMozSessionStorageChanged"), + Atom("onMozTogglePictureInPicture", "onMozTogglePictureInPicture"), + Atom("onPluginBindingAttached", "onPluginBindingAttached"), + Atom("onPluginCrashed", "onPluginCrashed"), + Atom("onPluginInstantiated", "onPluginInstantiated"), + Atom("onPluginOutdated", "onPluginOutdated"), + Atom("onPluginRemoved", "onPluginRemoved"), + Atom("onPrintingError", "onPrintingError"), + Atom("onTextZoomChange", "onTextZoomChange"), + Atom("onUAWidgetSetupOrChange", "onUAWidgetSetupOrChange"), + Atom("onUAWidgetTeardown", "onUAWidgetTeardown"), + Atom("onUnselectedTabHover_Disable", "onUnselectedTabHover:Disable"), + Atom("onUnselectedTabHover_Enable", "onUnselectedTabHover:Enable"), + Atom("onZoomChangeUsingMouseWheel", "onZoomChangeUsingMouseWheel"), + Atom("onmozshowdropdown", "onmozshowdropdown"), + Atom("onmozshowdropdown_sourcetouch", "onmozshowdropdown-sourcetouch"), + Atom("onprintPreviewUpdate", "onprintPreviewUpdate"), + Atom("onscrollend", "onscrollend"), + # WebExtensions Atom("moz_extension", "moz-extension"), Atom("all_urlsPermission", ""), diff --git a/xpcom/ds/nsAtomTable.cpp b/xpcom/ds/nsAtomTable.cpp index b281571eea..ebdcb0431c 100644 --- a/xpcom/ds/nsAtomTable.cpp +++ b/xpcom/ds/nsAtomTable.cpp @@ -428,9 +428,9 @@ void nsAtomSubTable::GCLocked(GCKind aKind) { if (nonZeroRefcountAtomsCount == 0) { nonZeroRefcountAtoms = name; } else if (nonZeroRefcountAtomsCount < 20) { - nonZeroRefcountAtoms += NS_LITERAL_CSTRING(",") + name; + nonZeroRefcountAtoms += ","_ns + name; } else if (nonZeroRefcountAtomsCount == 20) { - nonZeroRefcountAtoms += NS_LITERAL_CSTRING(",..."); + nonZeroRefcountAtoms += ",..."_ns; } nonZeroRefcountAtomsCount++; } diff --git a/xpcom/ds/nsExpirationTracker.h b/xpcom/ds/nsExpirationTracker.h index cf16b775b5..724c8681f6 100644 --- a/xpcom/ds/nsExpirationTracker.h +++ b/xpcom/ds/nsExpirationTracker.h @@ -311,7 +311,7 @@ class ExpirationTrackerImpl { friend class Iterator; - bool IsEmptyLocked(const AutoLock& aAutoLock) { + bool IsEmptyLocked(const AutoLock& aAutoLock) const { for (uint32_t i = 0; i < K; ++i) { if (!mGenerations[i].IsEmpty()) { return false; @@ -320,6 +320,26 @@ class ExpirationTrackerImpl { return true; } + size_t Length(const AutoLock& aAutoLock) const { + size_t len = 0; + for (uint32_t i = 0; i < K; ++i) { + len += mGenerations[i].Length(); + } + return len; + } + + // @return The amount of memory used by this ExpirationTrackerImpl, excluding + // sizeof(*this). If you want to measure anything hanging off the mGenerations + // array, you must iterate over the elements and measure them individually; + // hence the "Shallow" prefix. + size_t ShallowSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { + size_t bytes = 0; + for (uint32_t i = 0; i < K; ++i) { + bytes += mGenerations[i].ShallowSizeOfExcludingThis(aMallocSizeOf); + } + return bytes; + } + protected: /** * This must be overridden to catch notifications. It is called whenever diff --git a/xpcom/ds/nsObserverService.cpp b/xpcom/ds/nsObserverService.cpp index e56255bf1a..2b342b22d0 100644 --- a/xpcom/ds/nsObserverService.cpp +++ b/xpcom/ds/nsObserverService.cpp @@ -97,10 +97,10 @@ nsObserverService::CollectReports(nsIHandleReportCallback* aHandleReport, aHandleReport->Callback( /* process */ EmptyCString(), suspectPath, KIND_OTHER, UNITS_COUNT, suspect.mReferentCount, - NS_LITERAL_CSTRING("A topic with a suspiciously large number of " - "referents. This may be symptomatic of a leak " - "if the number of referents is high with " - "respect to the number of windows."), + nsLiteralCString("A topic with a suspiciously large number of " + "referents. This may be symptomatic of a leak " + "if the number of referents is high with " + "respect to the number of windows."), aData); } @@ -187,8 +187,7 @@ nsresult nsObserverService::FilterHttpOnTopics(const char* aTopic) { do_GetService(NS_CONSOLESERVICE_CONTRACTID)); nsCOMPtr error( do_CreateInstance(NS_SCRIPTERROR_CONTRACTID)); - error->Init(NS_LITERAL_STRING( - "http-on-* observers only work in the parent process"), + error->Init(u"http-on-* observers only work in the parent process"_ns, EmptyString(), EmptyString(), 0, 0, nsIScriptError::warningFlag, "chrome javascript", false /* from private window */, true /* from chrome context */); diff --git a/xpcom/idl-parser/xpidl/runtests.py b/xpcom/idl-parser/xpidl/runtests.py index 8d4570d312..6ee5b889ea 100644 --- a/xpcom/idl-parser/xpidl/runtests.py +++ b/xpcom/idl-parser/xpidl/runtests.py @@ -63,13 +63,15 @@ void bar(); self.assertEqual(xpidl.TypeId("void"), m.type) def testMethodParams(self): - i = self.p.parse("""[uuid(abc)] interface foo { -long bar(in long a, in float b, [array] in long c); -};""", filename='f') + i = self.p.parse(""" + [scriptable, uuid(aaa)] interface nsISupports {}; + [uuid(abc)] interface foo : nsISupports { + long bar(in long a, in float b, [array] in long c); + };""", filename='f') i.resolve([], self.p, {}) self.assertTrue(isinstance(i, xpidl.IDL)) - self.assertTrue(isinstance(i.productions[0], xpidl.Interface)) - iface = i.productions[0] + self.assertTrue(isinstance(i.productions[1], xpidl.Interface)) + iface = i.productions[1] m = iface.members[0] self.assertTrue(isinstance(m, xpidl.Method)) self.assertEqual("bar", m.name) @@ -97,10 +99,12 @@ attribute long bar; self.assertEqual(xpidl.TypeId("long"), a.type) def testOverloadedVirtual(self): - i = self.p.parse("""[uuid(abc)] interface foo { -attribute long bar; -void getBar(); -};""", filename='f') + i = self.p.parse(""" + [scriptable, uuid(00000000-0000-0000-0000-000000000000)] interface nsISupports {}; + [uuid(abc)] interface foo : nsISupports { + attribute long bar; + void getBar(); + };""", filename='f') self.assertTrue(isinstance(i, xpidl.IDL)) i.resolve([], self.p, {}) @@ -114,9 +118,24 @@ void getBar(); self.assertEqual( e.args[0], "Unexpected overloaded virtual method GetBar in interface foo") + def testNotISupports(self): + i = self.p.parse(""" + [uuid(abc)] interface foo {}; + """, filename='f') + self.assertTrue(isinstance(i, xpidl.IDL)) + try: + i.resolve([], self.p, {}) + self.assertTrue(False, + "Must check that interfaces inherit from nsISupports") + except xpidl.IDLError as e: + self.assertEqual( + e.message, + "Interface 'foo' must inherit from nsISupports") + def testBuiltinClassParent(self): i = self.p.parse(""" - [scriptable, builtinclass, uuid(abc)] interface foo {}; + [scriptable, uuid(aaa)] interface nsISupports {}; + [scriptable, builtinclass, uuid(abc)] interface foo : nsISupports {}; [scriptable, uuid(def)] interface bar : foo {}; """, filename='f') self.assertTrue(isinstance(i, xpidl.IDL)) @@ -132,7 +151,8 @@ void getBar(); def testScriptableNotXPCOM(self): # notxpcom method requires builtinclass on the interface i = self.p.parse(""" - [scriptable, uuid(abc)] interface nsIScriptableWithNotXPCOM { + [scriptable, uuid(aaa)] interface nsISupports {}; + [scriptable, uuid(abc)] interface nsIScriptableWithNotXPCOM : nsISupports { [notxpcom] void method2(); }; """, filename='f') @@ -150,7 +170,8 @@ void getBar(); # notxpcom attribute requires builtinclass on the interface i = self.p.parse(""" interface nsISomeInterface; - [scriptable, uuid(abc)] interface nsIScriptableWithNotXPCOM { + [scriptable, uuid(aaa)] interface nsISupports {}; + [scriptable, uuid(abc)] interface nsIScriptableWithNotXPCOM : nsISupports { [notxpcom] attribute nsISomeInterface attrib; }; """, filename='f') diff --git a/xpcom/idl-parser/xpidl/rust.py b/xpcom/idl-parser/xpidl/rust.py index c628539769..93d96b124f 100644 --- a/xpcom/idl-parser/xpidl/rust.py +++ b/xpcom/idl-parser/xpidl/rust.py @@ -479,12 +479,7 @@ def write_interface(iface, fd): if iface.namemap is None: raise Exception("Interface was not resolved.") - # if we see a base class-less type other than nsISupports, we just need - # to discard anything else about it other than its constants. - if iface.base is None and iface.name != "nsISupports": - assert len([m for m in iface.members - if type(m) == xpidl.Attribute or type(m) == xpidl.Method]) == 0 - return + assert iface.base or (iface.name == "nsISupports") # Extract the UUID's information so that it can be written into the struct definition names = uuid_decoder.match(iface.attributes.uuid).groupdict() diff --git a/xpcom/idl-parser/xpidl/rust_macros.py b/xpcom/idl-parser/xpidl/rust_macros.py index fec08e02ea..45b37d5f4a 100644 --- a/xpcom/idl-parser/xpidl/rust_macros.py +++ b/xpcom/idl-parser/xpidl/rust_macros.py @@ -51,12 +51,7 @@ def write_interface(iface, fd): if iface.namemap is None: raise Exception("Interface was not resolved.") - # if we see a base class-less type other than nsISupports, we just need - # to discard anything else about it other than its constants. - if iface.base is None and iface.name != "nsISupports": - assert len([m for m in iface.members - if type(m) == xpidl.Attribute or type(m) == xpidl.Method]) == 0 - return + assert iface.base or (iface.name == "nsISupports") base = 'Some("%s")' % iface.base if iface.base is not None else 'None' try: diff --git a/xpcom/idl-parser/xpidl/xpidl.py b/xpcom/idl-parser/xpidl/xpidl.py index 9d6ba2bf78..ea9483e50b 100644 --- a/xpcom/idl-parser/xpidl/xpidl.py +++ b/xpcom/idl-parser/xpidl/xpidl.py @@ -680,7 +680,7 @@ class Interface(object): if self.attributes.function: has_method = False for member in self.members: - if member.kind is 'method': + if member.kind == 'method': if has_method: raise IDLError( "interface '%s' has multiple methods, but marked 'function'" % @@ -705,6 +705,9 @@ class Interface(object): raise IDLError("interface '%s' is not builtinclass but derives from " "builtinclass '%s'" % (self.name, self.base), self.location) + elif self.name != 'nsISupports': + raise IDLError("Interface '%s' must inherit from nsISupports" % + self.name, self.location) for member in self.members: member.resolve(self) diff --git a/xpcom/io/Base64.cpp b/xpcom/io/Base64.cpp index aba99dba01..389d25a22d 100644 --- a/xpcom/io/Base64.cpp +++ b/xpcom/io/Base64.cpp @@ -200,7 +200,7 @@ nsresult EncodeInputStream(nsIInputStream* aInputStream, T& aDest, state.c[2] = '\0'; state.buffer = aOffset + aDest.BeginWriting(); - while (1) { + while (true) { uint32_t read = 0; rv = aInputStream->ReadSegments(&EncodeInputStream_Encoder, @@ -357,37 +357,61 @@ nsresult Base64Encode(const char* aBinary, uint32_t aBinaryLen, return NS_OK; } -template -static nsresult Base64EncodeHelper(const T& aBinary, T& aBase64) { - // Check for overflow. - if (aBinary.Length() > (UINT32_MAX / 4) * 3) { - return NS_ERROR_FAILURE; - } - - if (aBinary.IsEmpty()) { - aBase64.Truncate(); +template +static nsresult Base64EncodeHelper(const T* const aBinary, + const size_t aBinaryLen, U& aBase64) { + if (aBinaryLen == 0) { + if (!Append) { + aBase64.Truncate(); + } return NS_OK; } - uint32_t base64Len = ((aBinary.Length() + 2) / 3) * 4; + const uint32_t prefixLen = Append ? aBase64.Length() : 0; + const auto base64LenOrErr = [aBinaryLen, + prefixLen]() -> Result { + // XXX(sg) Necessary to silence bad warning about unused lambda capture when + // Append is false. + (void)prefixLen; + CheckedUint32 res = aBinaryLen; + // base 64 encoded length is 4/3rds the length of the input data, rounded up + res += 2; + res /= 3; + res *= 4; + res += prefixLen; + if (!res.isValid()) { + return Err(NS_ERROR_FAILURE); + } + return res.value(); + }(); + if (base64LenOrErr.isErr()) { + return base64LenOrErr.inspectErr(); + } + const uint32_t base64Len = base64LenOrErr.inspect(); - nsresult rv; - auto handle = aBase64.BulkWrite(base64Len, 0, false, rv); - if (NS_FAILED(rv)) { - return rv; + auto handleOrErr = aBase64.BulkWrite(base64Len, prefixLen, false); + if (handleOrErr.isErr()) { + return handleOrErr.unwrapErr(); } - Encode(aBinary.BeginReading(), aBinary.Length(), handle.Elements()); + auto handle = handleOrErr.unwrap(); + + Encode(aBinary, aBinaryLen, handle.Elements() + prefixLen); handle.Finish(base64Len, false); return NS_OK; } +nsresult Base64EncodeAppend(const char* aBinary, uint32_t aBinaryLen, + nsAString& aBase64) { + return Base64EncodeHelper(aBinary, aBinaryLen, aBase64); +} + nsresult Base64Encode(const nsACString& aBinary, nsACString& aBase64) { - return Base64EncodeHelper(aBinary, aBase64); + return Base64EncodeHelper(aBinary.BeginReading(), aBinary.Length(), aBase64); } nsresult Base64Encode(const nsAString& aBinary, nsAString& aBase64) { - return Base64EncodeHelper(aBinary, aBase64); + return Base64EncodeHelper(aBinary.BeginReading(), aBinary.Length(), aBase64); } template @@ -533,17 +557,18 @@ static nsresult Base64DecodeString(const T& aBase64, T& aBinary) { uint32_t binaryLen = ((aBase64.Length() * 3) / 4); - nsresult rv; - auto handle = aBinary.BulkWrite(binaryLen, 0, false, rv); - if (NS_FAILED(rv)) { + auto handleOrErr = aBinary.BulkWrite(binaryLen, 0, false); + if (handleOrErr.isErr()) { // Must not touch the handle if failing here, but we // already truncated the string at the top, so it's // unchanged. - return rv; + return handleOrErr.unwrapErr(); } - rv = Base64DecodeHelper(aBase64.BeginReading(), aBase64.Length(), - handle.Elements(), &binaryLen); + auto handle = handleOrErr.unwrap(); + + nsresult rv = Base64DecodeHelper(aBase64.BeginReading(), aBase64.Length(), + handle.Elements(), &binaryLen); if (NS_FAILED(rv)) { // Retruncate to match old semantics of this method. handle.Finish(0, true); @@ -662,12 +687,13 @@ nsresult Base64URLEncode(uint32_t aBinaryLen, const uint8_t* aBinary, // Allocate a buffer large enough to hold the encoded string with padding. uint32_t base64Len = ((aBinaryLen + 2) / 3) * 4; - nsresult rv; - auto handle = aBase64.BulkWrite(base64Len, 0, false, rv); - if (NS_FAILED(rv)) { - return rv; + auto handleOrErr = aBase64.BulkWrite(base64Len, 0, false); + if (handleOrErr.isErr()) { + return handleOrErr.unwrapErr(); } + auto handle = handleOrErr.unwrap(); + char* base64 = handle.Elements(); uint32_t index = 0; diff --git a/xpcom/io/Base64.h b/xpcom/io/Base64.h index 99fbb314fe..762d0e937b 100644 --- a/xpcom/io/Base64.h +++ b/xpcom/io/Base64.h @@ -20,6 +20,11 @@ namespace mozilla { uint32_t aCount, uint32_t aOffset = 0); +// Encode 8-bit data of a given length and append the Base64 encoded data to +// aBase64. +[[nodiscard]] nsresult Base64EncodeAppend(const char* aBinary, + uint32_t aBinaryLen, + nsAString& aBase64); [[nodiscard]] nsresult Base64Encode(const char* aBinary, uint32_t aBinaryLen, char** aBase64); [[nodiscard]] nsresult Base64Encode(const nsACString& aBinary, diff --git a/xpcom/io/SpecialSystemDirectory.cpp b/xpcom/io/SpecialSystemDirectory.cpp index 8b4d6bc46a..be7f3f09fc 100644 --- a/xpcom/io/SpecialSystemDirectory.cpp +++ b/xpcom/io/SpecialSystemDirectory.cpp @@ -404,7 +404,7 @@ static nsresult GetUnixXDGUserDirectory(SystemDirectories aSystemDirectory, return rv; } - rv = file->AppendNative(NS_LITERAL_CSTRING("Desktop")); + rv = file->AppendNative("Desktop"_ns); } else { // no fallback for the other XDG dirs rv = NS_ERROR_FAILURE; diff --git a/xpcom/io/SpecialSystemDirectory.h b/xpcom/io/SpecialSystemDirectory.h index 25a289bbb6..1c16124220 100644 --- a/xpcom/io/SpecialSystemDirectory.h +++ b/xpcom/io/SpecialSystemDirectory.h @@ -17,7 +17,8 @@ extern void StartupSpecialSystemDirectory(); enum SystemDirectories { OS_TemporaryDirectory = 2, - OS_CurrentProcessDirectory = 3, + // 3 Used to be OS_CurrentProcessDirectory, which we never actually + // supported getting... OS_CurrentWorkingDirectory = 4, Win_SystemDirectory = 201, diff --git a/xpcom/io/nsBinaryStream.cpp b/xpcom/io/nsBinaryStream.cpp index dffd38c88d..eb32ed91de 100644 --- a/xpcom/io/nsBinaryStream.cpp +++ b/xpcom/io/nsBinaryStream.cpp @@ -784,9 +784,9 @@ nsBinaryInputStream::ReadByteArray(uint32_t aLength, } NS_IMETHODIMP -nsBinaryInputStream::ReadArrayBuffer(uint32_t aLength, +nsBinaryInputStream::ReadArrayBuffer(uint64_t aLength, JS::Handle aBuffer, - JSContext* aCx, uint32_t* aReadLength) { + JSContext* aCx, uint64_t* aReadLength) { if (!aBuffer.isObject()) { return NS_ERROR_FAILURE; } @@ -795,20 +795,20 @@ nsBinaryInputStream::ReadArrayBuffer(uint32_t aLength, return NS_ERROR_FAILURE; } - uint32_t bufferLength = JS::GetArrayBufferByteLength(buffer); + size_t bufferLength = JS::GetArrayBufferByteLength(buffer); if (bufferLength < aLength) { return NS_ERROR_FAILURE; } - uint32_t bufSize = std::min(aLength, 4096); + uint32_t bufSize = std::min(aLength, 4096); UniquePtr buf = MakeUnique(bufSize); - uint32_t pos = 0; + uint64_t pos = 0; *aReadLength = 0; do { // Read data into temporary buffer. uint32_t bytesRead; - uint32_t amount = std::min(aLength - pos, bufSize); + uint32_t amount = std::min(aLength - pos, bufSize); nsresult rv = Read(buf.get(), amount, &bytesRead); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; diff --git a/xpcom/io/nsDirectoryService.cpp b/xpcom/io/nsDirectoryService.cpp index 1a90f3c94c..ad3873d3a2 100644 --- a/xpcom/io/nsDirectoryService.cpp +++ b/xpcom/io/nsDirectoryService.cpp @@ -52,21 +52,23 @@ nsresult nsDirectoryService::GetCurrentProcessDirectory(nsIFile** aFile) return NS_ERROR_FAILURE; } - nsCOMPtr file; - gService->Get(NS_XPCOM_INIT_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), - getter_AddRefs(file)); - if (file) { - file.forget(aFile); - return NS_OK; + if (!mXCurProcD) { + nsCOMPtr file; + if (NS_SUCCEEDED(BinaryPath::GetFile(getter_AddRefs(file)))) { + nsresult rv = file->GetParent(getter_AddRefs(mXCurProcD)); + if (NS_FAILED(rv)) { + return rv; + } + } } - - if (NS_SUCCEEDED(BinaryPath::GetFile(getter_AddRefs(file)))) { - return file->GetParent(aFile); - } - NS_ERROR("unable to get current process directory"); - return NS_ERROR_FAILURE; + return mXCurProcD->Clone(aFile); } // GetCurrentProcessDirectory() +nsresult nsDirectoryService::SetCurrentProcessDirectory(nsIFile* aFile) { + mXCurProcD = aFile; + return NS_OK; +} + StaticRefPtr nsDirectoryService::gService; nsDirectoryService::nsDirectoryService() : mHashtable(128) {} @@ -314,7 +316,7 @@ static nsresult GetLowIntegrityTempBase(nsIFile** aLowIntegrityTempBase) { return rv; } - rv = localFile->Append(NS_LITERAL_STRING(MOZ_USER_DIR)); + rv = localFile->Append(NS_LITERAL_STRING_FROM_CSTRING(MOZ_USER_DIR)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -355,9 +357,6 @@ nsDirectoryService::GetFile(const char* aProp, bool* aPersistent, } else if (inAtom == nsGkAtoms::DirectoryService_OS_TemporaryDirectory) { rv = GetSpecialSystemDirectory(OS_TemporaryDirectory, getter_AddRefs(localFile)); - } else if (inAtom == nsGkAtoms::DirectoryService_OS_CurrentProcessDirectory) { - rv = GetSpecialSystemDirectory(OS_CurrentProcessDirectory, - getter_AddRefs(localFile)); } else if (inAtom == nsGkAtoms::DirectoryService_OS_CurrentWorkingDirectory) { rv = GetSpecialSystemDirectory(OS_CurrentWorkingDirectory, getter_AddRefs(localFile)); diff --git a/xpcom/io/nsDirectoryService.h b/xpcom/io/nsDirectoryService.h index 63e9c56595..4b7e3a345a 100644 --- a/xpcom/io/nsDirectoryService.h +++ b/xpcom/io/nsDirectoryService.h @@ -13,9 +13,6 @@ #include "mozilla/Attributes.h" #include "mozilla/StaticPtr.h" -#define NS_XPCOM_INIT_CURRENT_PROCESS_DIR \ - "MozBinD" // Can be used to set NS_XPCOM_CURRENT_PROCESS_DIR - // CANNOT be used to GET a location #define NS_DIRECTORY_SERVICE_CID \ { \ 0xf00152d0, 0xb40b, 0x11d3, { \ @@ -46,10 +43,12 @@ class nsDirectoryService final : public nsIDirectoryService, static mozilla::StaticRefPtr gService; + nsresult SetCurrentProcessDirectory(nsIFile* aFile); + nsresult GetCurrentProcessDirectory(nsIFile** aFile); + private: ~nsDirectoryService(); - - nsresult GetCurrentProcessDirectory(nsIFile** aFile); + nsCOMPtr mXCurProcD; nsInterfaceHashtable mHashtable; nsTArray> mProviders; diff --git a/xpcom/io/nsIBinaryInputStream.idl b/xpcom/io/nsIBinaryInputStream.idl index 897d0651de..ebc7da605e 100644 --- a/xpcom/io/nsIBinaryInputStream.idl +++ b/xpcom/io/nsIBinaryInputStream.idl @@ -77,7 +77,7 @@ interface nsIBinaryInputStream : nsIInputStream { * @return The number of bytes actually read into aArrayBuffer. */ [implicit_jscontext] - unsigned long readArrayBuffer(in uint32_t aLength, in jsval aArrayBuffer); + uint64_t readArrayBuffer(in uint64_t aLength, in jsval aArrayBuffer); }; %{C++ diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp index 238d5d4290..4d12484732 100644 --- a/xpcom/io/nsLocalFileUnix.cpp +++ b/xpcom/io/nsLocalFileUnix.cpp @@ -32,7 +32,6 @@ # endif #endif -#include "xpcom-private.h" #include "nsDirectoryServiceDefs.h" #include "nsCRT.h" #include "nsCOMPtr.h" @@ -70,6 +69,43 @@ static nsresult MacErrorMapper(OSErr inErr); #include "nsTraceRefcnt.h" #include "nsHashKeys.h" +/** + * we need these for statfs() + */ +#ifdef HAVE_SYS_STATVFS_H +# if defined(__osf__) && defined(__DECCXX) +extern "C" int statvfs(const char*, struct statvfs*); +# endif +# include +#endif + +#ifdef HAVE_SYS_STATFS_H +# include +#endif + +#ifdef HAVE_SYS_VFS_H +# include +#endif + +#ifdef HAVE_SYS_MOUNT_H +# include +# include +#endif + +#if defined(HAVE_STATVFS64) && (!defined(LINUX) && !defined(__osf__)) +# define STATFS statvfs64 +# define F_BSIZE f_frsize +#elif defined(HAVE_STATVFS) && (!defined(LINUX) && !defined(__osf__)) +# define STATFS statvfs +# define F_BSIZE f_frsize +#elif defined(HAVE_STATFS64) +# define STATFS statfs64 +# define F_BSIZE f_bsize +#elif defined(HAVE_STATFS) +# define STATFS statfs +# define F_BSIZE f_bsize +#endif + using namespace mozilla; #define ENSURE_STAT_CACHE() \ @@ -654,7 +690,7 @@ nsresult nsLocalFile::GetNativeTargetPathName(nsIFile* aNewParent, return rv; } - aResult = dirName + NS_LITERAL_CSTRING("/") + Substring(nameBegin, nameEnd); + aResult = dirName + "/"_ns + Substring(nameBegin, nameEnd); return NS_OK; } @@ -1969,7 +2005,7 @@ nsLocalFile::Launch() { rv = mimeService->GetTypeFromFile(this, type); } - nsAutoCString fileUri = NS_LITERAL_CSTRING("file://") + mPath; + nsAutoCString fileUri = "file://"_ns + mPath; return java::GeckoAppShell::OpenUriExternal( NS_ConvertUTF8toUTF16(fileUri), NS_ConvertUTF8toUTF16(type), EmptyString(), EmptyString(), EmptyString(), EmptyString()) diff --git a/xpcom/io/nsLocalFileUnix.h b/xpcom/io/nsLocalFileUnix.h index 22038c3a36..2318a9a50b 100644 --- a/xpcom/io/nsLocalFileUnix.h +++ b/xpcom/io/nsLocalFileUnix.h @@ -22,43 +22,6 @@ # include "nsILocalFileMac.h" #endif -/** - * we need these for statfs() - */ -#ifdef HAVE_SYS_STATVFS_H -# if defined(__osf__) && defined(__DECCXX) -extern "C" int statvfs(const char*, struct statvfs*); -# endif -# include -#endif - -#ifdef HAVE_SYS_STATFS_H -# include -#endif - -#ifdef HAVE_SYS_VFS_H -# include -#endif - -#ifdef HAVE_SYS_MOUNT_H -# include -# include -#endif - -#if defined(HAVE_STATVFS64) && (!defined(LINUX) && !defined(__osf__)) -# define STATFS statvfs64 -# define F_BSIZE f_frsize -#elif defined(HAVE_STATVFS) && (!defined(LINUX) && !defined(__osf__)) -# define STATFS statvfs -# define F_BSIZE f_frsize -#elif defined(HAVE_STATFS64) -# define STATFS statfs64 -# define F_BSIZE f_bsize -#elif defined(HAVE_STATFS) -# define STATFS statfs -# define F_BSIZE f_bsize -#endif - // stat64 and lstat64 are deprecated on OS X. Normal stat and lstat are // 64-bit by default on OS X 10.6+. #if defined(HAVE_STAT64) && defined(HAVE_LSTAT64) && !defined(XP_DARWIN) diff --git a/xpcom/io/nsLocalFileWin.cpp b/xpcom/io/nsLocalFileWin.cpp index 1532c18832..529b190bf0 100644 --- a/xpcom/io/nsLocalFileWin.cpp +++ b/xpcom/io/nsLocalFileWin.cpp @@ -1335,7 +1335,7 @@ nsresult nsLocalFile::AppendInternal(const nsString& aNode, } // catches the remaining cases of prefixes - if (StringBeginsWith(aNode, NS_LITERAL_STRING("..\\"))) { + if (StringBeginsWith(aNode, u"..\\"_ns)) { return NS_ERROR_FILE_UNRECOGNIZED_PATH; } } @@ -1433,7 +1433,7 @@ nsLocalFile::Normalize() { if (currentDir.Last() == '\\') { path.Replace(0, 2, currentDir); } else { - path.Replace(0, 2, currentDir + NS_LITERAL_STRING("\\")); + path.Replace(0, 2, currentDir + u"\\"_ns); } } diff --git a/xpcom/io/nsMultiplexInputStream.cpp b/xpcom/io/nsMultiplexInputStream.cpp index 650863ddd3..71cc46a0f9 100644 --- a/xpcom/io/nsMultiplexInputStream.cpp +++ b/xpcom/io/nsMultiplexInputStream.cpp @@ -814,7 +814,7 @@ nsMultiplexInputStream::CloseWithStatus(nsresult aStatus) { return Close(); } // This class is used to inform nsMultiplexInputStream that it's time to execute // the asyncWait callback. -class AsyncWaitRunnable final : public CancelableRunnable { +class AsyncWaitRunnable final : public DiscardableRunnable { RefPtr mStream; public: @@ -836,7 +836,7 @@ class AsyncWaitRunnable final : public CancelableRunnable { private: explicit AsyncWaitRunnable(nsMultiplexInputStream* aStream) - : CancelableRunnable("AsyncWaitRunnable"), mStream(aStream) { + : DiscardableRunnable("AsyncWaitRunnable"), mStream(aStream) { MOZ_ASSERT(aStream); } }; diff --git a/xpcom/io/nsNativeCharsetUtils.cpp b/xpcom/io/nsNativeCharsetUtils.cpp index 5afa14eed6..bcf5712aea 100644 --- a/xpcom/io/nsNativeCharsetUtils.cpp +++ b/xpcom/io/nsNativeCharsetUtils.cpp @@ -2,8 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "xpcom-private.h" - //----------------------------------------------------------------------------- // Non-Windows //----------------------------------------------------------------------------- diff --git a/xpcom/io/nsStorageStream.cpp b/xpcom/io/nsStorageStream.cpp index 31d538dde2..05bb21bb73 100644 --- a/xpcom/io/nsStorageStream.cpp +++ b/xpcom/io/nsStorageStream.cpp @@ -601,8 +601,10 @@ void nsStorageInputStream::SerializeInternal(InputStreamParams& aParams, rv = Tell(&offset); MOZ_ASSERT(NS_SUCCEEDED(rv)); - auto handle = combined.BulkWrite(remaining, 0, false, rv); - MOZ_ASSERT(NS_SUCCEEDED(rv)); + auto handleOrErr = combined.BulkWrite(remaining, 0, false); + MOZ_ASSERT(!handleOrErr.isErr()); + + auto handle = handleOrErr.unwrap(); uint32_t numRead = 0; diff --git a/xpcom/moz.build b/xpcom/moz.build index 37699dbf2d..06adb5c747 100644 --- a/xpcom/moz.build +++ b/xpcom/moz.build @@ -38,7 +38,6 @@ TEST_DIRS += [ CONFIGURE_DEFINE_FILES += [ 'xpcom-config.h', - 'xpcom-private.h', ] EXPORTS += [ diff --git a/xpcom/rust/gtest/nsstring/Test.cpp b/xpcom/rust/gtest/nsstring/Test.cpp index c601b52ee7..4e14c7bca5 100644 --- a/xpcom/rust/gtest/nsstring/Test.cpp +++ b/xpcom/rust/gtest/nsstring/Test.cpp @@ -160,3 +160,18 @@ TEST(RustNsString, InlineCapacityFromRust) EXPECT_EQ(cStrCapacity, 92U); EXPECT_EQ(strCapacity, 92U); } + +extern "C" void Rust_VoidStringFromRust(nsACString* aCStr, nsAString* aStr); +TEST(RustNsString, VoidStringFromRust) +{ + nsAutoCString cs; + nsAutoString s; + + EXPECT_FALSE(cs.IsVoid()); + EXPECT_FALSE(s.IsVoid()); + + Rust_VoidStringFromRust(&cs, &s); + + EXPECT_TRUE(cs.IsVoid()); + EXPECT_TRUE(s.IsVoid()); +} diff --git a/xpcom/rust/gtest/nsstring/test.rs b/xpcom/rust/gtest/nsstring/test.rs index 18640994c5..25ec4ee2ef 100644 --- a/xpcom/rust/gtest/nsstring/test.rs +++ b/xpcom/rust/gtest/nsstring/test.rs @@ -122,3 +122,9 @@ pub extern "C" fn Rust_WriteToBufferFromRust( fallible_s_buf[2] = b'C' as u16; } } + +#[no_mangle] +pub extern "C" fn Rust_VoidStringFromRust(cs: &mut nsACString, s: &mut nsAString) { + cs.set_is_void(true); + s.set_is_void(true); +} diff --git a/xpcom/rust/nsstring/src/lib.rs b/xpcom/rust/nsstring/src/lib.rs index 2485a3598b..698a335f58 100644 --- a/xpcom/rust/nsstring/src/lib.rs +++ b/xpcom/rust/nsstring/src/lib.rs @@ -546,6 +546,23 @@ macro_rules! define_string_types { } } + /// Mark the string's data as void. If `true`, the string will be truncated. + /// + /// A void string is generally converted to a `null` JS value by bindings code. + pub fn set_is_void(&mut self, is_void: bool) { + if is_void { + self.truncate(); + } + unsafe { + self.as_repr_mut().as_mut().dataflags.set(DataFlags::VOIDED, is_void); + } + } + + /// Returns whether the string's data is voided. + pub fn is_void(&self) -> bool { + self.as_repr().dataflags.contains(DataFlags::VOIDED) + } + /// Set the length of the string to the passed-in length, and expand /// the backing capacity to match. This method is unsafe as it can /// expose uninitialized memory when len is greater than the current diff --git a/xpcom/string/nsLiteralString.h b/xpcom/string/nsLiteralString.h index 4e2a31fa92..b148a411bd 100644 --- a/xpcom/string/nsLiteralString.h +++ b/xpcom/string/nsLiteralString.h @@ -12,6 +12,12 @@ #include "mozilla/Char16.h" +#define NS_CSTRING_LITERAL_AS_STRING_LITERAL(s) u"" s + +#define NS_LITERAL_STRING_FROM_CSTRING(s) \ + static_cast( \ + nsLiteralString(NS_CSTRING_LITERAL_AS_STRING_LITERAL(s))) + #define NS_LITERAL_STRING(s) \ static_cast(nsLiteralString(u"" s)) #define NS_NAMED_LITERAL_STRING(n, s) const nsLiteralString n(u"" s) @@ -20,4 +26,12 @@ static_cast(nsLiteralCString("" s)) #define NS_NAMED_LITERAL_CSTRING(n, s) const nsLiteralCString n("" s) +constexpr auto operator""_ns(const char* aStr, std::size_t aLen) { + return nsLiteralCString{aStr, aLen}; +} + +constexpr auto operator""_ns(const char16_t* aStr, std::size_t aLen) { + return nsLiteralString{aStr, aLen}; +} + #endif /* !defined(nsLiteralString_h___) */ diff --git a/xpcom/string/nsStringBuffer.h b/xpcom/string/nsStringBuffer.h index f675b02e8f..b1ecac9d53 100644 --- a/xpcom/string/nsStringBuffer.h +++ b/xpcom/string/nsStringBuffer.h @@ -11,22 +11,6 @@ template struct already_AddRefed; -/* - * Add a canary field to protect against double-frees of nsStringBuffer and - * other potential heap corruptions. We intend to back this out before 58 hits - * beta. - */ -#if (defined(DEBUG) || defined(NIGHTLY_BUILD)) && !defined(MOZ_ASAN) -# define STRING_BUFFER_CANARY 1 -#endif - -#ifdef STRING_BUFFER_CANARY -enum nsStringBufferCanary : uint32_t { - CANARY_OK = 0xaf57c8fa, - CANARY_POISON = 0x534dc0f5 -}; -#endif - /** * This structure precedes the string buffers "we" allocate. It may be the * case that nsTAString::mData does not point to one of these special @@ -43,10 +27,6 @@ class nsStringBuffer { std::atomic mRefCount; uint32_t mStorageSize; -#ifdef STRING_BUFFER_CANARY - uint32_t mCanary; -#endif - public: /** * Allocates a new string buffer, with given size in bytes and a @@ -94,11 +74,7 @@ class nsStringBuffer { * call to the nsStringBuffer::Data method. */ static nsStringBuffer* FromData(void* aData) { - nsStringBuffer* sb = reinterpret_cast(aData) - 1; -#ifdef STRING_BUFFER_CANARY - if (MOZ_UNLIKELY(sb->mCanary != CANARY_OK)) sb->FromDataCanaryCheckFailed(); -#endif - return sb; + return reinterpret_cast(aData) - 1; } /** @@ -192,15 +168,6 @@ class nsStringBuffer { */ size_t SizeOfIncludingThisEvenIfShared( mozilla::MallocSizeOf aMallocSizeOf) const; - -#ifdef STRING_BUFFER_CANARY - /* - * Called by FromData if the canary check failed. This is out-of-line in - * nsSubstring.cpp so that MOZ_CRASH_UNSAFE_PRINTF is available via #includes. - * It is not available in FromData due to #include-order. - */ - void FromDataCanaryCheckFailed() const; -#endif }; #endif /* !defined(nsStringBuffer_h__ */ diff --git a/xpcom/string/nsStringObsolete.cpp b/xpcom/string/nsStringObsolete.cpp index cd220582b5..b53dc2244d 100644 --- a/xpcom/string/nsStringObsolete.cpp +++ b/xpcom/string/nsStringObsolete.cpp @@ -788,6 +788,9 @@ int32_t nsTString::Find(const self_type& aString, int32_t aOffset, return result; } +template int32_t nsTString::Find(const self_type&, int32_t, + int32_t) const; + template template int32_t nsTString::Find(const char_type* aString, int32_t aOffset, @@ -795,6 +798,9 @@ int32_t nsTString::Find(const char_type* aString, int32_t aOffset, return Find(nsTDependentString(aString), aOffset, aCount); } +template int32_t nsTString::Find(const char_type*, int32_t, + int32_t) const; + template template int32_t nsTString::RFind(const self_type& aString, int32_t aOffset, @@ -810,6 +816,9 @@ int32_t nsTString::RFind(const self_type& aString, int32_t aOffset, return result; } +template int32_t nsTString::RFind(const self_type&, int32_t, + int32_t) const; + template template int32_t nsTString::RFind(const char_type* aString, int32_t aOffset, @@ -817,6 +826,9 @@ int32_t nsTString::RFind(const char_type* aString, int32_t aOffset, return RFind(nsTDependentString(aString), aOffset, aCount); } +template int32_t nsTString::RFind(const char_type*, int32_t, + int32_t) const; + template template int32_t nsTString::FindCharInSet(const char* aSet, int32_t aOffset) const { @@ -831,6 +843,8 @@ int32_t nsTString::FindCharInSet(const char* aSet, int32_t aOffset) const { return result; } +template int32_t nsTString::FindCharInSet(const char*, int32_t) const; + template template void nsTString::ReplaceChar(const char* aSet, char16_t aNewChar) { @@ -881,6 +895,9 @@ int32_t nsTStringRepr::Compare(const char_type* aString, bool aIgnoreCase, return result; } +template int32_t nsTStringRepr::Compare(const char_type*, bool, + int32_t) const; + template template bool nsTStringRepr::EqualsIgnoreCase(const incompatible_char_type* aString, @@ -910,6 +927,9 @@ bool nsTStringRepr::EqualsIgnoreCase(const incompatible_char_type* aString, return result == 0; } +template bool nsTStringRepr::EqualsIgnoreCase( + const incompatible_char_type*, int32_t) const; + } // namespace detail } // namespace mozilla diff --git a/xpcom/string/nsSubstring.cpp b/xpcom/string/nsSubstring.cpp index 8348be75d4..a18535f018 100644 --- a/xpcom/string/nsSubstring.cpp +++ b/xpcom/string/nsSubstring.cpp @@ -18,7 +18,6 @@ #include "nsString.h" #include "nsStringBuffer.h" #include "nsDependentString.h" -#include "nsPrintfCString.h" #include "nsMemory.h" #include "prprf.h" #include "nsCOMPtr.h" @@ -34,19 +33,6 @@ # include #endif -#ifdef STRING_BUFFER_CANARY -# define CHECK_STRING_BUFFER_CANARY(c) \ - do { \ - if ((c) != CANARY_OK) { \ - MOZ_CRASH_UNSAFE_PRINTF("Bad canary value 0x%x", c); \ - } \ - } while (0) -#else -# define CHECK_STRING_BUFFER_CANARY(c) \ - do { \ - } while (0) -#endif - using mozilla::Atomic; // --------------------------------------------------------------------------- @@ -183,8 +169,6 @@ void nsStringBuffer::AddRef() { } void nsStringBuffer::Release() { - CHECK_STRING_BUFFER_CANARY(mCanary); - // Since this may be the last release on this thread, we need // release semantics so that prior writes on this thread are visible // to the thread that destroys the object when it reads mValue with @@ -197,9 +181,6 @@ void nsStringBuffer::Release() { // the last release on other threads, that is, to ensure that // writes prior to that release are now visible on this thread. count = mRefCount.load(std::memory_order_acquire); -#ifdef STRING_BUFFER_CANARY - mCanary = CANARY_POISON; -#endif STRING_STAT_INCREMENT(Free); free(this); // we were allocated with |malloc| @@ -221,9 +202,6 @@ already_AddRefed nsStringBuffer::Alloc(size_t aSize) { hdr->mRefCount = 1; hdr->mStorageSize = aSize; -#ifdef STRING_BUFFER_CANARY - hdr->mCanary = CANARY_OK; -#endif NS_LOG_ADDREF(hdr, 1, "nsStringBuffer", sizeof(*hdr)); } return dont_AddRef(hdr); @@ -232,7 +210,6 @@ already_AddRefed nsStringBuffer::Alloc(size_t aSize) { nsStringBuffer* nsStringBuffer::Realloc(nsStringBuffer* aHdr, size_t aSize) { STRING_STAT_INCREMENT(Realloc); - CHECK_STRING_BUFFER_CANARY(aHdr->mCanary); NS_ASSERTION(aSize != 0, "zero capacity allocation not allowed"); NS_ASSERTION(sizeof(nsStringBuffer) + aSize <= size_t(uint32_t(-1)) && sizeof(nsStringBuffer) + aSize > aSize, @@ -321,12 +298,6 @@ size_t nsStringBuffer::SizeOfIncludingThisEvenIfShared( return aMallocSizeOf(this); } -#ifdef STRING_BUFFER_CANARY -void nsStringBuffer::FromDataCanaryCheckFailed() const { - MOZ_CRASH_UNSAFE_PRINTF("Bad canary value 0x%x in FromData", mCanary); -} -#endif - // --------------------------------------------------------------------------- // define nsAString diff --git a/xpcom/string/nsTDependentSubstring.cpp b/xpcom/string/nsTDependentSubstring.cpp index 5210ba6a0b..0ec5b66e71 100644 --- a/xpcom/string/nsTDependentSubstring.cpp +++ b/xpcom/string/nsTDependentSubstring.cpp @@ -81,6 +81,11 @@ const nsTDependentSubstring Substring(const T* aStart, const T* aEnd) { return nsTDependentSubstring(aStart, aEnd); } +template nsTDependentSubstring const Substring(char const*, + char const*); +template nsTDependentSubstring const Substring( + char16_t const*, char16_t const*); + #if defined(MOZ_USE_CHAR16_WRAPPER) const nsTDependentSubstring Substring(char16ptr_t aData, uint32_t aLength) { diff --git a/xpcom/string/nsTDependentSubstring.h b/xpcom/string/nsTDependentSubstring.h index 34af7f6d84..6698697272 100644 --- a/xpcom/string/nsTDependentSubstring.h +++ b/xpcom/string/nsTDependentSubstring.h @@ -128,6 +128,12 @@ inline const nsTDependentSubstring Substring(const T* aData, template const nsTDependentSubstring Substring(const T* aStart, const T* aEnd); +extern template const nsTDependentSubstring Substring(const char* aStart, + const char* aEnd); + +extern template const nsTDependentSubstring Substring( + const char16_t* aStart, const char16_t* aEnd); + #if defined(MOZ_USE_CHAR16_WRAPPER) inline const nsTDependentSubstring Substring(char16ptr_t aData, uint32_t aLength); diff --git a/xpcom/string/nsTLiteralString.h b/xpcom/string/nsTLiteralString.h index 7b9d24b643..168af91d08 100644 --- a/xpcom/string/nsTLiteralString.h +++ b/xpcom/string/nsTLiteralString.h @@ -45,9 +45,7 @@ class nsTLiteralString : public mozilla::detail::nsTStringRepr { template explicit constexpr nsTLiteralString(const char_type (&aStr)[N]) - : base_string_type(const_cast(aStr), N - 1, - DataFlags::TERMINATED | DataFlags::LITERAL, - ClassFlags::NULL_TERMINATED) {} + : nsTLiteralString(aStr, N - 1) {} /** * For compatibility with existing code that requires const ns[C]String*. @@ -73,13 +71,31 @@ class nsTLiteralString : public mozilla::detail::nsTStringRepr { #endif /** - * Prohibit get() on temporaries as in nsLiteralCString("x").get(). + * Prohibit get() on temporaries as in "x"_ns.get(). * These should be written as just "x", using a string literal directly. */ const typename raw_type::type get() const&& = delete; const typename raw_type::type get() const& { return this->mData; } +// At least older gcc versions do not accept these friend declarations, +// complaining about an "invalid argument list" here, but not where the actual +// operators are defined or used. We make the supposed-to-be-private constructor +// public when building with gcc, relying on the default clang builds to fail if +// any non-private use of that constructor would get into the codebase. +#if defined(__clang__) private: + friend constexpr auto operator"" _ns(const char* aStr, std::size_t aLen); + friend constexpr auto operator"" _ns(const char16_t* aStr, std::size_t aLen); +#else + public: +#endif + // Only for use by operator"" + constexpr nsTLiteralString(const char_type* aStr, size_t aLen) + : base_string_type(const_cast(aStr), aLen, + DataFlags::TERMINATED | DataFlags::LITERAL, + ClassFlags::NULL_TERMINATED) {} + + public: // NOT TO BE IMPLEMENTED template nsTLiteralString(char_type (&aStr)[N]) = delete; diff --git a/xpcom/string/nsTStringComparator.cpp b/xpcom/string/nsTStringComparator.cpp index 97502fe5ab..3be53ceda7 100644 --- a/xpcom/string/nsTStringComparator.cpp +++ b/xpcom/string/nsTStringComparator.cpp @@ -36,6 +36,16 @@ int NS_FASTCALL Compare(const mozilla::detail::nsTStringRepr& aLhs, return result; } +template int NS_FASTCALL +Compare(mozilla::detail::nsTStringRepr const&, + mozilla::detail::nsTStringRepr const&, + nsTStringComparator const&); + +template int NS_FASTCALL +Compare(mozilla::detail::nsTStringRepr const&, + mozilla::detail::nsTStringRepr const&, + nsTStringComparator const&); + template int nsTDefaultStringComparator::operator()(const char_type* aLhs, const char_type* aRhs, diff --git a/xpcom/string/nsTStringObsolete.cpp b/xpcom/string/nsTStringObsolete.cpp index be2d2aabd4..bef30dd47f 100644 --- a/xpcom/string/nsTStringObsolete.cpp +++ b/xpcom/string/nsTStringObsolete.cpp @@ -139,6 +139,8 @@ void nsTString::StripChars(const incompatible_char_type* aSet) { } } +template void nsTString::StripChars(const incompatible_char_type*); + template template bool nsTString::StripChars(const incompatible_char_type* aSet, @@ -152,6 +154,9 @@ bool nsTString::StripChars(const incompatible_char_type* aSet, return true; } +template bool nsTString::StripChars(const incompatible_char_type*, + const fallible_t&); + template void nsTString::StripChars(const char_type* aSet) { nsTSubstring::StripChars(aSet); @@ -206,6 +211,8 @@ void nsTString::ReplaceChar(const char_type* aSet, char_type aNewChar) { } } +template void nsTString::ReplaceChar(const char*, char16_t); + void ReleaseData(void* aData, nsAString::DataFlags aFlags); template diff --git a/xpcom/string/nsTStringRepr.h b/xpcom/string/nsTStringRepr.h index ae3e8e2ee6..e856e768cb 100644 --- a/xpcom/string/nsTStringRepr.h +++ b/xpcom/string/nsTStringRepr.h @@ -10,6 +10,7 @@ #include "mozilla/Char16.h" #include "mozilla/fallible.h" #include "nsStringFlags.h" +#include "nsStringIterator.h" #include "nsCharTraits.h" template @@ -195,9 +196,7 @@ class nsTStringRepr { size_type NS_FASTCALL CountChar(char_type) const; int32_t NS_FASTCALL FindChar(char_type, index_type aOffset = 0) const; - inline bool Contains(char_type aChar) const { - return FindChar(aChar) != kNotFound; - } + bool Contains(char_type aChar) const; // Equality. bool NS_FASTCALL Equals(const self_type&) const; @@ -279,6 +278,21 @@ class nsTStringRepr { return EqualsASCII(aStr, N - 1); } + // EqualsLiteral must ONLY be called with an actual literal string, or + // a char array *constant* declared without an explicit size and with an + // initializer that is a string literal or is otherwise null-terminated. + // Use EqualsASCII for other char array variables. + // (Although this method may happen to produce expected results for other + // char arrays that have bound one greater than the sequence of interest, + // such use is discouraged for reasons of readability and maintainability.) + // The template trick to acquire the array bound at compile time without + // using a macro is due to Corey Kosak, with much thanks. + template >> + inline bool EqualsLiteral(const char_type (&aStr)[N]) const { + return *this == nsTLiteralString(aStr); + } + // The LowerCaseEquals methods compare the ASCII-lowercase version of // this string (lowercasing only ASCII uppercase characters) to some // ASCII/Literal string. The ASCII string is *not* lowercased for @@ -350,6 +364,16 @@ Compare(const mozilla::detail::nsTStringRepr& aLhs, const mozilla::detail::nsTStringRepr& aRhs, const nsTStringComparator& = nsTDefaultStringComparator()); +extern template int NS_FASTCALL +Compare(const mozilla::detail::nsTStringRepr&, + const mozilla::detail::nsTStringRepr&, + const nsTStringComparator&); + +extern template int NS_FASTCALL +Compare(const mozilla::detail::nsTStringRepr&, + const mozilla::detail::nsTStringRepr&, + const nsTStringComparator&); + template inline constexpr bool operator!=( const mozilla::detail::nsTStringRepr& aLhs, diff --git a/xpcom/string/nsTSubstring.cpp b/xpcom/string/nsTSubstring.cpp index da8818b692..9f6030779f 100644 --- a/xpcom/string/nsTSubstring.cpp +++ b/xpcom/string/nsTSubstring.cpp @@ -7,6 +7,7 @@ #include "mozilla/MathAlgorithms.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Printf.h" +#include "mozilla/ResultExtensions.h" #include "nsASCIIMask.h" @@ -61,15 +62,13 @@ inline const nsTAutoString* AsAutoString(const nsTSubstring* aStr) { } template -mozilla::BulkWriteHandle nsTSubstring::BulkWrite( - size_type aCapacity, size_type aPrefixToPreserve, bool aAllowShrinking, - nsresult& aRv) { +mozilla::Result, nsresult> +nsTSubstring::BulkWrite(size_type aCapacity, size_type aPrefixToPreserve, + bool aAllowShrinking) { auto r = StartBulkWriteImpl(aCapacity, aPrefixToPreserve, aAllowShrinking); if (MOZ_UNLIKELY(r.isErr())) { - aRv = r.unwrapErr(); - return mozilla::BulkWriteHandle(nullptr, 0); + return r.propagateErr(); } - aRv = NS_OK; return mozilla::BulkWriteHandle(this, r.unwrap()); } @@ -1054,6 +1053,11 @@ int32_t nsTStringRepr::FindChar(char_type aChar, index_type aOffset) const { return -1; } +template +bool nsTStringRepr::Contains(char_type aChar) const { + return FindChar(aChar) != kNotFound; +} + } // namespace detail } // namespace mozilla @@ -1265,64 +1269,13 @@ static int FormatWithoutTrailingZeros(char (&aBuf)[40], double aDouble, int aPrecision) { static const DoubleToStringConverter converter( DoubleToStringConverter::UNIQUE_ZERO | + DoubleToStringConverter::NO_TRAILING_ZERO | DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN, "Infinity", "NaN", 'e', -6, 21, 6, 1); double_conversion::StringBuilder builder(aBuf, sizeof(aBuf)); - bool exponential_notation = false; - converter.ToPrecision(aDouble, aPrecision, &exponential_notation, &builder); + converter.ToPrecision(aDouble, aPrecision, &builder); int length = builder.position(); - char* formattedDouble = builder.Finalize(); - - // If we have a shorter string than aPrecision, it means we have a special - // value (NaN or Infinity). All other numbers will be formatted with at - // least aPrecision digits. - if (length <= aPrecision) { - return length; - } - - char* end = formattedDouble + length; - char* decimalPoint = strchr(aBuf, '.'); - // No trailing zeros to remove. - if (!decimalPoint) { - return length; - } - - if (MOZ_UNLIKELY(exponential_notation)) { - // We need to check for cases like 1.00000e-10 (yes, this is - // disgusting). - char* exponent = end - 1; - for (;; --exponent) { - if (*exponent == 'e') { - break; - } - } - char* zerosBeforeExponent = exponent - 1; - for (; zerosBeforeExponent != decimalPoint; --zerosBeforeExponent) { - if (*zerosBeforeExponent != '0') { - break; - } - } - if (zerosBeforeExponent == decimalPoint) { - --zerosBeforeExponent; - } - // Slide the exponent to the left over the trailing zeros. Don't - // worry about copying the trailing NUL character. - size_t exponentSize = end - exponent; - memmove(zerosBeforeExponent + 1, exponent, exponentSize); - length -= exponent - (zerosBeforeExponent + 1); - } else { - char* trailingZeros = end - 1; - for (; trailingZeros != decimalPoint; --trailingZeros) { - if (*trailingZeros != '0') { - break; - } - } - if (trailingZeros == decimalPoint) { - --trailingZeros; - } - length -= end - (trailingZeros + 1); - } - + builder.Finalize(); return length; } diff --git a/xpcom/string/nsTSubstring.h b/xpcom/string/nsTSubstring.h index e9f0228b88..743fc37956 100644 --- a/xpcom/string/nsTSubstring.h +++ b/xpcom/string/nsTSubstring.h @@ -1182,11 +1182,6 @@ class nsTSubstring : public mozilla::detail::nsTStringRepr { * performed when the string is already mutable and the requested * capacity is smaller than the current capacity. * - * aRv takes a reference to an nsresult that will be set to - * NS_OK on success or to NS_ERROR_OUT_OF_MEMORY on failure, - * because mozilla::Result cannot wrap move-only types at - * this time. - * * If this method returns successfully, you must not access * the string except through the returned BulkWriteHandle * until either the BulkWriteHandle goes out of scope or @@ -1202,10 +1197,8 @@ class nsTSubstring : public mozilla::detail::nsTStringRepr { * content has been written, which results in a * cache-friendly linear write pattern. */ - mozilla::BulkWriteHandle NS_FASTCALL BulkWrite(size_type aCapacity, - size_type aPrefixToPreserve, - bool aAllowShrinking, - nsresult& aRv); + mozilla::Result, nsresult> NS_FASTCALL BulkWrite( + size_type aCapacity, size_type aPrefixToPreserve, bool aAllowShrinking); /** * THIS IS NOT REALLY A PUBLIC METHOD! DO NOT CALL FROM OUTSIDE diff --git a/xpcom/string/nsTSubstringTuple.cpp b/xpcom/string/nsTSubstringTuple.cpp index bafde8d77b..78257faf0e 100644 --- a/xpcom/string/nsTSubstringTuple.cpp +++ b/xpcom/string/nsTSubstringTuple.cpp @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "nsTSubstringTuple.h" #include "mozilla/CheckedInt.h" /** diff --git a/xpcom/string/precompiled_templates.cpp b/xpcom/string/precompiled_templates.cpp index 86997f7eb3..f246a48936 100644 --- a/xpcom/string/precompiled_templates.cpp +++ b/xpcom/string/precompiled_templates.cpp @@ -5,7 +5,7 @@ #include "nsString.h" // This file provides concrete instantiations for externed string template -// classes and functions. +// classes. // ================ // Template classes @@ -39,60 +39,3 @@ template class nsTSubstringSplitter; template class nsTDefaultStringComparator; template class nsTDefaultStringComparator; - -// ============================= -// Templated top-level functions -// ============================= - -template int NS_FASTCALL -Compare(mozilla::detail::nsTStringRepr const&, - mozilla::detail::nsTStringRepr const&, - nsTStringComparator const&); - -template int NS_FASTCALL -Compare(mozilla::detail::nsTStringRepr const&, - mozilla::detail::nsTStringRepr const&, - nsTStringComparator const&); - -template nsTDependentSubstring const Substring(char const*, - char const*); - -template nsTDependentSubstring const Substring( - char16_t const*, char16_t const*); - -// ========================================================= -// Templated member functions that are conditionally enabled -// ========================================================= - -template int32_t nsTString::Find(const self_type&, int32_t, - int32_t) const; - -template int32_t nsTString::Find(const char_type*, int32_t, - int32_t) const; - -template int32_t nsTString::RFind(const self_type&, int32_t, - int32_t) const; - -template int32_t nsTString::RFind(const char_type*, int32_t, - int32_t) const; - -template int32_t nsTString::FindCharInSet(const char*, int32_t) const; - -namespace mozilla { -namespace detail { - -template int32_t nsTStringRepr::Compare(const char_type*, bool, - int32_t) const; - -template bool nsTStringRepr::EqualsIgnoreCase( - const incompatible_char_type*, int32_t) const; - -} // namespace detail -} // namespace mozilla - -template bool nsTString::StripChars(const incompatible_char_type*, - const fallible_t&); - -template void nsTString::StripChars(const incompatible_char_type*); - -template void nsTString::ReplaceChar(const char*, char16_t); diff --git a/xpcom/tests/TestHarness.h b/xpcom/tests/TestHarness.h index 0dafba67f4..59610bdb01 100644 --- a/xpcom/tests/TestHarness.h +++ b/xpcom/tests/TestHarness.h @@ -142,7 +142,7 @@ class ScopedXPCOM : public nsIDirectoryServiceProvider2 { getter_AddRefs(profD)); NS_ENSURE_SUCCESS(rv, nullptr); - rv = profD->Append(NS_LITERAL_STRING("cpp-unit-profd")); + rv = profD->Append(u"cpp-unit-profd"_ns); NS_ENSURE_SUCCESS(rv, nullptr); rv = profD->CreateUnique(nsIFile::DIRECTORY_TYPE, 0755); @@ -184,7 +184,7 @@ class ScopedXPCOM : public nsIDirectoryServiceProvider2 { nsAutoCString leafName; mGREBinD->GetNativeLeafName(leafName); if (leafName.EqualsLiteral("Resources")) { - mGREBinD->SetNativeLeafName(NS_LITERAL_CSTRING("MacOS")); + mGREBinD->SetNativeLeafName("MacOS"_ns); } #endif diff --git a/xpcom/tests/gtest/TestAtoms.cpp b/xpcom/tests/gtest/TestAtoms.cpp index ff8290eed4..6a0165f829 100644 --- a/xpcom/tests/gtest/TestAtoms.cpp +++ b/xpcom/tests/gtest/TestAtoms.cpp @@ -54,7 +54,7 @@ TEST(Atoms, 16vs8) TEST(Atoms, Null) { - nsAutoString str(NS_LITERAL_STRING("string with a \0 char")); + nsAutoString str(u"string with a \0 char"_ns); nsDependentString strCut(str.get()); EXPECT_FALSE(str.Equals(strCut)); diff --git a/xpcom/tests/gtest/TestBase64.cpp b/xpcom/tests/gtest/TestBase64.cpp index f5147816ad..c79ca13215 100644 --- a/xpcom/tests/gtest/TestBase64.cpp +++ b/xpcom/tests/gtest/TestBase64.cpp @@ -243,6 +243,31 @@ TEST(Base64, RFC4648Encoding) } } +TEST(Base64, RFC4648Encoding_TransformAndAppend_EmptyPrefix) +{ + for (auto& testcase : sRFC4648TestCases) { + nsDependentCString in(testcase.mInput); + nsAutoString out; + nsresult rv = + mozilla::Base64EncodeAppend(in.BeginReading(), in.Length(), out); + ASSERT_TRUE(NS_SUCCEEDED(rv)); + ASSERT_TRUE(out.EqualsASCII(testcase.mOutput)); + } +} + +TEST(Base64, RFC4648Encoding_TransformAndAppend_NonEmptyPrefix) +{ + for (auto& testcase : sRFC4648TestCases) { + nsDependentCString in(testcase.mInput); + nsAutoString out{u"foo"_ns}; + nsresult rv = + mozilla::Base64EncodeAppend(in.BeginReading(), in.Length(), out); + ASSERT_TRUE(NS_SUCCEEDED(rv)); + ASSERT_TRUE(StringBeginsWith(out, u"foo"_ns)); + ASSERT_TRUE(Substring(out, 3).EqualsASCII(testcase.mOutput)); + } +} + TEST(Base64, RFC4648Decoding) { for (auto& testcase : sRFC4648TestCases) { diff --git a/xpcom/tests/gtest/TestDafsa.cpp b/xpcom/tests/gtest/TestDafsa.cpp index fa036bcdec..4db34ecd07 100644 --- a/xpcom/tests/gtest/TestDafsa.cpp +++ b/xpcom/tests/gtest/TestDafsa.cpp @@ -20,16 +20,16 @@ TEST(Dafsa, StringsFound) { Dafsa d(dafsa_test_1::kDafsa); - int tag = d.Lookup(NS_LITERAL_CSTRING("foo.bar.baz")); + int tag = d.Lookup("foo.bar.baz"_ns); EXPECT_EQ(tag, 1); - tag = d.Lookup(NS_LITERAL_CSTRING("a.test.string")); + tag = d.Lookup("a.test.string"_ns); EXPECT_EQ(tag, 0); - tag = d.Lookup(NS_LITERAL_CSTRING("a.test.string2")); + tag = d.Lookup("a.test.string2"_ns); EXPECT_EQ(tag, 2); - tag = d.Lookup(NS_LITERAL_CSTRING("aaaa")); + tag = d.Lookup("aaaa"_ns); EXPECT_EQ(tag, 4); } @@ -38,23 +38,23 @@ TEST(Dafsa, StringsNotFound) Dafsa d(dafsa_test_1::kDafsa); // Matches all but last letter. - int tag = d.Lookup(NS_LITERAL_CSTRING("foo.bar.ba")); + int tag = d.Lookup("foo.bar.ba"_ns); EXPECT_EQ(tag, Dafsa::kKeyNotFound); // Matches prefix with extra letter. - tag = d.Lookup(NS_LITERAL_CSTRING("a.test.strings")); + tag = d.Lookup("a.test.strings"_ns); EXPECT_EQ(tag, Dafsa::kKeyNotFound); // Matches small portion. - tag = d.Lookup(NS_LITERAL_CSTRING("a.test")); + tag = d.Lookup("a.test"_ns); EXPECT_EQ(tag, Dafsa::kKeyNotFound); // Matches repeating pattern with extra letters. - tag = d.Lookup(NS_LITERAL_CSTRING("aaaaa")); + tag = d.Lookup("aaaaa"_ns); EXPECT_EQ(tag, Dafsa::kKeyNotFound); // Empty string. - tag = d.Lookup(NS_LITERAL_CSTRING("")); + tag = d.Lookup(""_ns); EXPECT_EQ(tag, Dafsa::kKeyNotFound); } @@ -62,7 +62,7 @@ TEST(Dafsa, HugeString) { Dafsa d(dafsa_test_1::kDafsa); - int tag = d.Lookup(NS_LITERAL_CSTRING( + int tag = d.Lookup(nsLiteralCString( "This is a very long string that is larger than the dafsa itself. " "This is a very long string that is larger than the dafsa itself. " "This is a very long string that is larger than the dafsa itself. " diff --git a/xpcom/tests/gtest/TestEventTargetQI.cpp b/xpcom/tests/gtest/TestEventTargetQI.cpp index ee7e39e1e3..804f7b28df 100644 --- a/xpcom/tests/gtest/TestEventTargetQI.cpp +++ b/xpcom/tests/gtest/TestEventTargetQI.cpp @@ -38,8 +38,7 @@ TEST(TestEventTargetQI, ThreadPool) TEST(TestEventTargetQI, SharedThreadPool) { - nsCOMPtr thing = - SharedThreadPool::Get(NS_LITERAL_CSTRING("TestPool"), 1); + nsCOMPtr thing = SharedThreadPool::Get("TestPool"_ns, 1); EXPECT_TRUE(thing); EXPECT_FALSE(TestQITo(thing)); @@ -71,8 +70,7 @@ TEST(TestEventTargetQI, ThrottledEventQueue) TEST(TestEventTargetQI, LazyIdleThread) { - nsCOMPtr thing = - new LazyIdleThread(0, NS_LITERAL_CSTRING("TestThread")); + nsCOMPtr thing = new LazyIdleThread(0, "TestThread"_ns); EXPECT_TRUE(thing); EXPECT_TRUE(TestQITo(thing)); diff --git a/xpcom/tests/gtest/TestFile.cpp b/xpcom/tests/gtest/TestFile.cpp index 9acada97bc..b89a11121d 100644 --- a/xpcom/tests/gtest/TestFile.cpp +++ b/xpcom/tests/gtest/TestFile.cpp @@ -494,7 +494,7 @@ TEST(TestFile, Unprefixed) gTestWithPrefix_Win = false; #endif - SetupAndTestFunctions(NS_LITERAL_STRING("mozfiletests"), + SetupAndTestFunctions(u"mozfiletests"_ns, /* aTestCreateUnique */ true, /* aTestNormalize */ true); @@ -507,7 +507,7 @@ TEST(TestFile, Unprefixed) // SetUseDOSDevicePathSyntax if it's on Windows for NewFile) TEST(TestFile, PrefixedOnWin) { - SetupAndTestFunctions(NS_LITERAL_STRING("mozfiletests"), + SetupAndTestFunctions(u"mozfiletests"_ns, /* aTestCreateUnique */ true, /* aTestNormalize */ true); } @@ -535,7 +535,7 @@ TEST(TestFile, PrefixedOnWin_ComponentEndsWithPeriod) { // Bypass the normalization for this because it would strip the trailing // period. - SetupAndTestFunctions(NS_LITERAL_STRING("mozfiletests."), + SetupAndTestFunctions(u"mozfiletests."_ns, /* aTestCreateUnique */ true, /* aTestNormalize */ false); } diff --git a/xpcom/tests/gtest/TestFilePreferencesWin.cpp b/xpcom/tests/gtest/TestFilePreferencesWin.cpp index 16ad5a037b..fdf777c6f4 100644 --- a/xpcom/tests/gtest/TestFilePreferencesWin.cpp +++ b/xpcom/tests/gtest/TestFilePreferencesWin.cpp @@ -8,110 +8,103 @@ TEST(FilePreferencesWin, Normalization) { nsAutoString normalized; - mozilla::FilePreferences::testing::NormalizePath(NS_LITERAL_STRING("foo"), + mozilla::FilePreferences::testing::NormalizePath(u"foo"_ns, normalized); + ASSERT_TRUE(normalized == u"foo"_ns); + + mozilla::FilePreferences::testing::NormalizePath(u"\\foo"_ns, normalized); + ASSERT_TRUE(normalized == u"\\foo"_ns); + + mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo"_ns, normalized); + ASSERT_TRUE(normalized == u"\\\\foo"_ns); + + mozilla::FilePreferences::testing::NormalizePath(u"foo\\some"_ns, normalized); + ASSERT_TRUE(normalized == u"foo\\some"_ns); + + mozilla::FilePreferences::testing::NormalizePath(u"\\\\.\\foo"_ns, normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("foo")); + ASSERT_TRUE(normalized == u"\\\\foo"_ns); - mozilla::FilePreferences::testing::NormalizePath(NS_LITERAL_STRING("\\foo"), + mozilla::FilePreferences::testing::NormalizePath(u"\\\\."_ns, normalized); + ASSERT_TRUE(normalized == u"\\\\"_ns); + + mozilla::FilePreferences::testing::NormalizePath(u"\\\\.\\"_ns, normalized); + ASSERT_TRUE(normalized == u"\\\\"_ns); + + mozilla::FilePreferences::testing::NormalizePath(u"\\\\.\\."_ns, normalized); + ASSERT_TRUE(normalized == u"\\\\"_ns); + + mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo\\bar"_ns, normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("\\foo")); + ASSERT_TRUE(normalized == u"\\\\foo\\bar"_ns); - mozilla::FilePreferences::testing::NormalizePath(NS_LITERAL_STRING("\\\\foo"), + mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo\\bar\\"_ns, normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("\\\\foo")); + ASSERT_TRUE(normalized == u"\\\\foo\\bar\\"_ns); - mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("foo\\some"), normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("foo\\some")); - - mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\.\\foo"), normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("\\\\foo")); - - mozilla::FilePreferences::testing::NormalizePath(NS_LITERAL_STRING("\\\\."), + mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo\\bar\\."_ns, normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("\\\\")); + ASSERT_TRUE(normalized == u"\\\\foo\\bar\\"_ns); - mozilla::FilePreferences::testing::NormalizePath(NS_LITERAL_STRING("\\\\.\\"), + mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo\\bar\\.\\"_ns, normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("\\\\")); + ASSERT_TRUE(normalized == u"\\\\foo\\bar\\"_ns); + + mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo\\bar\\..\\"_ns, + normalized); + ASSERT_TRUE(normalized == u"\\\\foo\\"_ns); + + mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo\\bar\\.."_ns, + normalized); + ASSERT_TRUE(normalized == u"\\\\foo\\"_ns); + + mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo\\..\\bar\\..\\"_ns, + normalized); + ASSERT_TRUE(normalized == u"\\\\"_ns); + + mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo\\..\\bar"_ns, + normalized); + ASSERT_TRUE(normalized == u"\\\\bar"_ns); + + mozilla::FilePreferences::testing::NormalizePath(u"\\\\foo\\bar\\..\\..\\"_ns, + normalized); + ASSERT_TRUE(normalized == u"\\\\"_ns); mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\.\\."), normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("\\\\")); - - mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\foo\\bar"), normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("\\\\foo\\bar")); - - mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\foo\\bar\\"), normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("\\\\foo\\bar\\")); - - mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\foo\\bar\\."), normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("\\\\foo\\bar\\")); - - mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\foo\\bar\\.\\"), normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("\\\\foo\\bar\\")); - - mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\foo\\bar\\..\\"), normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("\\\\foo\\")); - - mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\foo\\bar\\.."), normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("\\\\foo\\")); - - mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\foo\\..\\bar\\..\\"), normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("\\\\")); - - mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\foo\\..\\bar"), normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("\\\\bar")); - - mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\foo\\bar\\..\\..\\"), normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("\\\\")); - - mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\foo\\bar\\.\\..\\.\\..\\"), normalized); - ASSERT_TRUE(normalized == NS_LITERAL_STRING("\\\\")); + u"\\\\foo\\bar\\.\\..\\.\\..\\"_ns, normalized); + ASSERT_TRUE(normalized == u"\\\\"_ns); bool result; - result = mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\.."), normalized); + result = mozilla::FilePreferences::testing::NormalizePath(u"\\\\.."_ns, + normalized); + ASSERT_FALSE(result); + + result = mozilla::FilePreferences::testing::NormalizePath(u"\\\\..\\"_ns, + normalized); + ASSERT_FALSE(result); + + result = mozilla::FilePreferences::testing::NormalizePath(u"\\\\.\\..\\"_ns, + normalized); ASSERT_FALSE(result); result = mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\..\\"), normalized); + u"\\\\foo\\\\bar"_ns, normalized); ASSERT_FALSE(result); result = mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\.\\..\\"), normalized); + u"\\\\foo\\bar\\..\\..\\..\\..\\"_ns, normalized); ASSERT_FALSE(result); - result = mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\foo\\\\bar"), normalized); + result = mozilla::FilePreferences::testing::NormalizePath(u"\\\\\\"_ns, + normalized); ASSERT_FALSE(result); - result = mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\foo\\bar\\..\\..\\..\\..\\"), normalized); + result = mozilla::FilePreferences::testing::NormalizePath(u"\\\\.\\\\"_ns, + normalized); ASSERT_FALSE(result); - result = mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\\\"), normalized); - ASSERT_FALSE(result); - - result = mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\.\\\\"), normalized); - ASSERT_FALSE(result); - - result = mozilla::FilePreferences::testing::NormalizePath( - NS_LITERAL_STRING("\\\\..\\\\"), normalized); + result = mozilla::FilePreferences::testing::NormalizePath(u"\\\\..\\\\"_ns, + normalized); ASSERT_FALSE(result); } @@ -123,27 +116,26 @@ TEST(FilePreferencesWin, AccessUNC) mozilla::FilePreferences::testing::SetBlockUNCPaths(false); - rv = lf->InitWithPath(NS_LITERAL_STRING("\\\\nice\\..\\evil\\share")); + rv = lf->InitWithPath(u"\\\\nice\\..\\evil\\share"_ns); ASSERT_EQ(rv, NS_OK); mozilla::FilePreferences::testing::SetBlockUNCPaths(true); - rv = lf->InitWithPath(NS_LITERAL_STRING("\\\\nice\\..\\evil\\share")); + rv = lf->InitWithPath(u"\\\\nice\\..\\evil\\share"_ns); ASSERT_EQ(rv, NS_ERROR_FILE_ACCESS_DENIED); - mozilla::FilePreferences::testing::AddDirectoryToWhitelist( - NS_LITERAL_STRING("\\\\nice")); + mozilla::FilePreferences::testing::AddDirectoryToWhitelist(u"\\\\nice"_ns); - rv = lf->InitWithPath(NS_LITERAL_STRING("\\\\nice\\share")); + rv = lf->InitWithPath(u"\\\\nice\\share"_ns); ASSERT_EQ(rv, NS_OK); - rv = lf->InitWithPath(NS_LITERAL_STRING("\\\\nice\\..\\evil\\share")); + rv = lf->InitWithPath(u"\\\\nice\\..\\evil\\share"_ns); ASSERT_EQ(rv, NS_ERROR_FILE_ACCESS_DENIED); } TEST(FilePreferencesWin, AccessDOSDevicePath) { - const auto devicePathSpecifier = NS_LITERAL_STRING("\\\\?\\"); + const auto devicePathSpecifier = u"\\\\?\\"_ns; nsCOMPtr lf = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID); @@ -151,15 +143,13 @@ TEST(FilePreferencesWin, AccessDOSDevicePath) mozilla::FilePreferences::testing::SetBlockUNCPaths(true); - rv = lf->InitWithPath(devicePathSpecifier + - NS_LITERAL_STRING("evil\\z:\\share")); + rv = lf->InitWithPath(devicePathSpecifier + u"evil\\z:\\share"_ns); ASSERT_EQ(rv, NS_ERROR_FILE_ACCESS_DENIED); - rv = lf->InitWithPath(devicePathSpecifier + - NS_LITERAL_STRING("UNC\\evil\\share")); + rv = lf->InitWithPath(devicePathSpecifier + u"UNC\\evil\\share"_ns); ASSERT_EQ(rv, NS_ERROR_FILE_ACCESS_DENIED); - rv = lf->InitWithPath(devicePathSpecifier + NS_LITERAL_STRING("C:\\")); + rv = lf->InitWithPath(devicePathSpecifier + u"C:\\"_ns); ASSERT_EQ(rv, NS_OK); nsCOMPtr base; @@ -179,26 +169,26 @@ TEST(FilePreferencesWin, StartsWithDiskDesignatorAndBackslash) bool result; result = mozilla::FilePreferences::StartsWithDiskDesignatorAndBackslash( - NS_LITERAL_STRING("\\\\UNC\\path")); + u"\\\\UNC\\path"_ns); ASSERT_FALSE(result); result = mozilla::FilePreferences::StartsWithDiskDesignatorAndBackslash( - NS_LITERAL_STRING("\\single\\backslash")); + u"\\single\\backslash"_ns); ASSERT_FALSE(result); result = mozilla::FilePreferences::StartsWithDiskDesignatorAndBackslash( - NS_LITERAL_STRING("C:relative")); + u"C:relative"_ns); ASSERT_FALSE(result); result = mozilla::FilePreferences::StartsWithDiskDesignatorAndBackslash( - NS_LITERAL_STRING("\\\\?\\C:\\")); + u"\\\\?\\C:\\"_ns); ASSERT_FALSE(result); result = mozilla::FilePreferences::StartsWithDiskDesignatorAndBackslash( - NS_LITERAL_STRING("C:\\")); + u"C:\\"_ns); ASSERT_TRUE(result); result = mozilla::FilePreferences::StartsWithDiskDesignatorAndBackslash( - NS_LITERAL_STRING("c:\\")); + u"c:\\"_ns); ASSERT_TRUE(result); } diff --git a/xpcom/tests/gtest/TestLogCommandLineHandler.cpp b/xpcom/tests/gtest/TestLogCommandLineHandler.cpp index 9765221357..8ffe06ccb1 100644 --- a/xpcom/tests/gtest/TestLogCommandLineHandler.cpp +++ b/xpcom/tests/gtest/TestLogCommandLineHandler.cpp @@ -46,26 +46,26 @@ TEST(LogCommandLineHandler, MOZ_LOG_regular) results.Clear(); mozilla::LoggingHandleCommandLineArgs(array_size(argv1), argv1, callback); EXPECT_TRUE(results.Length() == 1); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG=module1:5,module2:4,sync,timestamp") - .Equals(results[0])); + EXPECT_TRUE( + "MOZ_LOG=module1:5,module2:4,sync,timestamp"_ns.Equals(results[0])); char const* argv2[] = {"", "-MOZ_LOG=modules"}; results.Clear(); mozilla::LoggingHandleCommandLineArgs(array_size(argv2), argv2, callback); EXPECT_TRUE(results.Length() == 1); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG=modules").Equals(results[0])); + EXPECT_TRUE("MOZ_LOG=modules"_ns.Equals(results[0])); char const* argv3[] = {"", "--MOZ_LOG", "modules"}; results.Clear(); mozilla::LoggingHandleCommandLineArgs(array_size(argv3), argv3, callback); EXPECT_TRUE(results.Length() == 1); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG=modules").Equals(results[0])); + EXPECT_TRUE("MOZ_LOG=modules"_ns.Equals(results[0])); char const* argv4[] = {"", "--MOZ_LOG=modules"}; results.Clear(); mozilla::LoggingHandleCommandLineArgs(array_size(argv4), argv4, callback); EXPECT_TRUE(results.Length() == 1); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG=modules").Equals(results[0])); + EXPECT_TRUE("MOZ_LOG=modules"_ns.Equals(results[0])); } TEST(LogCommandLineHandler, MOZ_LOG_and_FILE_regular) @@ -81,38 +81,37 @@ TEST(LogCommandLineHandler, MOZ_LOG_and_FILE_regular) results.Clear(); mozilla::LoggingHandleCommandLineArgs(array_size(argv1), argv1, callback); EXPECT_TRUE(results.Length() == 2); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG=modules").Equals(results[0])); - EXPECT_TRUE( - NS_LITERAL_CSTRING("MOZ_LOG_FILE=c:\\file/path").Equals(results[1])); + EXPECT_TRUE("MOZ_LOG=modules"_ns.Equals(results[0])); + EXPECT_TRUE("MOZ_LOG_FILE=c:\\file/path"_ns.Equals(results[1])); char const* argv2[] = {"", "-MOZ_LOG=modules", "-MOZ_LOG_FILE=file"}; results.Clear(); mozilla::LoggingHandleCommandLineArgs(array_size(argv2), argv2, callback); EXPECT_TRUE(results.Length() == 2); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG=modules").Equals(results[0])); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG_FILE=file").Equals(results[1])); + EXPECT_TRUE("MOZ_LOG=modules"_ns.Equals(results[0])); + EXPECT_TRUE("MOZ_LOG_FILE=file"_ns.Equals(results[1])); char const* argv3[] = {"", "--MOZ_LOG", "modules", "--MOZ_LOG_FILE", "file"}; results.Clear(); mozilla::LoggingHandleCommandLineArgs(array_size(argv3), argv3, callback); EXPECT_TRUE(results.Length() == 2); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG=modules").Equals(results[0])); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG_FILE=file").Equals(results[1])); + EXPECT_TRUE("MOZ_LOG=modules"_ns.Equals(results[0])); + EXPECT_TRUE("MOZ_LOG_FILE=file"_ns.Equals(results[1])); char const* argv4[] = {"", "--MOZ_LOG=modules", "--MOZ_LOG_FILE=file"}; results.Clear(); mozilla::LoggingHandleCommandLineArgs(array_size(argv4), argv4, callback); EXPECT_TRUE(results.Length() == 2); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG=modules").Equals(results[0])); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG_FILE=file").Equals(results[1])); + EXPECT_TRUE("MOZ_LOG=modules"_ns.Equals(results[0])); + EXPECT_TRUE("MOZ_LOG_FILE=file"_ns.Equals(results[1])); char const* argv5[] = {"", "--MOZ_LOG", "modules", "-P", "foo", "--MOZ_LOG_FILE", "file"}; results.Clear(); mozilla::LoggingHandleCommandLineArgs(array_size(argv5), argv5, callback); EXPECT_TRUE(results.Length() == 2); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG=modules").Equals(results[0])); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG_FILE=file").Equals(results[1])); + EXPECT_TRUE("MOZ_LOG=modules"_ns.Equals(results[0])); + EXPECT_TRUE("MOZ_LOG_FILE=file"_ns.Equals(results[1])); } TEST(LogCommandLineHandler, MOZ_LOG_fuzzy) @@ -161,20 +160,20 @@ TEST(LogCommandLineHandler, MOZ_LOG_overlapping) results.Clear(); mozilla::LoggingHandleCommandLineArgs(array_size(argv1), argv1, callback); EXPECT_TRUE(results.Length() == 2); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG=modules1").Equals(results[0])); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG=modules2").Equals(results[1])); + EXPECT_TRUE("MOZ_LOG=modules1"_ns.Equals(results[0])); + EXPECT_TRUE("MOZ_LOG=modules2"_ns.Equals(results[1])); char const* argv2[] = {"", "-MOZ_LOG", "--MOZ_LOG", "modules"}; results.Clear(); mozilla::LoggingHandleCommandLineArgs(array_size(argv2), argv2, callback); EXPECT_TRUE(results.Length() == 1); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG=modules").Equals(results[0])); + EXPECT_TRUE("MOZ_LOG=modules"_ns.Equals(results[0])); char const* argv3[] = {"", "-MOZ_LOG_FILE", "-MOZ_LOG", "modules"}; results.Clear(); mozilla::LoggingHandleCommandLineArgs(array_size(argv3), argv3, callback); EXPECT_TRUE(results.Length() == 1); - EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG=modules").Equals(results[0])); + EXPECT_TRUE("MOZ_LOG=modules"_ns.Equals(results[0])); char const* argv4[] = {"", "-MOZ_LOG", "-MOZ_LOG_FILE", "-MOZ_LOG"}; results.Clear(); diff --git a/xpcom/tests/gtest/TestMruCache.cpp b/xpcom/tests/gtest/TestMruCache.cpp index 58c959a73f..07b97cb99a 100644 --- a/xpcom/tests/gtest/TestMruCache.cpp +++ b/xpcom/tests/gtest/TestMruCache.cpp @@ -237,7 +237,7 @@ TEST(MruCache, TestRemove) // Fill it up. for (char i = 1; i < 32; i++) { const nsCString key = MakeStringKey(i); - mru.Put(key, StringStruct{key, NS_LITERAL_CSTRING("foo")}); + mru.Put(key, StringStruct{key, "foo"_ns}); } // Now remove each value. @@ -382,12 +382,12 @@ TEST(MruCache, TestLookupAndSetWithMove) StringStructMap mru; const nsCString key = MakeStringKey((char)1); - StringStruct val{key, NS_LITERAL_CSTRING("foo")}; + StringStruct val{key, "foo"_ns}; auto p = mru.Lookup(key); EXPECT_FALSE(p); p.Set(std::move(val)); EXPECT_TRUE(p.Data().mKey == key); - EXPECT_TRUE(p.Data().mOther == NS_LITERAL_CSTRING("foo")); + EXPECT_TRUE(p.Data().mOther == "foo"_ns); } diff --git a/xpcom/tests/gtest/TestObserverService.cpp b/xpcom/tests/gtest/TestObserverService.cpp index bc842d3a96..f3f6603832 100644 --- a/xpcom/tests/gtest/TestObserverService.cpp +++ b/xpcom/tests/gtest/TestObserverService.cpp @@ -107,12 +107,12 @@ TEST(ObserverService, AddObserver) do_CreateInstance("@mozilla.org/observer-service;1"); // Add a strong ref. - RefPtr a = new TestObserver(NS_LITERAL_STRING("A")); + RefPtr a = new TestObserver(u"A"_ns); nsresult rv = svc->AddObserver(a, "Foo", false); testResult(rv); // Add a few weak ref. - RefPtr b = new TestObserver(NS_LITERAL_STRING("B")); + RefPtr b = new TestObserver(u"B"_ns); rv = svc->AddObserver(b, "Bar", true); testResult(rv); } @@ -122,9 +122,9 @@ TEST(ObserverService, RemoveObserver) nsCOMPtr svc = do_CreateInstance("@mozilla.org/observer-service;1"); - RefPtr a = new TestObserver(NS_LITERAL_STRING("A")); - RefPtr b = new TestObserver(NS_LITERAL_STRING("B")); - RefPtr c = new TestObserver(NS_LITERAL_STRING("C")); + RefPtr a = new TestObserver(u"A"_ns); + RefPtr b = new TestObserver(u"B"_ns); + RefPtr c = new TestObserver(u"C"_ns); svc->AddObserver(a, "Foo", false); svc->AddObserver(b, "Foo", true); @@ -153,7 +153,7 @@ TEST(ObserverService, EnumerateEmpty) TestExpectedCount(svc, "A", 0); // Now add an observer and enumerate an unobserved topic. - RefPtr a = new TestObserver(NS_LITERAL_STRING("A")); + RefPtr a = new TestObserver(u"A"_ns); testResult(svc->AddObserver(a, "Foo", false)); TestExpectedCount(svc, "A", 0); @@ -166,13 +166,13 @@ TEST(ObserverService, Enumerate) const size_t kFooCount = 10; for (size_t i = 0; i < kFooCount; i++) { - RefPtr a = new TestObserver(NS_LITERAL_STRING("A")); + RefPtr a = new TestObserver(u"A"_ns); testResult(svc->AddObserver(a, "Foo", false)); } const size_t kBarCount = kFooCount / 2; for (size_t i = 0; i < kBarCount; i++) { - RefPtr a = new TestObserver(NS_LITERAL_STRING("A")); + RefPtr a = new TestObserver(u"A"_ns); testResult(svc->AddObserver(a, "Bar", false)); } @@ -190,7 +190,7 @@ TEST(ObserverService, EnumerateWeakRefs) const size_t kFooCount = 10; for (size_t i = 0; i < kFooCount; i++) { - RefPtr a = new TestObserver(NS_LITERAL_STRING("A")); + RefPtr a = new TestObserver(u"A"_ns); testResult(svc->AddObserver(a, "Foo", true)); } @@ -199,8 +199,8 @@ TEST(ObserverService, EnumerateWeakRefs) // Now test a mixture. for (size_t i = 0; i < kFooCount; i++) { - RefPtr a = new TestObserver(NS_LITERAL_STRING("A")); - RefPtr b = new TestObserver(NS_LITERAL_STRING("B")); + RefPtr a = new TestObserver(u"A"_ns); + RefPtr b = new TestObserver(u"B"_ns); // Register a as weak for "Foo". testResult(svc->AddObserver(a, "Foo", true)); @@ -213,9 +213,9 @@ TEST(ObserverService, EnumerateWeakRefs) TestExpectedCount(svc, "Foo", kFooCount); // Now add a couple weak refs, but don't go out of scope. - RefPtr a = new TestObserver(NS_LITERAL_STRING("A")); + RefPtr a = new TestObserver(u"A"_ns); testResult(svc->AddObserver(a, "Foo", true)); - RefPtr b = new TestObserver(NS_LITERAL_STRING("B")); + RefPtr b = new TestObserver(u"B"_ns); testResult(svc->AddObserver(b, "Foo", true)); // Expect all the observers from before and the two new ones. @@ -232,10 +232,8 @@ TEST(ObserverService, TestNotify) nsCOMPtr svc = do_CreateInstance("@mozilla.org/observer-service;1"); - RefPtr aObserver = - new TestObserver(NS_LITERAL_STRING("Observer-A")); - RefPtr bObserver = - new TestObserver(NS_LITERAL_STRING("Observer-B")); + RefPtr aObserver = new TestObserver(u"Observer-A"_ns); + RefPtr bObserver = new TestObserver(u"Observer-B"_ns); // Add two observers for topicA. testResult(svc->AddObserver(aObserver, topicA.get(), false)); diff --git a/xpcom/tests/gtest/TestStrings.cpp b/xpcom/tests/gtest/TestStrings.cpp index 09d7a99423..4b92d0b29f 100644 --- a/xpcom/tests/gtest/TestStrings.cpp +++ b/xpcom/tests/gtest/TestStrings.cpp @@ -568,7 +568,7 @@ TEST_F(Strings, DependentStrings) { TEST_F(Strings, assign) { nsCString result; - test_assign_helper(NS_LITERAL_CSTRING("a") + NS_LITERAL_CSTRING("b"), result); + test_assign_helper("a"_ns + "b"_ns, result); EXPECT_STREQ(result.get(), "ab"); } @@ -663,7 +663,7 @@ TEST_F(Strings, findinreadable) { nsACString::const_iterator delim_begin(begin), delim_end(end); // Search for last !/ at the end of the string - EXPECT_TRUE(FindInReadable(NS_LITERAL_CSTRING("!/"), delim_begin, delim_end)); + EXPECT_TRUE(FindInReadable("!/"_ns, delim_begin, delim_end)); char* r = ToNewCString(Substring(delim_begin, delim_end)); // Should match the first "!/" but not the last EXPECT_NE(delim_end, end); @@ -674,8 +674,7 @@ TEST_F(Strings, findinreadable) { delim_end = end; // Search for first jar: - EXPECT_TRUE( - FindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end)); + EXPECT_TRUE(FindInReadable("jar:"_ns, delim_begin, delim_end)); r = ToNewCString(Substring(delim_begin, delim_end)); // Should not match the first jar:, but the second one @@ -687,8 +686,7 @@ TEST_F(Strings, findinreadable) { delim_begin = begin; delim_begin++; delim_end = end; - EXPECT_TRUE( - FindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end)); + EXPECT_TRUE(FindInReadable("jar:"_ns, delim_begin, delim_end)); r = ToNewCString(Substring(delim_begin, delim_end)); // Should not match the first jar:, but the second one @@ -697,8 +695,7 @@ TEST_F(Strings, findinreadable) { free(r); // Should not find a match - EXPECT_FALSE( - FindInReadable(NS_LITERAL_CSTRING("gecko"), delim_begin, delim_end)); + EXPECT_FALSE(FindInReadable("gecko"_ns, delim_begin, delim_end)); // When no match is found, range should be empty EXPECT_EQ(delim_begin, delim_end); @@ -707,8 +704,7 @@ TEST_F(Strings, findinreadable) { delim_begin = begin; for (int i = 0; i < 6; i++) delim_begin++; delim_end = end; - EXPECT_FALSE( - FindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end)); + EXPECT_FALSE(FindInReadable("jar:"_ns, delim_begin, delim_end)); // When no match is found, range should be empty EXPECT_EQ(delim_begin, delim_end); @@ -717,8 +713,7 @@ TEST_F(Strings, findinreadable) { delim_begin = begin; delim_end = end; for (int i = 0; i < 7; i++) delim_end--; - EXPECT_FALSE( - FindInReadable(NS_LITERAL_CSTRING("classic"), delim_begin, delim_end)); + EXPECT_FALSE(FindInReadable("classic"_ns, delim_begin, delim_end)); // When no match is found, range should be empty EXPECT_EQ(delim_begin, delim_end); @@ -736,8 +731,7 @@ TEST_F(Strings, rfindinreadable) { nsACString::const_iterator delim_begin(begin), delim_end(end); // Search for last !/ at the end of the string - EXPECT_TRUE( - RFindInReadable(NS_LITERAL_CSTRING("!/"), delim_begin, delim_end)); + EXPECT_TRUE(RFindInReadable("!/"_ns, delim_begin, delim_end)); char* r = ToNewCString(Substring(delim_begin, delim_end)); // Should match the last "!/" EXPECT_EQ(delim_end, end); @@ -748,8 +742,7 @@ TEST_F(Strings, rfindinreadable) { delim_end = end; // Search for last jar: but not the first one... - EXPECT_TRUE( - RFindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end)); + EXPECT_TRUE(RFindInReadable("jar:"_ns, delim_begin, delim_end)); r = ToNewCString(Substring(delim_begin, delim_end)); // Should not match the first jar:, but the second one @@ -761,8 +754,7 @@ TEST_F(Strings, rfindinreadable) { delim_begin = begin; delim_end = begin; for (int i = 0; i < 6; i++) delim_end++; - EXPECT_TRUE( - RFindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end)); + EXPECT_TRUE(RFindInReadable("jar:"_ns, delim_begin, delim_end)); r = ToNewCString(Substring(delim_begin, delim_end)); // Should not match the first jar:, but the second one @@ -773,8 +765,7 @@ TEST_F(Strings, rfindinreadable) { // Should not find a match delim_begin = begin; delim_end = end; - EXPECT_FALSE( - RFindInReadable(NS_LITERAL_CSTRING("gecko"), delim_begin, delim_end)); + EXPECT_FALSE(RFindInReadable("gecko"_ns, delim_begin, delim_end)); // When no match is found, range should be empty EXPECT_EQ(delim_begin, delim_end); @@ -783,8 +774,7 @@ TEST_F(Strings, rfindinreadable) { delim_begin = begin; for (int i = 0; i < 6; i++) delim_begin++; delim_end = end; - EXPECT_FALSE( - RFindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end)); + EXPECT_FALSE(RFindInReadable("jar:"_ns, delim_begin, delim_end)); // When no match is found, range should be empty EXPECT_EQ(delim_begin, delim_end); @@ -793,8 +783,7 @@ TEST_F(Strings, rfindinreadable) { delim_begin = begin; delim_end = end; for (int i = 0; i < 7; i++) delim_end--; - EXPECT_FALSE( - RFindInReadable(NS_LITERAL_CSTRING("classic"), delim_begin, delim_end)); + EXPECT_FALSE(RFindInReadable("classic"_ns, delim_begin, delim_end)); // When no match is found, range should be empty EXPECT_EQ(delim_begin, delim_end); @@ -965,8 +954,8 @@ TEST_F(Strings, concat) { nsCString bar("bar"); const nsACString& barRef = bar; - const nsPromiseFlatCString& result = PromiseFlatCString( - NS_LITERAL_CSTRING("foo") + NS_LITERAL_CSTRING(",") + barRef); + const nsPromiseFlatCString& result = + PromiseFlatCString("foo"_ns + ","_ns + barRef); EXPECT_STREQ(result.get(), "foo,bar"); } @@ -1328,13 +1317,12 @@ static void test_strip_chars_helper(const char16_t* str, const char16_t* strip, TEST(String, strip_chars) { - test_strip_chars_helper(u"foo \r \nbar", u" \n\r", - NS_LITERAL_STRING("foobar")); - test_strip_chars_helper(u"\r\nfoo\r\n", u" \n\r", NS_LITERAL_STRING("foo")); - test_strip_chars_helper(u"foo", u" \n\r", NS_LITERAL_STRING("foo")); - test_strip_chars_helper(u"foo", u"fo", NS_LITERAL_STRING("")); - test_strip_chars_helper(u"foo", u"foo", NS_LITERAL_STRING("")); - test_strip_chars_helper(u" foo", u" ", NS_LITERAL_STRING("foo")); + test_strip_chars_helper(u"foo \r \nbar", u" \n\r", u"foobar"_ns); + test_strip_chars_helper(u"\r\nfoo\r\n", u" \n\r", u"foo"_ns); + test_strip_chars_helper(u"foo", u" \n\r", u"foo"_ns); + test_strip_chars_helper(u"foo", u"fo", u""_ns); + test_strip_chars_helper(u"foo", u"foo", u""_ns); + test_strip_chars_helper(u" foo", u" ", u"foo"_ns); } TEST_F(Strings, append_with_capacity) { @@ -1398,12 +1386,14 @@ TEST_F(Strings, legacy_set_length_semantics) { #endif TEST_F(Strings, bulk_write) { - nsresult rv; nsCString s; const char* ptrTwoThousand; { - auto handle = s.BulkWrite(500, 0, true, rv); - EXPECT_EQ(rv, NS_OK); + auto handleOrErr = s.BulkWrite(500, 0, true); + EXPECT_TRUE(handleOrErr.isOk()); + + auto handle = handleOrErr.unwrap(); + auto span = handle.AsSpan(); for (auto&& c : span) { c = 'a'; @@ -1428,11 +1418,10 @@ TEST_F(Strings, bulk_write) { } TEST_F(Strings, bulk_write_fail) { - nsresult rv; nsCString s; { - auto handle = s.BulkWrite(500, 0, true, rv); - EXPECT_EQ(rv, NS_OK); + auto handleOrErr = s.BulkWrite(500, 0, true); + EXPECT_TRUE(handleOrErr.isOk()); } EXPECT_EQ(s.Length(), 3U); EXPECT_TRUE(s.Equals(u8"\uFFFD")); @@ -1541,20 +1530,19 @@ static void test_tofloat_helper(const nsString& aStr, float aExpected, } TEST_F(Strings, tofloat) { - test_tofloat_helper(NS_LITERAL_STRING("42"), 42.f, true); - test_tofloat_helper(NS_LITERAL_STRING("42.0"), 42.f, true); - test_tofloat_helper(NS_LITERAL_STRING("-42"), -42.f, true); - test_tofloat_helper(NS_LITERAL_STRING("+42"), 42, true); - test_tofloat_helper(NS_LITERAL_STRING("13.37"), 13.37f, true); - test_tofloat_helper(NS_LITERAL_STRING("1.23456789"), 1.23456789f, true); - test_tofloat_helper(NS_LITERAL_STRING("1.98765432123456"), 1.98765432123456f, - true); - test_tofloat_helper(NS_LITERAL_STRING("0"), 0.f, true); - test_tofloat_helper(NS_LITERAL_STRING("1.e5"), 100000, true); - test_tofloat_helper(NS_LITERAL_STRING(""), 0.f, false); - test_tofloat_helper(NS_LITERAL_STRING("42foo"), 42.f, false); - test_tofloat_helper(NS_LITERAL_STRING("foo"), 0.f, false); - test_tofloat_helper(NS_LITERAL_STRING("1.5e-"), 1.5f, false); + test_tofloat_helper(u"42"_ns, 42.f, true); + test_tofloat_helper(u"42.0"_ns, 42.f, true); + test_tofloat_helper(u"-42"_ns, -42.f, true); + test_tofloat_helper(u"+42"_ns, 42, true); + test_tofloat_helper(u"13.37"_ns, 13.37f, true); + test_tofloat_helper(u"1.23456789"_ns, 1.23456789f, true); + test_tofloat_helper(u"1.98765432123456"_ns, 1.98765432123456f, true); + test_tofloat_helper(u"0"_ns, 0.f, true); + test_tofloat_helper(u"1.e5"_ns, 100000, true); + test_tofloat_helper(u""_ns, 0.f, false); + test_tofloat_helper(u"42foo"_ns, 42.f, false); + test_tofloat_helper(u"foo"_ns, 0.f, false); + test_tofloat_helper(u"1.5e-"_ns, 1.5f, false); } static void test_tofloat_allow_trailing_chars_helper(const nsString& aStr, @@ -1570,17 +1558,12 @@ static void test_tofloat_allow_trailing_chars_helper(const nsString& aStr, } TEST_F(Strings, ToFloatAllowTrailingChars) { - test_tofloat_allow_trailing_chars_helper(NS_LITERAL_STRING(""), 0.f, false); - test_tofloat_allow_trailing_chars_helper(NS_LITERAL_STRING("foo"), 0.f, - false); - test_tofloat_allow_trailing_chars_helper(NS_LITERAL_STRING("42foo"), 42.f, - true); - test_tofloat_allow_trailing_chars_helper(NS_LITERAL_STRING("42-5"), 42.f, - true); - test_tofloat_allow_trailing_chars_helper(NS_LITERAL_STRING("13.37.8"), 13.37f, - true); - test_tofloat_allow_trailing_chars_helper(NS_LITERAL_STRING("1.5e-"), 1.5f, - true); + test_tofloat_allow_trailing_chars_helper(u""_ns, 0.f, false); + test_tofloat_allow_trailing_chars_helper(u"foo"_ns, 0.f, false); + test_tofloat_allow_trailing_chars_helper(u"42foo"_ns, 42.f, true); + test_tofloat_allow_trailing_chars_helper(u"42-5"_ns, 42.f, true); + test_tofloat_allow_trailing_chars_helper(u"13.37.8"_ns, 13.37f, true); + test_tofloat_allow_trailing_chars_helper(u"1.5e-"_ns, 1.5f, true); } static void test_todouble_helper(const nsString& aStr, double aExpected, @@ -1595,22 +1578,21 @@ static void test_todouble_helper(const nsString& aStr, double aExpected, } TEST_F(Strings, todouble) { - test_todouble_helper(NS_LITERAL_STRING("42"), 42, true); - test_todouble_helper(NS_LITERAL_STRING("42.0"), 42, true); - test_todouble_helper(NS_LITERAL_STRING("-42"), -42, true); - test_todouble_helper(NS_LITERAL_STRING("+42"), 42, true); - test_todouble_helper(NS_LITERAL_STRING("13.37"), 13.37, true); - test_todouble_helper(NS_LITERAL_STRING("1.23456789"), 1.23456789, true); - test_todouble_helper(NS_LITERAL_STRING("1.98765432123456"), 1.98765432123456, + test_todouble_helper(u"42"_ns, 42, true); + test_todouble_helper(u"42.0"_ns, 42, true); + test_todouble_helper(u"-42"_ns, -42, true); + test_todouble_helper(u"+42"_ns, 42, true); + test_todouble_helper(u"13.37"_ns, 13.37, true); + test_todouble_helper(u"1.23456789"_ns, 1.23456789, true); + test_todouble_helper(u"1.98765432123456"_ns, 1.98765432123456, true); + test_todouble_helper(u"123456789.98765432123456"_ns, 123456789.98765432123456, true); - test_todouble_helper(NS_LITERAL_STRING("123456789.98765432123456"), - 123456789.98765432123456, true); - test_todouble_helper(NS_LITERAL_STRING("0"), 0, true); - test_todouble_helper(NS_LITERAL_STRING("1.e5"), 100000, true); - test_todouble_helper(NS_LITERAL_STRING(""), 0, false); - test_todouble_helper(NS_LITERAL_STRING("42foo"), 42, false); - test_todouble_helper(NS_LITERAL_STRING("foo"), 0, false); - test_todouble_helper(NS_LITERAL_STRING("1.5e-"), 1.5, false); + test_todouble_helper(u"0"_ns, 0, true); + test_todouble_helper(u"1.e5"_ns, 100000, true); + test_todouble_helper(u""_ns, 0, false); + test_todouble_helper(u"42foo"_ns, 42, false); + test_todouble_helper(u"foo"_ns, 0, false); + test_todouble_helper(u"1.5e-"_ns, 1.5, false); } static void test_todouble_allow_trailing_chars_helper(const nsString& aStr, @@ -1626,16 +1608,12 @@ static void test_todouble_allow_trailing_chars_helper(const nsString& aStr, } TEST_F(Strings, ToDoubleAllowTrailingChars) { - test_todouble_allow_trailing_chars_helper(NS_LITERAL_STRING(""), 0, false); - test_todouble_allow_trailing_chars_helper(NS_LITERAL_STRING("foo"), 0, false); - test_todouble_allow_trailing_chars_helper(NS_LITERAL_STRING("42foo"), 42, - true); - test_todouble_allow_trailing_chars_helper(NS_LITERAL_STRING("42-5"), 42, - true); - test_todouble_allow_trailing_chars_helper(NS_LITERAL_STRING("13.37.8"), 13.37, - true); - test_todouble_allow_trailing_chars_helper(NS_LITERAL_STRING("1.5e-"), 1.5, - true); + test_todouble_allow_trailing_chars_helper(u""_ns, 0, false); + test_todouble_allow_trailing_chars_helper(u"foo"_ns, 0, false); + test_todouble_allow_trailing_chars_helper(u"42foo"_ns, 42, true); + test_todouble_allow_trailing_chars_helper(u"42-5"_ns, 42, true); + test_todouble_allow_trailing_chars_helper(u"13.37.8"_ns, 13.37, true); + test_todouble_allow_trailing_chars_helper(u"1.5e-"_ns, 1.5, true); } TEST_F(Strings, Split) { @@ -1707,9 +1685,9 @@ TEST_F(Strings, Split) { counter = 0; for (const nsAString& token : wide.Split(' ')) { if (counter == 0) { - EXPECT_TRUE(token.Equals(NS_LITERAL_STRING("hello"))); + EXPECT_TRUE(token.Equals(u"hello"_ns)); } else if (counter == 1) { - EXPECT_TRUE(token.Equals(NS_LITERAL_STRING("world"))); + EXPECT_TRUE(token.Equals(u"world"_ns)); } counter++; } @@ -2482,7 +2460,7 @@ CONVERSION_BENCH(PerfUTF8toUTF16VIThousand, CopyUTF8toUTF16, mViThousandUtf8, nsAutoString); // Tests for usability of nsTLiteralString in constant expressions. -static_assert(NS_LITERAL_STRING("").IsEmpty()); +static_assert(u""_ns.IsEmpty()); constexpr auto testStringA = NS_LITERAL_STRING("a"); static_assert(!testStringA.IsEmpty()); diff --git a/xpcom/tests/gtest/TestTextFormatter.cpp b/xpcom/tests/gtest/TestTextFormatter.cpp index ed510afe72..88bb7a9404 100644 --- a/xpcom/tests/gtest/TestTextFormatter.cpp +++ b/xpcom/tests/gtest/TestTextFormatter.cpp @@ -8,7 +8,7 @@ TEST(TextFormatter, Tests) { - nsAutoString fmt(NS_LITERAL_STRING("%3$s %4$S %1$d %2$d %2$d %3$s")); + nsAutoString fmt(u"%3$s %4$S %1$d %2$d %2$d %3$s"_ns); char utf8[] = "Hello"; char16_t ucs2[] = {'W', 'o', 'r', 'l', 'd', 0x4e00, 0xAc00, 0xFF45, 0x0103, 0x00}; diff --git a/xpcom/tests/gtest/TestTokenizer.cpp b/xpcom/tests/gtest/TestTokenizer.cpp index 1e1796ee58..24f008156f 100644 --- a/xpcom/tests/gtest/TestTokenizer.cpp +++ b/xpcom/tests/gtest/TestTokenizer.cpp @@ -26,11 +26,11 @@ TEST(Tokenizer, HTTPResponse) // Real life test, HTTP response Tokenizer p( - NS_LITERAL_CSTRING("HTTP/1.0 304 Not modified\r\n" - "ETag: hallo\r\n" - "Content-Length: 16\r\n" - "\r\n" - "This is the body")); + nsLiteralCString("HTTP/1.0 304 Not modified\r\n" + "ETag: hallo\r\n" + "Content-Length: 16\r\n" + "\r\n" + "This is the body")); EXPECT_TRUE(p.CheckWord("HTTP")); EXPECT_TRUE(p.CheckChar('/')); @@ -99,7 +99,7 @@ TEST(Tokenizer, Main) // Synthetic code-specific test - Tokenizer p(NS_LITERAL_CSTRING("test123 ,15 \t*\r\n%xx,-15\r\r")); + Tokenizer p("test123 ,15 \t*\r\n%xx,-15\r\r"_ns); EXPECT_TRUE(p.Next(t)); EXPECT_TRUE(t.Type() == Tokenizer::TOKEN_WORD); @@ -213,11 +213,11 @@ TEST(Tokenizer, Main16) // Synthetic code-specific test - Tokenizer16 p(NS_LITERAL_STRING("test123 ,15 \t*\r\n%xx,-15\r\r")); + Tokenizer16 p(u"test123 ,15 \t*\r\n%xx,-15\r\r"_ns); EXPECT_TRUE(p.Next(t)); EXPECT_TRUE(t.Type() == Tokenizer16::TOKEN_WORD); - EXPECT_TRUE(t.AsString() == NS_LITERAL_STRING("test123")); + EXPECT_TRUE(t.AsString() == u"test123"_ns); Tokenizer16::Token u; EXPECT_FALSE(p.Check(u)); @@ -272,21 +272,21 @@ TEST(Tokenizer, Main16) nsAutoString claim; p.Claim(claim, Tokenizer16::EXCLUDE_LAST); - EXPECT_TRUE(claim == NS_LITERAL_STRING("*\r\n")); + EXPECT_TRUE(claim == u"*\r\n"_ns); p.Claim(claim, Tokenizer16::INCLUDE_LAST); - EXPECT_TRUE(claim == NS_LITERAL_STRING("*\r\n%")); + EXPECT_TRUE(claim == u"*\r\n%"_ns); p.Rollback(); EXPECT_TRUE(p.CheckChar('%')); p.Record(Tokenizer16::INCLUDE_LAST); - EXPECT_FALSE(p.CheckWord(NS_LITERAL_STRING("xy"))); + EXPECT_FALSE(p.CheckWord(u"xy"_ns)); - EXPECT_TRUE(p.CheckWord(NS_LITERAL_STRING("xx"))); + EXPECT_TRUE(p.CheckWord(u"xx"_ns)); p.Claim(claim, Tokenizer16::INCLUDE_LAST); - EXPECT_TRUE(claim == NS_LITERAL_STRING("%xx")); + EXPECT_TRUE(claim == u"%xx"_ns); EXPECT_TRUE(p.Next(t)); EXPECT_TRUE(t.Type() == Tokenizer16::TOKEN_CHAR); @@ -325,7 +325,7 @@ TEST(Tokenizer, SingleWord) { // Single word with numbers in it test - Tokenizer p(NS_LITERAL_CSTRING("test123")); + Tokenizer p("test123"_ns); EXPECT_TRUE(p.CheckWord("test123")); EXPECT_TRUE(p.CheckEOF()); @@ -335,7 +335,7 @@ TEST(Tokenizer, EndingAfterNumber) { // An end handling after a number - Tokenizer p(NS_LITERAL_CSTRING("123")); + Tokenizer p("123"_ns); EXPECT_FALSE(p.CheckWord("123")); EXPECT_TRUE(p.Check(Tokenizer::Token::Number(123))); @@ -348,7 +348,7 @@ TEST(Tokenizer, BadInteger) // A bad integer test - Tokenizer p(NS_LITERAL_CSTRING("189234891274981758617846178651647620587135")); + Tokenizer p("189234891274981758617846178651647620587135"_ns); EXPECT_TRUE(p.Next(t)); EXPECT_TRUE(t.Type() == Tokenizer::TOKEN_ERROR); @@ -361,7 +361,7 @@ TEST(Tokenizer, CheckExpectedTokenValue) // Check expected token value test - Tokenizer p(NS_LITERAL_CSTRING("blue velvet")); + Tokenizer p("blue velvet"_ns); EXPECT_FALSE(p.Check(Tokenizer::TOKEN_INTEGER, t)); @@ -386,13 +386,13 @@ TEST(Tokenizer, HasFailed) // HasFailed test - Tokenizer p1(NS_LITERAL_CSTRING("a b")); + Tokenizer p1("a b"_ns); while (p1.Next(t) && t.Type() != Tokenizer::TOKEN_CHAR) ; EXPECT_TRUE(p1.HasFailed()); - Tokenizer p2(NS_LITERAL_CSTRING("a b ?!c")); + Tokenizer p2("a b ?!c"_ns); EXPECT_FALSE(p2.CheckChar('c')); EXPECT_TRUE(p2.HasFailed()); @@ -460,7 +460,7 @@ TEST(Tokenizer, Construction) } { - Tokenizer p1(NS_LITERAL_CSTRING("test")); + Tokenizer p1("test"_ns); EXPECT_TRUE(p1.CheckWord("test")); EXPECT_TRUE(p1.CheckEOF()); } @@ -474,15 +474,14 @@ TEST(Tokenizer, Construction) TEST(Tokenizer, Customization) { - Tokenizer p1(NS_LITERAL_CSTRING("test-custom*words and\tdefault-whites"), - nullptr, "-*"); + Tokenizer p1("test-custom*words and\tdefault-whites"_ns, nullptr, "-*"); EXPECT_TRUE(p1.CheckWord("test-custom*words")); EXPECT_TRUE(p1.CheckWhite()); EXPECT_TRUE(p1.CheckWord("and")); EXPECT_TRUE(p1.CheckWhite()); EXPECT_TRUE(p1.CheckWord("default-whites")); - Tokenizer p2(NS_LITERAL_CSTRING("test, custom,whites"), ", "); + Tokenizer p2("test, custom,whites"_ns, ", "); EXPECT_TRUE(p2.CheckWord("test")); EXPECT_TRUE(p2.CheckWhite()); EXPECT_TRUE(p2.CheckWhite()); @@ -490,8 +489,7 @@ TEST(Tokenizer, Customization) EXPECT_TRUE(p2.CheckWhite()); EXPECT_TRUE(p2.CheckWord("whites")); - Tokenizer p3(NS_LITERAL_CSTRING("test, custom, whites-and#word-chars"), ",", - "-#"); + Tokenizer p3("test, custom, whites-and#word-chars"_ns, ",", "-#"); EXPECT_TRUE(p3.CheckWord("test")); EXPECT_TRUE(p3.CheckWhite()); EXPECT_FALSE(p3.CheckWhite()); @@ -787,12 +785,11 @@ TEST(Tokenizer, ReadUntil) EXPECT_TRUE(f == "Hello;test 4,"); p.Rollback(); - EXPECT_TRUE( - p.ReadUntil(Tokenizer::Token::Word(NS_LITERAL_CSTRING("test")), f)); + EXPECT_TRUE(p.ReadUntil(Tokenizer::Token::Word("test"_ns), f)); EXPECT_TRUE(f == "Hello;"); p.Rollback(); - EXPECT_TRUE(p.ReadUntil(Tokenizer::Token::Word(NS_LITERAL_CSTRING("test")), f, + EXPECT_TRUE(p.ReadUntil(Tokenizer::Token::Word("test"_ns), f, Tokenizer::INCLUDE_LAST)); EXPECT_TRUE(f == "Hello;test"); EXPECT_TRUE(p.ReadUntil(Tokenizer::Token::Char(','), f)); @@ -947,13 +944,13 @@ TEST(Tokenizer, Incremental) [&](Token const& t, IncrementalTokenizer& i) -> nsresult { switch (++test) { case 1: - EXPECT_TRUE(t.Equals(Token::Word(NS_LITERAL_CSTRING("test1")))); + EXPECT_TRUE(t.Equals(Token::Word("test1"_ns))); break; case 2: EXPECT_TRUE(t.Equals(Token::Char(','))); break; case 3: - EXPECT_TRUE(t.Equals(Token::Word(NS_LITERAL_CSTRING("test2")))); + EXPECT_TRUE(t.Equals(Token::Word("test2"_ns))); break; case 4: EXPECT_TRUE(t.Equals(Token::Char(','))); @@ -965,7 +962,7 @@ TEST(Tokenizer, Incremental) EXPECT_TRUE(t.Equals(Token::Char(','))); break; case 7: - EXPECT_TRUE(t.Equals(Token::Word(NS_LITERAL_CSTRING("test3")))); + EXPECT_TRUE(t.Equals(Token::Word("test3"_ns))); break; case 8: EXPECT_TRUE(t.Equals(Token::EndOfFile())); @@ -996,17 +993,17 @@ TEST(Tokenizer, IncrementalRollback) [&](Token const& t, IncrementalTokenizer& i) -> nsresult { switch (++test) { case 1: - EXPECT_TRUE(t.Equals(Token::Word(NS_LITERAL_CSTRING("test1")))); + EXPECT_TRUE(t.Equals(Token::Word("test1"_ns))); break; case 2: EXPECT_TRUE(t.Equals(Token::Char(','))); break; case 3: - EXPECT_TRUE(t.Equals(Token::Word(NS_LITERAL_CSTRING("test2")))); + EXPECT_TRUE(t.Equals(Token::Word("test2"_ns))); i.Rollback(); // so that we get the token again break; case 4: - EXPECT_TRUE(t.Equals(Token::Word(NS_LITERAL_CSTRING("test2")))); + EXPECT_TRUE(t.Equals(Token::Word("test2"_ns))); break; case 5: EXPECT_TRUE(t.Equals(Token::Char(','))); @@ -1018,7 +1015,7 @@ TEST(Tokenizer, IncrementalRollback) EXPECT_TRUE(t.Equals(Token::Char(','))); break; case 8: - EXPECT_TRUE(t.Equals(Token::Word(NS_LITERAL_CSTRING("test3")))); + EXPECT_TRUE(t.Equals(Token::Word("test3"_ns))); break; case 9: EXPECT_TRUE(t.Equals(Token::EndOfFile())); @@ -1050,7 +1047,7 @@ TEST(Tokenizer, IncrementalNeedMoreInput) Token t2; switch (++test) { case 1: - EXPECT_TRUE(t.Equals(Token::Word(NS_LITERAL_CSTRING("a")))); + EXPECT_TRUE(t.Equals(Token::Word("a"_ns))); break; case 2: case 3: @@ -1059,7 +1056,7 @@ TEST(Tokenizer, IncrementalNeedMoreInput) EXPECT_TRUE(t.Equals(Token::Whitespace())); if (i.Next(t2)) { EXPECT_TRUE(test == 5); - EXPECT_TRUE(t2.Equals(Token::Word(NS_LITERAL_CSTRING("bb")))); + EXPECT_TRUE(t2.Equals(Token::Word("bb"_ns))); } else { EXPECT_TRUE(test < 5); i.NeedMoreInput(); @@ -1069,7 +1066,7 @@ TEST(Tokenizer, IncrementalNeedMoreInput) EXPECT_TRUE(t.Equals(Token::Char(','))); break; case 7: - EXPECT_TRUE(t.Equals(Token::Word(NS_LITERAL_CSTRING("c")))); + EXPECT_TRUE(t.Equals(Token::Word("c"_ns))); return NS_ERROR_FAILURE; default: EXPECT_TRUE(false); @@ -1112,7 +1109,7 @@ TEST(Tokenizer, IncrementalCustom) EXPECT_TRUE(t.Equals(custom)); break; case 2: - EXPECT_TRUE(t.Equals(Token::Word(NS_LITERAL_CSTRING("bla")))); + EXPECT_TRUE(t.Equals(Token::Word("bla"_ns))); break; case 3: EXPECT_TRUE(t.Equals(Token::EndOfFile())); @@ -1124,11 +1121,11 @@ TEST(Tokenizer, IncrementalCustom) nullptr, "-"); custom = i.AddCustomToken("some-test", Tokenizer::CASE_SENSITIVE); - i.FeedInput(NS_LITERAL_CSTRING("some-")); + i.FeedInput("some-"_ns); EXPECT_TRUE(test == 0); - i.FeedInput(NS_LITERAL_CSTRING("tes")); + i.FeedInput("tes"_ns); EXPECT_TRUE(test == 0); - i.FeedInput(NS_LITERAL_CSTRING("tbla")); + i.FeedInput("tbla"_ns); EXPECT_TRUE(test == 1); i.FinishInput(); EXPECT_TRUE(test == 3); @@ -1265,17 +1262,17 @@ TEST(Tokenizer, IncrementalBuffering1) Unused << i.AddCustomToken("bb", Tokenizer::CASE_SENSITIVE); i.SetTokenizingMode(Tokenizer::Mode::CUSTOM_ONLY); - i.FeedInput(NS_LITERAL_CSTRING("01234")); + i.FeedInput("01234"_ns); EXPECT_TRUE(test == 1); EXPECT_TRUE(observedFragment.EqualsLiteral("012")); - i.FeedInput(NS_LITERAL_CSTRING("5")); + i.FeedInput("5"_ns); EXPECT_TRUE(test == 1); - i.FeedInput(NS_LITERAL_CSTRING("6789aa")); + i.FeedInput("6789aa"_ns); EXPECT_TRUE(test == 2); EXPECT_TRUE(observedFragment.EqualsLiteral("3456789")); - i.FeedInput(NS_LITERAL_CSTRING("aqwert")); + i.FeedInput("aqwert"_ns); EXPECT_TRUE(test == 4); EXPECT_TRUE(observedFragment.EqualsLiteral("qwe")); @@ -1321,13 +1318,13 @@ TEST(Tokenizer, IncrementalBuffering2) Unused << i.AddCustomToken("bbbbb", Tokenizer::CASE_SENSITIVE); i.SetTokenizingMode(Tokenizer::Mode::CUSTOM_ONLY); - i.FeedInput(NS_LITERAL_CSTRING("01234")); + i.FeedInput("01234"_ns); EXPECT_TRUE(test == 0); - i.FeedInput(NS_LITERAL_CSTRING("5")); + i.FeedInput("5"_ns); EXPECT_TRUE(test == 1); - i.FeedInput(NS_LITERAL_CSTRING("6789aa")); + i.FeedInput("6789aa"_ns); EXPECT_TRUE(test == 2); - i.FeedInput(NS_LITERAL_CSTRING("aqwert")); + i.FeedInput("aqwert"_ns); EXPECT_TRUE(test == 4); i.FinishInput(); EXPECT_TRUE(test == 6); diff --git a/xpcom/tests/gtest/TestUTF.cpp b/xpcom/tests/gtest/TestUTF.cpp index aa91b5097e..2985112ab6 100644 --- a/xpcom/tests/gtest/TestUTF.cpp +++ b/xpcom/tests/gtest/TestUTF.cpp @@ -32,11 +32,11 @@ TEST(UTF, Valid) nsCString tmp8("string "); AppendUTF16toUTF8(str16, tmp8); - EXPECT_TRUE(tmp8.Equals(NS_LITERAL_CSTRING("string ") + str8)); + EXPECT_TRUE(tmp8.Equals("string "_ns + str8)); - nsString tmp16(NS_LITERAL_STRING("string ")); + nsString tmp16(u"string "_ns); AppendUTF8toUTF16(str8, tmp16); - EXPECT_TRUE(tmp16.Equals(NS_LITERAL_STRING("string ") + str16)); + EXPECT_TRUE(tmp16.Equals(u"string "_ns + str16)); EXPECT_EQ(CompareUTF8toUTF16(str8, str16), 0); } @@ -52,7 +52,7 @@ TEST(UTF, Invalid16) nsCString tmp8("string "); AppendUTF16toUTF8(str16, tmp8); - EXPECT_TRUE(tmp8.Equals(NS_LITERAL_CSTRING("string ") + str8)); + EXPECT_TRUE(tmp8.Equals("string "_ns + str8)); EXPECT_EQ(CompareUTF8toUTF16(str8, str16), 0); } @@ -66,9 +66,9 @@ TEST(UTF, Invalid8) EXPECT_TRUE(NS_ConvertUTF8toUTF16(str8).Equals(str16)); - nsString tmp16(NS_LITERAL_STRING("string ")); + nsString tmp16(u"string "_ns); AppendUTF8toUTF16(str8, tmp16); - EXPECT_TRUE(tmp16.Equals(NS_LITERAL_STRING("string ") + str16)); + EXPECT_TRUE(tmp16.Equals(u"string "_ns + str16)); EXPECT_EQ(CompareUTF8toUTF16(str8, str16), 0); } @@ -82,9 +82,9 @@ TEST(UTF, Malformed8) EXPECT_TRUE(NS_ConvertUTF8toUTF16(str8).Equals(str16)); - nsString tmp16(NS_LITERAL_STRING("string ")); + nsString tmp16(u"string "_ns); AppendUTF8toUTF16(str8, tmp16); - EXPECT_TRUE(tmp16.Equals(NS_LITERAL_STRING("string ") + str16)); + EXPECT_TRUE(tmp16.Equals(u"string "_ns + str16)); EXPECT_EQ(CompareUTF8toUTF16(str8, str16), 0); } diff --git a/xpcom/tests/windows/TestNtPathToDosPath.cpp b/xpcom/tests/windows/TestNtPathToDosPath.cpp index 5407caf8ec..8e5a85d5e9 100644 --- a/xpcom/tests/windows/TestNtPathToDosPath.cpp +++ b/xpcom/tests/windows/TestNtPathToDosPath.cpp @@ -149,7 +149,7 @@ TEST(NtPathToDosPath, Tests) EXPECT_TRUE(TestNtPathToDosPath(L"\\Device\\LanmanRedirector\\127.0.0.1\\C$", L"\\\\127.0.0.1\\C$")); - DriveMapping drvMapping(NS_LITERAL_STRING("\\\\127.0.0.1\\C$")); + DriveMapping drvMapping(u"\\\\127.0.0.1\\C$"_ns); // Only run these tests if we were able to map; some machines don't have perms if (drvMapping.Init()) { wchar_t expected[] = L" :\\"; diff --git a/xpcom/threads/CPUUsageWatcher.cpp b/xpcom/threads/CPUUsageWatcher.cpp index 63841cd6c6..6181cf6750 100644 --- a/xpcom/threads/CPUUsageWatcher.cpp +++ b/xpcom/threads/CPUUsageWatcher.cpp @@ -229,7 +229,7 @@ void CPUUsageWatcher::AnnotateHang(BackgroundHangAnnotations& aAnnotations) { } if (mExternalUsageRatio > mExternalUsageThreshold) { - aAnnotations.AddAnnotation(NS_LITERAL_STRING("ExternalCPUHigh"), true); + aAnnotations.AddAnnotation(u"ExternalCPUHigh"_ns, true); } } diff --git a/xpcom/threads/CPUUsageWatcher.h b/xpcom/threads/CPUUsageWatcher.h index 59471344b5..507549c3dc 100644 --- a/xpcom/threads/CPUUsageWatcher.h +++ b/xpcom/threads/CPUUsageWatcher.h @@ -9,6 +9,7 @@ #include "mozilla/HangAnnotations.h" #include "mozilla/BackgroundHangMonitor.h" +#include "mozilla/Result.h" // We only support OSX and Windows, because on Linux we're forced to read // from /proc/stat in order to get global CPU values. We would prefer to not @@ -19,8 +20,10 @@ namespace mozilla { +// Start error values at 1 to allow using the UnusedZero Result +// optimization. enum CPUUsageWatcherError : uint8_t { - ClockGetTimeError, + ClockGetTimeError = 1, GetNumberOfProcessorsError, GetProcessTimesError, GetSystemTimesError, @@ -28,6 +31,14 @@ enum CPUUsageWatcherError : uint8_t { ProcStatError, }; +namespace detail { + +template <> +struct UnusedZero : UnusedZeroEnum { +}; + +} // namespace detail + class CPUUsageHangAnnotator : public BackgroundHangAnnotator { public: }; diff --git a/xpcom/threads/IdleTaskRunner.cpp b/xpcom/threads/IdleTaskRunner.cpp index 9811ba109d..c9d5971504 100644 --- a/xpcom/threads/IdleTaskRunner.cpp +++ b/xpcom/threads/IdleTaskRunner.cpp @@ -10,8 +10,8 @@ namespace mozilla { already_AddRefed IdleTaskRunner::Create( - const CallbackType& aCallback, const char* aRunnableName, uint32_t aDelay, - int64_t aBudget, bool aRepeating, + const CallbackType& aCallback, const char* aRunnableName, + uint32_t aMaxDelay, int64_t aNonIdleBudget, bool aRepeating, const MayStopProcessingCallbackType& aMayStopProcessing, TaskCategory aTaskCategory) { if (aMayStopProcessing && aMayStopProcessing()) { @@ -19,21 +19,21 @@ already_AddRefed IdleTaskRunner::Create( } RefPtr runner = - new IdleTaskRunner(aCallback, aRunnableName, aDelay, aBudget, aRepeating, - aMayStopProcessing, aTaskCategory); + new IdleTaskRunner(aCallback, aRunnableName, aMaxDelay, aNonIdleBudget, + aRepeating, aMayStopProcessing, aTaskCategory); runner->Schedule(false); // Initial scheduling shouldn't use idle dispatch. return runner.forget(); } IdleTaskRunner::IdleTaskRunner( - const CallbackType& aCallback, const char* aRunnableName, uint32_t aDelay, - int64_t aBudget, bool aRepeating, + const CallbackType& aCallback, const char* aRunnableName, + uint32_t aMaxDelay, int64_t aNonIdleBudget, bool aRepeating, const MayStopProcessingCallbackType& aMayStopProcessing, TaskCategory aTaskCategory) - : IdleRunnable(aRunnableName), + : CancelableIdleRunnable(aRunnableName), mCallback(aCallback), - mDelay(aDelay), - mBudget(TimeDuration::FromMilliseconds(aBudget)), + mDelay(aMaxDelay), + mBudget(TimeDuration::FromMilliseconds(aNonIdleBudget)), mRepeating(aRepeating), mTimerActive(false), mMayStopProcessing(aMayStopProcessing), @@ -78,10 +78,15 @@ static void TimedOut(nsITimer* aTimer, void* aClosure) { void IdleTaskRunner::SetDeadline(mozilla::TimeStamp aDeadline) { mDeadline = aDeadline; -}; +} + +void IdleTaskRunner::SetBudget(int64_t aBudget) { + mBudget = TimeDuration::FromMilliseconds(aBudget); +} void IdleTaskRunner::SetTimer(uint32_t aDelay, nsIEventTarget* aTarget) { MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(aTarget->IsOnCurrentThread()); // aTarget is always the main thread event target provided from // NS_DispatchToCurrentThreadQueue(). We ignore aTarget here to ensure that // CollectorRunner always run specifically on SystemGroup::EventTargetFor( @@ -143,8 +148,8 @@ void IdleTaskRunner::Schedule(bool aAllowIdleDispatch) { // We weren't allowed to do idle dispatch immediately, do it after a // short timeout. mScheduleTimer->InitWithNamedFuncCallback( - ScheduleTimedOut, this, 16, nsITimer::TYPE_ONE_SHOT_LOW_PRIORITY, - mName); + ScheduleTimedOut, this, 16 /* ms */, + nsITimer::TYPE_ONE_SHOT_LOW_PRIORITY, mName); } } } diff --git a/xpcom/threads/IdleTaskRunner.h b/xpcom/threads/IdleTaskRunner.h index 959dcc6be9..4eb506be2b 100644 --- a/xpcom/threads/IdleTaskRunner.h +++ b/xpcom/threads/IdleTaskRunner.h @@ -12,12 +12,11 @@ namespace mozilla { -// A general purpose repeating callback runner (it can be configured -// to a one-time runner, too.) If it is running repeatedly, -// one has to either explicitly Cancel() the runner or have -// MayContinueProcessing() callback return false to completely remove -// the runner. -class IdleTaskRunner final : public IdleRunnable { +// A general purpose repeating callback runner (it can be configured to a +// one-time runner, too.) If it is running repeatedly, one has to either +// explicitly Cancel() the runner or have MayStopProcessing() callback return +// true to completely remove the runner. +class IdleTaskRunner final : public CancelableIdleRunnable { public: // Return true if some meaningful work was done. using CallbackType = std::function; @@ -28,24 +27,35 @@ class IdleTaskRunner final : public IdleRunnable { using MayStopProcessingCallbackType = std::function; public: + // An IdleTaskRunner will attempt to run in idle time, with a budget computed + // based on a (capped) estimate for how much idle time is available. If there + // is no idle time within `aMaxDelay` ms, it will fall back to running using + // a specified `aNonIdleBudget`. static already_AddRefed Create( - const CallbackType& aCallback, const char* aRunnableName, uint32_t aDelay, - int64_t aBudget, bool aRepeating, + const CallbackType& aCallback, const char* aRunnableName, + uint32_t aMaxDelay, int64_t aNonIdleBudget, bool aRepeating, const MayStopProcessingCallbackType& aMayStopProcessing, TaskCategory aTaskCategory = TaskCategory::Count); NS_IMETHOD Run() override; + // (Used by the task triggering code.) Record the end of the current idle + // period, or null if not running during idle time. void SetDeadline(mozilla::TimeStamp aDeadline) override; + void SetTimer(uint32_t aDelay, nsIEventTarget* aTarget) override; + // Update the non-idle time budgeted for this callback. This really only + // makes sense for a repeating runner. + void SetBudget(int64_t aBudget); + nsresult Cancel() override; void Schedule(bool aAllowIdleDispatch); private: explicit IdleTaskRunner( - const CallbackType& aCallback, const char* aRunnableName, uint32_t aDelay, - int64_t aBudget, bool aRepeating, + const CallbackType& aCallback, const char* aRunnableName, + uint32_t aMaxDelay, int64_t aNonIdleBudget, bool aRepeating, const MayStopProcessingCallbackType& aMayStopProcessing, TaskCategory aTaskCategory); ~IdleTaskRunner(); @@ -55,9 +65,19 @@ class IdleTaskRunner final : public IdleRunnable { nsCOMPtr mTimer; nsCOMPtr mScheduleTimer; CallbackType mCallback; + + // Wait this long for idle time before giving up and running a non-idle + // callback. uint32_t mDelay; + + // If running during idle time, the expected end of the current idle period. + // The null timestamp when the run is triggered by aMaxDelay instead of idle. TimeStamp mDeadline; + + // The expected amount of time the callback will run for, when not running + // during idle time. TimeDuration mBudget; + bool mRepeating; bool mTimerActive; MayStopProcessingCallbackType mMayStopProcessing; diff --git a/xpcom/threads/ThreadEventQueue.cpp b/xpcom/threads/ThreadEventQueue.cpp index 18f4ab95a0..257e4e5b3d 100644 --- a/xpcom/threads/ThreadEventQueue.cpp +++ b/xpcom/threads/ThreadEventQueue.cpp @@ -5,6 +5,7 @@ #include "mozilla/ThreadEventQueue.h" #include "mozilla/EventQueue.h" +#include "GeckoProfiler.h" #include "LeakRefPtr.h" #include "nsComponentManagerUtils.h" #include "nsIThreadInternal.h" diff --git a/xpcom/threads/ThrottledEventQueue.cpp b/xpcom/threads/ThrottledEventQueue.cpp index 7c4420eaa8..fba5f09d99 100644 --- a/xpcom/threads/ThrottledEventQueue.cpp +++ b/xpcom/threads/ThrottledEventQueue.cpp @@ -254,8 +254,10 @@ class ThrottledEventQueue::Inner final : public nsISupports { static already_AddRefed Create(nsISerialEventTarget* aBaseTarget, const char* aName, uint32_t aPriority) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(ClearOnShutdown_Internal::sCurrentShutdownPhase == - ShutdownPhase::NotInShutdown); + // FIXME: This assertion only worked when `sCurrentShutdownPhase` was not + // being updated. + // MOZ_ASSERT(ClearOnShutdown_Internal::sCurrentShutdownPhase == + // ShutdownPhase::NotInShutdown); RefPtr ref = new Inner(aBaseTarget, aName, aPriority); return ref.forget(); diff --git a/xpcom/threads/moz.build b/xpcom/threads/moz.build index 03d922adb8..b439f29dda 100644 --- a/xpcom/threads/moz.build +++ b/xpcom/threads/moz.build @@ -28,6 +28,7 @@ XPCOM_MANIFESTS += [ EXPORTS += [ 'MainThreadUtils.h', 'nsICancelableRunnable.h', + 'nsIDiscardableRunnable.h', 'nsIIdleRunnable.h', 'nsMemoryPressure.h', 'nsProcess.h', diff --git a/xpcom/threads/nsICancelableRunnable.h b/xpcom/threads/nsICancelableRunnable.h index f15b9c8a87..ed2ce25c6b 100644 --- a/xpcom/threads/nsICancelableRunnable.h +++ b/xpcom/threads/nsICancelableRunnable.h @@ -19,8 +19,9 @@ class nsICancelableRunnable : public nsISupports { NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICANCELABLERUNNABLE_IID) /* - * Cancels a pending task. If the task has already been executed this will - * be a no-op. Calling this method twice is considered an error. + * Cancels a pending task, so that calling run() on the task is a no-op. + * Calling cancel after the task execution has begun will be a no-op. + * Calling this method twice is considered an error. * * @throws NS_ERROR_UNEXPECTED * Indicates that the runnable has already been canceled. diff --git a/xpcom/threads/nsIDiscardableRunnable.h b/xpcom/threads/nsIDiscardableRunnable.h new file mode 100644 index 0000000000..9edfb84575 --- /dev/null +++ b/xpcom/threads/nsIDiscardableRunnable.h @@ -0,0 +1,39 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef XPCOM_THREADS_NSIDISCARDABLERUNNABLE_H_ +#define XPCOM_THREADS_NSIDISCARDABLERUNNABLE_H_ + +#include "nsISupports.h" + +/** + * An interface implemented by nsIRunnable tasks for which nsIRunnable::Run() + * might not be called. + */ +#define NS_IDISCARDABLERUNNABLE_IID \ + { \ + 0xde93dc4c, 0x755c, 0x4cdc, { \ + 0x96, 0x76, 0x35, 0xc6, 0x48, 0x81, 0x59, 0x78 \ + } \ + } + +class NS_NO_VTABLE nsIDiscardableRunnable : public nsISupports { + public: + NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDISCARDABLERUNNABLE_IID) + + /** + * Called exactly once on a queued task only if nsIRunnable::Run() is not + * called. + */ + virtual void OnDiscard() = 0; + + protected: + nsIDiscardableRunnable() = default; + virtual ~nsIDiscardableRunnable() = default; +}; + +NS_DEFINE_STATIC_IID_ACCESSOR(nsIDiscardableRunnable, + NS_IDISCARDABLERUNNABLE_IID) + +#endif // XPCOM_THREADS_NSIDISCARDABLERUNNABLE_H_ diff --git a/xpcom/threads/nsThreadManager.cpp b/xpcom/threads/nsThreadManager.cpp index e17653cb89..0940b06a3f 100644 --- a/xpcom/threads/nsThreadManager.cpp +++ b/xpcom/threads/nsThreadManager.cpp @@ -69,7 +69,7 @@ nsresult BackgroundEventTarget::Init() { nsCOMPtr pool(new nsThreadPool()); NS_ENSURE_TRUE(pool, NS_ERROR_FAILURE); - nsresult rv = pool->SetName(NS_LITERAL_CSTRING("BackgroundThreadPool")); + nsresult rv = pool->SetName("BackgroundThreadPool"_ns); NS_ENSURE_SUCCESS(rv, rv); // Use potentially more conservative stack size. @@ -88,7 +88,7 @@ nsresult BackgroundEventTarget::Init() { nsCOMPtr ioPool(new nsThreadPool()); NS_ENSURE_TRUE(pool, NS_ERROR_FAILURE); - rv = ioPool->SetName(NS_LITERAL_CSTRING("BgIOThreadPool")); + rv = ioPool->SetName("BgIOThreadPool"_ns); NS_ENSURE_SUCCESS(rv, rv); // Use potentially more conservative stack size. @@ -602,7 +602,7 @@ bool nsThreadManager::IsNSThread() const { NS_IMETHODIMP nsThreadManager::NewThread(uint32_t aCreationFlags, uint32_t aStackSize, nsIThread** aResult) { - return NewNamedThread(NS_LITERAL_CSTRING(""), aStackSize, aResult); + return NewNamedThread(""_ns, aStackSize, aResult); } NS_IMETHODIMP diff --git a/xpcom/threads/nsThreadUtils.cpp b/xpcom/threads/nsThreadUtils.cpp index 710ac2637b..dd98b31e59 100644 --- a/xpcom/threads/nsThreadUtils.cpp +++ b/xpcom/threads/nsThreadUtils.cpp @@ -75,14 +75,22 @@ Runnable::GetName(nsACString& aName) { } # endif -NS_IMPL_ISUPPORTS_INHERITED(CancelableRunnable, Runnable, nsICancelableRunnable) +NS_IMPL_ISUPPORTS_INHERITED(DiscardableRunnable, Runnable, + nsIDiscardableRunnable) -nsresult CancelableRunnable::Cancel() { - // Do nothing - return NS_OK; +NS_IMPL_ISUPPORTS_INHERITED(CancelableRunnable, DiscardableRunnable, + nsICancelableRunnable) + +void CancelableRunnable::OnDiscard() { + // Tasks that implement Cancel() can be safely cleaned up if it turns out + // that the task will not run. + (void)NS_WARN_IF(NS_FAILED(Cancel())); } -NS_IMPL_ISUPPORTS_INHERITED(IdleRunnable, CancelableRunnable, nsIIdleRunnable) +NS_IMPL_ISUPPORTS_INHERITED(IdleRunnable, DiscardableRunnable, nsIIdleRunnable) + +NS_IMPL_ISUPPORTS_INHERITED(CancelableIdleRunnable, CancelableRunnable, + nsIIdleRunnable) NS_IMPL_ISUPPORTS_INHERITED(PrioritizableRunnable, Runnable, nsIRunnablePriority) @@ -327,20 +335,38 @@ extern nsresult NS_DispatchToMainThreadQueue( return rv; } -class IdleRunnableWrapper final : public IdleRunnable { +class IdleRunnableWrapper final : public Runnable, + public nsIDiscardableRunnable, + public nsIIdleRunnable { public: explicit IdleRunnableWrapper(already_AddRefed&& aEvent) - : mRunnable(std::move(aEvent)) {} + : Runnable("IdleRunnableWrapper"), + mRunnable(std::move(aEvent)), + mDiscardable(do_QueryInterface(mRunnable)) {} + + NS_DECL_ISUPPORTS_INHERITED NS_IMETHOD Run() override { if (!mRunnable) { return NS_OK; } CancelTimer(); + // Don't clear mDiscardable because that would cause QueryInterface to + // change behavior during the lifetime of an instance. nsCOMPtr runnable = std::move(mRunnable); return runnable->Run(); } + // nsIDiscardableRunnable + void OnDiscard() override { + if (!mRunnable) { + // Run() was already called from TimedOut(). + return; + } + mDiscardable->OnDiscard(); + mRunnable = nullptr; + } + static void TimedOut(nsITimer* aTimer, void* aClosure) { RefPtr runnable = static_cast(aClosure); @@ -381,8 +407,17 @@ class IdleRunnableWrapper final : public IdleRunnable { nsCOMPtr mTimer; nsCOMPtr mRunnable; + nsCOMPtr mDiscardable; }; +NS_IMPL_ADDREF_INHERITED(IdleRunnableWrapper, Runnable) +NS_IMPL_RELEASE_INHERITED(IdleRunnableWrapper, Runnable) + +NS_INTERFACE_MAP_BEGIN(IdleRunnableWrapper) + NS_INTERFACE_MAP_ENTRY(nsIIdleRunnable) + NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIDiscardableRunnable, mDiscardable) +NS_INTERFACE_MAP_END_INHERITING(Runnable) + extern nsresult NS_DispatchToThreadQueue(already_AddRefed&& aEvent, uint32_t aTimeout, nsIThread* aThread, EventQueuePriority aQueue) { diff --git a/xpcom/threads/nsThreadUtils.h b/xpcom/threads/nsThreadUtils.h index dfe668099c..cc4b675c32 100644 --- a/xpcom/threads/nsThreadUtils.h +++ b/xpcom/threads/nsThreadUtils.h @@ -19,6 +19,7 @@ #include "mozilla/Tuple.h" #include "nsCOMPtr.h" #include "nsICancelableRunnable.h" +#include "nsIDiscardableRunnable.h" #include "nsIIdlePeriod.h" #include "nsIIdleRunnable.h" #include "nsINamed.h" @@ -496,15 +497,44 @@ class Runnable : public nsIRunnable Runnable& operator=(const Runnable&&) = delete; }; -// This class is designed to be subclassed. -class CancelableRunnable : public Runnable, public nsICancelableRunnable { +// This is a base class for tasks that might not be run, such as those that may +// be dispatched to workers. +// The owner of an event target will call either Run() or OnDiscard() +// exactly once. +// Derived classes should override Run(). An OnDiscard() override may +// provide cleanup when Run() will not be called. +class DiscardableRunnable : public Runnable, public nsIDiscardableRunnable { public: NS_DECL_ISUPPORTS_INHERITED + // nsIDiscardableRunnable + void OnDiscard() override {} + + DiscardableRunnable() = delete; + explicit DiscardableRunnable(const char* aName) : Runnable(aName) {} + + protected: + virtual ~DiscardableRunnable() = default; + + private: + DiscardableRunnable(const DiscardableRunnable&) = delete; + DiscardableRunnable& operator=(const DiscardableRunnable&) = delete; + DiscardableRunnable& operator=(const DiscardableRunnable&&) = delete; +}; + +// This class is designed to be subclassed. +// Derived classes should override Run() and Cancel() to provide that +// calling Run() after Cancel() is a no-op. +class CancelableRunnable : public DiscardableRunnable, + public nsICancelableRunnable { + public: + NS_DECL_ISUPPORTS_INHERITED + // nsIDiscardableRunnable + void OnDiscard() override; // nsICancelableRunnable - virtual nsresult Cancel() override; + virtual nsresult Cancel() override = 0; CancelableRunnable() = delete; - explicit CancelableRunnable(const char* aName) : Runnable(aName) {} + explicit CancelableRunnable(const char* aName) : DiscardableRunnable(aName) {} protected: virtual ~CancelableRunnable() = default; @@ -516,12 +546,12 @@ class CancelableRunnable : public Runnable, public nsICancelableRunnable { }; // This class is designed to be subclassed. -class IdleRunnable : public CancelableRunnable, public nsIIdleRunnable { +class IdleRunnable : public DiscardableRunnable, public nsIIdleRunnable { public: NS_DECL_ISUPPORTS_INHERITED - IdleRunnable() : CancelableRunnable("IdleRunnable") {} - explicit IdleRunnable(const char* aName) : CancelableRunnable(aName) {} + IdleRunnable() : DiscardableRunnable("IdleRunnable") {} + explicit IdleRunnable(const char* aName) : DiscardableRunnable(aName) {} protected: virtual ~IdleRunnable() = default; @@ -532,6 +562,25 @@ class IdleRunnable : public CancelableRunnable, public nsIIdleRunnable { IdleRunnable& operator=(const IdleRunnable&&) = delete; }; +// This class is designed to be subclassed. +class CancelableIdleRunnable : public CancelableRunnable, + public nsIIdleRunnable { + public: + NS_DECL_ISUPPORTS_INHERITED + + CancelableIdleRunnable() : CancelableRunnable("CancelableIdleRunnable") {} + explicit CancelableIdleRunnable(const char* aName) + : CancelableRunnable(aName) {} + + protected: + virtual ~CancelableIdleRunnable() = default; + + private: + CancelableIdleRunnable(const CancelableIdleRunnable&) = delete; + CancelableIdleRunnable& operator=(const CancelableIdleRunnable&) = delete; + CancelableIdleRunnable& operator=(const CancelableIdleRunnable&&) = delete; +}; + // This class is designed to be a wrapper of a real runnable to support event // prioritizable. class PrioritizableRunnable : public Runnable, public nsIRunnablePriority { @@ -720,12 +769,13 @@ class nsRunnableMethod Kind == mozilla::RunnableKind::Standard, mozilla::Runnable, std::conditional_t>, + mozilla::CancelableIdleRunnable>>, protected mozilla::detail::TimerBehaviour { using BaseType = std::conditional_t< Kind == mozilla::RunnableKind::Standard, mozilla::Runnable, std::conditional_t>; + mozilla::CancelableRunnable, + mozilla::CancelableIdleRunnable>>; public: nsRunnableMethod(const char* aName) : BaseType(aName) {} @@ -1172,7 +1222,8 @@ class RunnableMethodImpl final virtual ~RunnableMethodImpl() { Revoke(); }; static void TimedOut(nsITimer* aTimer, void* aClosure) { static_assert(IsIdle(Kind), "Don't use me!"); - RefPtr r = static_cast(aClosure); + RefPtr r = + static_cast(aClosure); r->SetDeadline(TimeStamp()); r->Run(); r->Cancel(); diff --git a/xpcom/xpcom-private.h.in b/xpcom/xpcom-private.h.in deleted file mode 100644 index d089d1ec50..0000000000 --- a/xpcom/xpcom-private.h.in +++ /dev/null @@ -1,38 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* The following defines are only used by the xpcom implementation */ - -#ifndef _XPCOM_PRIVATE_H_ -#define _XPCOM_PRIVATE_H_ - -/* Define if getpagesize() is available */ -#undef HAVE_GETPAGESIZE - -/* Define if statvfs64() is available */ -#undef HAVE_STATVFS64 - -/* Define if statvfs() is available */ -#undef HAVE_STATVFS - -/* Define if statfs64() is available */ -#undef HAVE_STATFS64 - -/* Define if statfs() is available */ -#undef HAVE_STATFS - -/* Define if is present */ -#undef HAVE_SYS_STATVFS_H - -/* Define if is present */ -#undef HAVE_SYS_STATFS_H - -/* Define if is present */ -#undef HAVE_SYS_VFS_H - -/* Define if is present */ -#undef HAVE_SYS_MOUNT_H - -#endif /* _XPCOM_PRIVATE_H_ */ - diff --git a/xpfe/appshell/nsContentTreeOwner.cpp b/xpfe/appshell/nsContentTreeOwner.cpp index b9cadb98bb..6cc052a092 100644 --- a/xpfe/appshell/nsContentTreeOwner.cpp +++ b/xpfe/appshell/nsContentTreeOwner.cpp @@ -282,8 +282,7 @@ nsContentTreeOwner::SetPersistence(bool aPersistPosition, bool aPersistSize, ErrorResult rv; if (saveString) { - docShellElement->SetAttribute(NS_LITERAL_STRING("persist"), persistString, - rv); + docShellElement->SetAttribute(u"persist"_ns, persistString, rv); } return NS_OK;