From 50f1e29000e188aacfa1a458e607b5500bde7775 Mon Sep 17 00:00:00 2001 From: vinoth Date: Sat, 21 Apr 2018 02:16:30 +0300 Subject: [PATCH 01/11] Bug 1453989 - Apply Meta CSP to Content Privileged about:checkerboard. r=ckerschb,Gijs Reviewers: ckerschb, Gijs Reviewed By: ckerschb, Gijs Subscribers: Gijs, ckerschb Bug #: 1453989 Differential Revision: https://phabricator.services.mozilla.com/D944 --HG-- extra : rebase_source : 9d6a668ee4e1da7ae19e9141d7303ee0abf8cf35 --- modules/libpref/init/all.js | 2 +- .../content/aboutCheckerboard.css | 8 ++++++ .../content/aboutCheckerboard.js | 26 ++++++++++++++++--- .../content/aboutCheckerboard.xhtml | 25 +++++++++--------- 4 files changed, 45 insertions(+), 16 deletions(-) diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 5f045d14cc0f..cd7fe1d4a48e 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -2459,7 +2459,7 @@ pref("security.csp.experimentalEnabled", false); pref("security.csp.enableStrictDynamic", true); #if defined(DEBUG) && !defined(ANDROID) -pref("csp.content_privileged_about_uris_without_csp", "blank,cache,certerror,checkerboard,credits,home,logo,neterror,newtab,printpreview,srcdoc,studies"); +pref("csp.content_privileged_about_uris_without_csp", "blank,cache,certerror,credits,home,logo,neterror,newtab,printpreview,srcdoc,studies"); #endif #ifdef NIGHTLY_BUILD diff --git a/toolkit/components/aboutcheckerboard/content/aboutCheckerboard.css b/toolkit/components/aboutcheckerboard/content/aboutCheckerboard.css index 7f88612db18b..6dca9d25387b 100644 --- a/toolkit/components/aboutcheckerboard/content/aboutCheckerboard.css +++ b/toolkit/components/aboutcheckerboard/content/aboutCheckerboard.css @@ -47,3 +47,11 @@ iframe { #trace { width: 100%; } + +#enabled { + color: red; +} + +#enabled.enabled { + color: green; +} diff --git a/toolkit/components/aboutcheckerboard/content/aboutCheckerboard.js b/toolkit/components/aboutcheckerboard/content/aboutCheckerboard.js index f9dd12101be7..d507d75d8ef5 100644 --- a/toolkit/components/aboutcheckerboard/content/aboutCheckerboard.js +++ b/toolkit/components/aboutcheckerboard/content/aboutCheckerboard.js @@ -26,13 +26,13 @@ function onLoad() { function updateEnabled() { let enabled = document.getElementById("enabled"); - if (service.isRecordingEnabled()) { + let isEnabled = service.isRecordingEnabled(); + if (isEnabled) { enabled.textContent = "enabled"; - enabled.style.color = "green"; } else { enabled.textContent = "disabled"; - enabled.style.color = "red"; } + enabled.classList.toggle("enabled", isEnabled); } function toggleEnabled() { @@ -274,3 +274,23 @@ function stopPlay() { currentFrame = 0; renderFrame(); } + +document.getElementById("pauseButton").addEventListener("click", togglePlay); +document.getElementById("stopButton").addEventListener("click", stopPlay); +document.getElementById("enableToggleButton").addEventListener("click", toggleEnabled); +document.getElementById("flushReportsButton").addEventListener("click", flushReports); +document.getElementById("excludePageFromZoom").addEventListener("click", loadData); +document.getElementById("stepForwardButton").addEventListener("click", function() { + step(false); +}); +document.getElementById("forwardButton").addEventListener("click", function() { + reset(false); +}); +document.getElementById("rewindButton").addEventListener("click", function() { + reset(true); +}); +document.getElementById("stepBackButton").addEventListener("click", function() { + step(true); +}); +window.addEventListener("load", onLoad); + diff --git a/toolkit/components/aboutcheckerboard/content/aboutCheckerboard.xhtml b/toolkit/components/aboutcheckerboard/content/aboutCheckerboard.xhtml index 57223a5f5db4..5d25a9520013 100644 --- a/toolkit/components/aboutcheckerboard/content/aboutCheckerboard.xhtml +++ b/toolkit/components/aboutcheckerboard/content/aboutCheckerboard.xhtml @@ -6,16 +6,16 @@ + - - -

Checkerboard recording is undetermined. - .

+ +

Checkerboard recording is undetermined. + .

If there are active reports in progress, you can stop and flush them by clicking here: -

+

@@ -31,12 +31,12 @@
- - - - - - + + + + + +
Canvas not supported!
(Details for currently visible replay frame)
@@ -48,8 +48,9 @@ Raw log:
-
+
+ From 1c74b688f73ea7a4789d024770ce59781d29ec93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 20 Apr 2018 03:42:00 +0200 Subject: [PATCH 02/11] Bug 1455492: Remove redundant ParseSheet arguments. r=bholley For the async caller, pretty much everything can be extracted out of the loader / loadData. For the sync callers, we need to be a bit more careful because ReparseSheet tries to get its line number on its own. I changed the compat mode passed to the reparse stuff to be the document's one in this case, but that seems a bug fix. MozReview-Commit-ID: 2wi5HPRAlPi --- dom/base/nsTreeSanitizer.cpp | 7 ++-- layout/style/Loader.cpp | 44 +++++++----------------- layout/style/ServoStyleSheet.cpp | 36 ++++++++----------- layout/style/ServoStyleSheet.h | 11 +----- layout/style/nsLayoutStylesheetCache.cpp | 9 ++--- 5 files changed, 37 insertions(+), 70 deletions(-) diff --git a/dom/base/nsTreeSanitizer.cpp b/dom/base/nsTreeSanitizer.cpp index 883290dcf7c6..36ff5e001048 100644 --- a/dom/base/nsTreeSanitizer.cpp +++ b/dom/base/nsTreeSanitizer.cpp @@ -1098,9 +1098,10 @@ nsTreeSanitizer::SanitizeStyleSheet(const nsAString& aOriginal, sheet->SetURIs(aDocument->GetDocumentURI(), nullptr, aBaseURI); sheet->SetPrincipal(aDocument->NodePrincipal()); sheet->AsServo()->ParseSheetSync( - aDocument->CSSLoader(), NS_ConvertUTF16toUTF8(aOriginal), - aDocument->GetDocumentURI(), aBaseURI, aDocument->NodePrincipal(), - /* aLoadData = */ nullptr, 0, aDocument->GetCompatibilityMode()); + aDocument->CSSLoader(), + NS_ConvertUTF16toUTF8(aOriginal), + /* aLoadData = */ nullptr, + /* aLineNumber = */ 0); NS_ENSURE_SUCCESS(rv, true); // Mark the sheet as complete. MOZ_ASSERT(!sheet->HasForcedUniqueInner(), diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index 0e26acef2c4b..4299b6da662b 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -1635,16 +1635,7 @@ Loader::DoParseSheetServo(ServoStyleSheet* aSheet, // Some cases, like inline style and UA stylesheets, need to be parsed // synchronously. The former may trigger child loads, the latter must not. if (aLoadData->mSyncLoad || !aAllowAsync) { - aSheet->ParseSheetSync( - this, - aBytes, - aSheet->GetSheetURI(), - aSheet->GetBaseURI(), - aSheet->Principal(), - aLoadData, - aLoadData->mLineNumber, - GetCompatibilityMode() - ); + aSheet->ParseSheetSync(this, aBytes, aLoadData, aLoadData->mLineNumber); aLoadData->mIsBeingParsed = false; bool noPendingChildren = aLoadData->mPendingChildren == 0; @@ -1664,27 +1655,18 @@ Loader::DoParseSheetServo(ServoStyleSheet* aSheet, BlockOnload(); RefPtr loadData = aLoadData; nsCOMPtr target = DispatchTarget(); - aSheet->ParseSheet( - this, - aBytes, - aSheet->GetSheetURI(), - aSheet->GetBaseURI(), - aSheet->Principal(), - aLoadData, - aLoadData->mLineNumber, - GetCompatibilityMode() - )->Then(target, __func__, - [loadData](bool aDummy) { - MOZ_ASSERT(NS_IsMainThread()); - loadData->mIsBeingParsed = false; - loadData->mLoader->UnblockOnload(/* aFireSync = */ false); - // If there are no child sheets outstanding, mark us as complete. - // Otherwise, the children are holding strong refs to the data and - // will call SheetComplete() on it when they complete. - if (loadData->mPendingChildren == 0) { - loadData->mLoader->SheetComplete(loadData, NS_OK); - } - }, [] { MOZ_CRASH("rejected parse promise"); } + aSheet->ParseSheet(this, aBytes, aLoadData)->Then(target, __func__, + [loadData](bool aDummy) { + MOZ_ASSERT(NS_IsMainThread()); + loadData->mIsBeingParsed = false; + loadData->mLoader->UnblockOnload(/* aFireSync = */ false); + // If there are no child sheets outstanding, mark us as complete. + // Otherwise, the children are holding strong refs to the data and + // will call SheetComplete() on it when they complete. + if (loadData->mPendingChildren == 0) { + loadData->mLoader->SheetComplete(loadData, NS_OK); + } + }, [] { MOZ_CRASH("rejected parse promise"); } ); return NS_OK; diff --git a/layout/style/ServoStyleSheet.cpp b/layout/style/ServoStyleSheet.cpp index e4e805f89b30..2426bd1a58a2 100644 --- a/layout/style/ServoStyleSheet.cpp +++ b/layout/style/ServoStyleSheet.cpp @@ -234,18 +234,16 @@ AllowParallelParse(css::Loader* aLoader, nsIURI* aSheetURI) RefPtr ServoStyleSheet::ParseSheet(css::Loader* aLoader, const nsACString& aBytes, - nsIURI* aSheetURI, - nsIURI* aBaseURI, - nsIPrincipal* aSheetPrincipal, - css::SheetLoadData* aLoadData, - uint32_t aLineNumber, - nsCompatibility aCompatMode) + css::SheetLoadData* aLoadData) { + MOZ_ASSERT(aLoader); + MOZ_ASSERT(aLoadData); MOZ_ASSERT(mParsePromise.IsEmpty()); RefPtr p = mParsePromise.Ensure(__func__); - Inner()->mURLData = new URLExtraData(aBaseURI, aSheetURI, aSheetPrincipal); // RefPtr + Inner()->mURLData = + new URLExtraData(GetBaseURI(), GetSheetURI(), Principal()); // RefPtr - if (!AllowParallelParse(aLoader, aSheetURI)) { + if (!AllowParallelParse(aLoader, GetSheetURI())) { RefPtr contents = Servo_StyleSheet_FromUTF8Bytes(aLoader, this, @@ -253,8 +251,8 @@ ServoStyleSheet::ParseSheet(css::Loader* aLoader, &aBytes, mParsingMode, Inner()->mURLData, - aLineNumber, - aCompatMode, + aLoadData->mLineNumber, + aLoader->GetCompatibilityMode(), /* reusable_sheets = */ nullptr) .Consume(); FinishAsyncParse(contents.forget()); @@ -265,8 +263,8 @@ ServoStyleSheet::ParseSheet(css::Loader* aLoader, Inner()->mURLData, &aBytes, mParsingMode, - aLineNumber, - aCompatMode); + aLoadData->mLineNumber, + aLoader->GetCompatibilityMode()); } return Move(p); @@ -286,16 +284,14 @@ ServoStyleSheet::FinishAsyncParse(already_AddRefed a void ServoStyleSheet::ParseSheetSync(css::Loader* aLoader, const nsACString& aBytes, - nsIURI* aSheetURI, - nsIURI* aBaseURI, - nsIPrincipal* aSheetPrincipal, css::SheetLoadData* aLoadData, uint32_t aLineNumber, - nsCompatibility aCompatMode, css::LoaderReusableStyleSheets* aReusableSheets) { - Inner()->mURLData = new URLExtraData(aBaseURI, aSheetURI, aSheetPrincipal); // RefPtr + nsCompatibility compatMode = + aLoader ? aLoader->GetCompatibilityMode() : eCompatibility_FullStandards; + Inner()->mURLData = new URLExtraData(GetBaseURI(), GetSheetURI(), Principal()); // RefPtr Inner()->mContents = Servo_StyleSheet_FromUTF8Bytes(aLoader, this, aLoadData, @@ -303,7 +299,7 @@ ServoStyleSheet::ParseSheetSync(css::Loader* aLoader, mParsingMode, Inner()->mURLData, aLineNumber, - aCompatMode, + compatMode, aReusableSheets) .Consume(); @@ -390,12 +386,8 @@ ServoStyleSheet::ReparseSheet(const nsAString& aInput) ParseSheetSync(loader, NS_ConvertUTF16toUTF8(aInput), - mInner->mSheetURI, - mInner->mBaseURI, - mInner->mPrincipal, /* aLoadData = */ nullptr, lineNumber, - eCompatibility_FullStandards, &reusableSheets); DidDirty(); diff --git a/layout/style/ServoStyleSheet.h b/layout/style/ServoStyleSheet.h index 54ab705165b3..1c3b533c1c30 100644 --- a/layout/style/ServoStyleSheet.h +++ b/layout/style/ServoStyleSheet.h @@ -94,12 +94,7 @@ public: RefPtr ParseSheet(css::Loader* aLoader, const nsACString& aBytes, - nsIURI* aSheetURI, - nsIURI* aBaseURI, - nsIPrincipal* aSheetPrincipal, - css::SheetLoadData* aLoadData, - uint32_t aLineNumber, - nsCompatibility aCompatMode); + css::SheetLoadData* aLoadData); // Common code that needs to be called after servo finishes parsing. This is // shared between the parallel and sequential paths. @@ -110,12 +105,8 @@ public: void ParseSheetSync(css::Loader* aLoader, const nsACString& aBytes, - nsIURI* aSheetURI, - nsIURI* aBaseURI, - nsIPrincipal* aSheetPrincipal, css::SheetLoadData* aLoadData, uint32_t aLineNumber, - nsCompatibility aCompatMode, css::LoaderReusableStyleSheets* aReusableSheets = nullptr); nsresult ReparseSheet(const nsAString& aInput); diff --git a/layout/style/nsLayoutStylesheetCache.cpp b/layout/style/nsLayoutStylesheetCache.cpp index 10122805db90..8b1ec7050a04 100644 --- a/layout/style/nsLayoutStylesheetCache.cpp +++ b/layout/style/nsLayoutStylesheetCache.cpp @@ -888,10 +888,11 @@ nsLayoutStylesheetCache::BuildPreferenceSheet(RefPtr* aSheet, "sheet without reallocation"); ServoStyleSheet* servoSheet = sheet->AsServo(); - // NB: The pref sheet never has @import rules. - servoSheet->ParseSheetSync(nullptr, sheetText, uri, uri, nullptr, - /* aLoadData = */ nullptr, 0, - eCompatibility_FullStandards); + // NB: The pref sheet never has @import rules, thus no loader. + servoSheet->ParseSheetSync(nullptr, + sheetText, + /* aLoadData = */ nullptr, + /* aLineNumber = */ 0); #undef NS_GET_R_G_B } From f790d1c4cb2f1c9a8ecf64462ea5ae1811311332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 20 Apr 2018 03:45:04 +0200 Subject: [PATCH 03/11] Bug 1455492: While here, fix refcount churn. r=bholley MozReview-Commit-ID: 88jzsn25e53 --- layout/style/Loader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index 4299b6da662b..f9dc1e6ba003 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -1656,7 +1656,7 @@ Loader::DoParseSheetServo(ServoStyleSheet* aSheet, RefPtr loadData = aLoadData; nsCOMPtr target = DispatchTarget(); aSheet->ParseSheet(this, aBytes, aLoadData)->Then(target, __func__, - [loadData](bool aDummy) { + [loadData = Move(loadData)](bool aDummy) { MOZ_ASSERT(NS_IsMainThread()); loadData->mIsBeingParsed = false; loadData->mLoader->UnblockOnload(/* aFireSync = */ false); From a904515b3effab73209998cbb9ad6a0674224289 Mon Sep 17 00:00:00 2001 From: Paolo Amadini Date: Sat, 21 Apr 2018 11:12:55 +0100 Subject: [PATCH 04/11] Backed out changeset 40c5d3600d35 (bug 1455737) for breaking DownloadHistoryList. a=backout --HG-- extra : rebase_source : ebb793b3cc4864593d18df1a1b69cc74df0cf2af --- toolkit/components/downloads/DownloadHistory.jsm | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/toolkit/components/downloads/DownloadHistory.jsm b/toolkit/components/downloads/DownloadHistory.jsm index d1501e6294cd..40ce09d9a91f 100644 --- a/toolkit/components/downloads/DownloadHistory.jsm +++ b/toolkit/components/downloads/DownloadHistory.jsm @@ -454,17 +454,6 @@ this.DownloadHistoryList.prototype = { }, _result: null, - /** - * Remove the view that belongs to this list via DownloadList's removeView. In - * addition, delete the result object to ensure there are no memory leaks. - */ - removeView(aView) { - DownloadList.prototype.removeView.call(this, aView); - - // Clean up any active results that might still be observing. See bug 1455737 - this.result = null; - }, - /** * Index of the first slot that contains a session download. This is equal to * the length of the list when there are no session downloads. From f90e036199688d13e1675b66d9053b2d1ebd3dae Mon Sep 17 00:00:00 2001 From: Petru Lingurar Date: Wed, 18 Apr 2018 10:59:16 +0300 Subject: [PATCH 05/11] Bug 1445798 - Add Leanplum settings opt-out strings needed for bug #1454686; r=mcomella To allow users to opt-out from receiving LeanPlum messages we need a new setting added. This are the Strings for the title and summary of that setting. Localization notes also added as this Strings will ship before the feature. MozReview-Commit-ID: 9Kx567ruY3n --HG-- extra : source : 9dece6b7a5949d4c56415ee7ed6f4e03c3eb8e42 --- mobile/android/base/locales/en-US/android_strings.dtd | 7 +++++++ mobile/android/base/strings.xml.in | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/mobile/android/base/locales/en-US/android_strings.dtd b/mobile/android/base/locales/en-US/android_strings.dtd index 917ed534fc9f..987b6d470601 100644 --- a/mobile/android/base/locales/en-US/android_strings.dtd +++ b/mobile/android/base/locales/en-US/android_strings.dtd @@ -282,6 +282,13 @@ + + + + + diff --git a/mobile/android/base/strings.xml.in b/mobile/android/base/strings.xml.in index b510012948b9..7a8ae0c658cb 100644 --- a/mobile/android/base/strings.xml.in +++ b/mobile/android/base/strings.xml.in @@ -225,6 +225,10 @@ &pref_whats_new_notification; &pref_whats_new_notification_summary; + + &pref_feature_tips_notification; + &pref_feature_tips_notification_summary; + &pref_category_experimental; &pref_custom_tabs2; From 85bba01ca28ec8909a902c81ee994ceaad7a1ae5 Mon Sep 17 00:00:00 2001 From: Jason Laster Date: Fri, 20 Apr 2018 08:50:11 -0400 Subject: [PATCH 06/11] Bug 1455345 - Update Debugger Frontend v42. r=jdescottes --- devtools/client/debugger/new/README.mozilla | 4 +- devtools/client/debugger/new/debugger.css | 43 +- devtools/client/debugger/new/debugger.js | 703 +++++++++++++++--- .../test/mochitest/browser_dbg-stepping.js | 2 +- devtools/client/jar.mn | 1 + .../client/locales/en-US/debugger.properties | 4 + devtools/client/preferences/debugger.js | 3 + .../themes/images/debugger/breakpoint.svg | 6 + 8 files changed, 631 insertions(+), 135 deletions(-) create mode 100644 devtools/client/themes/images/debugger/breakpoint.svg diff --git a/devtools/client/debugger/new/README.mozilla b/devtools/client/debugger/new/README.mozilla index d01a20833f50..e044e21d4131 100644 --- a/devtools/client/debugger/new/README.mozilla +++ b/devtools/client/debugger/new/README.mozilla @@ -1,9 +1,9 @@ This is the debugger.html project output. See https://github.com/devtools-html/debugger.html -Version 41.0 +Version 42.0 -Comparison: https://github.com/devtools-html/debugger.html/compare/release-40...release-41 +Comparison: https://github.com/devtools-html/debugger.html/compare/release-41...release-42 Packages: - babel-plugin-transform-es2015-modules-commonjs @6.26.0 diff --git a/devtools/client/debugger/new/debugger.css b/devtools/client/debugger/new/debugger.css index 1623255aa575..cba2166d57f0 100644 --- a/devtools/client/debugger/new/debugger.css +++ b/devtools/client/debugger/new/debugger.css @@ -2527,13 +2527,6 @@ button.jump-definition { * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at . */ -.empty-line .CodeMirror-linenumber { - opacity: 0.5; -} -/* 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 . */ - .conditional-breakpoint-panel { cursor: initial; margin: 1em 0; @@ -2621,6 +2614,32 @@ html[dir="rtl"] .editor-mount { direction: ltr; } +.theme-light { + --gutter-hover-background-color: #dde1e4; +} + +.theme-dark { + --gutter-hover-background-color: #414141; +} + +:not(.empty-line):not(.new-breakpoint) > .CodeMirror-gutter-wrapper:hover { + width: 60px; + height: 13px; + left: -55px !important; + background-color: var(--gutter-hover-background-color) !important; + mask: url("chrome://devtools/skin/images/debugger/breakpoint.svg") no-repeat; + mask-size: 100%; + mask-position: 0 1px; +} + +:not(.empty-line):not(.new-breakpoint) + > .CodeMirror-gutter-wrapper:hover + > .CodeMirror-linenumber { + left: auto !important; + right: 6px; + color: var(--theme-body-color); +} + .editor-wrapper .breakpoints { position: absolute; top: 0; @@ -2668,6 +2687,11 @@ html[dir="rtl"] .editor-mount { border: 1px solid #00b6ff; } +.editor .breakpoint { + position: absolute; + right: -2px; +} + .editor.new-breakpoint.folding-enabled svg { right: -16px; } @@ -2712,7 +2736,10 @@ html[dir="rtl"] .editor-mount { } /* set the linenumber white when there is a breakpoint */ -.cm-s-mozilla .new-breakpoint .CodeMirror-gutter-wrapper .CodeMirror-linenumber { +.cm-s-mozilla + .new-breakpoint + .CodeMirror-gutter-wrapper + .CodeMirror-linenumber { color: white; } diff --git a/devtools/client/debugger/new/debugger.js b/devtools/client/debugger/new/debugger.js index 8b8cfaafddf5..4e95c9cf150e 100644 --- a/devtools/client/debugger/new/debugger.js +++ b/devtools/client/debugger/new/debugger.js @@ -1615,13 +1615,6 @@ module.exports = " + + + From 75433b81706a1d1748d4117fd68568d13568eec2 Mon Sep 17 00:00:00 2001 From: Ursula Sarracini Date: Sat, 21 Apr 2018 17:01:31 +0300 Subject: [PATCH 07/11] Bug 1455737 - Remove the result object from DownloadHistory when removing the view r=Mardak on a CLOSED TREE MozReview-Commit-ID: 5Qb5j30eqFO --- toolkit/components/downloads/DownloadHistory.jsm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/toolkit/components/downloads/DownloadHistory.jsm b/toolkit/components/downloads/DownloadHistory.jsm index 40ce09d9a91f..d1501e6294cd 100644 --- a/toolkit/components/downloads/DownloadHistory.jsm +++ b/toolkit/components/downloads/DownloadHistory.jsm @@ -454,6 +454,17 @@ this.DownloadHistoryList.prototype = { }, _result: null, + /** + * Remove the view that belongs to this list via DownloadList's removeView. In + * addition, delete the result object to ensure there are no memory leaks. + */ + removeView(aView) { + DownloadList.prototype.removeView.call(this, aView); + + // Clean up any active results that might still be observing. See bug 1455737 + this.result = null; + }, + /** * Index of the first slot that contains a session download. This is equal to * the length of the list when there are no session downloads. From ca890cd4cc96bf34dcce6ca4fc943ed84ac4aae9 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Fri, 20 Apr 2018 13:04:07 +0200 Subject: [PATCH 08/11] Bug 1454592 part 1 - Make some constructors constexpr. r=jonco --- js/src/ds/BitArray.h | 2 ++ js/src/gc/StoreBuffer.cpp | 10 +--------- js/src/gc/StoreBuffer.h | 8 +++++++- js/src/jit/VMFunctions.cpp | 7 ------- js/src/jit/VMFunctions.h | 10 ++++------ js/src/vm/Printer.cpp | 12 ++---------- js/src/vm/Printer.h | 13 +++++++++++-- 7 files changed, 27 insertions(+), 35 deletions(-) diff --git a/js/src/ds/BitArray.h b/js/src/ds/BitArray.h index ef75a08b9a9d..9d3d43054e5a 100644 --- a/js/src/ds/BitArray.h +++ b/js/src/ds/BitArray.h @@ -32,6 +32,8 @@ class BitArray WordT map[numSlots]; public: + constexpr BitArray() : map() {}; + void clear(bool value) { memset(map, value ? 0xFF : 0, sizeof(map)); if (value) diff --git a/js/src/gc/StoreBuffer.cpp b/js/src/gc/StoreBuffer.cpp index ef3ff6f733e1..46649bf0719c 100644 --- a/js/src/gc/StoreBuffer.cpp +++ b/js/src/gc/StoreBuffer.cpp @@ -115,14 +115,6 @@ StoreBuffer::addSizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::GCSi ArenaCellSet ArenaCellSet::Empty; -ArenaCellSet::ArenaCellSet() - : arena(nullptr) - , next(nullptr) -#ifdef DEBUG - , minorGCNumberAtCreation(0) -#endif -{} - ArenaCellSet::ArenaCellSet(Arena* arena, ArenaCellSet* next) : arena(arena) , next(next) @@ -131,7 +123,7 @@ ArenaCellSet::ArenaCellSet(Arena* arena, ArenaCellSet* next) #endif { MOZ_ASSERT(arena); - bits.clear(false); + MOZ_ASSERT(bits.isAllClear()); } ArenaCellSet* diff --git a/js/src/gc/StoreBuffer.h b/js/src/gc/StoreBuffer.h index 946599509352..7d7eb020223c 100644 --- a/js/src/gc/StoreBuffer.h +++ b/js/src/gc/StoreBuffer.h @@ -525,7 +525,13 @@ class ArenaCellSet #endif // Construct the empty sentinel object. - ArenaCellSet(); + constexpr ArenaCellSet() + : arena(nullptr) + , next(nullptr) +#ifdef DEBUG + , minorGCNumberAtCreation(0) +#endif + {} public: ArenaCellSet(Arena* arena, ArenaCellSet* next); diff --git a/js/src/jit/VMFunctions.cpp b/js/src/jit/VMFunctions.cpp index 6149ef259186..e8da03035820 100644 --- a/js/src/jit/VMFunctions.cpp +++ b/js/src/jit/VMFunctions.cpp @@ -44,13 +44,6 @@ AutoDetectInvalidation::AutoDetectInvalidation(JSContext* cx, MutableHandleValue disabled_(false) { } -void -VMFunction::addToFunctions() -{ - this->next = functions; - functions = this; -} - bool InvokeFunction(JSContext* cx, HandleObject obj, bool constructing, bool ignoresReturnValue, uint32_t argc, Value* argv, MutableHandleValue rval) diff --git a/js/src/jit/VMFunctions.h b/js/src/jit/VMFunctions.h index b381dd428260..39ea709003bf 100644 --- a/js/src/jit/VMFunctions.h +++ b/js/src/jit/VMFunctions.h @@ -261,7 +261,7 @@ struct VMFunction { } VMFunction(const VMFunction& o) - : next(nullptr), + : next(functions), wrapped(o.wrapped), #ifdef JS_TRACE_LOGGING name_(o.name_), @@ -276,6 +276,9 @@ struct VMFunction extraValuesToPop(o.extraValuesToPop), expectTailCall(o.expectTailCall) { + // Add this to the global list of VMFunctions. + functions = this; + // Check for valid failure/return type. MOZ_ASSERT_IF(outParam != Type_Void, returnType == Type_Void || @@ -283,7 +286,6 @@ struct VMFunction MOZ_ASSERT(returnType == Type_Void || returnType == Type_Bool || returnType == Type_Object); - addToFunctions(); } typedef const VMFunction* Lookup; @@ -317,10 +319,6 @@ struct VMFunction MOZ_ASSERT(f1->outParamRootType == f2->outParamRootType); return true; } - - private: - // Add this to the global list of VMFunctions. - void addToFunctions(); }; template struct TypeToDataType { /* Unexpected return type for a VMFunction. */ }; diff --git a/js/src/vm/Printer.cpp b/js/src/vm/Printer.cpp index edd17b27b975..fa400c37c156 100644 --- a/js/src/vm/Printer.cpp +++ b/js/src/vm/Printer.cpp @@ -46,11 +46,6 @@ private: namespace js { -GenericPrinter::GenericPrinter() - : hadOOM_(false) -{ -} - void GenericPrinter::reportOutOfMemory() { @@ -397,15 +392,12 @@ Fprinter::Fprinter(FILE* fp) init(fp); } -Fprinter::Fprinter() - : file_(nullptr), - init_(false) -{ } - +#ifdef DEBUG Fprinter::~Fprinter() { MOZ_ASSERT_IF(init_, !file_); } +#endif bool Fprinter::init(const char* path) diff --git a/js/src/vm/Printer.h b/js/src/vm/Printer.h index 590319b77c92..3fbaebb5da82 100644 --- a/js/src/vm/Printer.h +++ b/js/src/vm/Printer.h @@ -30,7 +30,9 @@ class GenericPrinter protected: bool hadOOM_; // whether reportOutOfMemory() has been called. - GenericPrinter(); + constexpr GenericPrinter() + : hadOOM_(false) + {} public: // Puts |len| characters from |s| at the current position and @@ -139,8 +141,15 @@ class Fprinter final : public GenericPrinter public: explicit Fprinter(FILE* fp); - Fprinter(); + + constexpr Fprinter() + : file_(nullptr), + init_(false) + {} + +#ifdef DEBUG ~Fprinter(); +#endif // Initialize this printer, returns false on error. MOZ_MUST_USE bool init(const char* path); From f57cb4a925a74f6d2c168b3a50589c10bf9b7e6e Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Fri, 20 Apr 2018 13:07:14 +0200 Subject: [PATCH 09/11] Bug 1454592 part 2 - Get rid of a static constructor for protoTable array. r=jonco --- js/public/ProtoKey.h | 2 +- js/public/Proxy.h | 6 +++--- js/public/Wrapper.h | 2 +- js/src/proxy/Proxy.cpp | 6 ++---- js/src/proxy/Wrapper.cpp | 2 +- js/src/vm/ProxyObject.h | 9 ++++----- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/js/public/ProtoKey.h b/js/public/ProtoKey.h index 95e49e074737..fae73dfe5d74 100644 --- a/js/public/ProtoKey.h +++ b/js/public/ProtoKey.h @@ -95,7 +95,7 @@ real(Float32Array, InitViaClassSpec, TYPED_ARRAY_CLASP(Float32)) \ real(Float64Array, InitViaClassSpec, TYPED_ARRAY_CLASP(Float64)) \ real(Uint8ClampedArray, InitViaClassSpec, TYPED_ARRAY_CLASP(Uint8Clamped)) \ - real(Proxy, InitProxyClass, js::ProxyClassPtr) \ + real(Proxy, InitProxyClass, &js::ProxyClass) \ real(WeakMap, InitWeakMapClass, OCLASP(WeakMap)) \ real(Map, InitViaClassSpec, OCLASP(Map)) \ real(Set, InitViaClassSpec, OCLASP(Set)) \ diff --git a/js/public/Proxy.h b/js/public/Proxy.h index eb2306fa4caa..96eaa4d0f21a 100644 --- a/js/public/Proxy.h +++ b/js/public/Proxy.h @@ -352,7 +352,7 @@ class JS_FRIEND_API(BaseProxyHandler) virtual bool isScripted() const { return false; } }; -extern JS_FRIEND_DATA(const js::Class* const) ProxyClassPtr; +extern JS_FRIEND_DATA(const js::Class) ProxyClass; inline bool IsProxy(const JSObject* obj) { @@ -547,13 +547,13 @@ class MOZ_STACK_CLASS ProxyOptions { explicit ProxyOptions(bool singletonArg, bool lazyProtoArg = false) : singleton_(singletonArg), lazyProto_(lazyProtoArg), - clasp_(ProxyClassPtr) + clasp_(&ProxyClass) {} public: ProxyOptions() : singleton_(false), lazyProto_(false), - clasp_(ProxyClassPtr) + clasp_(&ProxyClass) {} bool singleton() const { return singleton_; } diff --git a/js/public/Wrapper.h b/js/public/Wrapper.h index a00a19b192b5..57b786d48f43 100644 --- a/js/public/Wrapper.h +++ b/js/public/Wrapper.h @@ -155,7 +155,7 @@ class JS_FRIEND_API(Wrapper) : public ForwardingProxyHandler static const Wrapper singleton; static const Wrapper singletonWithPrototype; - static JSObject* defaultProto; + static JSObject* const defaultProto; }; inline JSObject* diff --git a/js/src/proxy/Proxy.cpp b/js/src/proxy/Proxy.cpp index e0fd6046b0da..8d12fd07f80b 100644 --- a/js/src/proxy/Proxy.cpp +++ b/js/src/proxy/Proxy.cpp @@ -809,13 +809,11 @@ const ObjectOps js::ProxyObjectOps = { Proxy::fun_toString }; -const Class js::ProxyObject::proxyClass = +const Class js::ProxyClass = PROXY_CLASS_DEF("Proxy", JSCLASS_HAS_CACHED_PROTO(JSProto_Proxy) | JSCLASS_HAS_RESERVED_SLOTS(2)); -const Class* const js::ProxyClassPtr = &js::ProxyObject::proxyClass; - JS_FRIEND_API(JSObject*) js::NewProxyObject(JSContext* cx, const BaseProxyHandler* handler, HandleValue priv, JSObject* proto_, const ProxyOptions& options) @@ -833,7 +831,7 @@ ProxyObject::renew(const BaseProxyHandler* handler, const Value& priv) { MOZ_ASSERT(!IsInsideNursery(this)); MOZ_ASSERT_IF(IsCrossCompartmentWrapper(this), IsDeadProxyObject(this)); - MOZ_ASSERT(getClass() == &ProxyObject::proxyClass); + MOZ_ASSERT(getClass() == &ProxyClass); MOZ_ASSERT(!IsWindowProxy(this)); MOZ_ASSERT(hasDynamicPrototype()); diff --git a/js/src/proxy/Wrapper.cpp b/js/src/proxy/Wrapper.cpp index 1e5f91d06f93..b5a08aad80c1 100644 --- a/js/src/proxy/Wrapper.cpp +++ b/js/src/proxy/Wrapper.cpp @@ -429,7 +429,7 @@ js::ReportAccessDenied(JSContext* cx) const char Wrapper::family = 0; const Wrapper Wrapper::singleton((unsigned)0); const Wrapper Wrapper::singletonWithPrototype((unsigned)0, true); -JSObject* Wrapper::defaultProto = TaggedProto::LazyProto; +JSObject* const Wrapper::defaultProto = TaggedProto::LazyProto; /* Compartments. */ diff --git a/js/src/vm/ProxyObject.h b/js/src/vm/ProxyObject.h index 1bb00561d1fc..833c4ecfa749 100644 --- a/js/src/vm/ProxyObject.h +++ b/js/src/vm/ProxyObject.h @@ -18,6 +18,10 @@ namespace js { * * Proxy objects use ShapedObject::shape_ primarily to record flags. Property * information, &c. is all dynamically computed. + * + * There is no class_ member to force specialization of JSObject::is(). + * The implementation in JSObject is incorrect for proxies since it doesn't + * take account of the handler type. */ class ProxyObject : public ShapedObject { @@ -127,11 +131,6 @@ class ProxyObject : public ShapedObject static void traceEdgeToTarget(JSTracer* trc, ProxyObject* obj); void nuke(); - - // There is no class_ member to force specialization of JSObject::is(). - // The implementation in JSObject is incorrect for proxies since it doesn't - // take account of the handler type. - static const Class proxyClass; }; inline bool From 5d21d267901dd71318aafa57a7aafab9d27c29ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 21 Apr 2018 19:28:32 +0200 Subject: [PATCH 10/11] Bug 1411008: Add crashtest. r=me MozReview-Commit-ID: CbhZXAORyoV --- layout/style/crashtests/1411008.html | 22 ++++++++++++++++++++++ layout/style/crashtests/crashtests.list | 1 + 2 files changed, 23 insertions(+) create mode 100644 layout/style/crashtests/1411008.html diff --git a/layout/style/crashtests/1411008.html b/layout/style/crashtests/1411008.html new file mode 100644 index 000000000000..9621a559ee7b --- /dev/null +++ b/layout/style/crashtests/1411008.html @@ -0,0 +1,22 @@ + + diff --git a/layout/style/crashtests/crashtests.list b/layout/style/crashtests/crashtests.list index 7300e05c27ec..172d597dd2dd 100644 --- a/layout/style/crashtests/crashtests.list +++ b/layout/style/crashtests/crashtests.list @@ -257,6 +257,7 @@ load 1409502.html load 1409931.html load 1410226-1.html load 1410226-2.html +load 1411008.html load 1411143.html load 1411478.html load 1413288.html From 902c8cde47420072b4b2ec25233a843742c13ae5 Mon Sep 17 00:00:00 2001 From: Gabriele Svelto Date: Wed, 18 Apr 2018 17:07:39 +0200 Subject: [PATCH 11/11] Bug 1451002 - Send ongoing memory pressure notifications when a low-memory condition persists for a long time; r=njn --HG-- extra : rebase_source : d98800a5116e13dfc28e546cbf26beb0d6090147 --- xpcom/base/AvailableMemoryTracker.cpp | 90 ++++++++++++++++----------- 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/xpcom/base/AvailableMemoryTracker.cpp b/xpcom/base/AvailableMemoryTracker.cpp index d0ed25d11cb7..30140989c8db 100644 --- a/xpcom/base/AvailableMemoryTracker.cpp +++ b/xpcom/base/AvailableMemoryTracker.cpp @@ -37,25 +37,25 @@ namespace { #if defined(_M_IX86) && defined(XP_WIN) -// Fire a low-memory notification if we have less than this many MiB of virtual -// address space available. -static const uint32_t kLowVirtualMemoryThresholdMiB = 256; +// Fire a low-memory notification if we have less than this many bytes of +// virtual address space available. +static const size_t kLowVirtualMemoryThreshold = 256 * 1024 * 1024; -// Fire a low-memory notification if we have less than this many MiB of commit +// Fire a low-memory notification if we have less than this many bytes of commit // space (physical memory plus page file) left. -static const uint32_t kLowCommitSpaceThresholdMiB = 256; +static const size_t kLowCommitSpaceThreshold = 256 * 1024 * 1024; -// Fire a low-memory notification if we have less than this many MiB of +// Fire a low-memory notification if we have less than this many bytes of // physical memory available on the whole machine. -static const uint32_t kLowPhysicalMemoryThresholdMiB = 0; +static const size_t kLowPhysicalMemoryThreshold = 0; // Don't fire a low-memory notification because of low available physical // memory or low commit space more often than this interval. static const uint32_t kLowMemoryNotificationIntervalMS = 10000; -Atomic sNumLowVirtualMemEvents; -Atomic sNumLowCommitSpaceEvents; -Atomic sNumLowPhysicalMemEvents; +Atomic sNumLowVirtualMemEvents; +Atomic sNumLowCommitSpaceEvents; +Atomic sNumLowPhysicalMemEvents; WindowsDllInterceptor sKernel32Intercept; WindowsDllInterceptor sGdi32Intercept; @@ -68,7 +68,7 @@ bool sHooksActive = false; // Alas, we'd like to use mozilla::TimeStamp, but we can't, because it acquires // a lock! -volatile bool sHasScheduledOneLowMemoryNotification = false; +volatile bool sUnderMemoryPressure = false; volatile PRIntervalTime sLastLowMemoryNotificationTime; // These are function pointers to the functions we wrap in Init(). @@ -85,19 +85,26 @@ HBITMAP(WINAPI* sCreateDIBSectionOrig)(HDC aDC, const BITMAPINFO* aBitmapInfo, HANDLE aSection, DWORD aOffset); /** - * Fire a memory pressure event if it's been long enough since the last one we + * Fire a memory pressure event if we were not under memory pressure yet, or + * fire an ongoing one if it's been long enough since the last one we * fired. */ bool MaybeScheduleMemoryPressureEvent() { + MemoryPressureState state = MemPressure_New; + PRIntervalTime now = PR_IntervalNow(); + // If this interval rolls over, we may fire an extra memory pressure // event, but that's not a big deal. - PRIntervalTime interval = PR_IntervalNow() - sLastLowMemoryNotificationTime; - if (sHasScheduledOneLowMemoryNotification && - PR_IntervalToMilliseconds(interval) < kLowMemoryNotificationIntervalMS) { + PRIntervalTime interval = now - sLastLowMemoryNotificationTime; + if (sUnderMemoryPressure) { + if (PR_IntervalToMilliseconds(interval) < + kLowMemoryNotificationIntervalMS) { + return false; + } - return false; + state = MemPressure_Ongoing; } // There's a bit of a race condition here, since an interval may be a @@ -106,13 +113,28 @@ MaybeScheduleMemoryPressureEvent() // experiencing memory pressure and firing notifications, so the worst // thing that can happen is that we fire two notifications when we // should have fired only one. - sHasScheduledOneLowMemoryNotification = true; - sLastLowMemoryNotificationTime = PR_IntervalNow(); + sUnderMemoryPressure = true; + sLastLowMemoryNotificationTime = now; - NS_DispatchEventualMemoryPressure(MemPressure_New); + NS_DispatchEventualMemoryPressure(state); return true; } +static bool +CheckLowMemory(DWORDLONG available, size_t threshold, + Atomic& counter) +{ + if (available < threshold) { + if (MaybeScheduleMemoryPressureEvent()) { + counter++; + } + + return true; + } + + return false; +} + void CheckMemAvailable() { @@ -125,22 +147,15 @@ CheckMemAvailable() bool success = GlobalMemoryStatusEx(&stat); if (success) { - // kLowVirtualMemoryThresholdMiB is in MiB, but ullAvailVirtual is in bytes. - if (stat.ullAvailVirtual < kLowVirtualMemoryThresholdMiB * 1024 * 1024) { - // If we're running low on virtual memory, unconditionally schedule the - // notification. We'll probably crash if we run out of virtual memory, - // so don't worry about firing this notification too often. - ++sNumLowVirtualMemEvents; - NS_DispatchEventualMemoryPressure(MemPressure_New); - } else if (stat.ullAvailPageFile < kLowCommitSpaceThresholdMiB * 1024 * 1024) { - if (MaybeScheduleMemoryPressureEvent()) { - ++sNumLowCommitSpaceEvents; - } - } else if (stat.ullAvailPhys < kLowPhysicalMemoryThresholdMiB * 1024 * 1024) { - if (MaybeScheduleMemoryPressureEvent()) { - ++sNumLowPhysicalMemEvents; - } - } + bool lowMemory = CheckLowMemory(stat.ullAvailVirtual, + kLowVirtualMemoryThreshold, + sNumLowVirtualMemEvents); + lowMemory |= CheckLowMemory(stat.ullAvailPageFile, kLowCommitSpaceThreshold, + sNumLowCommitSpaceEvents); + lowMemory |= CheckLowMemory(stat.ullAvailPhys, kLowPhysicalMemoryThreshold, + sNumLowPhysicalMemEvents); + + sUnderMemoryPressure = lowMemory; } } @@ -166,8 +181,9 @@ VirtualAllocHook(LPVOID aAddress, SIZE_T aSize, // Don't call CheckMemAvailable for MEM_RESERVE if we're not tracking low // virtual memory. Similarly, don't call CheckMemAvailable for MEM_COMMIT if // we're not tracking low physical memory. - if ((kLowVirtualMemoryThresholdMiB != 0 && aAllocationType & MEM_RESERVE) || - (kLowPhysicalMemoryThresholdMiB != 0 && aAllocationType & MEM_COMMIT)) { + if ((kLowVirtualMemoryThreshold != 0 && aAllocationType & MEM_RESERVE) || + ((kLowCommitSpaceThreshold != 0 || kLowPhysicalMemoryThreshold != 0) && + aAllocationType & MEM_COMMIT)) { CheckMemAvailable(); }
Most severe checkerboarding reports