diff --git a/accessible/base/NotificationController.h b/accessible/base/NotificationController.h index 26606bdefcd1a184f0ae731fb5ffe973253c8b2e..e4f62f9d31914b37ba3eb9c2f5f65da36d33b781 100644 --- a/accessible/base/NotificationController.h +++ b/accessible/base/NotificationController.h @@ -275,6 +275,8 @@ class NotificationController final : public EventQueue, } #endif + bool IsUpdatePendingForJugglerAccessibility() { return IsUpdatePending(); } + protected: virtual ~NotificationController(); diff --git a/accessible/interfaces/nsIAccessibleDocument.idl b/accessible/interfaces/nsIAccessibleDocument.idl index a91df31c96afda66f478a5a38eaa4352039c2a0b..ee777c1746284027fb3aa2f1686f8082af9d89ee 100644 --- a/accessible/interfaces/nsIAccessibleDocument.idl +++ b/accessible/interfaces/nsIAccessibleDocument.idl @@ -72,4 +72,9 @@ interface nsIAccessibleDocument : nsISupports * Return the child document accessible at the given index. */ nsIAccessibleDocument getChildDocumentAt(in unsigned long index); + + /** + * Return whether it is updating. + */ + readonly attribute boolean isUpdatePendingForJugglerAccessibility; }; diff --git a/accessible/xpcom/xpcAccessibleDocument.cpp b/accessible/xpcom/xpcAccessibleDocument.cpp index ec83b699e1449b2610b43b35694ee18d80cee2ff..66854bda7d8c20627949289b9f2e2e161a00fea8 100644 --- a/accessible/xpcom/xpcAccessibleDocument.cpp +++ b/accessible/xpcom/xpcAccessibleDocument.cpp @@ -142,6 +142,15 @@ xpcAccessibleDocument::GetVirtualCursor(nsIAccessiblePivot** aVirtualCursor) { return NS_OK; } + +NS_IMETHODIMP +xpcAccessibleDocument::GetIsUpdatePendingForJugglerAccessibility(bool* updating) { + NS_ENSURE_ARG_POINTER(updating); + *updating = Intl()->Controller()->IsUpdatePendingForJugglerAccessibility(); + return NS_OK; +} + + //////////////////////////////////////////////////////////////////////////////// // xpcAccessibleDocument diff --git a/accessible/xpcom/xpcAccessibleDocument.h b/accessible/xpcom/xpcAccessibleDocument.h index 94aab80cef662a0ba092557cf2a9882c3dc919ac..f1df85042035d89665d7103faf52a8922856a052 100644 --- a/accessible/xpcom/xpcAccessibleDocument.h +++ b/accessible/xpcom/xpcAccessibleDocument.h @@ -48,6 +48,8 @@ class xpcAccessibleDocument : public xpcAccessibleHyperText, nsIAccessibleDocument** aDocument) final; NS_IMETHOD GetVirtualCursor(nsIAccessiblePivot** aVirtualCursor) final; + NS_IMETHOD GetIsUpdatePendingForJugglerAccessibility(bool* aUpdating) final; + /** * Return XPCOM wrapper for the internal accessible. */ diff --git a/browser/app/winlauncher/LauncherProcessWin.cpp b/browser/app/winlauncher/LauncherProcessWin.cpp index 6aebc7bde2cbb00ef2e127e417d92e5406c21259..dfbd67d4c8316c8f9d1019969a6f8433f75cb9a7 100644 --- a/browser/app/winlauncher/LauncherProcessWin.cpp +++ b/browser/app/winlauncher/LauncherProcessWin.cpp @@ -23,6 +23,7 @@ #include "mozilla/WinHeaderOnlyUtils.h" #include "nsWindowsHelpers.h" +#include #include #include @@ -327,8 +328,19 @@ Maybe LauncherMain(int& argc, wchar_t* argv[], HANDLE stdHandles[] = {::GetStdHandle(STD_INPUT_HANDLE), ::GetStdHandle(STD_OUTPUT_HANDLE), ::GetStdHandle(STD_ERROR_HANDLE)}; - attrs.AddInheritableHandles(stdHandles); + // Playwright pipe installation. + bool hasJugglerPipe = + mozilla::CheckArg(argc, argv, L"juggler-pipe", + static_cast(nullptr), + mozilla::CheckArgFlag::None) == mozilla::ARG_FOUND; + if (hasJugglerPipe) { + intptr_t stdio3 = _get_osfhandle(3); + intptr_t stdio4 = _get_osfhandle(4); + HANDLE pipeHandles[] = {reinterpret_cast(stdio3), + reinterpret_cast(stdio4)}; + attrs.AddInheritableHandles(pipeHandles); + } DWORD creationFlags = CREATE_SUSPENDED | CREATE_UNICODE_ENVIRONMENT; diff --git a/browser/installer/allowed-dupes.mn b/browser/installer/allowed-dupes.mn index b78182e949e6677f39fe3af742b9fa2dd3ea4181..a382f9b20225e4bee3eaba438298b015060f1ad5 100644 --- a/browser/installer/allowed-dupes.mn +++ b/browser/installer/allowed-dupes.mn @@ -72,6 +72,12 @@ browser/features/webcompat@mozilla.org/shims/empty-shim.txt removed-files #endif +# Juggler/marionette files +chrome/juggler/content/content/floating-scrollbars.css +browser/chrome/devtools/skin/floating-scrollbars-responsive-design.css +chrome/juggler/content/server/stream-utils.js +chrome/marionette/content/stream-utils.js + #ifdef MOZ_EME_WIN32_ARTIFACT gmp-clearkey/0.1/manifest.json i686/gmp-clearkey/0.1/manifest.json diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 7bb8dbfbfc61f77a733075d6dcd3fc79f3957cad..85f002adf0e70ff57df124301ee1f65417c06f2b 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -203,6 +203,11 @@ @RESPATH@/chrome/remote.manifest #endif +@RESPATH@/chrome/juggler@JAREXT@ +@RESPATH@/chrome/juggler.manifest +@RESPATH@/components/juggler.manifest +@RESPATH@/components/juggler.js + #if defined(ENABLE_TESTS) && defined(MOZ_DEBUG) @RESPATH@/components/TestInterfaceJS.js @RESPATH@/components/TestInterfaceJS.manifest diff --git a/devtools/server/socket/websocket-server.js b/devtools/server/socket/websocket-server.js index 040c7b124dec6bb254563bbe74fe50012cb077a3..b4e6b8132786af70e8ad0dce88b67c2835307f88 100644 --- a/devtools/server/socket/websocket-server.js +++ b/devtools/server/socket/websocket-server.js @@ -133,13 +133,12 @@ function writeHttpResponse(output, response) { * Process the WebSocket handshake headers and return the key to be sent in * Sec-WebSocket-Accept response header. */ -function processRequest({ requestLine, headers }) { +function processRequest({ requestLine, headers }, expectedPath) { const [method, path] = requestLine.split(" "); if (method !== "GET") { throw new Error("The handshake request must use GET method"); } - - if (path !== "/") { + if (path !== expectedPath) { throw new Error("The handshake request has unknown path"); } @@ -189,13 +188,13 @@ function computeKey(key) { /** * Perform the server part of a WebSocket opening handshake on an incoming connection. */ -const serverHandshake = async function(input, output) { +const serverHandshake = async function(input, output, expectedPath) { // Read the request const request = await readHttpRequest(input); try { // Check and extract info from the request - const { acceptKey } = processRequest(request); + const { acceptKey } = processRequest(request, expectedPath); // Send response headers await writeHttpResponse(output, [ @@ -217,8 +216,8 @@ const serverHandshake = async function(input, output) { * Performs the WebSocket handshake and waits for the WebSocket to open. * Returns Promise with a WebSocket ready to send and receive messages. */ -const accept = async function(transport, input, output) { - await serverHandshake(input, output); +const accept = async function(transport, input, output, expectedPath) { + await serverHandshake(input, output, expectedPath || "/"); const transportProvider = { setListener(upgradeListener) { diff --git a/docshell/base/BrowsingContext.cpp b/docshell/base/BrowsingContext.cpp index 466c28d578ec0c719683ce0c5788e81603c776fd..3d72cc323cfa97b67515278375ac175eacd7ba66 100644 --- a/docshell/base/BrowsingContext.cpp +++ b/docshell/base/BrowsingContext.cpp @@ -107,6 +107,20 @@ struct ParamTraits mozilla::dom::PrefersColorSchemeOverride::None, mozilla::dom::PrefersColorSchemeOverride::EndGuard_> {}; +template <> +struct ParamTraits + : public ContiguousEnumSerializer< + mozilla::dom::PrefersReducedMotionOverride, + mozilla::dom::PrefersReducedMotionOverride::None, + mozilla::dom::PrefersReducedMotionOverride::EndGuard_> {}; + +template <> +struct ParamTraits + : public ContiguousEnumSerializer< + mozilla::dom::ForcedColorsOverride, + mozilla::dom::ForcedColorsOverride::None, + mozilla::dom::ForcedColorsOverride::EndGuard_> {}; + template <> struct ParamTraits : public ContiguousEnumSerializer< @@ -2720,6 +2734,40 @@ void BrowsingContext::DidSet(FieldIndex, }); } +void BrowsingContext::DidSet(FieldIndex, + dom::PrefersReducedMotionOverride aOldValue) { + MOZ_ASSERT(IsTop()); + if (PrefersReducedMotionOverride() == aOldValue) { + return; + } + PreOrderWalk([&](BrowsingContext* aContext) { + if (nsIDocShell* shell = aContext->GetDocShell()) { + if (nsPresContext* pc = shell->GetPresContext()) { + pc->MediaFeatureValuesChanged( + {MediaFeatureChangeReason::SystemMetricsChange}, + MediaFeatureChangePropagation::JustThisDocument); + } + } + }); +} + +void BrowsingContext::DidSet(FieldIndex, + dom::ForcedColorsOverride aOldValue) { + MOZ_ASSERT(IsTop()); + if (ForcedColorsOverride() == aOldValue) { + return; + } + PreOrderWalk([&](BrowsingContext* aContext) { + if (nsIDocShell* shell = aContext->GetDocShell()) { + if (nsPresContext* pc = shell->GetPresContext()) { + pc->MediaFeatureValuesChanged( + {MediaFeatureChangeReason::SystemMetricsChange}, + MediaFeatureChangePropagation::JustThisDocument); + } + } + }); +} + void BrowsingContext::DidSet(FieldIndex, nsString&& aOldValue) { MOZ_ASSERT(IsTop()); diff --git a/docshell/base/BrowsingContext.h b/docshell/base/BrowsingContext.h index 236e344f7be0e1528ad74ec015bdfd1b83598558..8d65af5e5efb9798213ecc8f781706c9b114279a 100644 --- a/docshell/base/BrowsingContext.h +++ b/docshell/base/BrowsingContext.h @@ -191,6 +191,8 @@ enum class ExplicitActiveStatus : uint8_t { FIELD(ServiceWorkersTestingEnabled, bool) \ FIELD(MediumOverride, nsString) \ FIELD(PrefersColorSchemeOverride, mozilla::dom::PrefersColorSchemeOverride) \ + FIELD(PrefersReducedMotionOverride, mozilla::dom::PrefersReducedMotionOverride) \ + FIELD(ForcedColorsOverride, mozilla::dom::ForcedColorsOverride) \ FIELD(DisplayMode, mozilla::dom::DisplayMode) \ /* True if the top level browsing context owns a main media controller */ \ FIELD(HasMainMediaController, bool) \ @@ -852,6 +854,14 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache { return GetPrefersColorSchemeOverride(); } + dom::PrefersReducedMotionOverride PrefersReducedMotionOverride() const { + return GetPrefersReducedMotionOverride(); + } + + dom::ForcedColorsOverride ForcedColorsOverride() const { + return GetForcedColorsOverride(); + } + void FlushSessionStore(); bool IsInBFCache() const { return mIsInBFCache; } @@ -979,6 +989,23 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache { void DidSet(FieldIndex, dom::PrefersColorSchemeOverride aOldValue); + bool CanSet(FieldIndex, + dom::PrefersReducedMotionOverride, ContentParent*) { + return IsTop(); + } + + void DidSet(FieldIndex, + dom::PrefersReducedMotionOverride aOldValue); + + + bool CanSet(FieldIndex, + dom::ForcedColorsOverride, ContentParent*) { + return IsTop(); + } + + void DidSet(FieldIndex, + dom::ForcedColorsOverride aOldValue); + void DidSet(FieldIndex, nsString&& aOldValue); bool CanSet(FieldIndex, bool, ContentParent*) { diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index e17c7c805992e6380ee795480463f3b1c53af2a0..6235f9937a3d04aacf891de31dc602b2704b57f7 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -15,6 +15,12 @@ # include // for getpid() #endif +#if JS_HAS_INTL_API && !MOZ_SYSTEM_ICU +# include "unicode/locid.h" +#endif /* JS_HAS_INTL_API && !MOZ_SYSTEM_ICU */ + +#include "js/LocaleSensitive.h" + #include "mozilla/ArrayUtils.h" #include "mozilla/Attributes.h" #include "mozilla/AutoRestore.h" @@ -64,6 +70,7 @@ #include "mozilla/dom/ContentFrameMessageManager.h" #include "mozilla/dom/DocGroup.h" #include "mozilla/dom/Element.h" +#include "mozilla/dom/Geolocation.h" #include "mozilla/dom/HTMLAnchorElement.h" #include "mozilla/dom/HTMLIFrameElement.h" #include "mozilla/dom/PerformanceNavigation.h" @@ -88,6 +95,7 @@ #include "mozilla/dom/LoadURIOptionsBinding.h" #include "mozilla/dom/JSWindowActorChild.h" #include "mozilla/ipc/ProtocolUtils.h" +#include "mozilla/dom/WorkerCommon.h" #include "mozilla/net/DocumentChannel.h" #include "mozilla/net/DocumentChannelChild.h" #include "mozilla/net/ParentChannelWrapper.h" @@ -111,6 +119,7 @@ #include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeOwner.h" #include "mozilla/dom/Document.h" +#include "mozilla/dom/Element.h" #include "nsIDocumentLoaderFactory.h" #include "nsIDOMWindow.h" #include "nsIEditingSession.h" @@ -205,6 +214,7 @@ #include "nsGlobalWindow.h" #include "nsISearchService.h" #include "nsJSEnvironment.h" +#include "nsJSUtils.h" #include "nsNetCID.h" #include "nsNetUtil.h" #include "nsObjectLoadingContent.h" @@ -368,6 +378,14 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext, mAllowDNSPrefetch(true), mAllowWindowControl(true), mCSSErrorReportingEnabled(false), + mFileInputInterceptionEnabled(false), + mOverrideHasFocus(false), + mBypassCSPEnabled(false), + mForceActiveState(false), + mOnlineOverride(nsIDocShell::ONLINE_OVERRIDE_NONE), + mColorSchemeOverride(COLOR_SCHEME_OVERRIDE_NONE), + mReducedMotionOverride(REDUCED_MOTION_OVERRIDE_NONE), + mForcedColorsOverride(FORCED_COLORS_OVERRIDE_NO_OVERRIDE), mAllowAuth(mItemType == typeContent), mAllowKeywordFixup(false), mDisableMetaRefreshWhenInactive(false), @@ -3087,6 +3105,239 @@ nsDocShell::GetMessageManager(ContentFrameMessageManager** aMessageManager) { return NS_OK; } +// =============== Juggler Begin ======================= + +nsDocShell* nsDocShell::GetRootDocShell() { + nsCOMPtr rootAsItem; + GetInProcessSameTypeRootTreeItem(getter_AddRefs(rootAsItem)); + nsCOMPtr rootShell = do_QueryInterface(rootAsItem); + return nsDocShell::Cast(rootShell); +} + +NS_IMETHODIMP +nsDocShell::GetBypassCSPEnabled(bool* aEnabled) { + MOZ_ASSERT(aEnabled); + *aEnabled = mBypassCSPEnabled; + return NS_OK; +} + +NS_IMETHODIMP +nsDocShell::SetBypassCSPEnabled(bool aEnabled) { + mBypassCSPEnabled = aEnabled; + return NS_OK; +} + +NS_IMETHODIMP +nsDocShell::GetForceActiveState(bool* aEnabled) { + MOZ_ASSERT(aEnabled); + *aEnabled = mForceActiveState; + return NS_OK; +} + +NS_IMETHODIMP +nsDocShell::SetForceActiveState(bool aEnabled) { + mForceActiveState = aEnabled; + ActivenessMaybeChanged(); + return NS_OK; +} + +bool nsDocShell::IsBypassCSPEnabled() { + return GetRootDocShell()->mBypassCSPEnabled; +} + +NS_IMETHODIMP +nsDocShell::GetOverrideHasFocus(bool* aEnabled) { + MOZ_ASSERT(aEnabled); + *aEnabled = mOverrideHasFocus; + return NS_OK; +} + +NS_IMETHODIMP +nsDocShell::SetOverrideHasFocus(bool aEnabled) { + mOverrideHasFocus = aEnabled; + return NS_OK; +} + +bool nsDocShell::ShouldOverrideHasFocus() const { + return mOverrideHasFocus; +} + +NS_IMETHODIMP +nsDocShell::GetLanguageOverride(nsAString& aLanguageOverride) { + aLanguageOverride = GetRootDocShell()->mLanguageOverride; + return NS_OK; +} + + +static void SetIcuLocale(const nsAString& aLanguageOverride) { + icu::Locale locale(NS_LossyConvertUTF16toASCII(aLanguageOverride).get()); + if (icu::Locale::getDefault() == locale) + return; + UErrorCode error_code = U_ZERO_ERROR; + const char* lang = locale.getLanguage(); + if (lang != nullptr && *lang != '\0') { + icu::Locale::setDefault(locale, error_code); + } else { + fprintf(stderr, "SetIcuLocale Failed to set the ICU default locale to %s\n", NS_LossyConvertUTF16toASCII(aLanguageOverride).get()); + } + + AutoJSAPI jsapi; + jsapi.Init(); + JSContext* cx = jsapi.cx(); + JS_ResetDefaultLocale(JS_GetRuntime(cx)); + + ResetDefaultLocaleInAllWorkers(); +} + +NS_IMETHODIMP +nsDocShell::SetLanguageOverride(const nsAString& aLanguageOverride) { + mLanguageOverride = aLanguageOverride; + SetIcuLocale(aLanguageOverride); + return NS_OK; +} + +NS_IMETHODIMP +nsDocShell::OverrideTimezone(const nsAString& aTimezoneOverride, + bool* aSuccess) { + NS_ENSURE_ARG(aSuccess); + NS_LossyConvertUTF16toASCII timeZoneId(aTimezoneOverride); + *aSuccess = nsJSUtils::SetTimeZoneOverride(timeZoneId.get()); + + // Set TZ which affects localtime_s(). + auto setTimeZoneEnv = [](const char* value) { +#if defined(_WIN32) + return _putenv_s("TZ", value) == 0; +#else + return setenv("TZ", value, true) == 0; +#endif /* _WIN32 */ + }; + if (*aSuccess) { + *aSuccess = setTimeZoneEnv(timeZoneId.get()); + if (!*aSuccess) { + fprintf(stderr, "Failed to set 'TZ' to '%s'\n", timeZoneId.get()); + } + } + return NS_OK; +} + +NS_IMETHODIMP +nsDocShell::GetFileInputInterceptionEnabled(bool* aEnabled) { + MOZ_ASSERT(aEnabled); + *aEnabled = GetRootDocShell()->mFileInputInterceptionEnabled; + return NS_OK; +} + +NS_IMETHODIMP +nsDocShell::SetFileInputInterceptionEnabled(bool aEnabled) { + mFileInputInterceptionEnabled = aEnabled; + return NS_OK; +} + +bool nsDocShell::IsFileInputInterceptionEnabled() { + return GetRootDocShell()->mFileInputInterceptionEnabled; +} + +void nsDocShell::FilePickerShown(mozilla::dom::Element* element) { + nsCOMPtr observerService = + mozilla::services::GetObserverService(); + observerService->NotifyObservers( + ToSupports(element), "juggler-file-picker-shown", nullptr); +} + +RefPtr nsDocShell::GetGeolocationServiceOverride() { + return GetRootDocShell()->mGeolocationServiceOverride; +} + +NS_IMETHODIMP +nsDocShell::SetGeolocationOverride(nsIDOMGeoPosition* aGeolocationOverride) { + if (aGeolocationOverride) { + if (!mGeolocationServiceOverride) { + mGeolocationServiceOverride = new nsGeolocationService(); + mGeolocationServiceOverride->Init(); + } + mGeolocationServiceOverride->Update(aGeolocationOverride); + } else { + mGeolocationServiceOverride = nullptr; + } + return NS_OK; +} + +NS_IMETHODIMP +nsDocShell::GetOnlineOverride(OnlineOverride* aOnlineOverride) { + *aOnlineOverride = GetRootDocShell()->mOnlineOverride; + return NS_OK; +} + +NS_IMETHODIMP +nsDocShell::SetOnlineOverride(OnlineOverride aOnlineOverride) { + // We don't have a way to verify this coming from Javascript, so this check is + // still needed. + if (!(aOnlineOverride == ONLINE_OVERRIDE_NONE || + aOnlineOverride == ONLINE_OVERRIDE_ONLINE || + aOnlineOverride == ONLINE_OVERRIDE_OFFLINE)) { + return NS_ERROR_INVALID_ARG; + } + + mOnlineOverride = aOnlineOverride; + return NS_OK; +} + +NS_IMETHODIMP +nsDocShell::GetColorSchemeOverride(ColorSchemeOverride* aColorSchemeOverride) { + *aColorSchemeOverride = GetRootDocShell()->mColorSchemeOverride; + return NS_OK; +} + +NS_IMETHODIMP +nsDocShell::SetColorSchemeOverride(ColorSchemeOverride aColorSchemeOverride) { + mColorSchemeOverride = aColorSchemeOverride; + RefPtr presContext = GetPresContext(); + if (presContext) { + presContext->MediaFeatureValuesChanged( + {MediaFeatureChangeReason::SystemMetricsChange}, + MediaFeatureChangePropagation::JustThisDocument); + } + return NS_OK; +} + +NS_IMETHODIMP +nsDocShell::GetReducedMotionOverride(ReducedMotionOverride* aReducedMotionOverride) { + *aReducedMotionOverride = GetRootDocShell()->mReducedMotionOverride; + return NS_OK; +} + +NS_IMETHODIMP +nsDocShell::SetReducedMotionOverride(ReducedMotionOverride aReducedMotionOverride) { + mReducedMotionOverride = aReducedMotionOverride; + RefPtr presContext = GetPresContext(); + if (presContext) { + presContext->MediaFeatureValuesChanged( + {MediaFeatureChangeReason::SystemMetricsChange}, + MediaFeatureChangePropagation::JustThisDocument); + } + return NS_OK; +} + +NS_IMETHODIMP +nsDocShell::GetForcedColorsOverride(ForcedColorsOverride* aForcedColorsOverride) { + *aForcedColorsOverride = GetRootDocShell()->mForcedColorsOverride; + return NS_OK; +} + +NS_IMETHODIMP +nsDocShell::SetForcedColorsOverride(ForcedColorsOverride aForcedColorsOverride) { + mForcedColorsOverride = aForcedColorsOverride; + RefPtr presContext = GetPresContext(); + if (presContext) { + presContext->MediaFeatureValuesChanged( + {MediaFeatureChangeReason::SystemMetricsChange}, + MediaFeatureChangePropagation::JustThisDocument); + } + return NS_OK; +} + +// =============== Juggler End ======================= + NS_IMETHODIMP nsDocShell::GetIsNavigating(bool* aOut) { *aOut = mIsNavigating; @@ -4721,7 +4972,7 @@ nsDocShell::GetVisibility(bool* aVisibility) { } void nsDocShell::ActivenessMaybeChanged() { - const bool isActive = mBrowsingContext->IsActive(); + const bool isActive = mForceActiveState || mBrowsingContext->IsActive(); if (RefPtr presShell = GetPresShell()) { presShell->ActivenessMaybeChanged(); } @@ -8429,6 +8680,12 @@ nsresult nsDocShell::PerformRetargeting(nsDocShellLoadState* aLoadState) { true, // aForceNoOpener getter_AddRefs(newBC)); MOZ_ASSERT(!newBC); + if (rv == NS_OK) { + nsCOMPtr observerService = mozilla::services::GetObserverService(); + if (observerService) { + observerService->NotifyObservers(GetAsSupports(this), "juggler-window-open-in-new-context", nullptr); + } + } return rv; } @@ -12454,6 +12711,9 @@ class OnLinkClickEvent : public Runnable { mHandler->OnLinkClickSync(mContent, mLoadState, mNoOpenerImplied, mTriggeringPrincipal); } + nsCOMPtr observerService = mozilla::services::GetObserverService(); + observerService->NotifyObservers(ToSupports(mContent), "juggler-link-click-sync", nullptr); + return NS_OK; } @@ -12532,6 +12792,8 @@ nsresult nsDocShell::OnLinkClick( nsCOMPtr ev = new OnLinkClickEvent(this, aContent, loadState, noOpenerImplied, aIsTrusted, aTriggeringPrincipal); + nsCOMPtr observerService = mozilla::services::GetObserverService(); + observerService->NotifyObservers(ToSupports(aContent), "juggler-link-click", nullptr); return Dispatch(TaskCategory::UI, ev.forget()); } diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 0be1c873204e50eb5c7846ce29939a13faa10ec4..f3e277dc9ddda9984a199a56d0b8558327393b2a 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -16,6 +16,7 @@ #include "mozilla/UniquePtr.h" #include "mozilla/WeakPtr.h" #include "mozilla/dom/BrowsingContext.h" +#include "mozilla/dom/Element.h" #include "mozilla/dom/WindowProxyHolder.h" #include "nsCOMPtr.h" #include "nsCharsetSource.h" @@ -77,6 +78,7 @@ class nsCommandManager; class nsDocShellEditorData; class nsDOMNavigationTiming; class nsDSURIContentListener; +class nsGeolocationService; class nsGlobalWindowOuter; class FramingChecker; @@ -403,6 +405,15 @@ class nsDocShell final : public nsDocLoader, void SetWillChangeProcess() { mWillChangeProcess = true; } bool WillChangeProcess() { return mWillChangeProcess; } + bool IsFileInputInterceptionEnabled(); + void FilePickerShown(mozilla::dom::Element* element); + + bool ShouldOverrideHasFocus() const; + + bool IsBypassCSPEnabled(); + + RefPtr GetGeolocationServiceOverride(); + // Create a content viewer within this nsDocShell for the given // `WindowGlobalChild` actor. nsresult CreateContentViewerForActor( @@ -1002,6 +1013,8 @@ class nsDocShell final : public nsDocLoader, bool CSSErrorReportingEnabled() const { return mCSSErrorReportingEnabled; } + nsDocShell* GetRootDocShell(); + // Handles retrieval of subframe session history for nsDocShell::LoadURI. If a // load is requested in a subframe of the current DocShell, the subframe // loadType may need to reflect the loadType of the parent document, or in @@ -1253,6 +1266,17 @@ class nsDocShell final : public nsDocLoader, bool mAllowDNSPrefetch : 1; bool mAllowWindowControl : 1; bool mCSSErrorReportingEnabled : 1; + bool mFileInputInterceptionEnabled: 1; + bool mOverrideHasFocus : 1; + bool mBypassCSPEnabled : 1; + bool mForceActiveState : 1; + nsString mLanguageOverride; + RefPtr mGeolocationServiceOverride; + OnlineOverride mOnlineOverride; + ColorSchemeOverride mColorSchemeOverride; + ReducedMotionOverride mReducedMotionOverride; + ForcedColorsOverride mForcedColorsOverride; + bool mAllowAuth : 1; bool mAllowKeywordFixup : 1; bool mDisableMetaRefreshWhenInactive : 1; diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl index 352b70d120305c3c643313020ed49652b2f14672..1a18f478363cab370a6f80c80a7fc71eac22e0a2 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -44,6 +44,7 @@ interface nsIURI; interface nsIChannel; interface nsIContentViewer; interface nsIContentSecurityPolicy; +interface nsIDOMGeoPosition; interface nsIEditor; interface nsIEditingSession; interface nsIInputStream; @@ -829,6 +830,49 @@ interface nsIDocShell : nsIDocShellTreeItem */ void synchronizeLayoutHistoryState(); + attribute boolean fileInputInterceptionEnabled; + + attribute boolean overrideHasFocus; + + attribute boolean bypassCSPEnabled; + + attribute boolean forceActiveState; + + attribute AString languageOverride; + + boolean overrideTimezone(in AString timezoneId); + + cenum OnlineOverride: 8 { + ONLINE_OVERRIDE_NONE = 0, + ONLINE_OVERRIDE_ONLINE = 1, + ONLINE_OVERRIDE_OFFLINE = 2, + }; + [infallible] attribute nsIDocShell_OnlineOverride onlineOverride; + + cenum ColorSchemeOverride : 8 { + COLOR_SCHEME_OVERRIDE_LIGHT, + COLOR_SCHEME_OVERRIDE_DARK, + COLOR_SCHEME_OVERRIDE_NO_PREFERENCE, + COLOR_SCHEME_OVERRIDE_NONE, /* This clears the override. */ + }; + [infallible] attribute nsIDocShell_ColorSchemeOverride colorSchemeOverride; + + cenum ReducedMotionOverride : 8 { + REDUCED_MOTION_OVERRIDE_REDUCE, + REDUCED_MOTION_OVERRIDE_NO_PREFERENCE, + REDUCED_MOTION_OVERRIDE_NONE, /* This clears the override. */ + }; + [infallible] attribute nsIDocShell_ReducedMotionOverride reducedMotionOverride; + + cenum ForcedColorsOverride : 8 { + FORCED_COLORS_OVERRIDE_ACTIVE, + FORCED_COLORS_OVERRIDE_NONE, + FORCED_COLORS_OVERRIDE_NO_OVERRIDE, /* This clears the override. */ + }; + [infallible] attribute nsIDocShell_ForcedColorsOverride forcedColorsOverride; + + void setGeolocationOverride(in nsIDOMGeoPosition position); + /** * This attempts to save any applicable layout history state (like * scroll position) in the nsISHEntry. This is normally done diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 28ecd71ece6b46ba7c68391a30588d51d3b56d1e..331955ca8f3f2afad73153e00b39a5eeccbde17e 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -3494,6 +3494,9 @@ void Document::SendToConsole(nsCOMArray& aMessages) { } void Document::ApplySettingsFromCSP(bool aSpeculative) { + if (mDocumentContainer && mDocumentContainer->IsBypassCSPEnabled()) + return; + nsresult rv = NS_OK; if (!aSpeculative) { // 1) apply settings from regular CSP @@ -3556,6 +3559,11 @@ nsresult Document::InitCSP(nsIChannel* aChannel) { return NS_OK; } + nsCOMPtr shell(mDocumentContainer); + if (shell && nsDocShell::Cast(shell)->IsBypassCSPEnabled()) { + return NS_OK; + } + // If this is a data document - no need to set CSP. if (mLoadedAsData) { return NS_OK; @@ -4341,6 +4349,10 @@ bool Document::HasFocus(ErrorResult& rv) const { return false; } + if (IsActive() && mDocumentContainer->ShouldOverrideHasFocus()) { + return true; + } + if (!fm->IsInActiveWindow(bc)) { return false; } @@ -17090,6 +17102,20 @@ void Document::RemoveToplevelLoadingDocument(Document* aDoc) { StylePrefersColorScheme Document::PrefersColorScheme( IgnoreRFP aIgnoreRFP) const { + auto* docShell = static_cast(GetDocShell()); + nsIDocShell::ColorSchemeOverride colorScheme; + if (docShell && docShell->GetColorSchemeOverride(&colorScheme) == NS_OK && + colorScheme != nsIDocShell::COLOR_SCHEME_OVERRIDE_NONE) { + switch (colorScheme) { + case nsIDocShell::COLOR_SCHEME_OVERRIDE_LIGHT: + return StylePrefersColorScheme::Light; + case nsIDocShell::COLOR_SCHEME_OVERRIDE_DARK: + return StylePrefersColorScheme::Dark; + case nsIDocShell::COLOR_SCHEME_OVERRIDE_NONE: + case nsIDocShell::COLOR_SCHEME_OVERRIDE_NO_PREFERENCE: + break; + }; + } if (aIgnoreRFP == IgnoreRFP::No && nsContentUtils::ShouldResistFingerprinting(this)) { return StylePrefersColorScheme::Light; @@ -17118,6 +17144,71 @@ StylePrefersColorScheme Document::PrefersColorScheme( return dark ? StylePrefersColorScheme::Dark : StylePrefersColorScheme::Light; } +bool Document::PrefersReducedMotion() const { + auto* docShell = static_cast(GetDocShell()); + nsIDocShell::ReducedMotionOverride reducedMotion; + if (docShell && docShell->GetReducedMotionOverride(&reducedMotion) == NS_OK && + reducedMotion != nsIDocShell::REDUCED_MOTION_OVERRIDE_NONE) { + switch (reducedMotion) { + case nsIDocShell::REDUCED_MOTION_OVERRIDE_REDUCE: + return true; + case nsIDocShell::REDUCED_MOTION_OVERRIDE_NO_PREFERENCE: + return false; + case nsIDocShell::REDUCED_MOTION_OVERRIDE_NONE: + break; + }; + } + + if (auto* bc = GetBrowsingContext()) { + switch (bc->Top()->PrefersReducedMotionOverride()) { + case dom::PrefersReducedMotionOverride::Reduce: + return true; + case dom::PrefersReducedMotionOverride::No_preference: + return false; + case dom::PrefersReducedMotionOverride::None: + case dom::PrefersReducedMotionOverride::EndGuard_: + break; + } + } + + if (nsContentUtils::ShouldResistFingerprinting(this)) { + return false; + } + return LookAndFeel::GetInt(LookAndFeel::IntID::PrefersReducedMotion, 0) == 1; +} + +bool Document::ForcedColors() const { + auto* docShell = static_cast(GetDocShell()); + nsIDocShell::ForcedColorsOverride forcedColors; + if (docShell && docShell->GetForcedColorsOverride(&forcedColors) == NS_OK) { + switch (forcedColors) { + case nsIDocShell::FORCED_COLORS_OVERRIDE_ACTIVE: + return true; + case nsIDocShell::FORCED_COLORS_OVERRIDE_NONE: + return false; + case nsIDocShell::FORCED_COLORS_OVERRIDE_NO_OVERRIDE: + break; + }; + } + + if (auto* bc = GetBrowsingContext()) { + switch (bc->Top()->ForcedColorsOverride()) { + case dom::ForcedColorsOverride::Active: + return true; + case dom::ForcedColorsOverride::None: + return false; + case dom::ForcedColorsOverride::No_override: + case dom::ForcedColorsOverride::EndGuard_: + break; + } + } + + if (mIsBeingUsedAsImage) { + return false; + } + return !PreferenceSheet::PrefsFor(*this).mUseDocumentColors; +} + // static bool Document::UseOverlayScrollbars(const Document* aDocument) { BrowsingContext* bc = aDocument ? aDocument->GetBrowsingContext() : nullptr; diff --git a/dom/base/Document.h b/dom/base/Document.h index 8ac8d56ff541ca5f8959d09b9196d323323e74c9..ba2d7738232e7f03d46e60e71183c1b6de0ddeeb 100644 --- a/dom/base/Document.h +++ b/dom/base/Document.h @@ -3984,6 +3984,9 @@ class Document : public nsINode, enum class IgnoreRFP { No, Yes }; StylePrefersColorScheme PrefersColorScheme(IgnoreRFP = IgnoreRFP::No) const; + bool PrefersReducedMotion() const; + bool ForcedColors() const; + // Returns true if we use overlay scrollbars on the system wide or on the // given document. static bool UseOverlayScrollbars(const Document* aDocument); diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 1a2bea9e1568e697f0653af7fc6cab6f38c5f930..bc8d3a0a7c687a8171213b1438016fbdc2022bad 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -323,14 +323,18 @@ void Navigator::GetAppName(nsAString& aAppName, CallerType aCallerType) const { * for more detail. */ /* static */ -void Navigator::GetAcceptLanguages(nsTArray& aLanguages) { +void Navigator::GetAcceptLanguages(const nsString* aLanguageOverride, nsTArray& aLanguages) { MOZ_ASSERT(NS_IsMainThread()); aLanguages.Clear(); // E.g. "de-de, en-us,en". nsAutoString acceptLang; - Preferences::GetLocalizedString("intl.accept_languages", acceptLang); + if (aLanguageOverride && aLanguageOverride->Length()) + acceptLang = *aLanguageOverride; + else + Preferences::GetLocalizedString("intl.accept_languages", acceptLang); + // Split values on commas. for (nsDependentSubstring lang : @@ -382,7 +386,9 @@ void Navigator::GetLanguage(nsAString& aLanguage) { } void Navigator::GetLanguages(nsTArray& aLanguages) { - GetAcceptLanguages(aLanguages); + nsString languageOverride; + mWindow->GetDocShell()->GetLanguageOverride(languageOverride); + GetAcceptLanguages(&languageOverride, aLanguages); // The returned value is cached by the binding code. The window listens to the // accept languages change and will clear the cache when needed. It has to @@ -550,7 +556,13 @@ bool Navigator::CookieEnabled() { return granted; } -bool Navigator::OnLine() { return !NS_IsOffline(); } +bool Navigator::OnLine() { + nsDocShell* docShell = static_cast(GetDocShell()); + nsIDocShell::OnlineOverride onlineOverride; + if (!docShell || docShell->GetOnlineOverride(&onlineOverride) != NS_OK || onlineOverride == nsIDocShell::ONLINE_OVERRIDE_NONE) + return !NS_IsOffline(); + return onlineOverride == nsIDocShell::ONLINE_OVERRIDE_ONLINE; +} void Navigator::GetBuildID(nsAString& aBuildID, CallerType aCallerType, ErrorResult& aRv) const { diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 5bd681978b6da3cc677f47d5e46348338a04db6b..0145cb0c8f852d2229129add9d459d12789fec70 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -213,7 +213,7 @@ class Navigator final : public nsISupports, public nsWrapperCache { StorageManager* Storage(); - static void GetAcceptLanguages(nsTArray& aLanguages); + static void GetAcceptLanguages(const nsString* aLanguageOverride, nsTArray& aLanguages); dom::MediaCapabilities* MediaCapabilities(); dom::MediaSession* MediaSession(); diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 0ea50461840c59a299705c1f039a490e1b4df1eb..108cbe22d4530eef16f9a3fe8686e757046f8b26 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -8198,7 +8198,8 @@ nsresult nsContentUtils::SendMouseEvent( bool aIgnoreRootScrollFrame, float aPressure, unsigned short aInputSourceArg, uint32_t aIdentifier, bool aToWindow, PreventDefaultResult* aPreventDefault, bool aIsDOMEventSynthesized, - bool aIsWidgetEventSynthesized) { + bool aIsWidgetEventSynthesized, + bool convertToPointer) { nsPoint offset; nsCOMPtr widget = GetWidget(aPresShell, &offset); if (!widget) return NS_ERROR_FAILURE; @@ -8255,6 +8256,7 @@ nsresult nsContentUtils::SendMouseEvent( event.mTime = PR_IntervalNow(); event.mFlags.mIsSynthesizedForTests = aIsDOMEventSynthesized; event.mExitFrom = exitFrom; + event.convertToPointer = convertToPointer; nsPresContext* presContext = aPresShell->GetPresContext(); if (!presContext) return NS_ERROR_FAILURE; diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 94805199a8fd5e018025aa8c4a56ab55b3464446..85f6840dbf0820e0c837df773c6e312181581bc9 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -2922,7 +2922,8 @@ class nsContentUtils { int32_t aModifiers, bool aIgnoreRootScrollFrame, float aPressure, unsigned short aInputSourceArg, uint32_t aIdentifier, bool aToWindow, mozilla::PreventDefaultResult* aPreventDefault, - bool aIsDOMEventSynthesized, bool aIsWidgetEventSynthesized); + bool aIsDOMEventSynthesized, bool aIsWidgetEventSynthesized, + bool convertToPointer = true); static void FirePageShowEventForFrameLoaderSwap( nsIDocShellTreeItem* aItem, diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 816f159566ce396b7ff32d2553c7052fb5ab16ac..8a6075314893cf9ad8a751a02660e1c06a3172ca 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -692,7 +692,7 @@ nsDOMWindowUtils::SendMouseEvent( int32_t aClickCount, int32_t aModifiers, bool aIgnoreRootScrollFrame, float aPressure, unsigned short aInputSourceArg, bool aIsDOMEventSynthesized, bool aIsWidgetEventSynthesized, - int32_t aButtons, uint32_t aIdentifier, uint8_t aOptionalArgCount, + int32_t aButtons, uint32_t aIdentifier, bool aDisablePointerEvent, uint8_t aOptionalArgCount, bool* aPreventDefault) { return SendMouseEventCommon( aType, aX, aY, aButton, aClickCount, aModifiers, aIgnoreRootScrollFrame, @@ -700,7 +700,7 @@ nsDOMWindowUtils::SendMouseEvent( aOptionalArgCount >= 7 ? aIdentifier : DEFAULT_MOUSE_POINTER_ID, false, aPreventDefault, aOptionalArgCount >= 4 ? aIsDOMEventSynthesized : true, aOptionalArgCount >= 5 ? aIsWidgetEventSynthesized : false, - aOptionalArgCount >= 6 ? aButtons : MOUSE_BUTTONS_NOT_SPECIFIED); + aOptionalArgCount >= 6 ? aButtons : MOUSE_BUTTONS_NOT_SPECIFIED, !aDisablePointerEvent); } NS_IMETHODIMP @@ -727,13 +727,13 @@ nsDOMWindowUtils::SendMouseEventCommon( int32_t aClickCount, int32_t aModifiers, bool aIgnoreRootScrollFrame, float aPressure, unsigned short aInputSourceArg, uint32_t aPointerId, bool aToWindow, bool* aPreventDefault, bool aIsDOMEventSynthesized, - bool aIsWidgetEventSynthesized, int32_t aButtons) { + bool aIsWidgetEventSynthesized, int32_t aButtons, bool aConvertToPointer) { RefPtr presShell = GetPresShell(); PreventDefaultResult preventDefaultResult; nsresult rv = nsContentUtils::SendMouseEvent( presShell, aType, aX, aY, aButton, aButtons, aClickCount, aModifiers, aIgnoreRootScrollFrame, aPressure, aInputSourceArg, aPointerId, aToWindow, - &preventDefaultResult, aIsDOMEventSynthesized, aIsWidgetEventSynthesized); + &preventDefaultResult, aIsDOMEventSynthesized, aIsWidgetEventSynthesized, aConvertToPointer); if (aPreventDefault) { *aPreventDefault = preventDefaultResult != PreventDefaultResult::No; diff --git a/dom/base/nsDOMWindowUtils.h b/dom/base/nsDOMWindowUtils.h index 08e81b1c24a17729ec7b6c9e048c2febe57e18dc..cb09fe30de0a42c89da220e3bf8afe5f05923084 100644 --- a/dom/base/nsDOMWindowUtils.h +++ b/dom/base/nsDOMWindowUtils.h @@ -93,7 +93,7 @@ class nsDOMWindowUtils final : public nsIDOMWindowUtils, int32_t aClickCount, int32_t aModifiers, bool aIgnoreRootScrollFrame, float aPressure, unsigned short aInputSourceArg, uint32_t aIdentifier, bool aToWindow, bool* aPreventDefault, bool aIsDOMEventSynthesized, - bool aIsWidgetEventSynthesized, int32_t aButtons); + bool aIsWidgetEventSynthesized, int32_t aButtons, bool aConvertToPointer = true); MOZ_CAN_RUN_SCRIPT nsresult SendTouchEventCommon( diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 8ee36305d1a74b6d4cf0cbb985bac8aa7b4c95d4..adbac6b3380b4e2ce88de991e03975aa9fc1c616 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -1603,6 +1603,10 @@ void nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags, (GetActiveBrowsingContext() == newRootBrowsingContext); } + // In Playwright, we want to send focus events even if the element + // isn't actually in the active window. + isElementInActiveWindow = true; + // Exit fullscreen if a website focuses another window if (StaticPrefs::full_screen_api_exit_on_windowRaise() && !isElementInActiveWindow && (aFlags & FLAG_RAISE) && @@ -2870,7 +2874,9 @@ void nsFocusManager::RaiseWindow(nsPIDOMWindowOuter* aWindow, } } - if (sTestMode) { + // In Playwright, we still want to execte the embedder functions + // to actually show / focus windows. + if (false && sTestMode) { // In test mode, emulate raising the window. WindowRaised takes // care of lowering the present active window. This happens in // a separate runnable to avoid touching multiple windows in diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index 7f932f97d3c3c5ca365f6ef4e4c5c57900d2ef98..3dee48d1c7aa1aec725fcc6e9cf116cbd922df0b 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -2466,7 +2466,7 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument, &nsGlobalWindowInner::FireOnNewGlobalObject)); } - if (newInnerWindow && !newInnerWindow->mHasNotifiedGlobalCreated && mDoc) { + if (newInnerWindow && mDoc) { // We should probably notify. However if this is the, arguably bad, // situation when we're creating a temporary non-chrome-about-blank // document in a chrome docshell, don't notify just yet. Instead wait @@ -2485,10 +2485,16 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument, }(); if (!isContentAboutBlankInChromeDocshell) { - newInnerWindow->mHasNotifiedGlobalCreated = true; - nsContentUtils::AddScriptRunner(NewRunnableMethod( - "nsGlobalWindowOuter::DispatchDOMWindowCreated", this, - &nsGlobalWindowOuter::DispatchDOMWindowCreated)); + if (!newInnerWindow->mHasNotifiedGlobalCreated) { + newInnerWindow->mHasNotifiedGlobalCreated = true; + nsContentUtils::AddScriptRunner(NewRunnableMethod( + "nsGlobalWindowOuter::DispatchDOMWindowCreated", this, + &nsGlobalWindowOuter::DispatchDOMWindowCreated)); + } else if (!reUseInnerWindow) { + nsContentUtils::AddScriptRunner(NewRunnableMethod( + "nsGlobalWindowOuter::JugglerDispatchDOMWindowReused", this, + &nsGlobalWindowOuter::JugglerDispatchDOMWindowReused)); + } } } @@ -2612,6 +2618,19 @@ void nsGlobalWindowOuter::DispatchDOMWindowCreated() { } } +void nsGlobalWindowOuter::JugglerDispatchDOMWindowReused() { + nsCOMPtr observerService = + mozilla::services::GetObserverService(); + if (observerService && mDoc) { + nsIPrincipal* principal = mDoc->NodePrincipal(); + if (!principal->IsSystemPrincipal()) { + observerService->NotifyObservers(static_cast(this), + "juggler-dom-window-reused", + nullptr); + } + } +} + void nsGlobalWindowOuter::ClearStatus() { SetStatusOuter(u""_ns); } void nsGlobalWindowOuter::SetDocShell(nsDocShell* aDocShell) { @@ -3831,6 +3850,14 @@ Maybe nsGlobalWindowOuter::GetRDMDeviceSize( } } } + if (topInProcessContentDoc) { + nsIDocShell* docShell = topInProcessContentDoc->GetDocShell(); + if (docShell && docShell->GetDeviceSizeIsPageSize()) { + nsPresContext* presContext = docShell->GetPresContext(); + if (presContext) + return Some(CSSPixel::FromAppUnitsRounded(presContext->GetVisibleArea().Size())); + } + } return Nothing(); } diff --git a/dom/base/nsGlobalWindowOuter.h b/dom/base/nsGlobalWindowOuter.h index 3c13c26f115ce32fe0e1cd898c6d4fac2038def1..4cd5102940a99baf2cb55141664c7b15d3adff82 100644 --- a/dom/base/nsGlobalWindowOuter.h +++ b/dom/base/nsGlobalWindowOuter.h @@ -324,6 +324,7 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget, // Outer windows only. void DispatchDOMWindowCreated(); + void JugglerDispatchDOMWindowReused(); // Outer windows only. virtual void EnsureSizeAndPositionUpToDate() override; diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp index 2b33f0aaf3ddffd9ab4a118a4cdc4a9cb75fe9bc..ee50ed644afc419b85ff3e37fc931efdf427dbbb 100644 --- a/dom/base/nsINode.cpp +++ b/dom/base/nsINode.cpp @@ -1289,6 +1289,49 @@ void nsINode::GetBoxQuadsFromWindowOrigin(const BoxQuadOptions& aOptions, mozilla::GetBoxQuadsFromWindowOrigin(this, aOptions, aResult, aRv); } +void nsINode::ScrollRectIntoViewIfNeeded(int32_t x, int32_t y, + int32_t w, int32_t h, + ErrorResult& aRv) { + aRv = NS_ERROR_UNEXPECTED; + nsCOMPtr document = OwnerDoc(); + if (!document) { + return aRv.ThrowNotFoundError("Node is detached from document"); + } + PresShell* presShell = document->GetPresShell(); + if (!presShell) { + return aRv.ThrowNotFoundError("Node is detached from document"); + } + if (!IsContent()) { + return aRv.ThrowNotFoundError("Node does not have a layout object"); + } + aRv = NS_OK; + nsIFrame* primaryFrame = AsContent()->GetPrimaryFrame(FlushType::Frames); + if (!primaryFrame) { + return aRv.ThrowNotFoundError("Node does not have a layout object"); + } + nsRect rect; + if (x == -1 && y == -1 && w == -1 && h == -1) { + rect = primaryFrame->GetRectRelativeToSelf(); + } else { + rect = nsRect(nsPresContext::CSSPixelsToAppUnits(x), + nsPresContext::CSSPixelsToAppUnits(y), + nsPresContext::CSSPixelsToAppUnits(w), + nsPresContext::CSSPixelsToAppUnits(h)); + } + presShell->ScrollFrameRectIntoView( + primaryFrame, rect, + nsMargin(), + ScrollAxis(kScrollToCenter, WhenToScroll::Always), + ScrollAxis(kScrollToCenter, WhenToScroll::Always), + ScrollFlags::ScrollOverflowHidden); + // If a _visual_ scroll update is pending, cancel it; otherwise, it will + // clobber next scroll (e.g. subsequent window.scrollTo(0, 0) wlll break). + if (presShell->GetPendingVisualScrollUpdate()) { + presShell->AcknowledgePendingVisualScrollUpdate(); + presShell->ClearPendingVisualScrollUpdate(); + } +} + already_AddRefed nsINode::ConvertQuadFromNode( DOMQuad& aQuad, const GeometryNode& aFrom, const ConvertCoordinateOptions& aOptions, CallerType aCallerType, diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h index fe58672e90019bb52d2c67dc499c09879cd20f32..d2f7c9adb75925682cbef28cd162f86b16dacc49 100644 --- a/dom/base/nsINode.h +++ b/dom/base/nsINode.h @@ -2060,6 +2060,10 @@ class nsINode : public mozilla::dom::EventTarget { nsTArray>& aResult, ErrorResult& aRv); + void ScrollRectIntoViewIfNeeded(int32_t x, int32_t y, + int32_t w, int32_t h, + ErrorResult& aRv); + already_AddRefed ConvertQuadFromNode( DOMQuad& aQuad, const TextOrElementOrDocument& aFrom, const ConvertCoordinateOptions& aOptions, CallerType aCallerType, diff --git a/dom/base/nsJSUtils.cpp b/dom/base/nsJSUtils.cpp index e80aeccd572446f7c35f554510a98b11bd01dfab..2edb82b914c2a2c4ed36ee663a7c54da91df5690 100644 --- a/dom/base/nsJSUtils.cpp +++ b/dom/base/nsJSUtils.cpp @@ -242,6 +242,11 @@ bool nsJSUtils::GetScopeChainForElement( return true; } +/* static */ +bool nsJSUtils::SetTimeZoneOverride(const char* timezoneId) { + return JS::SetTimeZoneOverride(timezoneId); +} + /* static */ void nsJSUtils::ResetTimeZone() { JS::ResetTimeZone(); } diff --git a/dom/base/nsJSUtils.h b/dom/base/nsJSUtils.h index 4f4d35ba7addcc0f6fa4253ec25f334b7a68069c..319caf7c10b29076b2c60ecfd7b9d477445c908f 100644 --- a/dom/base/nsJSUtils.h +++ b/dom/base/nsJSUtils.h @@ -105,6 +105,7 @@ class nsJSUtils { JSContext* aCx, mozilla::dom::Element* aElement, JS::MutableHandleVector aScopeChain); + static bool SetTimeZoneOverride(const char* timezoneId); static void ResetTimeZone(); static bool DumpEnabled(); diff --git a/dom/chrome-webidl/BrowsingContext.webidl b/dom/chrome-webidl/BrowsingContext.webidl index 3770bede80e270764d99423d43b865e5d77b48ff..6779ca105cacb316f422374a0695a1d1eb651cf5 100644 --- a/dom/chrome-webidl/BrowsingContext.webidl +++ b/dom/chrome-webidl/BrowsingContext.webidl @@ -52,6 +52,24 @@ enum PrefersColorSchemeOverride { "dark", }; +/** + * CSS prefers-reduced-motion values. + */ +enum PrefersReducedMotionOverride { + "none", + "reduce", + "no-preference", +}; + +/** + * CSS forced-colors values. + */ +enum ForcedColorsOverride { + "none", + "active", + "no-override", /* This clears the override. */ +}; + /** * Allowed overrides of platform/pref default behaviour for touch events. */ @@ -175,6 +193,12 @@ interface BrowsingContext { // Color-scheme simulation, for DevTools. [SetterThrows] attribute PrefersColorSchemeOverride prefersColorSchemeOverride; + // Reduced-Motion simulation, for DevTools. + [SetterThrows] attribute PrefersReducedMotionOverride prefersReducedMotionOverride; + + // Forced-Colors simulation, for DevTools. + [SetterThrows] attribute ForcedColorsOverride forcedColorsOverride; + /** * A unique identifier for the browser element that is hosting this * BrowsingContext tree. Every BrowsingContext in the element's tree will diff --git a/dom/geolocation/Geolocation.cpp b/dom/geolocation/Geolocation.cpp index 763192a50cf8dce36eaf1fd2b470c631eecfe65c..436f01a2ca6166f1a97139f1cda7e1832b9df36c 100644 --- a/dom/geolocation/Geolocation.cpp +++ b/dom/geolocation/Geolocation.cpp @@ -23,6 +23,7 @@ #include "nsComponentManagerUtils.h" #include "nsContentPermissionHelper.h" #include "nsContentUtils.h" +#include "nsDocShell.h" #include "nsGlobalWindow.h" #include "mozilla/dom/Document.h" #include "nsINamed.h" @@ -254,10 +255,8 @@ nsGeolocationRequest::Allow(JS::HandleValue aChoices) { return NS_OK; } - RefPtr gs = - nsGeolocationService::GetGeolocationService(); - - bool canUseCache = false; + nsGeolocationService* gs = mLocator->GetGeolocationService(); + bool canUseCache = gs != nsGeolocationService::sService.get(); CachedPositionAndAccuracy lastPosition = gs->GetCachedPosition(); if (lastPosition.position) { DOMTimeStamp cachedPositionTime_ms; @@ -431,8 +430,7 @@ void nsGeolocationRequest::Shutdown() { // If there are no other high accuracy requests, the geolocation service will // notify the provider to switch to the default accuracy. if (mOptions && mOptions->mEnableHighAccuracy) { - RefPtr gs = - nsGeolocationService::GetGeolocationService(); + nsGeolocationService* gs = mLocator ? mLocator->GetGeolocationService() : nullptr; if (gs) { gs->UpdateAccuracy(); } @@ -708,8 +706,14 @@ void nsGeolocationService::StopDevice() { StaticRefPtr nsGeolocationService::sService; already_AddRefed -nsGeolocationService::GetGeolocationService() { +nsGeolocationService::GetGeolocationService(nsDocShell* docShell) { RefPtr result; + if (docShell) { + result = docShell->GetGeolocationServiceOverride(); + if (result) + return result.forget(); + } + if (nsGeolocationService::sService) { result = nsGeolocationService::sService; @@ -801,7 +805,9 @@ nsresult Geolocation::Init(nsPIDOMWindowInner* aContentDom) { // If no aContentDom was passed into us, we are being used // by chrome/c++ and have no mOwner, no mPrincipal, and no need // to prompt. - mService = nsGeolocationService::GetGeolocationService(); + nsCOMPtr doc = aContentDom ? aContentDom->GetDoc() : nullptr; + mService = nsGeolocationService::GetGeolocationService( + doc ? static_cast(doc->GetDocShell()) : nullptr); if (mService) { mService->AddLocator(this); } diff --git a/dom/geolocation/Geolocation.h b/dom/geolocation/Geolocation.h index d92bd1c738016f93c66dbdc449c70937c37b6f9a..16fb91cc37b5ce2a8522c56e61e5aed89033a0b8 100644 --- a/dom/geolocation/Geolocation.h +++ b/dom/geolocation/Geolocation.h @@ -31,6 +31,7 @@ #include "nsIGeolocationProvider.h" #include "mozilla/Attributes.h" +#include "nsDocShell.h" class nsGeolocationService; class nsGeolocationRequest; @@ -38,6 +39,7 @@ class nsGeolocationRequest; namespace mozilla { namespace dom { class Geolocation; + typedef CallbackObjectHolder GeoPositionCallback; typedef CallbackObjectHolder GetGeolocationService(); + static already_AddRefed GetGeolocationService(nsDocShell* docShell = nullptr); static mozilla::StaticRefPtr sService; NS_DECL_THREADSAFE_ISUPPORTS @@ -182,6 +185,8 @@ class Geolocation final : public nsIGeolocationUpdate, public nsWrapperCache { // null. static already_AddRefed NonWindowSingleton(); + nsGeolocationService* GetGeolocationService() { return mService; }; + private: ~Geolocation(); diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 4d244a48767d7f45544f986ba73b4c1dac722ad8..708170c70edb834f7ceae304e34bb559838d7c0c 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -52,6 +52,7 @@ #include "nsMappedAttributes.h" #include "nsIFormControl.h" #include "mozilla/dom/Document.h" +#include "nsDocShell.h" #include "nsIFormControlFrame.h" #include "nsITextControlFrame.h" #include "nsIFrame.h" @@ -735,6 +736,12 @@ nsresult HTMLInputElement::InitFilePicker(FilePickerType aType) { return NS_ERROR_FAILURE; } + nsDocShell* docShell = static_cast(win->GetDocShell()); + if (docShell && docShell->IsFileInputInterceptionEnabled()) { + docShell->FilePickerShown(this); + return NS_OK; + } + if (IsPopupBlocked(doc)) { return NS_OK; } diff --git a/dom/interfaces/base/nsIDOMWindowUtils.idl b/dom/interfaces/base/nsIDOMWindowUtils.idl index 89caac9753b86d5cc89093dc858f1cbabf17e3ef..2161c945719264f3cc909b2913d0481afd25cd26 100644 --- a/dom/interfaces/base/nsIDOMWindowUtils.idl +++ b/dom/interfaces/base/nsIDOMWindowUtils.idl @@ -353,7 +353,8 @@ interface nsIDOMWindowUtils : nsISupports { [optional] in boolean aIsDOMEventSynthesized, [optional] in boolean aIsWidgetEventSynthesized, [optional] in long aButtons, - [optional] in unsigned long aIdentifier); + [optional] in unsigned long aIdentifier, + [optional] in boolean aDisablePointerEvent); /** Synthesize a touch event. The event types supported are: * touchstart, touchend, touchmove, and touchcancel diff --git a/dom/media/systemservices/video_engine/desktop_capture_impl.cc b/dom/media/systemservices/video_engine/desktop_capture_impl.cc index 7bc92fe4408c2878c9d7c8bdb97a7c257258ee31..b20480c3c0ca96097e61d37f44e127d45ab4648a 100644 --- a/dom/media/systemservices/video_engine/desktop_capture_impl.cc +++ b/dom/media/systemservices/video_engine/desktop_capture_impl.cc @@ -123,10 +123,11 @@ int32_t ScreenDeviceInfoImpl::GetOrientation(const char* deviceUniqueIdUTF8, return 0; } -VideoCaptureModule* DesktopCaptureImpl::Create(const int32_t id, +VideoCaptureModuleEx* DesktopCaptureImpl::Create(const int32_t id, const char* uniqueId, - const CaptureDeviceType type) { - return new rtc::RefCountedObject(id, uniqueId, type); + const CaptureDeviceType type, + bool captureCursor) { + return new rtc::RefCountedObject(id, uniqueId, type, captureCursor); } int32_t WindowDeviceInfoImpl::Init() { @@ -360,12 +361,16 @@ int32_t DesktopCaptureImpl::Init() { DesktopCapturer::SourceId sourceId = atoi(_deviceUniqueId.c_str()); pWindowCapturer->SelectSource(sourceId); - MouseCursorMonitor* pMouseCursorMonitor = - MouseCursorMonitor::CreateForWindow( - webrtc::DesktopCaptureOptions::CreateDefault(), sourceId); - desktop_capturer_cursor_composer_ = - std::unique_ptr(new DesktopAndCursorComposer( - pWindowCapturer.release(), pMouseCursorMonitor)); + if (capture_cursor_) { + MouseCursorMonitor* pMouseCursorMonitor = + MouseCursorMonitor::CreateForWindow( + webrtc::DesktopCaptureOptions::CreateDefault(), sourceId); + desktop_capturer_cursor_composer_ = + std::unique_ptr(new DesktopAndCursorComposer( + pWindowCapturer.release(), pMouseCursorMonitor)); + } else { + desktop_capturer_cursor_composer_ = std::move(pWindowCapturer); + } } else if (_deviceType == CaptureDeviceType::Browser) { // XXX We don't capture cursors, so avoid the extra indirection layer. We // could also pass null for the pMouseCursorMonitor. @@ -382,7 +387,8 @@ int32_t DesktopCaptureImpl::Init() { } DesktopCaptureImpl::DesktopCaptureImpl(const int32_t id, const char* uniqueId, - const CaptureDeviceType type) + const CaptureDeviceType type, + bool captureCursor) : _id(id), _deviceUniqueId(uniqueId), _deviceType(type), @@ -393,6 +399,7 @@ DesktopCaptureImpl::DesktopCaptureImpl(const int32_t id, const char* uniqueId, delta_ntp_internal_ms_( Clock::GetRealTimeClock()->CurrentNtpInMilliseconds() - last_capture_time_), + capture_cursor_(captureCursor), time_event_(EventWrapper::Create()), #if defined(_WIN32) capturer_thread_( @@ -437,6 +444,19 @@ void DesktopCaptureImpl::DeRegisterCaptureDataCallback( } } +void DesktopCaptureImpl::RegisterRawFrameCallback(RawFrameCallback* rawFrameCallback) { + rtc::CritScope lock(&_apiCs); + _rawFrameCallbacks.insert(rawFrameCallback); +} + +void DesktopCaptureImpl::DeRegisterRawFrameCallback(RawFrameCallback* rawFrameCallback) { + rtc::CritScope lock(&_apiCs); + auto it = _rawFrameCallbacks.find(rawFrameCallback); + if (it != _rawFrameCallbacks.end()) { + _rawFrameCallbacks.erase(it); + } +} + int32_t DesktopCaptureImpl::StopCaptureIfAllClientsClose() { if (_dataCallBacks.empty()) { return StopCapture(); @@ -644,6 +664,12 @@ void DesktopCaptureImpl::OnCaptureResult(DesktopCapturer::Result result, frameInfo.height = frame->size().height(); frameInfo.videoType = VideoType::kARGB; + size_t videoFrameStride = + frameInfo.width * DesktopFrame::kBytesPerPixel; + for (auto rawFrameCallback : _rawFrameCallbacks) { + rawFrameCallback->OnRawFrame(videoFrame, videoFrameStride, frameInfo); + } + size_t videoFrameLength = frameInfo.width * frameInfo.height * DesktopFrame::kBytesPerPixel; IncomingFrame(videoFrame, videoFrameLength, frameInfo); diff --git a/dom/media/systemservices/video_engine/desktop_capture_impl.h b/dom/media/systemservices/video_engine/desktop_capture_impl.h index 137281596e66793b8525ca2a5d156b4bd171da65..0e64c0b810b306e4a2509e4ad0d9596034d338fa 100644 --- a/dom/media/systemservices/video_engine/desktop_capture_impl.h +++ b/dom/media/systemservices/video_engine/desktop_capture_impl.h @@ -42,6 +42,21 @@ namespace webrtc { class VideoCaptureEncodeInterface; +class RawFrameCallback { + public: + virtual ~RawFrameCallback() {} + + virtual void OnRawFrame(uint8_t* videoFrame, size_t videoFrameLength, const VideoCaptureCapability& frameInfo) = 0; +}; + +class VideoCaptureModuleEx : public VideoCaptureModule { + public: + virtual ~VideoCaptureModuleEx() {} + + virtual void RegisterRawFrameCallback(RawFrameCallback* rawFrameCallback) = 0; + virtual void DeRegisterRawFrameCallback(RawFrameCallback* rawFrameCallback) = 0; +}; + // simulate deviceInfo interface for video engine, bridge screen/application and // real screen/application device info @@ -154,13 +169,14 @@ class BrowserDeviceInfoImpl : public VideoCaptureModule::DeviceInfo { // As with video, DesktopCaptureImpl is a proxy for screen sharing // and follows the video pipeline design class DesktopCaptureImpl : public DesktopCapturer::Callback, - public VideoCaptureModule, + public VideoCaptureModuleEx, public VideoCaptureExternal { public: /* Create a screen capture modules object */ - static VideoCaptureModule* Create(const int32_t id, const char* uniqueId, - const CaptureDeviceType type); + static VideoCaptureModuleEx* Create(const int32_t id, const char* uniqueId, + const CaptureDeviceType type, + bool captureCursor = true); static VideoCaptureModule::DeviceInfo* CreateDeviceInfo( const int32_t id, const CaptureDeviceType type); @@ -170,6 +186,8 @@ class DesktopCaptureImpl : public DesktopCapturer::Callback, void DeRegisterCaptureDataCallback( rtc::VideoSinkInterface* dataCallback) override; int32_t StopCaptureIfAllClientsClose() override; + void RegisterRawFrameCallback(RawFrameCallback* rawFrameCallback) override; + void DeRegisterRawFrameCallback(RawFrameCallback* rawFrameCallback) override; int32_t SetCaptureRotation(VideoRotation rotation) override; bool SetApplyRotation(bool enable) override; @@ -192,7 +210,7 @@ class DesktopCaptureImpl : public DesktopCapturer::Callback, protected: DesktopCaptureImpl(const int32_t id, const char* uniqueId, - const CaptureDeviceType type); + const CaptureDeviceType type, bool captureCursor); virtual ~DesktopCaptureImpl(); int32_t DeliverCapturedFrame(webrtc::VideoFrame& captureFrame, int64_t capture_time); @@ -215,6 +233,7 @@ class DesktopCaptureImpl : public DesktopCapturer::Callback, rtc::CriticalSection _apiCs; std::set*> _dataCallBacks; + std::set _rawFrameCallbacks; int64_t _incomingFrameTimesNanos [kFrameRateCountHistorySize]; // timestamp for local captured frames @@ -240,6 +259,7 @@ class DesktopCaptureImpl : public DesktopCapturer::Callback, void process(); private: + bool capture_cursor_ = true; // This is created on the main thread and accessed on both the main thread // and the capturer thread. It is created prior to the capturer thread // starting and is destroyed after it is stopped. diff --git a/dom/script/ScriptSettings.cpp b/dom/script/ScriptSettings.cpp index d04c0d8cfa1a0b5b677936bf503195df741d159b..e6e78b317491411a36e970c6bf91a67d11821813 100644 --- a/dom/script/ScriptSettings.cpp +++ b/dom/script/ScriptSettings.cpp @@ -178,6 +178,30 @@ ScriptSettingsStackEntry::~ScriptSettingsStackEntry() { MOZ_ASSERT_IF(mGlobalObject, mGlobalObject->HasJSGlobal()); } +static nsIGlobalObject* UnwrapSandboxGlobal(nsIGlobalObject* global) { + if (!global) + return global; + JSObject* globalObject = global->GetGlobalJSObject(); + if (!globalObject) + return global; + JSContext* cx = nsContentUtils::GetCurrentJSContext(); + if (!cx) + return global; + JS::Rooted proto(cx); + JS::RootedObject rootedGlobal(cx, globalObject); + if (!JS_GetPrototype(cx, rootedGlobal, &proto)) + return global; + if (!proto || !xpc::IsSandboxPrototypeProxy(proto)) + return global; + // If this is a sandbox associated with a DOMWindow via a + // sandboxPrototype, use that DOMWindow. This supports GreaseMonkey + // and JetPack content scripts. + proto = js::CheckedUnwrapDynamic(proto, cx, /* stopAtWindowProxy = */ false); + if (!proto) + return global; + return xpc::WindowGlobalOrNull(proto); +} + // If the entry or incumbent global ends up being something that the subject // principal doesn't subsume, we don't want to use it. This never happens on // the web, but can happen with asymmetric privilege relationships (i.e. @@ -205,7 +229,7 @@ static nsIGlobalObject* ClampToSubject(nsIGlobalObject* aGlobalOrNull) { NS_ENSURE_TRUE(globalPrin, GetCurrentGlobal()); if (!nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller() ->SubsumesConsideringDomain(globalPrin)) { - return GetCurrentGlobal(); + return UnwrapSandboxGlobal(GetCurrentGlobal()); } return aGlobalOrNull; diff --git a/dom/security/nsCSPUtils.cpp b/dom/security/nsCSPUtils.cpp index 532c12cd7d447d1d4f3faca3d06b81450b4ede2a..c2d480b3d9924ae469343d5825983ac5132c72ec 100644 --- a/dom/security/nsCSPUtils.cpp +++ b/dom/security/nsCSPUtils.cpp @@ -127,6 +127,11 @@ void CSP_ApplyMetaCSPToDoc(mozilla::dom::Document& aDoc, return; } + if (aDoc.GetDocShell() && + nsDocShell::Cast(aDoc.GetDocShell())->IsBypassCSPEnabled()) { + return; + } + nsAutoString policyStr( nsContentUtils::TrimWhitespace( aPolicyStr)); diff --git a/dom/webidl/GeometryUtils.webidl b/dom/webidl/GeometryUtils.webidl index 2f71b284ee5f7e11f117c447834b48355784448c..d996e0a3cbbb19c1dc320c305c6d74037bffa0d3 100644 --- a/dom/webidl/GeometryUtils.webidl +++ b/dom/webidl/GeometryUtils.webidl @@ -27,6 +27,9 @@ interface mixin GeometryUtils { [Throws, Func="nsINode::HasBoxQuadsSupport", NeedsCallerType] sequence getBoxQuads(optional BoxQuadOptions options = {}); + [ChromeOnly, Throws, Func="nsINode::HasBoxQuadsSupport"] + void scrollRectIntoViewIfNeeded(long x, long y, long w, long h); + /* getBoxQuadsFromWindowOrigin is similar to getBoxQuads, but the * returned quads are further translated relative to the window * origin -- which is not the layout origin. Further translation diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index 3fda0a78fd2359f666877017b171b9214bff722d..710333ce69baa96dcc88f590f8b4314e9f20bbf1 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -1022,7 +1022,7 @@ void PrefLanguagesChanged(const char* /* aPrefName */, void* /* aClosure */) { AssertIsOnMainThread(); nsTArray languages; - Navigator::GetAcceptLanguages(languages); + Navigator::GetAcceptLanguages(nullptr, languages); RuntimeService* runtime = RuntimeService::GetService(); if (runtime) { @@ -1225,8 +1225,7 @@ bool RuntimeService::RegisterWorker(WorkerPrivate& aWorkerPrivate) { } // The navigator overridden properties should have already been read. - - Navigator::GetAcceptLanguages(mNavigatorProperties.mLanguages); + Navigator::GetAcceptLanguages(nullptr, mNavigatorProperties.mLanguages); mNavigatorPropertiesLoaded = true; } @@ -1934,6 +1933,13 @@ void RuntimeService::PropagateStorageAccessPermissionGranted( } } +void RuntimeService::ResetDefaultLocaleInAllWorkers() { + AssertIsOnMainThread(); + BroadcastAllWorkers([](auto& worker) { + worker.ResetDefaultLocale(); + }); +} + void RuntimeService::NoteIdleThread(SafeRefPtr aThread) { AssertIsOnMainThread(); MOZ_ASSERT(aThread); @@ -2352,6 +2358,14 @@ void PropagateStorageAccessPermissionGrantedToWorkers( } } +void ResetDefaultLocaleInAllWorkers() { + AssertIsOnMainThread(); + RuntimeService* runtime = RuntimeService::GetService(); + if (runtime) { + runtime->ResetDefaultLocaleInAllWorkers(); + } +} + WorkerPrivate* GetWorkerPrivateFromContext(JSContext* aCx) { MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(aCx); diff --git a/dom/workers/RuntimeService.h b/dom/workers/RuntimeService.h index 0ca5f99fab6fe97135a0852d538d6fed027ae054..472c00b8b75c4d79e0dd62973445824420e14d2e 100644 --- a/dom/workers/RuntimeService.h +++ b/dom/workers/RuntimeService.h @@ -122,6 +122,8 @@ class RuntimeService final : public nsIObserver { void PropagateStorageAccessPermissionGranted( const nsPIDOMWindowInner& aWindow); + void ResetDefaultLocaleInAllWorkers(); + const NavigatorProperties& GetNavigatorProperties() const { return mNavigatorProperties; } diff --git a/dom/workers/WorkerCommon.h b/dom/workers/WorkerCommon.h index 8b1b46d69f2c90d851d292c285a1ba9bdbd4d9b7..dea5259b0a82e5e6d3c431fc78e60d5df80b3eda 100644 --- a/dom/workers/WorkerCommon.h +++ b/dom/workers/WorkerCommon.h @@ -45,6 +45,8 @@ void ResumeWorkersForWindow(const nsPIDOMWindowInner& aWindow); void PropagateStorageAccessPermissionGrantedToWorkers( const nsPIDOMWindowInner& aWindow); +void ResetDefaultLocaleInAllWorkers(); + // All of these are implemented in WorkerScope.cpp bool IsWorkerGlobal(JSObject* global); diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index af627f33d86d568078d25051108147b2468a7557..d4a29a4f7310e253abd1e3c2d7692d92fdf29c61 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -664,6 +664,18 @@ class UpdateContextOptionsRunnable final : public WorkerControlRunnable { } }; +class ResetDefaultLocaleRunnable final : public WorkerControlRunnable { + public: + explicit ResetDefaultLocaleRunnable(WorkerPrivate* aWorkerPrivate) + : WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount) {} + + virtual bool WorkerRun(JSContext* aCx, + WorkerPrivate* aWorkerPrivate) override { + aWorkerPrivate->ResetDefaultLocaleInternal(aCx); + return true; + } +}; + class UpdateLanguagesRunnable final : public WorkerRunnable { nsTArray mLanguages; @@ -1870,6 +1882,16 @@ void WorkerPrivate::UpdateContextOptions( } } +void WorkerPrivate::ResetDefaultLocale() { + AssertIsOnParentThread(); + + RefPtr runnable = + new ResetDefaultLocaleRunnable(this); + if (!runnable->Dispatch()) { + NS_WARNING("Failed to reset default locale in worker!"); + } +} + void WorkerPrivate::UpdateLanguages(const nsTArray& aLanguages) { AssertIsOnParentThread(); @@ -4888,6 +4910,15 @@ void WorkerPrivate::UpdateContextOptionsInternal( } } +void WorkerPrivate::ResetDefaultLocaleInternal(JSContext* aCx) { + JS_ResetDefaultLocale(JS_GetRuntime(aCx)); + auto data = mWorkerThreadAccessible.Access(); + + for (uint32_t index = 0; index < data->mChildWorkers.Length(); index++) { + data->mChildWorkers[index]->ResetDefaultLocale(); + } +} + void WorkerPrivate::UpdateLanguagesInternal( const nsTArray& aLanguages) { WorkerGlobalScope* globalScope = GlobalScope(); diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h index e375f5847a3408d2e772f3b337464cab02896596..2c72d1f41cbede7304965cf83ed6bb48a74e5583 100644 --- a/dom/workers/WorkerPrivate.h +++ b/dom/workers/WorkerPrivate.h @@ -309,6 +309,8 @@ class WorkerPrivate final : public RelativeTimeline { void UpdateContextOptionsInternal(JSContext* aCx, const JS::ContextOptions& aContextOptions); + void ResetDefaultLocaleInternal(JSContext* aCx); + void UpdateLanguagesInternal(const nsTArray& aLanguages); void UpdateJSWorkerMemoryParameterInternal(JSContext* aCx, JSGCParamKey key, @@ -898,6 +900,8 @@ class WorkerPrivate final : public RelativeTimeline { void UpdateContextOptions(const JS::ContextOptions& aContextOptions); + void ResetDefaultLocale(); + void UpdateLanguages(const nsTArray& aLanguages); void UpdateJSWorkerMemoryParameter(JSGCParamKey key, Maybe value); diff --git a/js/public/Date.h b/js/public/Date.h index bb69d58dc96ed7f0b37f73e26abdd0bdfeaaf556..8436d439f72287176a2fe6a1a837d3db73409e67 100644 --- a/js/public/Date.h +++ b/js/public/Date.h @@ -53,6 +53,8 @@ namespace JS { */ extern JS_PUBLIC_API void ResetTimeZone(); +extern JS_PUBLIC_API bool SetTimeZoneOverride(const char* timezoneId); + class ClippedTime; inline ClippedTime TimeClip(double time); diff --git a/js/src/debugger/Object.cpp b/js/src/debugger/Object.cpp index 2508cd1329acbea322e16adb493b81dd338342ff..7ddc9bba686734ad1a60ddfdc8352165590a9128 100644 --- a/js/src/debugger/Object.cpp +++ b/js/src/debugger/Object.cpp @@ -2338,7 +2338,11 @@ Maybe DebuggerObject::call(JSContext* cx, invokeArgs[i].set(args2[i]); } + // Disable CSP for the scope of the call. + const JSSecurityCallbacks* securityCallbacks = JS_GetSecurityCallbacks(cx); + JS_SetSecurityCallbacks(cx, nullptr); ok = js::Call(cx, calleev, thisv, invokeArgs, &result); + JS_SetSecurityCallbacks(cx, securityCallbacks); } } diff --git a/js/src/vm/DateTime.cpp b/js/src/vm/DateTime.cpp index 056f87c0e4bed207192937337e36dca3e7801c1f..bb569c20ddaba30642b2021cf9bfc6439c449a3b 100644 --- a/js/src/vm/DateTime.cpp +++ b/js/src/vm/DateTime.cpp @@ -168,6 +168,11 @@ void js::DateTimeInfo::internalResetTimeZone(ResetTimeZoneMode mode) { } } +void js::DateTimeInfo::internalSetTimeZoneOverride(mozilla::UniquePtr timeZone) { + timeZoneOverride_ = std::move(timeZone); + internalResetTimeZone(ResetTimeZoneMode::ResetEvenIfOffsetUnchanged); +} + void js::DateTimeInfo::updateTimeZone() { MOZ_ASSERT(timeZoneStatus_ != TimeZoneStatus::Valid); @@ -528,10 +533,27 @@ void js::ResetTimeZoneInternal(ResetTimeZoneMode mode) { js::DateTimeInfo::resetTimeZone(mode); } +void js::SetTimeZoneOverrideInternal(mozilla::UniquePtr timeZone) { + auto guard = js::DateTimeInfo::instance->lock(); + guard->internalSetTimeZoneOverride(std::move(timeZone)); +} + JS_PUBLIC_API void JS::ResetTimeZone() { js::ResetTimeZoneInternal(js::ResetTimeZoneMode::ResetEvenIfOffsetUnchanged); } +JS_PUBLIC_API bool JS::SetTimeZoneOverride(const char* timeZoneId) { + // Validate timezone id. + mozilla::UniquePtr timeZone(icu::TimeZone::createTimeZone( + icu::UnicodeString(timeZoneId, -1, US_INV))); + if (!timeZone || *timeZone == icu::TimeZone::getUnknown()) { + fprintf(stderr, "Invalid timezone id: %s\n", timeZoneId); + return false; + } + js::SetTimeZoneOverrideInternal(std::move(timeZone)); + return true; +} + #if defined(XP_WIN) static bool IsOlsonCompatibleWindowsTimeZoneId(const char* tz) { // ICU ignores the TZ environment variable on Windows and instead directly @@ -732,6 +754,11 @@ void js::ResyncICUDefaultTimeZone() { void js::DateTimeInfo::internalResyncICUDefaultTimeZone() { #if JS_HAS_INTL_API && !MOZ_SYSTEM_ICU + if (timeZoneOverride_) { + icu::TimeZone::setDefault(*timeZoneOverride_); + return; + } + if (const char* tz = std::getenv("TZ")) { icu::UnicodeString tzid; diff --git a/js/src/vm/DateTime.h b/js/src/vm/DateTime.h index 7dfeb9c257112b24bf6561789d7fa7f9dde932b2..5bacec827b1f5249434acbe09902e5c13ecdf4de 100644 --- a/js/src/vm/DateTime.h +++ b/js/src/vm/DateTime.h @@ -65,6 +65,8 @@ enum class ResetTimeZoneMode : bool { */ extern void ResetTimeZoneInternal(ResetTimeZoneMode mode); +extern void SetTimeZoneOverrideInternal(mozilla::UniquePtr timeZone); + /** * ICU's default time zone, used for various date/time formatting operations * that include the local time in the representation, is allowed to go stale @@ -204,6 +206,7 @@ class DateTimeInfo { // and js::ResyncICUDefaultTimeZone(). friend void js::ResetTimeZoneInternal(ResetTimeZoneMode); friend void js::ResyncICUDefaultTimeZone(); + friend void js::SetTimeZoneOverrideInternal(mozilla::UniquePtr); static void resetTimeZone(ResetTimeZoneMode mode) { auto guard = instance->lock(); @@ -300,6 +303,8 @@ class DateTimeInfo { JS::UniqueChars locale_; JS::UniqueTwoByteChars standardName_; JS::UniqueTwoByteChars daylightSavingsName_; + + mozilla::UniquePtr timeZoneOverride_; #else // Restrict the data-time range to the minimum required time_t range as // specified in POSIX. Most operating systems support 64-bit time_t @@ -315,6 +320,8 @@ class DateTimeInfo { void internalResetTimeZone(ResetTimeZoneMode mode); + void internalSetTimeZoneOverride(mozilla::UniquePtr timeZone); + void updateTimeZone(); void internalResyncICUDefaultTimeZone(); diff --git a/layout/style/GeckoBindings.h b/layout/style/GeckoBindings.h index dea1a2f2d5440a30572313443fe47142522ce578..eb909086a0efbe736b0793fe52f60e477780c23c 100644 --- a/layout/style/GeckoBindings.h +++ b/layout/style/GeckoBindings.h @@ -595,6 +595,7 @@ void Gecko_MediaFeatures_GetDeviceSize(const mozilla::dom::Document*, float Gecko_MediaFeatures_GetResolution(const mozilla::dom::Document*); bool Gecko_MediaFeatures_PrefersReducedMotion(const mozilla::dom::Document*); +bool Gecko_MediaFeatures_ForcedColors(const mozilla::dom::Document*); mozilla::StylePrefersContrast Gecko_MediaFeatures_PrefersContrast( const mozilla::dom::Document*); mozilla::StylePrefersColorScheme Gecko_MediaFeatures_PrefersColorScheme( diff --git a/layout/style/nsMediaFeatures.cpp b/layout/style/nsMediaFeatures.cpp index fffe37c359c5ba3a4e8cb4a44256f2c69182885b..6ef5b76cc58313266025f806755a89a8836c4e14 100644 --- a/layout/style/nsMediaFeatures.cpp +++ b/layout/style/nsMediaFeatures.cpp @@ -246,10 +246,11 @@ nsAtom* Gecko_MediaFeatures_GetOperatingSystemVersion( } bool Gecko_MediaFeatures_PrefersReducedMotion(const Document* aDocument) { - if (nsContentUtils::ShouldResistFingerprinting(aDocument)) { - return false; - } - return LookAndFeel::GetInt(LookAndFeel::IntID::PrefersReducedMotion, 0) == 1; + return aDocument->PrefersReducedMotion(); +} + +bool Gecko_MediaFeatures_ForcedColors(const Document* aDocument) { + return aDocument->ForcedColors(); } StylePrefersColorScheme Gecko_MediaFeatures_PrefersColorScheme( diff --git a/media/libjpeg/jconfig.h b/media/libjpeg/jconfig.h index f2723e654098ff27542e1eb16a536c11ad0af617..b0b480551ff7d895dfdeb5a9800874858929c8ba 100644 --- a/media/libjpeg/jconfig.h +++ b/media/libjpeg/jconfig.h @@ -17,6 +17,7 @@ /* #undef D_ARITH_CODING_SUPPORTED */ /* Support in-memory source/destination managers */ +#define MEM_SRCDST_SUPPORTED 1 /* #undef MEM_SRCDST_SUPPORTED */ /* Use accelerated SIMD routines. */ diff --git a/netwerk/base/nsINetworkInterceptController.idl b/netwerk/base/nsINetworkInterceptController.idl index c1ee73acde26b1a77a3e32b7132ce687d48e3347..0ce45a1d7b10eef91164e517522c4ea11487bf26 100644 --- a/netwerk/base/nsINetworkInterceptController.idl +++ b/netwerk/base/nsINetworkInterceptController.idl @@ -59,6 +59,7 @@ interface nsIInterceptedChannel : nsISupports * results in the resulting client not being controlled. */ void resetInterception(in boolean bypass); + void resetInterceptionWithURI(in nsIURI aURI); /** * Set the status and reason for the forthcoming synthesized response. diff --git a/netwerk/protocol/http/InterceptedHttpChannel.cpp b/netwerk/protocol/http/InterceptedHttpChannel.cpp index 7a2107ab31df0a462ad387e3338c4d5ed9fd5a88..fef893afe12c6078d6c58499f2f4ad703b5c7a9b 100644 --- a/netwerk/protocol/http/InterceptedHttpChannel.cpp +++ b/netwerk/protocol/http/InterceptedHttpChannel.cpp @@ -596,6 +596,14 @@ void InterceptedHttpChannel::DoAsyncAbort(nsresult aStatus) { Unused << AsyncAbort(aStatus); } +NS_IMETHODIMP +InterceptedHttpChannel::ResetInterceptionWithURI(nsIURI* aURI) { + if (aURI) { + mURI = aURI; + } + return ResetInterception(true); +} + NS_IMETHODIMP InterceptedHttpChannel::ResetInterception(bool aBypass) { if (mCanceled) { diff --git a/parser/html/nsHtml5TreeOpExecutor.cpp b/parser/html/nsHtml5TreeOpExecutor.cpp index dd865ee6eb2280db7f3d2345e931e2fb2722b8d4..469711b1539ca56d047672e1241096da437f26e0 100644 --- a/parser/html/nsHtml5TreeOpExecutor.cpp +++ b/parser/html/nsHtml5TreeOpExecutor.cpp @@ -1279,9 +1279,12 @@ void nsHtml5TreeOpExecutor::AddSpeculationCSP(const nsAString& aCSP) { if (!StaticPrefs::security_csp_enable()) { return; } - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + if (mDocShell && static_cast(mDocShell.get())->IsBypassCSPEnabled()) { + return; + } + nsresult rv = NS_OK; nsCOMPtr preloadCsp = mDocument->GetPreloadCsp(); if (!preloadCsp) { diff --git a/security/manager/ssl/nsCertOverrideService.cpp b/security/manager/ssl/nsCertOverrideService.cpp index e108f50ef6d3e9b7b2fd6dbdf5742bcba2e65571..6d34e51fc2f63626014ec8c13ff85c5f63e4cdd1 100644 --- a/security/manager/ssl/nsCertOverrideService.cpp +++ b/security/manager/ssl/nsCertOverrideService.cpp @@ -565,7 +565,12 @@ nsCertOverrideService::HasMatchingOverride( bool disableAllSecurityCheck = false; { MutexAutoLock lock(mMutex); - disableAllSecurityCheck = mDisableAllSecurityCheck; + if (aOriginAttributes.mUserContextId) { + disableAllSecurityCheck = mUserContextIdsWithDisabledSecurityChecks.has( + aOriginAttributes.mUserContextId); + } else { + disableAllSecurityCheck = mDisableAllSecurityCheck; + } } if (disableAllSecurityCheck) { nsCertOverride::OverrideBits all = nsCertOverride::OverrideBits::Untrusted | @@ -811,14 +816,24 @@ static bool IsDebugger() { NS_IMETHODIMP nsCertOverrideService:: - SetDisableAllSecurityChecksAndLetAttackersInterceptMyData(bool aDisable) { - if (!(PR_GetEnv("XPCSHELL_TEST_PROFILE_DIR") || IsDebugger())) { + SetDisableAllSecurityChecksAndLetAttackersInterceptMyData( + bool aDisable, uint32_t aUserContextId) { + if (false /* juggler hacks */ && !(PR_GetEnv("XPCSHELL_TEST_PROFILE_DIR") || IsDebugger())) { return NS_ERROR_NOT_AVAILABLE; } { MutexAutoLock lock(mMutex); - mDisableAllSecurityCheck = aDisable; + if (aUserContextId) { + if (aDisable) { + mozilla::Unused << mUserContextIdsWithDisabledSecurityChecks.put(aUserContextId); + } else { + mUserContextIdsWithDisabledSecurityChecks.remove(aUserContextId); + } + return NS_OK; + } else { + mDisableAllSecurityCheck = aDisable; + } } nsCOMPtr nss(do_GetService(PSM_COMPONENT_CONTRACTID)); diff --git a/security/manager/ssl/nsCertOverrideService.h b/security/manager/ssl/nsCertOverrideService.h index 4c23cd20b9ccb72c2bc9d25ef7a832fe54993127..f43754414de091e5d745b96d440f9df8ac87f008 100644 --- a/security/manager/ssl/nsCertOverrideService.h +++ b/security/manager/ssl/nsCertOverrideService.h @@ -132,6 +132,7 @@ class nsCertOverrideService final : public nsICertOverrideService, private: ~nsCertOverrideService(); + mozilla::HashSet mUserContextIdsWithDisabledSecurityChecks; mozilla::Mutex mMutex; bool mDisableAllSecurityCheck; nsCOMPtr mSettingsFile; diff --git a/security/manager/ssl/nsICertOverrideService.idl b/security/manager/ssl/nsICertOverrideService.idl index da8f32c8f618d7fbea39f1c47645f0328d6aa28e..260424dc96b352d5de90db56aa8e4a777914fdfe 100644 --- a/security/manager/ssl/nsICertOverrideService.idl +++ b/security/manager/ssl/nsICertOverrideService.idl @@ -213,7 +213,9 @@ interface nsICertOverrideService : nsISupports { * @param aDisable If true, disable all security check and make * hasMatchingOverride always return true. */ - void setDisableAllSecurityChecksAndLetAttackersInterceptMyData(in boolean aDisable); + void setDisableAllSecurityChecksAndLetAttackersInterceptMyData( + in boolean aDisable, + [optional] in uint32_t aUserContextId); readonly attribute boolean securityCheckDisabled; }; diff --git a/services/settings/Utils.jsm b/services/settings/Utils.jsm index 549f8cc41da880dfd947893db9f05c03eb4a0242..188e9a725f7af1bed9ed68915b5b4d81df4aa6c7 100644 --- a/services/settings/Utils.jsm +++ b/services/settings/Utils.jsm @@ -60,7 +60,7 @@ var Utils = { ); const isXpcshell = env.exists("XPCSHELL_TEST_PROFILE_DIR"); const isNotThunderbird = AppConstants.MOZ_APP_NAME != "thunderbird"; - return AppConstants.RELEASE_OR_BETA && + return false && AppConstants.RELEASE_OR_BETA && !Cu.isInAutomation && !isXpcshell && isNotThunderbird diff --git a/servo/components/style/gecko/media_features.rs b/servo/components/style/gecko/media_features.rs index 664a12f4108f8056f68893c1127d96099c0d30c9..2e2873f7f3127420e96154314acf363ef06806fc 100644 --- a/servo/components/style/gecko/media_features.rs +++ b/servo/components/style/gecko/media_features.rs @@ -336,10 +336,15 @@ pub enum ForcedColors { /// https://drafts.csswg.org/mediaqueries-5/#forced-colors fn eval_forced_colors(device: &Device, query_value: Option) -> bool { - let forced = !device.use_document_colors(); + let prefers_forced_colors = + unsafe { bindings::Gecko_MediaFeatures_ForcedColors(device.document()) }; + let query_value = match query_value { + Some(v) => v, + None => return prefers_forced_colors, + }; match query_value { - Some(query_value) => forced == (query_value == ForcedColors::Active), - None => forced, + ForcedColors::Active => prefers_forced_colors, + ForcedColors::None => !prefers_forced_colors, } } diff --git a/toolkit/components/browser/nsIWebBrowserChrome.idl b/toolkit/components/browser/nsIWebBrowserChrome.idl index 1e9bea1655af731fc003f8d0cab3ad4d2ad29f5d..5081c0e1ee0c41c6a79bd2ed358a57442e3baa6b 100644 --- a/toolkit/components/browser/nsIWebBrowserChrome.idl +++ b/toolkit/components/browser/nsIWebBrowserChrome.idl @@ -70,6 +70,9 @@ interface nsIWebBrowserChrome : nsISupports // Whether this window should use out-of-process cross-origin subframes. const unsigned long CHROME_FISSION_WINDOW = 0x00200000; + // Whether this window has "width" or "height" defined in features + const unsigned long JUGGLER_WINDOW_EXPLICIT_SIZE = 0x00400000; + // Prevents new window animations on MacOS and Windows. Currently // ignored for Linux. const unsigned long CHROME_SUPPRESS_ANIMATION = 0x01000000; diff --git a/toolkit/components/startup/nsAppStartup.cpp b/toolkit/components/startup/nsAppStartup.cpp index fb42e6cfc5ee21454ab4b5692575c0161f633f78..80d64aea17f78b46223dce3310831524021d779e 100644 --- a/toolkit/components/startup/nsAppStartup.cpp +++ b/toolkit/components/startup/nsAppStartup.cpp @@ -343,7 +343,7 @@ nsAppStartup::Quit(uint32_t aMode, int aExitCode, bool* aUserAllowedQuit) { nsCOMPtr windowEnumerator; nsCOMPtr mediator( do_GetService(NS_WINDOWMEDIATOR_CONTRACTID)); - if (mediator) { + if (ferocity != eForceQuit && mediator) { mediator->GetEnumerator(nullptr, getter_AddRefs(windowEnumerator)); if (windowEnumerator) { bool more; diff --git a/toolkit/components/statusfilter/nsBrowserStatusFilter.cpp b/toolkit/components/statusfilter/nsBrowserStatusFilter.cpp index 318037b12e9ea7b8bad92498950ac48ff936fb3c..30cbfcee188080f922dad0d9c1277cbe1c97b2cc 100644 --- a/toolkit/components/statusfilter/nsBrowserStatusFilter.cpp +++ b/toolkit/components/statusfilter/nsBrowserStatusFilter.cpp @@ -162,8 +162,8 @@ nsBrowserStatusFilter::OnStateChange(nsIWebProgress* aWebProgress, } NS_IMETHODIMP -nsBrowserStatusFilter::OnProgressChange(nsIWebProgress* aWebProgress, - nsIRequest* aRequest, +nsBrowserStatusFilter::OnProgressChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, int32_t aCurSelfProgress, int32_t aMaxSelfProgress, int32_t aCurTotalProgress, diff --git a/toolkit/components/windowwatcher/nsWindowWatcher.cpp b/toolkit/components/windowwatcher/nsWindowWatcher.cpp index 52efe54b2b7050dff5881664cedd15ccb5fc35a8..79cc2f85516cfd362b1ce4dbf5a62515ede48cd8 100644 --- a/toolkit/components/windowwatcher/nsWindowWatcher.cpp +++ b/toolkit/components/windowwatcher/nsWindowWatcher.cpp @@ -1863,6 +1863,10 @@ uint32_t nsWindowWatcher::CalculateChromeFlagsForContent( uint32_t chromeFlags = CalculateChromeFlagsHelper( nsIWebBrowserChrome::CHROME_WINDOW_BORDERS, aFeatures, aSizeSpec); + if (aFeatures.Exists("width") || aFeatures.Exists("height")) { + chromeFlags |= nsIWebBrowserChrome::JUGGLER_WINDOW_EXPLICIT_SIZE; + } + return EnsureFlagsSafeForContent(chromeFlags); } diff --git a/toolkit/mozapps/update/UpdateService.jsm b/toolkit/mozapps/update/UpdateService.jsm index 4d1b1c59eff5c3a7e1957d3d453a6896e2c5c5c4..f5c69f27a4e851e8f6a5d95a851217ed6284a7c7 100644 --- a/toolkit/mozapps/update/UpdateService.jsm +++ b/toolkit/mozapps/update/UpdateService.jsm @@ -3662,7 +3662,7 @@ UpdateService.prototype = { }, get disabledForTesting() { - return ( + return true || ( (Cu.isInAutomation || Marionette.running || RemoteAgent.listening) && Services.prefs.getBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, false) ); diff --git a/toolkit/toolkit.mozbuild b/toolkit/toolkit.mozbuild index 5576f6acc427f593606214741e344d74572021c6..38423c5db4e3b907e1c5507a289a6a902d002b5f 100644 --- a/toolkit/toolkit.mozbuild +++ b/toolkit/toolkit.mozbuild @@ -168,6 +168,7 @@ if CONFIG['ENABLE_WEBDRIVER']: '/remote', '/testing/firefox-ui', '/testing/marionette', + '/juggler', '/toolkit/components/telemetry/tests/marionette', ] diff --git a/toolkit/xre/nsWindowsWMain.cpp b/toolkit/xre/nsWindowsWMain.cpp index 109c53cac98302d657d2a5a997f2ba687db14515..4d3c4beddaf627441e28f2a49d793d56fe4e2447 100644 --- a/toolkit/xre/nsWindowsWMain.cpp +++ b/toolkit/xre/nsWindowsWMain.cpp @@ -14,8 +14,10 @@ #endif #include "mozilla/Char16.h" +#include "mozilla/CmdLineAndEnvUtils.h" #include "nsUTF8Utils.h" +#include #include #ifdef __MINGW32__ @@ -94,6 +96,20 @@ static void FreeAllocStrings(int argc, char** argv) { int wmain(int argc, WCHAR** argv) { SanitizeEnvironmentVariables(); SetDllDirectoryW(L""); + bool hasJugglerPipe = + mozilla::CheckArg(argc, argv, L"juggler-pipe", + static_cast(nullptr), + mozilla::CheckArgFlag::None) == mozilla::ARG_FOUND; + if (hasJugglerPipe && !mozilla::EnvHasValue("PW_PIPE_READ")) { + intptr_t stdio3 = _get_osfhandle(3); + intptr_t stdio4 = _get_osfhandle(4); + CHAR stdio3str[20]; + CHAR stdio4str[20]; + itoa(stdio3, stdio3str, 10); + itoa(stdio4, stdio4str, 10); + SetEnvironmentVariableA("PW_PIPE_READ", stdio3str); + SetEnvironmentVariableA("PW_PIPE_WRITE", stdio4str); + } // Only run this code if LauncherProcessWin.h was included beforehand, thus // signalling that the hosting process should support launcher mode. diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp index 50263dfe2f50c382d6fec3da320b5f0aec8481ca..8a6e9612163545fe16390cc384c4e8cb69e4bcdf 100644 --- a/uriloader/base/nsDocLoader.cpp +++ b/uriloader/base/nsDocLoader.cpp @@ -820,6 +820,13 @@ void nsDocLoader::DocLoaderIsEmpty(bool aFlushLayout, ("DocLoader:%p: Firing load event for document.open\n", this)); + nsCOMPtr os = mozilla::services::GetObserverService(); + if (os) { + nsIPrincipal* principal = doc->NodePrincipal(); + if (!principal->IsSystemPrincipal()) + os->NotifyObservers(ToSupports(doc), "juggler-document-open-loaded", nullptr); + } + // This is a very cut-down version of // nsDocumentViewer::LoadComplete that doesn't do various things // that are not relevant here because this wasn't an actual diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 228c6ba51be44f73e4968baba5636180f84d061f..a0d352fea7411d1decac5d2f2f4fd56f97d57070 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -101,6 +101,7 @@ #include "mozilla/Components.h" #include "mozilla/ClearOnShutdown.h" +#include "mozilla/ErrorNames.h" #include "mozilla/Preferences.h" #include "mozilla/ipc/URIUtils.h" @@ -922,6 +923,12 @@ NS_IMETHODIMP nsExternalHelperAppService::ApplyDecodingForExtension( return NS_OK; } +NS_IMETHODIMP nsExternalHelperAppService::SetDownloadInterceptor( + nsIDownloadInterceptor* interceptor) { + mInterceptor = interceptor; + return NS_OK; +} + nsresult nsExternalHelperAppService::GetFileTokenForPath( const char16_t* aPlatformAppPath, nsIFile** aFile) { nsDependentString platformAppPath(aPlatformAppPath); @@ -1588,7 +1595,12 @@ nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel* aChannel) { // Strip off the ".part" from mTempLeafName mTempLeafName.Truncate(mTempLeafName.Length() - ArrayLength(".part") + 1); + return CreateSaverForTempFile(); +} + +nsresult nsExternalAppHandler::CreateSaverForTempFile() { MOZ_ASSERT(!mSaver, "Output file initialization called more than once!"); + nsresult rv; mSaver = do_CreateInstance(NS_BACKGROUNDFILESAVERSTREAMLISTENER_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); @@ -1761,7 +1773,36 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) { return NS_OK; } - rv = SetUpTempFile(aChannel); + bool isIntercepted = false; + nsCOMPtr interceptor = mExtProtSvc->mInterceptor; + if (interceptor) { + nsCOMPtr fileToUse; + rv = interceptor->InterceptDownloadRequest(this, request, mBrowsingContext, getter_AddRefs(fileToUse), &isIntercepted); + if (!NS_SUCCEEDED(rv)) { + LOG((" failed to call nsIDowloadInterceptor.interceptDownloadRequest")); + return rv; + } + if (isIntercepted) { + LOG((" request interceped by nsIDowloadInterceptor")); + if (fileToUse) { + mTempFile = fileToUse; + rv = mTempFile->GetLeafName(mTempLeafName); + NS_ENSURE_SUCCESS(rv, rv); + } else { + Cancel(NS_BINDING_ABORTED); + return NS_OK; + } + } + } + + // Temp file is the final destination when download is intercepted. In that + // case we only need to create saver (and not create transfer later). Not creating + // mTransfer also cuts off all downloads handling logic in the js compoenents and + // browser UI. + if (isIntercepted) + rv = CreateSaverForTempFile(); + else + rv = SetUpTempFile(aChannel); if (NS_FAILED(rv)) { nsresult transferError = rv; @@ -1826,6 +1867,10 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) { mMimeInfo->GetAlwaysAskBeforeHandling(&alwaysAsk); } + if (isIntercepted) { + return NS_OK; + } + if (alwaysAsk) { // But we *don't* ask if this mimeInfo didn't come from // our user configuration datastore and the user has said @@ -2248,6 +2293,16 @@ nsExternalAppHandler::OnSaveComplete(nsIBackgroundFileSaver* aSaver, NotifyTransfer(aStatus); } + if (!mCanceled) { + nsCOMPtr interceptor = mExtProtSvc->mInterceptor; + if (interceptor) { + nsCString noError; + nsresult rv = interceptor->OnDownloadComplete(this, noError); + MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed to call nsIDowloadInterceptor.OnDownloadComplete"); + Unused << rv; + } + } + return NS_OK; } @@ -2651,6 +2706,15 @@ NS_IMETHODIMP nsExternalAppHandler::Cancel(nsresult aReason) { } } + nsCOMPtr interceptor = mExtProtSvc->mInterceptor; + if (interceptor) { + nsCString errorName; + GetErrorName(aReason, errorName); + nsresult rv = interceptor->OnDownloadComplete(this, errorName); + MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed notify nsIDowloadInterceptor about cancel"); + Unused << rv; + } + // Break our reference cycle with the helper app dialog (set up in // OnStartRequest) mDialog = nullptr; diff --git a/uriloader/exthandler/nsExternalHelperAppService.h b/uriloader/exthandler/nsExternalHelperAppService.h index 5735e73bcde72f0bb72ea9f7bc66cc445bf9813a..f228b8c44e06a9d1893a066dfde3eeb11f34d4fe 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.h +++ b/uriloader/exthandler/nsExternalHelperAppService.h @@ -207,6 +207,8 @@ class nsExternalHelperAppService : public nsIExternalHelperAppService, mozilla::dom::BrowsingContext* aContentContext, bool aForceSave, nsIInterfaceRequestor* aWindowContext, nsIStreamListener** aStreamListener); + + nsCOMPtr mInterceptor; }; /** @@ -398,6 +400,9 @@ class nsExternalAppHandler final : public nsIStreamListener, * Upon successful return, both mTempFile and mSaver will be valid. */ nsresult SetUpTempFile(nsIChannel* aChannel); + + nsresult CreateSaverForTempFile(); + /** * When we download a helper app, we are going to retarget all load * notifications into our own docloader and load group instead of diff --git a/uriloader/exthandler/nsIExternalHelperAppService.idl b/uriloader/exthandler/nsIExternalHelperAppService.idl index 657e15bc07426745b9488b903c5a53b8d977fb2d..4f61835e64d537ab7a35c2c2fb059e67cd7cd0fc 100644 --- a/uriloader/exthandler/nsIExternalHelperAppService.idl +++ b/uriloader/exthandler/nsIExternalHelperAppService.idl @@ -6,6 +6,8 @@ #include "nsICancelable.idl" +webidl BrowsingContext; +interface nsIHelperAppLauncher; interface nsIURI; interface nsIRequest; interface nsIStreamListener; @@ -15,6 +17,17 @@ interface nsIWebProgressListener2; interface nsIInterfaceRequestor; webidl BrowsingContext; +/** + * Interceptor interface used by Juggler. + */ +[scriptable, uuid(9a20e9b0-75d0-11ea-bc55-0242ac130003)] +interface nsIDownloadInterceptor : nsISupports +{ + bool interceptDownloadRequest(in nsIHelperAppLauncher aHandler, in nsIRequest aRequest, in BrowsingContext aBrowsingContext, out nsIFile file); + + void onDownloadComplete(in nsIHelperAppLauncher aHandler, in ACString aErrorName); +}; + /** * The external helper app service is used for finding and launching * platform specific external applications for a given mime content type. @@ -43,7 +56,7 @@ interface nsIExternalHelperAppService : nsISupports in nsIInterfaceRequestor aContentContext, in boolean aForceSave, [optional] in nsIInterfaceRequestor aWindowContext); - + /** * Binds an external helper application to a stream listener. The caller * should pump data into the returned stream listener. When the OnStopRequest @@ -76,6 +89,7 @@ interface nsIExternalHelperAppService : nsISupports boolean applyDecodingForExtension(in AUTF8String aExtension, in ACString aEncodingType); + void setDownloadInterceptor(in nsIDownloadInterceptor interceptor); }; /** diff --git a/widget/InProcessCompositorWidget.cpp b/widget/InProcessCompositorWidget.cpp index 3ebf466afd8aae8ab38ac5b711da2e100626ecf8..c8be7b53f0054c16adb9e76f424675dd9a3600a0 100644 --- a/widget/InProcessCompositorWidget.cpp +++ b/widget/InProcessCompositorWidget.cpp @@ -4,7 +4,10 @@ #include "InProcessCompositorWidget.h" +#include "HeadlessCompositorWidget.h" +#include "HeadlessWidget.h" #include "mozilla/VsyncDispatcher.h" +#include "mozilla/widget/PlatformWidgetTypes.h" #include "nsBaseWidget.h" #if defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING) @@ -27,6 +30,12 @@ RefPtr CompositorWidget::CreateLocal( // do it after the static_cast. nsBaseWidget* widget = static_cast(aWidget); MOZ_RELEASE_ASSERT(widget); + if (aInitData.type() == + CompositorWidgetInitData::THeadlessCompositorWidgetInitData) { + return new HeadlessCompositorWidget( + aInitData.get_HeadlessCompositorWidgetInitData(), aOptions, + static_cast(aWidget)); + } # ifdef MOZ_WIDGET_ANDROID return new AndroidCompositorWidget(aOptions, widget); # else diff --git a/widget/cocoa/NativeKeyBindings.mm b/widget/cocoa/NativeKeyBindings.mm index 2b11df66d9445080d4d8a19a915b3e00285c5d32..caef1b65bbcff899f45c3e3cddfe76e88479ec30 100644 --- a/widget/cocoa/NativeKeyBindings.mm +++ b/widget/cocoa/NativeKeyBindings.mm @@ -491,6 +491,13 @@ void NativeKeyBindings::GetEditCommandsForTests(NativeKeyBindingsType aType, break; case KEY_NAME_INDEX_ArrowLeft: if (aEvent.IsAlt()) { + if (aEvent.IsMeta() || aEvent.IsControl()) + break; + instance->AppendEditCommandsForSelector( + !aEvent.IsShift() + ? ToObjcSelectorPtr(@selector(moveWordLeft:)) + : ToObjcSelectorPtr(@selector(moveWordLeftAndModifySelection:)), + aCommands); break; } if (aEvent.IsMeta() || (aEvent.IsControl() && aEvent.IsShift())) { @@ -511,6 +518,13 @@ void NativeKeyBindings::GetEditCommandsForTests(NativeKeyBindingsType aType, break; case KEY_NAME_INDEX_ArrowRight: if (aEvent.IsAlt()) { + if (aEvent.IsMeta() || aEvent.IsControl()) + break; + instance->AppendEditCommandsForSelector( + !aEvent.IsShift() + ? ToObjcSelectorPtr(@selector(moveWordRight:)) + : ToObjcSelectorPtr(@selector(moveWordRightAndModifySelection:)), + aCommands); break; } if (aEvent.IsMeta() || (aEvent.IsControl() && aEvent.IsShift())) { @@ -531,6 +545,10 @@ void NativeKeyBindings::GetEditCommandsForTests(NativeKeyBindingsType aType, break; case KEY_NAME_INDEX_ArrowUp: if (aEvent.IsControl()) { + if (aEvent.IsMeta() || aEvent.IsAlt()) + break; + instance->AppendEditCommandsForSelector( + ToObjcSelectorPtr(@selector(scrollPageUp:)), aCommands); break; } if (aEvent.IsMeta()) { @@ -540,7 +558,7 @@ void NativeKeyBindings::GetEditCommandsForTests(NativeKeyBindingsType aType, instance->AppendEditCommandsForSelector( !aEvent.IsShift() ? ToObjcSelectorPtr(@selector(moveToBeginningOfDocument:)) - : ToObjcSelectorPtr(@selector(moveToBegginingOfDocumentAndModifySelection:)), + : ToObjcSelectorPtr(@selector(moveToBeginningOfDocumentAndModifySelection:)), aCommands); break; } @@ -563,6 +581,10 @@ void NativeKeyBindings::GetEditCommandsForTests(NativeKeyBindingsType aType, break; case KEY_NAME_INDEX_ArrowDown: if (aEvent.IsControl()) { + if (aEvent.IsMeta() || aEvent.IsAlt()) + break; + instance->AppendEditCommandsForSelector( + ToObjcSelectorPtr(@selector(scrollPageDown:)), aCommands); break; } if (aEvent.IsMeta()) { diff --git a/widget/headless/HeadlessCompositorWidget.cpp b/widget/headless/HeadlessCompositorWidget.cpp index b31a969b7ab3d0fc80912b110d91dfdf3e5991f4..beb2343fe704e0f700693fd13280689caca0e4ca 100644 --- a/widget/headless/HeadlessCompositorWidget.cpp +++ b/widget/headless/HeadlessCompositorWidget.cpp @@ -3,6 +3,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 "mozilla/layers/CompositorThread.h" #include "mozilla/widget/PlatformWidgetTypes.h" #include "HeadlessCompositorWidget.h" #include "VsyncDispatcher.h" @@ -17,6 +18,33 @@ HeadlessCompositorWidget::HeadlessCompositorWidget( mClientSize = aInitData.InitialClientSize(); } +void HeadlessCompositorWidget::SetSnapshotListener(HeadlessWidget::SnapshotListener&& listener) { + MOZ_ASSERT(NS_IsMainThread()); + + layers::CompositorThread()->Dispatch(NewRunnableMethod( + "HeadlessCompositorWidget::SetSnapshotListener", this, + &HeadlessCompositorWidget::SetSnapshotListenerOnCompositorThread, + std::move(listener))); +} + +void HeadlessCompositorWidget::SetSnapshotListenerOnCompositorThread( + HeadlessWidget::SnapshotListener&& listener) { + MOZ_ASSERT(NS_IsInCompositorThread()); + mSnapshotListener = std::move(listener); + PeriodicSnapshot(); +} + +already_AddRefed HeadlessCompositorWidget::StartRemoteDrawingInRegion( + const LayoutDeviceIntRegion& aInvalidRegion, + layers::BufferMode* aBufferMode) { + if (!mDrawTarget) + return nullptr; + + *aBufferMode = layers::BufferMode::BUFFER_NONE; + RefPtr result = mDrawTarget; + return result.forget(); +} + void HeadlessCompositorWidget::ObserveVsync(VsyncObserver* aObserver) { if (RefPtr cvd = mWidget->GetCompositorVsyncDispatcher()) { @@ -29,6 +57,58 @@ nsIWidget* HeadlessCompositorWidget::RealWidget() { return mWidget; } void HeadlessCompositorWidget::NotifyClientSizeChanged( const LayoutDeviceIntSize& aClientSize) { mClientSize = aClientSize; + layers::CompositorThread()->Dispatch(NewRunnableMethod( + "HeadlessCompositorWidget::UpdateDrawTarget", this, + &HeadlessCompositorWidget::UpdateDrawTarget, + aClientSize)); +} + +void HeadlessCompositorWidget::UpdateDrawTarget(const LayoutDeviceIntSize& aClientSize) { + MOZ_ASSERT(NS_IsInCompositorThread()); + if (aClientSize.IsEmpty()) { + mDrawTarget = nullptr; + return; + } + + RefPtr old = std::move(mDrawTarget); + gfx::SurfaceFormat format = gfx::SurfaceFormat::B8G8R8A8; + gfx::IntSize size = aClientSize.ToUnknownSize(); + mDrawTarget = mozilla::gfx::Factory::CreateDrawTarget( + mozilla::gfx::BackendType::SKIA, size, format); + if (old) { + RefPtr snapshot = old->Snapshot(); + if (snapshot) + mDrawTarget->CopySurface(snapshot.get(), old->GetRect(), gfx::IntPoint(0, 0)); + } +} + +void HeadlessCompositorWidget::PeriodicSnapshot() { + if (!mSnapshotListener) + return; + + TakeSnapshot(); + NS_DelayedDispatchToCurrentThread(NewRunnableMethod( + "HeadlessCompositorWidget::PeriodicSnapshot", this, + &HeadlessCompositorWidget::PeriodicSnapshot), 40); +} + +void HeadlessCompositorWidget::TakeSnapshot() { + if (!mDrawTarget) + return; + + RefPtr snapshot = mDrawTarget->Snapshot(); + if (!snapshot) { + fprintf(stderr, "Failed to get snapshot of draw target\n"); + return; + } + + RefPtr dataSurface = snapshot->GetDataSurface(); + if (!dataSurface) { + fprintf(stderr, "Failed to get data surface from snapshot\n"); + return; + } + + mSnapshotListener(std::move(dataSurface)); } LayoutDeviceIntSize HeadlessCompositorWidget::GetClientSize() { diff --git a/widget/headless/HeadlessCompositorWidget.h b/widget/headless/HeadlessCompositorWidget.h index 7f91de9e67d7ffa02de3eef1d760e5cfd05e7ad6..684293dab3e81e8a60d245f979f2051df395948f 100644 --- a/widget/headless/HeadlessCompositorWidget.h +++ b/widget/headless/HeadlessCompositorWidget.h @@ -23,8 +23,12 @@ class HeadlessCompositorWidget final : public CompositorWidget, HeadlessWidget* aWindow); void NotifyClientSizeChanged(const LayoutDeviceIntSize& aClientSize); + void SetSnapshotListener(HeadlessWidget::SnapshotListener&& listener); // CompositorWidget Overrides + already_AddRefed StartRemoteDrawingInRegion( + const LayoutDeviceIntRegion& aInvalidRegion, + layers::BufferMode* aBufferMode) override; uintptr_t GetWidgetKey() override; @@ -42,9 +46,18 @@ class HeadlessCompositorWidget final : public CompositorWidget, } private: + void SetSnapshotListenerOnCompositorThread( + HeadlessWidget::SnapshotListener&& listener); + void UpdateDrawTarget(const LayoutDeviceIntSize& aClientSize); + void PeriodicSnapshot(); + void TakeSnapshot(); + HeadlessWidget* mWidget; LayoutDeviceIntSize mClientSize; + + HeadlessWidget::SnapshotListener mSnapshotListener; + RefPtr mDrawTarget; }; } // namespace widget diff --git a/widget/headless/HeadlessWidget.cpp b/widget/headless/HeadlessWidget.cpp index 9a3e710b752852a6bb023feeb18ac18019dda87b..afebd348a2526b5f425c7af8ceb4d3872cb957ad 100644 --- a/widget/headless/HeadlessWidget.cpp +++ b/widget/headless/HeadlessWidget.cpp @@ -108,6 +108,8 @@ void HeadlessWidget::Destroy() { } } + SetSnapshotListener(nullptr); + nsBaseWidget::OnDestroy(); nsBaseWidget::Destroy(); @@ -565,5 +567,15 @@ nsresult HeadlessWidget::SynthesizeNativeTouchPadPinch( DispatchPinchGestureInput(inputToDispatch); return NS_OK; } + +void HeadlessWidget::SetSnapshotListener(SnapshotListener&& listener) { + if (!mCompositorWidget) { + if (listener) + fprintf(stderr, "Trying to set SnapshotListener without compositor widget\n"); + return; + } + mCompositorWidget->SetSnapshotListener(std::move(listener)); +} + } // namespace widget } // namespace mozilla diff --git a/widget/headless/HeadlessWidget.h b/widget/headless/HeadlessWidget.h index 225f9636dd5c26c571136b53bb4061b6f39f7537..48c03c3d301b9b76cfefe4371e45c8262a0fa50c 100644 --- a/widget/headless/HeadlessWidget.h +++ b/widget/headless/HeadlessWidget.h @@ -143,6 +143,9 @@ class HeadlessWidget : public nsBaseWidget { TouchpadPinchPhase aEventPhase, float aScale, LayoutDeviceIntPoint aPoint, int32_t aModifierFlags) override; + using SnapshotListener = std::function&&)>; + void SetSnapshotListener(SnapshotListener&& listener); + private: ~HeadlessWidget(); bool mEnabled; diff --git a/xpcom/reflect/xptinfo/xptinfo.h b/xpcom/reflect/xptinfo/xptinfo.h index efee881c142175c29d15f7ceaaebf852f39e44cd..014bf4b39b99eaf2fba6fb08827e7d2f964bab33 100644 --- a/xpcom/reflect/xptinfo/xptinfo.h +++ b/xpcom/reflect/xptinfo/xptinfo.h @@ -514,7 +514,7 @@ static_assert(sizeof(nsXPTMethodInfo) == 8, "wrong size"); #if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE) # define PARAM_BUFFER_COUNT 18 #else -# define PARAM_BUFFER_COUNT 14 +# define PARAM_BUFFER_COUNT 15 #endif /**