mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-15 14:11:50 +03:00
2407 lines
96 KiB
Diff
2407 lines
96 KiB
Diff
diff --git a/accessible/base/NotificationController.h b/accessible/base/NotificationController.h
|
|
index 0a5ebee659a06e3d3fdcd6fc88f749dfda617af5..cd3f3085560d91ada10ea92ebaf2c76412e69579 100644
|
|
--- a/accessible/base/NotificationController.h
|
|
+++ b/accessible/base/NotificationController.h
|
|
@@ -284,6 +284,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 e3dbe73f22252f11080c3f266b2309f842eba9dc..87f50fe3df7cc8f9bc26dabd5ee571cae270912a 100644
|
|
--- a/accessible/xpcom/xpcAccessibleDocument.cpp
|
|
+++ b/accessible/xpcom/xpcAccessibleDocument.cpp
|
|
@@ -143,6 +143,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 f042cc1081850ac60e329b70b5569f8b97d4e4dc..65bcff9b41b9471ef1427e3ea330481c194409bc 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 faf53eff9a46f958890d2c50de4c741fce75f1b1..7ad4b9f2203dbf1706518a0ba372d424673c9d64 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 <io.h>
|
|
#include <windows.h>
|
|
#include <processthreadsapi.h>
|
|
|
|
@@ -324,8 +325,25 @@ Maybe<int> 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<const wchar_t**>(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);
|
|
+ SetEnvironmentVariable("PW_PIPE_READ", stdio3str);
|
|
+ SetEnvironmentVariable("PW_PIPE_WRITE", stdio4str);
|
|
+ HANDLE pipeHandles[] = {reinterpret_cast<HANDLE>(stdio3),
|
|
+ reinterpret_cast<HANDLE>(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 a01e9a49ecac2134ab2d3b28f920fa564d88935f..1b1073ecf0d3ec061fac6d34f9161d0096167821 100644
|
|
--- a/browser/installer/allowed-dupes.mn
|
|
+++ b/browser/installer/allowed-dupes.mn
|
|
@@ -65,6 +65,12 @@ browser/defaults/settings/main/example.json
|
|
browser/defaults/settings/main/search-default-override-allowlist.json
|
|
browser/defaults/settings/main/url-classifier-skip-urls.json
|
|
|
|
+# 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 566e6435ea0592e307a6d12065accd8aae5aaa82..9edab09886845d4ceeb39a2e314eb9bb649eb6ba 100644
|
|
--- a/browser/installer/package-manifest.in
|
|
+++ b/browser/installer/package-manifest.in
|
|
@@ -215,6 +215,11 @@
|
|
@RESPATH@/components/marionette.js
|
|
#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/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
|
|
index ee271e6d7fd265aea278d841f66340a9c70e59f9..80665230adf04130e5bf79a3a2b09bec2c117442 100644
|
|
--- a/docshell/base/nsDocShell.cpp
|
|
+++ b/docshell/base/nsDocShell.cpp
|
|
@@ -15,6 +15,12 @@
|
|
# include <unistd.h> // 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"
|
|
@@ -62,6 +68,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"
|
|
@@ -83,6 +90,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/ParentChannelWrapper.h"
|
|
#include "mozilla/net/UrlClassifierFeatureFactory.h"
|
|
@@ -107,6 +115,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"
|
|
@@ -201,6 +210,7 @@
|
|
#include "nsGlobalWindow.h"
|
|
#include "nsISearchService.h"
|
|
#include "nsJSEnvironment.h"
|
|
+#include "nsJSUtils.h"
|
|
#include "nsNetCID.h"
|
|
#include "nsNetUtil.h"
|
|
#include "nsObjectLoadingContent.h"
|
|
@@ -396,6 +406,12 @@ 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),
|
|
mAllowAuth(mItemType == typeContent),
|
|
mAllowKeywordFixup(false),
|
|
mIsOffScreenBrowser(false),
|
|
@@ -1428,6 +1444,7 @@ bool nsDocShell::SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest,
|
|
}
|
|
}
|
|
|
|
+ FireOnFrameLocationChange(this, aRequest, aURI, aLocationFlags);
|
|
if (!isSubFrame && !isRoot) {
|
|
/*
|
|
* We don't want to send OnLocationChange notifications when
|
|
@@ -3256,6 +3273,204 @@ nsDocShell::GetMessageManager(ContentFrameMessageManager** aMessageManager) {
|
|
return NS_OK;
|
|
}
|
|
|
|
+// =============== Juggler Begin =======================
|
|
+
|
|
+nsDocShell* nsDocShell::GetRootDocShell() {
|
|
+ nsCOMPtr<nsIDocShellTreeItem> rootAsItem;
|
|
+ GetInProcessSameTypeRootTreeItem(getter_AddRefs(rootAsItem));
|
|
+ nsCOMPtr<nsIDocShell> 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) {
|
|
+ MOZ_ASSERT(aEnabled);
|
|
+ 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<nsIObserverService> observerService =
|
|
+ mozilla::services::GetObserverService();
|
|
+ observerService->NotifyObservers(
|
|
+ ToSupports(element), "juggler-file-picker-shown", nullptr);
|
|
+}
|
|
+
|
|
+RefPtr<nsGeolocationService> 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<nsPresContext> presContext = GetPresContext();
|
|
+ if (presContext) {
|
|
+ presContext->MediaFeatureValuesChanged(
|
|
+ {MediaFeatureChangeReason::SystemMetricsChange},
|
|
+ MediaFeatureChangePropagation::JustThisDocument);
|
|
+ }
|
|
+ return NS_OK;
|
|
+}
|
|
+
|
|
+// =============== Juggler End =======================
|
|
+
|
|
NS_IMETHODIMP
|
|
nsDocShell::GetIsNavigating(bool* aOut) {
|
|
*aOut = mIsNavigating;
|
|
@@ -4864,7 +5079,7 @@ nsDocShell::GetIsOffScreenBrowser(bool* aIsOffScreen) {
|
|
}
|
|
|
|
void nsDocShell::ActivenessMaybeChanged() {
|
|
- bool isActive = mBrowsingContext->IsActive();
|
|
+ bool isActive = mForceActiveState || mBrowsingContext->IsActive();
|
|
if (RefPtr<PresShell> presShell = GetPresShell()) {
|
|
presShell->SetIsActive(isActive);
|
|
}
|
|
@@ -8589,6 +8804,12 @@ nsresult nsDocShell::PerformRetargeting(nsDocShellLoadState* aLoadState) {
|
|
true, // aForceNoOpener
|
|
getter_AddRefs(newBC));
|
|
MOZ_ASSERT(!newBC);
|
|
+ if (rv == NS_OK) {
|
|
+ nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
|
|
+ if (observerService) {
|
|
+ observerService->NotifyObservers(GetAsSupports(this), "juggler-window-open-in-new-context", nullptr);
|
|
+ }
|
|
+ }
|
|
return rv;
|
|
}
|
|
|
|
@@ -12548,6 +12769,9 @@ class OnLinkClickEvent : public Runnable {
|
|
mHandler->OnLinkClickSync(mContent, mLoadState, mNoOpenerImplied,
|
|
mTriggeringPrincipal);
|
|
}
|
|
+ nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
|
|
+ observerService->NotifyObservers(ToSupports(mContent), "juggler-link-click-sync", nullptr);
|
|
+
|
|
return NS_OK;
|
|
}
|
|
|
|
@@ -12633,6 +12857,8 @@ nsresult nsDocShell::OnLinkClick(
|
|
nsCOMPtr<nsIRunnable> ev =
|
|
new OnLinkClickEvent(this, aContent, loadState, noOpenerImplied,
|
|
aIsTrusted, aTriggeringPrincipal);
|
|
+ nsCOMPtr<nsIObserverService> 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 9e0d878a7ee5fd02366bf6d5619a4f487c198ec3..0f48ae91881c37f02fdbf734dfad5e7b4a972bc3 100644
|
|
--- a/docshell/base/nsDocShell.h
|
|
+++ b/docshell/base/nsDocShell.h
|
|
@@ -14,6 +14,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"
|
|
@@ -75,6 +76,7 @@ class nsCommandManager;
|
|
class nsDocShellEditorData;
|
|
class nsDOMNavigationTiming;
|
|
class nsDSURIContentListener;
|
|
+class nsGeolocationService;
|
|
class nsGlobalWindowOuter;
|
|
|
|
class FramingChecker;
|
|
@@ -401,6 +403,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<nsGeolocationService> GetGeolocationServiceOverride();
|
|
+
|
|
// Create a content viewer within this nsDocShell for the given
|
|
// `WindowGlobalChild` actor.
|
|
nsresult CreateContentViewerForActor(
|
|
@@ -988,6 +999,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
|
|
@@ -1214,6 +1227,15 @@ 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<nsGeolocationService> mGeolocationServiceOverride;
|
|
+ OnlineOverride mOnlineOverride;
|
|
+ ColorSchemeOverride mColorSchemeOverride;
|
|
+
|
|
bool mAllowAuth : 1;
|
|
bool mAllowKeywordFixup : 1;
|
|
bool mIsOffScreenBrowser : 1;
|
|
diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl
|
|
index afa1eee3a6107067be52bf635e94be4271facee0..8d3e7bca533da4e55cc43843de552a12036d8340 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 nsIDocShellLoadInfo;
|
|
interface nsIEditor;
|
|
interface nsIEditingSession;
|
|
@@ -888,6 +889,35 @@ 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;
|
|
+
|
|
+ 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 3ca18053061af7ce2051e1426be915f7db051866..4827224bc7fde9ff4992a7829df9fca3d3421e25 100644
|
|
--- a/dom/base/Document.cpp
|
|
+++ b/dom/base/Document.cpp
|
|
@@ -3508,6 +3508,9 @@ void Document::SendToConsole(nsCOMArray<nsISecurityConsoleMessage>& aMessages) {
|
|
}
|
|
|
|
void Document::ApplySettingsFromCSP(bool aSpeculative) {
|
|
+ if (mDocumentContainer && mDocumentContainer->IsBypassCSPEnabled())
|
|
+ return;
|
|
+
|
|
nsresult rv = NS_OK;
|
|
if (!aSpeculative) {
|
|
// 1) apply settings from regular CSP
|
|
@@ -3562,6 +3565,11 @@ nsresult Document::InitCSP(nsIChannel* aChannel) {
|
|
return NS_OK;
|
|
}
|
|
|
|
+ nsCOMPtr<nsIDocShell> 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;
|
|
@@ -4354,6 +4362,10 @@ bool Document::HasFocus(ErrorResult& rv) const {
|
|
return false;
|
|
}
|
|
|
|
+ if (IsActive() && mDocumentContainer->ShouldOverrideHasFocus()) {
|
|
+ return true;
|
|
+ }
|
|
+
|
|
// Is there a focused DOMWindow?
|
|
nsCOMPtr<mozIDOMWindowProxy> focusedWindow;
|
|
fm->GetFocusedWindow(getter_AddRefs(focusedWindow));
|
|
@@ -17131,6 +17143,19 @@ void Document::RemoveToplevelLoadingDocument(Document* aDoc) {
|
|
|
|
StylePrefersColorScheme Document::PrefersColorScheme(
|
|
IgnoreRFP aIgnoreRFP) const {
|
|
+ auto* docShell = static_cast<nsDocShell*>(GetDocShell());
|
|
+ nsIDocShell::ColorSchemeOverride colorScheme;
|
|
+ if (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_NO_PREFERENCE:
|
|
+ return StylePrefersColorScheme::NoPreference;
|
|
+ };
|
|
+ }
|
|
if (aIgnoreRFP == IgnoreRFP::No &&
|
|
nsContentUtils::ShouldResistFingerprinting(this)) {
|
|
return StylePrefersColorScheme::Light;
|
|
diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp
|
|
index db65cd4bade5f14dc510a7f831ff6686167e90d6..c73575d3798572c32453ad86a8bfb632a6ddf31e 100644
|
|
--- a/dom/base/Navigator.cpp
|
|
+++ b/dom/base/Navigator.cpp
|
|
@@ -325,14 +325,18 @@ void Navigator::GetAppName(nsAString& aAppName, CallerType aCallerType) const {
|
|
* for more detail.
|
|
*/
|
|
/* static */
|
|
-void Navigator::GetAcceptLanguages(nsTArray<nsString>& aLanguages) {
|
|
+void Navigator::GetAcceptLanguages(const nsString* aLanguageOverride, nsTArray<nsString>& 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 :
|
|
@@ -384,7 +388,9 @@ void Navigator::GetLanguage(nsAString& aLanguage) {
|
|
}
|
|
|
|
void Navigator::GetLanguages(nsTArray<nsString>& 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
|
|
@@ -548,7 +554,13 @@ bool Navigator::CookieEnabled() {
|
|
return granted;
|
|
}
|
|
|
|
-bool Navigator::OnLine() { return !NS_IsOffline(); }
|
|
+bool Navigator::OnLine() {
|
|
+ nsDocShell* docShell = static_cast<nsDocShell*>(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 99be251bf05a0252d624c6b0e216e5fa9be58260..cca8719a07ce51aa386ac45c72b01711423ec740 100644
|
|
--- a/dom/base/Navigator.h
|
|
+++ b/dom/base/Navigator.h
|
|
@@ -221,7 +221,7 @@ class Navigator final : public nsISupports, public nsWrapperCache {
|
|
|
|
StorageManager* Storage();
|
|
|
|
- static void GetAcceptLanguages(nsTArray<nsString>& aLanguages);
|
|
+ static void GetAcceptLanguages(const nsString* aLanguageOverride, nsTArray<nsString>& aLanguages);
|
|
|
|
dom::MediaCapabilities* MediaCapabilities();
|
|
dom::MediaSession* MediaSession();
|
|
diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
|
|
index 86850992a9146b49d9b332ff6ad74cd699509362..87fd36dfaced34b49d5a61967765863b1453e256 100644
|
|
--- a/dom/base/nsContentUtils.cpp
|
|
+++ b/dom/base/nsContentUtils.cpp
|
|
@@ -8104,7 +8104,8 @@ nsresult nsContentUtils::SendMouseEvent(
|
|
bool aIgnoreRootScrollFrame, float aPressure,
|
|
unsigned short aInputSourceArg, uint32_t aIdentifier, bool aToWindow,
|
|
bool* aPreventDefault, bool aIsDOMEventSynthesized,
|
|
- bool aIsWidgetEventSynthesized) {
|
|
+ bool aIsWidgetEventSynthesized,
|
|
+ bool convertToPointer) {
|
|
nsPoint offset;
|
|
nsCOMPtr<nsIWidget> widget = GetWidget(aPresShell, &offset);
|
|
if (!widget) return NS_ERROR_FAILURE;
|
|
@@ -8161,6 +8162,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 d418448ef27acb5ec3798422e5b90cfedfb39289..4fa538a6a24c8a1e7b28ad3fffa76dbeb9321cc7 100644
|
|
--- a/dom/base/nsContentUtils.h
|
|
+++ b/dom/base/nsContentUtils.h
|
|
@@ -2903,7 +2903,7 @@ class nsContentUtils {
|
|
int32_t aModifiers, bool aIgnoreRootScrollFrame, float aPressure,
|
|
unsigned short aInputSourceArg, uint32_t aIdentifier, bool aToWindow,
|
|
bool* aPreventDefault, bool aIsDOMEventSynthesized,
|
|
- bool aIsWidgetEventSynthesized);
|
|
+ bool aIsWidgetEventSynthesized, bool convertToPointer = true);
|
|
|
|
static void FirePageShowEventForFrameLoaderSwap(
|
|
nsIDocShellTreeItem* aItem,
|
|
diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp
|
|
index c48d11d1d943c76a81cca1afa1e4b2c5c842022b..f0b0ebdb8fd065e3b346bfe003cc81514626118a 100644
|
|
--- a/dom/base/nsDOMWindowUtils.cpp
|
|
+++ b/dom/base/nsDOMWindowUtils.cpp
|
|
@@ -684,7 +684,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,
|
|
@@ -692,7 +692,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
|
|
@@ -719,12 +719,12 @@ 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> presShell = GetPresShell();
|
|
return nsContentUtils::SendMouseEvent(
|
|
presShell, aType, aX, aY, aButton, aButtons, aClickCount, aModifiers,
|
|
aIgnoreRootScrollFrame, aPressure, aInputSourceArg, aPointerId, aToWindow,
|
|
- aPreventDefault, aIsDOMEventSynthesized, aIsWidgetEventSynthesized);
|
|
+ aPreventDefault, aIsDOMEventSynthesized, aIsWidgetEventSynthesized, aConvertToPointer);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
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 bc165f897b2bdb4e965ad1796b5ca96c70a1315c..abb06912f0d1e143c5fb25d0ecc65bd2d9ae76c1 100644
|
|
--- a/dom/base/nsFocusManager.cpp
|
|
+++ b/dom/base/nsFocusManager.cpp
|
|
@@ -1541,6 +1541,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 &&
|
|
@@ -2834,7 +2838,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 25dc13cc6fa6623147a9be2a565d791fae47764f..c284a26e855a1787b230b2d9a555f61008fae665 100644
|
|
--- a/dom/base/nsGlobalWindowOuter.cpp
|
|
+++ b/dom/base/nsGlobalWindowOuter.cpp
|
|
@@ -2465,7 +2465,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
|
|
@@ -2484,10 +2484,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));
|
|
+ }
|
|
}
|
|
}
|
|
|
|
@@ -2611,6 +2617,19 @@ void nsGlobalWindowOuter::DispatchDOMWindowCreated() {
|
|
}
|
|
}
|
|
|
|
+void nsGlobalWindowOuter::JugglerDispatchDOMWindowReused() {
|
|
+ nsCOMPtr<nsIObserverService> observerService =
|
|
+ mozilla::services::GetObserverService();
|
|
+ if (observerService && mDoc) {
|
|
+ nsIPrincipal* principal = mDoc->NodePrincipal();
|
|
+ if (!principal->IsSystemPrincipal()) {
|
|
+ observerService->NotifyObservers(static_cast<nsIDOMWindow*>(this),
|
|
+ "juggler-dom-window-reused",
|
|
+ nullptr);
|
|
+ }
|
|
+ }
|
|
+}
|
|
+
|
|
void nsGlobalWindowOuter::ClearStatus() { SetStatusOuter(u""_ns); }
|
|
|
|
void nsGlobalWindowOuter::SetDocShell(nsDocShell* aDocShell) {
|
|
@@ -3866,6 +3885,14 @@ Maybe<CSSIntSize> 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 cbcb92591729b1c60ac37831ef6b2305d67f79dd..ea8eeaa814960be4aea7d61896ce8cde5927f6b2 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 c4092ce9138022cc73d0800650745f1d42082726..61f3adb2d5ac691593bb09a94f62a0f1234f05f6 100644
|
|
--- a/dom/base/nsINode.cpp
|
|
+++ b/dom/base/nsINode.cpp
|
|
@@ -1289,6 +1289,48 @@ 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> 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,
|
|
+ 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<DOMQuad> 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 7ba2a9b84d51a2d72eca9624a102554a4ac60260..10644adced58c07e52f8650e35fa49383ec1309c 100644
|
|
--- a/dom/base/nsINode.h
|
|
+++ b/dom/base/nsINode.h
|
|
@@ -2059,6 +2059,10 @@ class nsINode : public mozilla::dom::EventTarget {
|
|
nsTArray<RefPtr<DOMQuad>>& aResult,
|
|
ErrorResult& aRv);
|
|
|
|
+ void ScrollRectIntoViewIfNeeded(int32_t x, int32_t y,
|
|
+ int32_t w, int32_t h,
|
|
+ ErrorResult& aRv);
|
|
+
|
|
already_AddRefed<DOMQuad> ConvertQuadFromNode(
|
|
DOMQuad& aQuad, const TextOrElementOrDocument& aFrom,
|
|
const ConvertCoordinateOptions& aOptions, CallerType aCallerType,
|
|
diff --git a/dom/base/nsJSUtils.cpp b/dom/base/nsJSUtils.cpp
|
|
index 46db78b384e40d11962b8ae7eacce63e986f6507..3e3b9e23fe301f6032d3f71fd3e46d75f9283dee 100644
|
|
--- a/dom/base/nsJSUtils.cpp
|
|
+++ b/dom/base/nsJSUtils.cpp
|
|
@@ -219,6 +219,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 b53d2f740b5901e4422fa3af84198dc687c535d9..052d15cccb021540cc9c7dfe5a9337d9cd43661b 100644
|
|
--- a/dom/base/nsJSUtils.h
|
|
+++ b/dom/base/nsJSUtils.h
|
|
@@ -102,6 +102,7 @@ class nsJSUtils {
|
|
JSContext* aCx, mozilla::dom::Element* aElement,
|
|
JS::MutableHandleVector<JSObject*> aScopeChain);
|
|
|
|
+ static bool SetTimeZoneOverride(const char* timezoneId);
|
|
static void ResetTimeZone();
|
|
|
|
static bool DumpEnabled();
|
|
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<nsGeolocationService> 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<nsGeolocationService> gs =
|
|
- nsGeolocationService::GetGeolocationService();
|
|
+ nsGeolocationService* gs = mLocator ? mLocator->GetGeolocationService() : nullptr;
|
|
if (gs) {
|
|
gs->UpdateAccuracy();
|
|
}
|
|
@@ -708,8 +706,14 @@ void nsGeolocationService::StopDevice() {
|
|
StaticRefPtr<nsGeolocationService> nsGeolocationService::sService;
|
|
|
|
already_AddRefed<nsGeolocationService>
|
|
-nsGeolocationService::GetGeolocationService() {
|
|
+nsGeolocationService::GetGeolocationService(nsDocShell* docShell) {
|
|
RefPtr<nsGeolocationService> 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<Document> doc = aContentDom ? aContentDom->GetDoc() : nullptr;
|
|
+ mService = nsGeolocationService::GetGeolocationService(
|
|
+ doc ? static_cast<nsDocShell*>(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<PositionCallback, nsIDOMGeoPositionCallback>
|
|
GeoPositionCallback;
|
|
typedef CallbackObjectHolder<PositionErrorCallback,
|
|
@@ -51,13 +53,14 @@ struct CachedPositionAndAccuracy {
|
|
bool isHighAccuracy;
|
|
};
|
|
|
|
+
|
|
/**
|
|
* Singleton that manages the geolocation provider
|
|
*/
|
|
class nsGeolocationService final : public nsIGeolocationUpdate,
|
|
public nsIObserver {
|
|
public:
|
|
- static already_AddRefed<nsGeolocationService> GetGeolocationService();
|
|
+ static already_AddRefed<nsGeolocationService> GetGeolocationService(nsDocShell* docShell = nullptr);
|
|
static mozilla::StaticRefPtr<nsGeolocationService> sService;
|
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
@@ -182,6 +185,8 @@ class Geolocation final : public nsIGeolocationUpdate, public nsWrapperCache {
|
|
// null.
|
|
static already_AddRefed<Geolocation> NonWindowSingleton();
|
|
|
|
+ nsGeolocationService* GetGeolocationService() { return mService; };
|
|
+
|
|
private:
|
|
~Geolocation();
|
|
|
|
diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp
|
|
index e84d681d10f28cd43d814e347aae395519ddf82e..b1eded508e019e294581e769a1079b303b416ab1 100644
|
|
--- a/dom/html/HTMLInputElement.cpp
|
|
+++ b/dom/html/HTMLInputElement.cpp
|
|
@@ -51,6 +51,7 @@
|
|
#include "nsMappedAttributes.h"
|
|
#include "nsIFormControl.h"
|
|
#include "mozilla/dom/Document.h"
|
|
+#include "nsDocShell.h"
|
|
#include "nsIFormControlFrame.h"
|
|
#include "nsITextControlFrame.h"
|
|
#include "nsIFrame.h"
|
|
@@ -738,6 +739,12 @@ nsresult HTMLInputElement::InitFilePicker(FilePickerType aType) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
+ nsDocShell* docShell = static_cast<nsDocShell*>(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 d69348abd5286474ad2795f294020fe3c4f175b0..349ddfae368b519a1f9cc59d2c6d202085aaaa0f 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/ipc/BrowserChild.cpp b/dom/ipc/BrowserChild.cpp
|
|
index 9438f3468944c579d8de0ef2391e2652b8f655c6..4577ada3b3bbf563b27a144eb1c9a7ae63841bed 100644
|
|
--- a/dom/ipc/BrowserChild.cpp
|
|
+++ b/dom/ipc/BrowserChild.cpp
|
|
@@ -3601,6 +3601,13 @@ NS_IMETHODIMP BrowserChild::OnStateChange(nsIWebProgress* aWebProgress,
|
|
return NS_OK;
|
|
}
|
|
|
|
+NS_IMETHODIMP BrowserChild::OnFrameLocationChange(nsIWebProgress *aWebProgress,
|
|
+ nsIRequest *aRequest,
|
|
+ nsIURI *aLocation,
|
|
+ uint32_t aFlags) {
|
|
+ return NS_OK;
|
|
+}
|
|
+
|
|
NS_IMETHODIMP BrowserChild::OnProgressChange(nsIWebProgress* aWebProgress,
|
|
nsIRequest* aRequest,
|
|
int32_t aCurSelfProgress,
|
|
diff --git a/dom/media/systemservices/video_engine/desktop_capture_impl.cc b/dom/media/systemservices/video_engine/desktop_capture_impl.cc
|
|
index 7bc92fe4408c2878c9d7c8bdb97a7c257258ee31..8885feebedf53c0748cef19d80ce5aa23adc900b 100644
|
|
--- a/dom/media/systemservices/video_engine/desktop_capture_impl.cc
|
|
+++ b/dom/media/systemservices/video_engine/desktop_capture_impl.cc
|
|
@@ -125,8 +125,9 @@ int32_t ScreenDeviceInfoImpl::GetOrientation(const char* deviceUniqueIdUTF8,
|
|
|
|
VideoCaptureModule* DesktopCaptureImpl::Create(const int32_t id,
|
|
const char* uniqueId,
|
|
- const CaptureDeviceType type) {
|
|
- return new rtc::RefCountedObject<DesktopCaptureImpl>(id, uniqueId, type);
|
|
+ const CaptureDeviceType type,
|
|
+ bool captureCursor) {
|
|
+ return new rtc::RefCountedObject<DesktopCaptureImpl>(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<DesktopAndCursorComposer>(new DesktopAndCursorComposer(
|
|
- pWindowCapturer.release(), pMouseCursorMonitor));
|
|
+ if (capture_cursor_) {
|
|
+ MouseCursorMonitor* pMouseCursorMonitor =
|
|
+ MouseCursorMonitor::CreateForWindow(
|
|
+ webrtc::DesktopCaptureOptions::CreateDefault(), sourceId);
|
|
+ desktop_capturer_cursor_composer_ =
|
|
+ std::unique_ptr<DesktopAndCursorComposer>(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_(
|
|
diff --git a/dom/media/systemservices/video_engine/desktop_capture_impl.h b/dom/media/systemservices/video_engine/desktop_capture_impl.h
|
|
index 75995564e5438261a2886840ecad32d2f1d7663f..dfdabcedcda4e212ed0ffd7bc4def57079218413 100644
|
|
--- a/dom/media/systemservices/video_engine/desktop_capture_impl.h
|
|
+++ b/dom/media/systemservices/video_engine/desktop_capture_impl.h
|
|
@@ -159,7 +159,8 @@ class DesktopCaptureImpl : public DesktopCapturer::Callback,
|
|
/* Create a screen capture modules object
|
|
*/
|
|
static VideoCaptureModule* Create(const int32_t id, const char* uniqueId,
|
|
- const CaptureDeviceType type);
|
|
+ const CaptureDeviceType type,
|
|
+ bool captureCursor = true);
|
|
static VideoCaptureModule::DeviceInfo* CreateDeviceInfo(
|
|
const int32_t id, const CaptureDeviceType type);
|
|
|
|
@@ -191,7 +192,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);
|
|
@@ -239,6 +240,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 589b46999c7f917c55e9e5e042f45a01cca7e9eb..128eb07822da31d1f6040b2505247c71fc9353b0 100644
|
|
--- a/dom/script/ScriptSettings.cpp
|
|
+++ b/dom/script/ScriptSettings.cpp
|
|
@@ -195,6 +195,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<JSObject*> 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.
|
|
@@ -222,7 +246,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 9835738d05bb7dce525ab4ae35cf1a143ab61fb7..8517fb771efc15588aa1764de668a60f988c0267 100644
|
|
--- a/dom/security/nsCSPUtils.cpp
|
|
+++ b/dom/security/nsCSPUtils.cpp
|
|
@@ -126,6 +126,11 @@ void CSP_ApplyMetaCSPToDoc(mozilla::dom::Document& aDoc,
|
|
return;
|
|
}
|
|
|
|
+ if (aDoc.GetDocShell() &&
|
|
+ nsDocShell::Cast(aDoc.GetDocShell())->IsBypassCSPEnabled()) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
nsAutoString policyStr(
|
|
nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespace>(
|
|
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<DOMQuad> 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 71f6d5e1acdfe6e4afeb36582063a6879ab5fa1d..97c226ef0521bf4fc1ae86c209a123a28bb08a16 100644
|
|
--- a/dom/workers/RuntimeService.cpp
|
|
+++ b/dom/workers/RuntimeService.cpp
|
|
@@ -1009,7 +1009,7 @@ void PrefLanguagesChanged(const char* /* aPrefName */, void* /* aClosure */) {
|
|
AssertIsOnMainThread();
|
|
|
|
nsTArray<nsString> languages;
|
|
- Navigator::GetAcceptLanguages(languages);
|
|
+ Navigator::GetAcceptLanguages(nullptr, languages);
|
|
|
|
RuntimeService* runtime = RuntimeService::GetService();
|
|
if (runtime) {
|
|
@@ -1208,8 +1208,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;
|
|
}
|
|
|
|
@@ -1922,6 +1921,13 @@ void RuntimeService::PropagateStorageAccessPermissionGranted(
|
|
}
|
|
}
|
|
|
|
+void RuntimeService::ResetDefaultLocaleInAllWorkers() {
|
|
+ AssertIsOnMainThread();
|
|
+ BroadcastAllWorkers([](auto& worker) {
|
|
+ worker.ResetDefaultLocale();
|
|
+ });
|
|
+}
|
|
+
|
|
void RuntimeService::NoteIdleThread(SafeRefPtr<WorkerThread> aThread) {
|
|
AssertIsOnMainThread();
|
|
MOZ_ASSERT(aThread);
|
|
@@ -2340,6 +2346,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 67eac10dabd93da344a1366dee5d1c4428a4352c..1c31651d8087c90983c08fe184b344853af87033 100644
|
|
--- a/dom/workers/RuntimeService.h
|
|
+++ b/dom/workers/RuntimeService.h
|
|
@@ -121,6 +121,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 a1434c6b43e57abbccf3003540ce50f5bf6bb5bd..178583e81354d957bcf0058a4c3a416072c99526 100644
|
|
--- a/dom/workers/WorkerPrivate.cpp
|
|
+++ b/dom/workers/WorkerPrivate.cpp
|
|
@@ -660,6 +660,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<nsString> mLanguages;
|
|
|
|
@@ -1840,6 +1852,16 @@ void WorkerPrivate::UpdateContextOptions(
|
|
}
|
|
}
|
|
|
|
+void WorkerPrivate::ResetDefaultLocale() {
|
|
+ AssertIsOnParentThread();
|
|
+
|
|
+ RefPtr<ResetDefaultLocaleRunnable> runnable =
|
|
+ new ResetDefaultLocaleRunnable(this);
|
|
+ if (!runnable->Dispatch()) {
|
|
+ NS_WARNING("Failed to reset default locale in worker!");
|
|
+ }
|
|
+}
|
|
+
|
|
void WorkerPrivate::UpdateLanguages(const nsTArray<nsString>& aLanguages) {
|
|
AssertIsOnParentThread();
|
|
|
|
@@ -4807,6 +4829,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<nsString>& aLanguages) {
|
|
WorkerGlobalScope* globalScope = GlobalScope();
|
|
diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
|
|
index 49255ca854d9082186fb8055f0a40d7f57e6d6e2..94dc99e306c823ee5d515c469f289c0d1c6dff02 100644
|
|
--- a/dom/workers/WorkerPrivate.h
|
|
+++ b/dom/workers/WorkerPrivate.h
|
|
@@ -299,6 +299,8 @@ class WorkerPrivate : public RelativeTimeline {
|
|
void UpdateContextOptionsInternal(JSContext* aCx,
|
|
const JS::ContextOptions& aContextOptions);
|
|
|
|
+ void ResetDefaultLocaleInternal(JSContext* aCx);
|
|
+
|
|
void UpdateLanguagesInternal(const nsTArray<nsString>& aLanguages);
|
|
|
|
void UpdateJSWorkerMemoryParameterInternal(JSContext* aCx, JSGCParamKey key,
|
|
@@ -888,6 +890,8 @@ class WorkerPrivate : public RelativeTimeline {
|
|
|
|
void UpdateContextOptions(const JS::ContextOptions& aContextOptions);
|
|
|
|
+ void ResetDefaultLocale();
|
|
+
|
|
void UpdateLanguages(const nsTArray<nsString>& aLanguages);
|
|
|
|
void UpdateJSWorkerMemoryParameter(JSGCParamKey key, Maybe<uint32_t> value);
|
|
diff --git a/js/public/Date.h b/js/public/Date.h
|
|
index e7a54d86c44499a3ec2adf1c156b9f9dfb0bc6b4..f56c1b419c4cb52bc371f6b8dbfffba464326fc4 100644
|
|
--- a/js/public/Date.h
|
|
+++ b/js/public/Date.h
|
|
@@ -56,6 +56,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 5675b63ad8e172578db2375f01a51219f5deb0b7..d390b9a426f3176215f7ed548cb2a9b96ea79d7a 100644
|
|
--- a/js/src/debugger/Object.cpp
|
|
+++ b/js/src/debugger/Object.cpp
|
|
@@ -2353,7 +2353,11 @@ Maybe<Completion> 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 a587c912b36f2a142aef7ed03e245636f8a0100d..95864acc2d9fc4ef9e1ad2bb7a2b97642ada1a22 100644
|
|
--- a/js/src/vm/DateTime.cpp
|
|
+++ b/js/src/vm/DateTime.cpp
|
|
@@ -169,6 +169,11 @@ void js::DateTimeInfo::internalResetTimeZone(ResetTimeZoneMode mode) {
|
|
}
|
|
}
|
|
|
|
+void js::DateTimeInfo::internalSetTimeZoneOverride(mozilla::UniquePtr<icu::TimeZone> timeZone) {
|
|
+ timeZoneOverride_ = std::move(timeZone);
|
|
+ internalResetTimeZone(ResetTimeZoneMode::ResetEvenIfOffsetUnchanged);
|
|
+}
|
|
+
|
|
void js::DateTimeInfo::updateTimeZone() {
|
|
MOZ_ASSERT(timeZoneStatus_ != TimeZoneStatus::Valid);
|
|
|
|
@@ -529,10 +534,27 @@ void js::ResetTimeZoneInternal(ResetTimeZoneMode mode) {
|
|
js::DateTimeInfo::resetTimeZone(mode);
|
|
}
|
|
|
|
+void js::SetTimeZoneOverrideInternal(mozilla::UniquePtr<icu::TimeZone> 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<icu::TimeZone> 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
|
|
@@ -733,6 +755,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 25c5b01fc54c8d45da8ceb7cf6ba163bee3c5361..490c5ce49cd9b5f804df59abbfb0450fb9d1f877 100644
|
|
--- a/js/src/vm/DateTime.h
|
|
+++ b/js/src/vm/DateTime.h
|
|
@@ -67,6 +67,8 @@ enum class ResetTimeZoneMode : bool {
|
|
*/
|
|
extern void ResetTimeZoneInternal(ResetTimeZoneMode mode);
|
|
|
|
+extern void SetTimeZoneOverrideInternal(mozilla::UniquePtr<icu::TimeZone> 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
|
|
@@ -206,6 +208,7 @@ class DateTimeInfo {
|
|
// and js::ResyncICUDefaultTimeZone().
|
|
friend void js::ResetTimeZoneInternal(ResetTimeZoneMode);
|
|
friend void js::ResyncICUDefaultTimeZone();
|
|
+ friend void js::SetTimeZoneOverrideInternal(mozilla::UniquePtr<icu::TimeZone>);
|
|
|
|
static void resetTimeZone(ResetTimeZoneMode mode) {
|
|
auto guard = instance->lock();
|
|
@@ -302,6 +305,8 @@ class DateTimeInfo {
|
|
JS::UniqueChars locale_;
|
|
JS::UniqueTwoByteChars standardName_;
|
|
JS::UniqueTwoByteChars daylightSavingsName_;
|
|
+
|
|
+ mozilla::UniquePtr<icu::TimeZone> 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
|
|
@@ -317,6 +322,8 @@ class DateTimeInfo {
|
|
|
|
void internalResetTimeZone(ResetTimeZoneMode mode);
|
|
|
|
+ void internalSetTimeZoneOverride(mozilla::UniquePtr<icu::TimeZone> timeZone);
|
|
+
|
|
void updateTimeZone();
|
|
|
|
void internalResyncICUDefaultTimeZone();
|
|
diff --git a/netwerk/base/nsINetworkInterceptController.idl b/netwerk/base/nsINetworkInterceptController.idl
|
|
index 64a4a71b03b28872f376aac8eee12805bebd1bd8..f6fa7d731f3b0c7c4fcb26babad3fc2cdb29aec1 100644
|
|
--- a/netwerk/base/nsINetworkInterceptController.idl
|
|
+++ b/netwerk/base/nsINetworkInterceptController.idl
|
|
@@ -56,6 +56,7 @@ interface nsIInterceptedChannel : nsISupports
|
|
* network request.
|
|
*/
|
|
void resetInterception();
|
|
+ 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 667990b9d411963f23734652e04c5b5aa5574eef..9408cd2c88443c1a0053b1d9d15146a51900e320 100644
|
|
--- a/netwerk/protocol/http/InterceptedHttpChannel.cpp
|
|
+++ b/netwerk/protocol/http/InterceptedHttpChannel.cpp
|
|
@@ -602,6 +602,14 @@ void InterceptedHttpChannel::DoAsyncAbort(nsresult aStatus) {
|
|
Unused << AsyncAbort(aStatus);
|
|
}
|
|
|
|
+NS_IMETHODIMP
|
|
+InterceptedHttpChannel::ResetInterceptionWithURI(nsIURI* aURI) {
|
|
+ if (aURI) {
|
|
+ mURI = aURI;
|
|
+ }
|
|
+ return ResetInterception();
|
|
+}
|
|
+
|
|
NS_IMETHODIMP
|
|
InterceptedHttpChannel::ResetInterception(void) {
|
|
if (mCanceled) {
|
|
diff --git a/parser/html/nsHtml5TreeOpExecutor.cpp b/parser/html/nsHtml5TreeOpExecutor.cpp
|
|
index a49cac38b8fb09ed1b3fe0f67e24c57dc26c2321..cb8b40f1f58d3dffe4c5e335f8dcfa5e7fefc62f 100644
|
|
--- a/parser/html/nsHtml5TreeOpExecutor.cpp
|
|
+++ b/parser/html/nsHtml5TreeOpExecutor.cpp
|
|
@@ -1209,9 +1209,12 @@ void nsHtml5TreeOpExecutor::AddSpeculationCSP(const nsAString& aCSP) {
|
|
if (!StaticPrefs::security_csp_enable()) {
|
|
return;
|
|
}
|
|
-
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
+ if (mDocShell && static_cast<nsDocShell*>(mDocShell.get())->IsBypassCSPEnabled()) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
nsresult rv = NS_OK;
|
|
nsCOMPtr<nsIContentSecurityPolicy> preloadCsp = mDocument->GetPreloadCsp();
|
|
if (!preloadCsp) {
|
|
diff --git a/security/manager/ssl/SSLServerCertVerification.cpp b/security/manager/ssl/SSLServerCertVerification.cpp
|
|
index 3c5512c95e9c1f6f06387238063a29c01f7aab64..357aaf8a0f45ee81864d25e2205d6276188ca81e 100644
|
|
--- a/security/manager/ssl/SSLServerCertVerification.cpp
|
|
+++ b/security/manager/ssl/SSLServerCertVerification.cpp
|
|
@@ -977,8 +977,8 @@ PRErrorCode AuthCertificateParseResults(
|
|
return SEC_ERROR_NO_MEMORY;
|
|
}
|
|
nsresult rv = overrideService->HasMatchingOverride(
|
|
- aHostName, aPort, nssCert, &overrideBits, &isTemporaryOverride,
|
|
- &haveOverride);
|
|
+ aHostName, aPort, aOriginAttributes.mUserContextId, nssCert,
|
|
+ &overrideBits, &isTemporaryOverride, &haveOverride);
|
|
if (NS_SUCCEEDED(rv) && haveOverride) {
|
|
// remove the errors that are already overriden
|
|
remainingDisplayErrors &= ~overrideBits;
|
|
diff --git a/security/manager/ssl/nsCertOverrideService.cpp b/security/manager/ssl/nsCertOverrideService.cpp
|
|
index 04fdc8b475dbf14d934bb4b8ffdf9dad2c32a1ab..04f3889910a2fc626da682d1d9c5e04d0d35cd32 100644
|
|
--- a/security/manager/ssl/nsCertOverrideService.cpp
|
|
+++ b/security/manager/ssl/nsCertOverrideService.cpp
|
|
@@ -522,13 +522,20 @@ nsCertOverrideService::RememberTemporaryValidityOverrideUsingFingerprint(
|
|
|
|
NS_IMETHODIMP
|
|
nsCertOverrideService::HasMatchingOverride(const nsACString& aHostName,
|
|
- int32_t aPort, nsIX509Cert* aCert,
|
|
+ int32_t aPort,
|
|
+ uint32_t aUserContextId,
|
|
+ nsIX509Cert* aCert,
|
|
uint32_t* aOverrideBits,
|
|
bool* aIsTemporary, bool* _retval) {
|
|
bool disableAllSecurityCheck = false;
|
|
{
|
|
MutexAutoLock lock(mMutex);
|
|
- disableAllSecurityCheck = mDisableAllSecurityCheck;
|
|
+ if (aUserContextId) {
|
|
+ disableAllSecurityCheck = mUserContextIdsWithDisabledSecurityChecks.has(
|
|
+ aUserContextId);
|
|
+ } else {
|
|
+ disableAllSecurityCheck = mDisableAllSecurityCheck;
|
|
+ }
|
|
}
|
|
if (disableAllSecurityCheck) {
|
|
nsCertOverride::OverrideBits all = nsCertOverride::OverrideBits::Untrusted |
|
|
@@ -740,12 +747,21 @@ 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);
|
|
+ if (aUserContextId) {
|
|
+ if (aDisable) {
|
|
+ mozilla::Unused << mUserContextIdsWithDisabledSecurityChecks.put(aUserContextId);
|
|
+ } else {
|
|
+ mUserContextIdsWithDisabledSecurityChecks.remove(aUserContextId);
|
|
+ }
|
|
+ return NS_OK;
|
|
+ }
|
|
mDisableAllSecurityCheck = aDisable;
|
|
return NS_OK;
|
|
}
|
|
diff --git a/security/manager/ssl/nsCertOverrideService.h b/security/manager/ssl/nsCertOverrideService.h
|
|
index ba995b75e6d8836abf367e26217f1b33c28909f5..092aea36289651d69369a88ec7f7751bbcb31473 100644
|
|
--- a/security/manager/ssl/nsCertOverrideService.h
|
|
+++ b/security/manager/ssl/nsCertOverrideService.h
|
|
@@ -126,6 +126,7 @@ class nsCertOverrideService final : public nsICertOverrideService,
|
|
private:
|
|
~nsCertOverrideService();
|
|
|
|
+ mozilla::HashSet<uint32_t> mUserContextIdsWithDisabledSecurityChecks;
|
|
mozilla::Mutex mMutex;
|
|
bool mDisableAllSecurityCheck;
|
|
nsCOMPtr<nsIFile> mSettingsFile;
|
|
diff --git a/security/manager/ssl/nsICertOverrideService.idl b/security/manager/ssl/nsICertOverrideService.idl
|
|
index 23276fbe1933b87eca13f41550c4a9ec78b1c76b..02ad890e2a884f9988ec02eef88727836a92e8d2 100644
|
|
--- a/security/manager/ssl/nsICertOverrideService.idl
|
|
+++ b/security/manager/ssl/nsICertOverrideService.idl
|
|
@@ -130,6 +130,7 @@ interface nsICertOverrideService : nsISupports {
|
|
[must_use]
|
|
boolean hasMatchingOverride(in AUTF8String aHostName,
|
|
in int32_t aPort,
|
|
+ in uint32_t aUserContextId,
|
|
in nsIX509Cert aCert,
|
|
out uint32_t aOverrideBits,
|
|
out boolean aIsTemporary);
|
|
@@ -171,5 +172,7 @@ 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);
|
|
};
|
|
diff --git a/services/settings/Utils.jsm b/services/settings/Utils.jsm
|
|
index 66df8509044600a0d71eb36bb838f96087a53ef1..e4558874434e3aa57bc26344f0ca89b3ebb837bf 100644
|
|
--- a/services/settings/Utils.jsm
|
|
+++ b/services/settings/Utils.jsm
|
|
@@ -59,7 +59,7 @@ var Utils = {
|
|
Ci.nsIEnvironment
|
|
);
|
|
const isXpcshell = env.exists("XPCSHELL_TEST_PROFILE_DIR");
|
|
- return AppConstants.RELEASE_OR_BETA && !Cu.isInAutomation && !isXpcshell
|
|
+ return false && !Cu.isInAutomation && !isXpcshell
|
|
? "https://firefox.settings.services.mozilla.com/v1"
|
|
: gServerURL;
|
|
},
|
|
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 dd475eb83b3bc0206f33807d416fb7b29326986c..207f76bf7e3bf2725a036ecaa280672e39e81005 100644
|
|
--- a/toolkit/components/startup/nsAppStartup.cpp
|
|
+++ b/toolkit/components/startup/nsAppStartup.cpp
|
|
@@ -341,7 +341,7 @@ nsAppStartup::Quit(uint32_t aMode, int aExitCode, bool* aUserAllowedQuit) {
|
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
|
nsCOMPtr<nsIWindowMediator> 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..44db941025a5253da38572600cd0fc57f54ee6bf 100644
|
|
--- a/toolkit/components/statusfilter/nsBrowserStatusFilter.cpp
|
|
+++ b/toolkit/components/statusfilter/nsBrowserStatusFilter.cpp
|
|
@@ -162,8 +162,16 @@ nsBrowserStatusFilter::OnStateChange(nsIWebProgress* aWebProgress,
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
-nsBrowserStatusFilter::OnProgressChange(nsIWebProgress* aWebProgress,
|
|
- nsIRequest* aRequest,
|
|
+nsBrowserStatusFilter::OnFrameLocationChange(nsIWebProgress *aWebProgress,
|
|
+ nsIRequest *aRequest,
|
|
+ nsIURI *aLocation,
|
|
+ uint32_t aFlags) {
|
|
+ return NS_OK;
|
|
+}
|
|
+
|
|
+NS_IMETHODIMP
|
|
+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 7ed92e814cd4a952bf98e97a88075f4c1a208e7e..04c58cf1897823db276c1b006c6d5ebe798c2d0d 100644
|
|
--- a/toolkit/components/windowwatcher/nsWindowWatcher.cpp
|
|
+++ b/toolkit/components/windowwatcher/nsWindowWatcher.cpp
|
|
@@ -1815,6 +1815,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 43fd3ddbf7f2678365d48524e366d4647ee1b815..046290332ad7fa2f0b9bbe12b6fa350c6cece8a4 100644
|
|
--- a/toolkit/mozapps/update/UpdateService.jsm
|
|
+++ b/toolkit/mozapps/update/UpdateService.jsm
|
|
@@ -3565,7 +3565,7 @@ UpdateService.prototype = {
|
|
).running;
|
|
}
|
|
|
|
- return (
|
|
+ return true || (
|
|
(Cu.isInAutomation || marionetteRunning) &&
|
|
Services.prefs.getBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, false)
|
|
);
|
|
diff --git a/toolkit/toolkit.mozbuild b/toolkit/toolkit.mozbuild
|
|
index bbc3c98e4885f23f03f83b7c2aa00e4eb4faaef5..45dcb084904c1d2729ef1e2cd1bef1a4665d8848 100644
|
|
--- a/toolkit/toolkit.mozbuild
|
|
+++ b/toolkit/toolkit.mozbuild
|
|
@@ -167,6 +167,7 @@ if CONFIG['ENABLE_MARIONETTE']:
|
|
DIRS += [
|
|
'/testing/firefox-ui',
|
|
'/testing/marionette',
|
|
+ '/juggler',
|
|
'/toolkit/components/telemetry/tests/marionette',
|
|
]
|
|
|
|
diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp
|
|
index bf7902f5dd642e2800b3fa83f4d379ab1ac9fda0..b94c24f9534cc19a5c2828e035e33c95f671d181 100644
|
|
--- a/uriloader/base/nsDocLoader.cpp
|
|
+++ b/uriloader/base/nsDocLoader.cpp
|
|
@@ -793,6 +793,13 @@ void nsDocLoader::DocLoaderIsEmpty(bool aFlushLayout,
|
|
("DocLoader:%p: Firing load event for document.open\n",
|
|
this));
|
|
|
|
+ nsCOMPtr<nsIObserverService> 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
|
|
@@ -1366,6 +1373,24 @@ void nsDocLoader::FireOnLocationChange(nsIWebProgress* aWebProgress,
|
|
}
|
|
}
|
|
|
|
+void nsDocLoader::FireOnFrameLocationChange(nsIWebProgress* aWebProgress,
|
|
+ nsIRequest* aRequest,
|
|
+ nsIURI *aUri,
|
|
+ uint32_t aFlags) {
|
|
+ NOTIFY_LISTENERS(nsIWebProgress::NOTIFY_FRAME_LOCATION,
|
|
+ nsCOMPtr<nsIWebProgressListener2> listener2 =
|
|
+ do_QueryReferent(info.mWeakListener);
|
|
+ if (!listener2)
|
|
+ continue;
|
|
+ listener2->OnFrameLocationChange(aWebProgress, aRequest, aUri, aFlags);
|
|
+ );
|
|
+
|
|
+ // Pass the notification up to the parent...
|
|
+ if (mParent) {
|
|
+ mParent->FireOnFrameLocationChange(aWebProgress, aRequest, aUri, aFlags);
|
|
+ }
|
|
+}
|
|
+
|
|
void nsDocLoader::FireOnStatusChange(nsIWebProgress* aWebProgress,
|
|
nsIRequest* aRequest, nsresult aStatus,
|
|
const char16_t* aMessage) {
|
|
diff --git a/uriloader/base/nsDocLoader.h b/uriloader/base/nsDocLoader.h
|
|
index 9f39fca7f2c7212c383a02b34079d54ce8cd0fac..71e8ca931656b89863427665eb2e7f17a81566f3 100644
|
|
--- a/uriloader/base/nsDocLoader.h
|
|
+++ b/uriloader/base/nsDocLoader.h
|
|
@@ -209,6 +209,11 @@ class nsDocLoader : public nsIDocumentLoader,
|
|
nsIURI* aURI, int32_t aDelay,
|
|
bool aSameURI);
|
|
|
|
+ void FireOnFrameLocationChange(nsIWebProgress* aWebProgress,
|
|
+ nsIRequest* aRequest,
|
|
+ nsIURI *aUri,
|
|
+ uint32_t aFlags);
|
|
+
|
|
// this function is overridden by the docshell, it is provided so that we
|
|
// can pass more information about redirect state (the normal OnStateChange
|
|
// doesn't get the new channel).
|
|
diff --git a/uriloader/base/nsIWebProgress.idl b/uriloader/base/nsIWebProgress.idl
|
|
index 70079adfff8a1b625ffd5aad5572c960cec5b646..5822ca46fb4022b0b31288f5492fcb4a2ac9baa1 100644
|
|
--- a/uriloader/base/nsIWebProgress.idl
|
|
+++ b/uriloader/base/nsIWebProgress.idl
|
|
@@ -87,6 +87,10 @@ interface nsIWebProgress : nsISupports
|
|
* NOTIFY_REFRESH
|
|
* Receive onRefreshAttempted events.
|
|
* This is defined on nsIWebProgressListener2.
|
|
+ *
|
|
+ * NOTIFY_FRAME_LOCATION
|
|
+ * Receive onFrameLocationChange events.
|
|
+ * This is defined on nsIWebProgressListener2.
|
|
*/
|
|
const unsigned long NOTIFY_PROGRESS = 0x00000010;
|
|
const unsigned long NOTIFY_STATUS = 0x00000020;
|
|
@@ -94,11 +98,12 @@ interface nsIWebProgress : nsISupports
|
|
const unsigned long NOTIFY_LOCATION = 0x00000080;
|
|
const unsigned long NOTIFY_REFRESH = 0x00000100;
|
|
const unsigned long NOTIFY_CONTENT_BLOCKING = 0x00000200;
|
|
+ const unsigned long NOTIFY_FRAME_LOCATION = 0x00000400;
|
|
|
|
/**
|
|
* This flag enables all notifications.
|
|
*/
|
|
- const unsigned long NOTIFY_ALL = 0x000003ff;
|
|
+ const unsigned long NOTIFY_ALL = 0x000007ff;
|
|
|
|
/**
|
|
* Registers a listener to receive web progress events.
|
|
diff --git a/uriloader/base/nsIWebProgressListener2.idl b/uriloader/base/nsIWebProgressListener2.idl
|
|
index 87701f8d2cfee8bd84acd28c62b3be4989c9474c..ae1aa85c019cb21d4f7e79c35e8afe72709468a1 100644
|
|
--- a/uriloader/base/nsIWebProgressListener2.idl
|
|
+++ b/uriloader/base/nsIWebProgressListener2.idl
|
|
@@ -66,4 +66,27 @@ interface nsIWebProgressListener2 : nsIWebProgressListener {
|
|
in nsIURI aRefreshURI,
|
|
in long aMillis,
|
|
in boolean aSameURI);
|
|
+
|
|
+ /**
|
|
+ * Called when the location of the window or its subframes changes. This is not
|
|
+ * when a load is requested, but rather once it is verified that the load is
|
|
+ * going to occur in the given window. For instance, a load that starts in a
|
|
+ * window might send progress and status messages for the new site, but it
|
|
+ * will not send the onLocationChange until we are sure that we are loading
|
|
+ * this new page here.
|
|
+ *
|
|
+ * @param aWebProgress
|
|
+ * The nsIWebProgress instance that fired the notification.
|
|
+ * @param aRequest
|
|
+ * The associated nsIRequest. This may be null in some cases.
|
|
+ * @param aLocation
|
|
+ * The URI of the location that is being loaded.
|
|
+ * @param aFlags
|
|
+ * This is a value which explains the situation or the reason why
|
|
+ * the location has changed.
|
|
+ */
|
|
+ void onFrameLocationChange(in nsIWebProgress aWebProgress,
|
|
+ in nsIRequest aRequest,
|
|
+ in nsIURI aLocation,
|
|
+ [optional] in unsigned long aFlags);
|
|
};
|
|
diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp
|
|
index b78eac71d5c144c1622d057407ab017c9e6f2e93..a256d6cd896b690099cf8ae495ff171d638b0a8d 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"
|
|
|
|
@@ -924,6 +925,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);
|
|
@@ -1589,7 +1596,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);
|
|
@@ -1762,7 +1774,36 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) {
|
|
return NS_OK;
|
|
}
|
|
|
|
- rv = SetUpTempFile(aChannel);
|
|
+ bool isIntercepted = false;
|
|
+ nsCOMPtr<nsIDownloadInterceptor> interceptor = mExtProtSvc->mInterceptor;
|
|
+ if (interceptor) {
|
|
+ nsCOMPtr<nsIFile> 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;
|
|
|
|
@@ -1815,6 +1856,11 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) {
|
|
|
|
bool alwaysAsk = true;
|
|
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
|
|
@@ -2221,6 +2267,16 @@ nsExternalAppHandler::OnSaveComplete(nsIBackgroundFileSaver* aSaver,
|
|
NotifyTransfer(aStatus);
|
|
}
|
|
|
|
+ if (!mCanceled) {
|
|
+ nsCOMPtr<nsIDownloadInterceptor> 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;
|
|
}
|
|
|
|
@@ -2608,6 +2664,15 @@ NS_IMETHODIMP nsExternalAppHandler::Cancel(nsresult aReason) {
|
|
}
|
|
}
|
|
|
|
+ nsCOMPtr<nsIDownloadInterceptor> 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 8c87587e9ee70d2786ee0d73d3cce8be387a382d..90acb4cb1075639821c58e4506731b7acab18e61 100644
|
|
--- a/uriloader/exthandler/nsExternalHelperAppService.h
|
|
+++ b/uriloader/exthandler/nsExternalHelperAppService.h
|
|
@@ -206,6 +206,8 @@ class nsExternalHelperAppService : public nsIExternalHelperAppService,
|
|
mozilla::dom::BrowsingContext* aContentContext, bool aForceSave,
|
|
nsIInterfaceRequestor* aWindowContext,
|
|
nsIStreamListener** aStreamListener);
|
|
+
|
|
+ nsCOMPtr<nsIDownloadInterceptor> mInterceptor;
|
|
};
|
|
|
|
/**
|
|
@@ -397,6 +399,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 2083825cec0019a76710afd516a82936e9743708..5a324df5800acb989f143c7d48b942b6b5dde286 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)
|
|
@@ -22,6 +25,12 @@ RefPtr<CompositorWidget> CompositorWidget::CreateLocal(
|
|
const CompositorWidgetInitData& aInitData,
|
|
const layers::CompositorOptions& aOptions, nsIWidget* aWidget) {
|
|
MOZ_ASSERT(aWidget);
|
|
+ if (aInitData.type() ==
|
|
+ CompositorWidgetInitData::THeadlessCompositorWidgetInitData) {
|
|
+ return new HeadlessCompositorWidget(
|
|
+ aInitData.get_HeadlessCompositorWidgetInitData(), aOptions,
|
|
+ static_cast<HeadlessWidget*>(aWidget));
|
|
+ }
|
|
# ifdef MOZ_WIDGET_ANDROID
|
|
return new AndroidCompositorWidget(aOptions,
|
|
static_cast<nsBaseWidget*>(aWidget));
|
|
diff --git a/widget/headless/HeadlessCompositorWidget.cpp b/widget/headless/HeadlessCompositorWidget.cpp
|
|
index b31a969b7ab3d0fc80912b110d91dfdf3e5991f4..45456bd34713a32695c0fe6a84588f31e40c137d 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,32 @@ HeadlessCompositorWidget::HeadlessCompositorWidget(
|
|
mClientSize = aInitData.InitialClientSize();
|
|
}
|
|
|
|
+void HeadlessCompositorWidget::SetSnapshotListener(HeadlessWidget::SnapshotListener&& listener) {
|
|
+ MOZ_ASSERT(NS_IsMainThread());
|
|
+
|
|
+ layers::CompositorThread()->Dispatch(NewRunnableMethod<HeadlessWidget::SnapshotListener&&>(
|
|
+ "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<gfx::DrawTarget> HeadlessCompositorWidget::StartRemoteDrawingInRegion(
|
|
+ LayoutDeviceIntRegion& aInvalidRegion, layers::BufferMode* aBufferMode) {
|
|
+ if (!mDrawTarget)
|
|
+ return nullptr;
|
|
+
|
|
+ *aBufferMode = layers::BufferMode::BUFFER_NONE;
|
|
+ RefPtr<gfx::DrawTarget> result = mDrawTarget;
|
|
+ return result.forget();
|
|
+}
|
|
+
|
|
void HeadlessCompositorWidget::ObserveVsync(VsyncObserver* aObserver) {
|
|
if (RefPtr<CompositorVsyncDispatcher> cvd =
|
|
mWidget->GetCompositorVsyncDispatcher()) {
|
|
@@ -29,6 +56,58 @@ nsIWidget* HeadlessCompositorWidget::RealWidget() { return mWidget; }
|
|
void HeadlessCompositorWidget::NotifyClientSizeChanged(
|
|
const LayoutDeviceIntSize& aClientSize) {
|
|
mClientSize = aClientSize;
|
|
+ layers::CompositorThread()->Dispatch(NewRunnableMethod<LayoutDeviceIntSize>(
|
|
+ "HeadlessCompositorWidget::UpdateDrawTarget", this,
|
|
+ &HeadlessCompositorWidget::UpdateDrawTarget,
|
|
+ aClientSize));
|
|
+}
|
|
+
|
|
+void HeadlessCompositorWidget::UpdateDrawTarget(const LayoutDeviceIntSize& aClientSize) {
|
|
+ MOZ_ASSERT(NS_IsInCompositorThread());
|
|
+ if (aClientSize.IsEmpty()) {
|
|
+ mDrawTarget = nullptr;
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ RefPtr<gfx::DrawTarget> 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<gfx::SourceSurface> 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<gfx::SourceSurface> snapshot = mDrawTarget->Snapshot();
|
|
+ if (!snapshot) {
|
|
+ fprintf(stderr, "Failed to get snapshot of draw target\n");
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ RefPtr<gfx::DataSourceSurface> 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..b0e3572413f80e5bd125f777c3247b10b8521a73 100644
|
|
--- a/widget/headless/HeadlessCompositorWidget.h
|
|
+++ b/widget/headless/HeadlessCompositorWidget.h
|
|
@@ -23,9 +23,13 @@ class HeadlessCompositorWidget final : public CompositorWidget,
|
|
HeadlessWidget* aWindow);
|
|
|
|
void NotifyClientSizeChanged(const LayoutDeviceIntSize& aClientSize);
|
|
+ void SetSnapshotListener(HeadlessWidget::SnapshotListener&& listener);
|
|
|
|
// CompositorWidget Overrides
|
|
|
|
+ already_AddRefed<gfx::DrawTarget> StartRemoteDrawingInRegion(
|
|
+ LayoutDeviceIntRegion& aInvalidRegion, layers::BufferMode* aBufferMode) override;
|
|
+
|
|
uintptr_t GetWidgetKey() override;
|
|
|
|
LayoutDeviceIntSize GetClientSize() 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<gfx::DrawTarget> mDrawTarget;
|
|
};
|
|
|
|
} // namespace widget
|
|
diff --git a/widget/headless/HeadlessWidget.cpp b/widget/headless/HeadlessWidget.cpp
|
|
index f4f3acda7e645bf3c97b4bdd50eed6b429a7e74a..c1bbd3e07397b7b341538f78e18db987ae0d244e 100644
|
|
--- a/widget/headless/HeadlessWidget.cpp
|
|
+++ b/widget/headless/HeadlessWidget.cpp
|
|
@@ -104,6 +104,8 @@ void HeadlessWidget::Destroy() {
|
|
}
|
|
}
|
|
|
|
+ SetSnapshotListener(nullptr);
|
|
+
|
|
nsBaseWidget::OnDestroy();
|
|
|
|
nsBaseWidget::Destroy();
|
|
@@ -499,5 +501,14 @@ nsresult HeadlessWidget::SynthesizeNativeTouchPoint(
|
|
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 25cb1623ba86109c232ab21ff5c67a349c1bf060..80ab2790cae984a190b12604c7b66958e2b03f6b 100644
|
|
--- a/widget/headless/HeadlessWidget.h
|
|
+++ b/widget/headless/HeadlessWidget.h
|
|
@@ -153,6 +153,9 @@ class HeadlessWidget : public nsBaseWidget {
|
|
uint32_t aPointerOrientation,
|
|
nsIObserver* aObserver) override;
|
|
|
|
+ using SnapshotListener = std::function<void(RefPtr<gfx::DataSourceSurface>&&)>;
|
|
+ void SetSnapshotListener(SnapshotListener&& listener);
|
|
+
|
|
private:
|
|
~HeadlessWidget();
|
|
bool mEnabled;
|
|
diff --git a/xpcom/reflect/xptinfo/xptinfo.h b/xpcom/reflect/xptinfo/xptinfo.h
|
|
index 33b1f25411fd6a8d02edca9198054347289a1501..ee6ea48f3986a8d7c0e2f351b6d30b9fb706524e 100644
|
|
--- a/xpcom/reflect/xptinfo/xptinfo.h
|
|
+++ b/xpcom/reflect/xptinfo/xptinfo.h
|
|
@@ -513,7 +513,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
|
|
|
|
/**
|