mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
2ce8c88a9b
- Bug 1265072 part 1. Add GetWindowIfCurrent and GetDocumentIfCurrent helpers to DOMEventTargetHelper. r=smaug (238cf93592) - Bug 1265072 part 2. Get rid of uses of GetDocumentFromScriptContext in XMLHttpRequest code. r=smaug (263f063149) - Bug 1265072 part 3. Get rid of the use of GetDocumentFromScriptContext in DOMEventTargetHelper. r=smaug (8dd8dca53d) - Bug 1265072 part 4. Get rid of uses of GetDocumentFromScriptContext in WebSocket code. r=smaug (be9c18769b) - Bug 1265072 part 5. Get rid of uses of GetDocumentFromScriptContext in EventSource code. r=smaug (5fbcf73629) - Bug 1265072 part 6. Get rid of nsContentUtils::GetDocumentFromScriptContext. r=smaug (752aa67986) - Bug 1258576 part.1 nsContentIterator should give up to find next/previous node if it reached the root node unexpectedly r=smaug (7175ce5477) - Bug 1230660 - Remove verbose warnings emitted from nsContentIterator. r=smaug (ef0b8a3a4c) - Bug 1260908 - Fix type of kMinTelemetryMessageSize. r=smaug (8817839277) - Bug 1209461 - Remove compilation warnings in nsFrameMessageManager, r=smaug (da95cf91ab) - Bug 1251361 - "Assertion failure: cache->PreservingWrapper()" with <marquee>, navigation, adoptNode. r=smaug. (630cff1943) - Bug 1144204. Stop returning things for non-plug-in MIME types from the navigator.mimeTypes getter. r=smaug (329eac72b1) - Bug 1150709 - Add mForceContentDispatch to nsInProcessTabChildGlobal (r=smaug) (d7e2887457) - Bug 233705 - remove mDontWrapAnyQuotes, mWrapToWindow and pref wrap_to_window_width. r=ehsan (c7e98bc307) - Bug 1105556 - nsPerformance::CheckAllowedOrigin should return early for TYPE_DOCUMENT loads. TYPE_DOCUMENT loads don't go through a TimingAllowedCheck(). r=bz, vgosu (5da5530caf) - Bug 1241183 - Make nsScriptLoadRequest non-threadsafe now it's no longer used as a context for network loads r=sicking (206d763af8) - Bug 962251 - Add relatedTarget in FocusEvent, r=smaug (f66018e5a4) - Bug 1248806 - Splitting out protocol handlers from nsLayoutModule. r=bholley (572243ca92) - Bug 1256488 - Use Base64 URL-encoding in CryptoBuffer. r=ttaubert (9d28ca5f9c) - Bug 1243311 - Add structured cloning tests for CryptoKeys r=rbarnes (5cde35d811) - Bug 842818 - Enable structured cloning for CryptoKeys across threads r=baku,keeler (8863b23dc3) - Bug 1257325 - Silence VS2015 compiler warnings in CryptoKey.cpp f=gps r=rbarnes (0d93bdc950) - Bug 1188750 - Add test to ensure NSS is initialized before the WebCrypto API tries to deserialize a key f=keeler r=khuey (8d08363e2c) - Bug 842818 - Run WebCrypto tests in Workers r=mt,rbarnes (48477dfeb4) - Bug 1205177 - call fileHandleQueue->Finish if aFinish in FileHandleThreadPool::Enqueue. r=janv (f5d6737f27) - Bug 1206166 - Move FetchUtil::Consume methods into separate BodyUtil class and update Fetch.cpp and ServiceWorkerEvents.cpp accordingly. r=kitcambridge (967f2f58e1) - Bug 1250930 - Use SubtleCrypto's global when creating keys for an ImportKeyTask r=bz (6227fb14b3) - Bug 1250930 - Use correct global when creating a key in GenerateSymmetricKeyTask r=bz (92d7faa773) - Bug 1240436 - Part1: Convert UTF16 to UTF8 before generating nsStringInputStream. r=khuey (1919accaf8) - Bug 1240436 - Part2: Lossy convert UTF16 to ASCII before generating nsStringInputStream. r=mayhemer (03aa1b6dbe) - Bug 1240436 - Part3: Remove NS_NewStringInputStream to prevent misuse. r=froydnj (cff40c1b2e) - Bug 1263405 - Some headers missing in dom/base, r=smaug (12043c5368) - Bug 964583 - Revert Web IDL [EnforceRange] (unsigned) long long boundary conditions to match ES6. r=bz (6e235bb6b7) - Bug 1260838 - Assert that ScriptSource's reference count is zero upon destruction; r=jimb a=kwierso (8455465c92) - Bug 1257164 - Check for interrupts in a few loops in JSON.stringify to eliminate feedback-less hangs. r=evilpie (dbe1336aa8) - Bug 837192 followup: In js::FunctionToString, fold variable into its only remaining usage-site (an assertion) to fix opt Werror build failures. rs=Waldo (e6b4f52d6a) - Bug 1258436 - Remove GC suppression in JSFunction::createScriptForLazilyInterpretedFunction. r=sfink (206023942d) - Declare and define ExecutableAllocator::reprotectRegion only #ifdef NON_WRITABLE_JIT_CODE, to eliminate MOZ_ASSERT of a constant condition that makes some compilers warn. No bug, r=efaust over IRC (5a4d3ab11b) - Bug 1254369 - IonMonkey: MIPS: Fix ma_b(Register, Imm32, wasm::JumpTarget) missing. r=arai (2f906fec70) - Bug 1256502 - Use a uint32_t cast to avoid C4319 on VS2015; r=botond (93ba380002) - Bug 1236043 - Use TiledRegion for the invalid region of a layer. r=jrmuizel (37b87bc355) - Bug 1248044 - Add PingPongRegion for faster region operations for 2x memory usage. r=jrmuizel (fbd73fb879) - Bug 1236043 - Add a TiledRegion class. r=jrmuizel (3056f641a4) - Bug 1116473 - [3.2] Use RefPtr for AndroidSurfaceTexture references. r=snorp (c6e80d0d84) - Bug 1116473 - [1.1] Handle AndroidSurfaceTexture mapping in thread-safe class. r=snorp (ee8b1d0736) - Bug 1116473 - [2.1] Const-correctness fixes. r=snorp (5f5fb8fbc4) - Bug 1251163 - Clear android surface texture before widget shutdown, r=nical (b71d849297) - Bug 1245813 - Make TextureHost bullet-proof against changing its compositor. r=dvander (b0ef2492fc) - Recreate GLTextureSources after changing compositors on Mac. (bug 1247611, r=mattwoodrow) (26bd0e69aa) - Bug 1258768 - Check compositor backends before casting. r=dvander (98929ca492) - Bug 1245813 - Fix a trivial inverted null check in TextureHostOGL.cpp. r=me (956cfd2e5c) - Bug 1245813 - Add a missing parenthesis on NS_SUCCEEDED, on a CLOSED TREE. (8e13cc3e1b) - Bug 1262601 - Handle video content as opaque in PostProcessLayers() r=mattwoodrow (ba578d7394) - Bug 1258768 - Remove the remaining unsafe compositor casts. r=dvander (8ec58c0ce8) - Bug 1229946 - report GL_ARB_texture_rg extension to SkiaGL to avoid using GL_ALPHA render targets. r=jgilbert (cf0f3a9fec) - Bug 1238541 - Don't die in SharedSurface_EGLImage::ProducerReadReleaseImpl() if there is an existing fence r=jgilbert (c1ea4891f7) - Bug 1240806 - Remove some dead code in GLContextProviderEGL. r=jgilbert (40484e9039) - Bug 1258094 - Use SurfaceFormat::B8G8R8A8 as back buffer surface r=jrmuizel (cec7a31ffd) - Bug 1254897 - Recycle back buffer in BasicCompositor r=jrmuizel (0359698b68)
353 lines
11 KiB
C++
353 lines
11 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "nsInProcessTabChildGlobal.h"
|
|
#include "nsContentUtils.h"
|
|
#include "nsIScriptSecurityManager.h"
|
|
#include "nsIInterfaceRequestorUtils.h"
|
|
#include "nsIComponentManager.h"
|
|
#include "nsIServiceManager.h"
|
|
#include "nsComponentManagerUtils.h"
|
|
#include "nsScriptLoader.h"
|
|
#include "nsFrameLoader.h"
|
|
#include "xpcpublic.h"
|
|
#include "nsIMozBrowserFrame.h"
|
|
#include "nsDOMClassInfoID.h"
|
|
#include "mozilla/EventDispatcher.h"
|
|
#include "mozilla/dom/SameProcessMessageQueue.h"
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::dom;
|
|
using namespace mozilla::dom::ipc;
|
|
|
|
bool
|
|
nsInProcessTabChildGlobal::DoSendBlockingMessage(JSContext* aCx,
|
|
const nsAString& aMessage,
|
|
StructuredCloneData& aData,
|
|
JS::Handle<JSObject *> aCpows,
|
|
nsIPrincipal* aPrincipal,
|
|
nsTArray<StructuredCloneData>* aRetVal,
|
|
bool aIsSync)
|
|
{
|
|
SameProcessMessageQueue* queue = SameProcessMessageQueue::Get();
|
|
queue->Flush();
|
|
|
|
if (mChromeMessageManager) {
|
|
SameProcessCpowHolder cpows(js::GetRuntime(aCx), aCpows);
|
|
RefPtr<nsFrameMessageManager> mm = mChromeMessageManager;
|
|
nsCOMPtr<nsIFrameLoader> fl = GetFrameLoader();
|
|
mm->ReceiveMessage(mOwner, fl, aMessage, true, &aData, &cpows, aPrincipal,
|
|
aRetVal);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
class nsAsyncMessageToParent : public nsSameProcessAsyncMessageBase,
|
|
public SameProcessMessageQueue::Runnable
|
|
{
|
|
public:
|
|
nsAsyncMessageToParent(JSContext* aCx, JS::Handle<JSObject*> aCpows, nsInProcessTabChildGlobal* aTabChild)
|
|
: nsSameProcessAsyncMessageBase(aCx, aCpows)
|
|
, mTabChild(aTabChild)
|
|
{ }
|
|
|
|
virtual nsresult HandleMessage() override
|
|
{
|
|
nsCOMPtr<nsIFrameLoader> fl = mTabChild->GetFrameLoader();
|
|
ReceiveMessage(mTabChild->mOwner, fl, mTabChild->mChromeMessageManager);
|
|
return NS_OK;
|
|
}
|
|
RefPtr<nsInProcessTabChildGlobal> mTabChild;
|
|
};
|
|
|
|
nsresult
|
|
nsInProcessTabChildGlobal::DoSendAsyncMessage(JSContext* aCx,
|
|
const nsAString& aMessage,
|
|
StructuredCloneData& aData,
|
|
JS::Handle<JSObject *> aCpows,
|
|
nsIPrincipal* aPrincipal)
|
|
{
|
|
SameProcessMessageQueue* queue = SameProcessMessageQueue::Get();
|
|
RefPtr<nsAsyncMessageToParent> ev =
|
|
new nsAsyncMessageToParent(aCx, aCpows, this);
|
|
|
|
nsresult rv = ev->Init(aCx, aMessage, aData, aPrincipal);
|
|
if (NS_FAILED(rv)) {
|
|
return rv;
|
|
}
|
|
|
|
queue->Push(ev);
|
|
return NS_OK;
|
|
}
|
|
|
|
nsInProcessTabChildGlobal::nsInProcessTabChildGlobal(nsIDocShell* aShell,
|
|
nsIContent* aOwner,
|
|
nsFrameMessageManager* aChrome)
|
|
: mDocShell(aShell), mInitialized(false), mLoadingScript(false),
|
|
mPreventEventsEscaping(false),
|
|
mOwner(aOwner), mChromeMessageManager(aChrome)
|
|
{
|
|
SetIsNotDOMBinding();
|
|
mozilla::HoldJSObjects(this);
|
|
|
|
// If owner corresponds to an <iframe mozbrowser> or <iframe mozapp>, we'll
|
|
// have to tweak our PreHandleEvent implementation.
|
|
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwner);
|
|
if (browserFrame) {
|
|
mIsBrowserOrAppFrame = browserFrame->GetReallyIsBrowserOrApp();
|
|
}
|
|
else {
|
|
mIsBrowserOrAppFrame = false;
|
|
}
|
|
}
|
|
|
|
nsInProcessTabChildGlobal::~nsInProcessTabChildGlobal()
|
|
{
|
|
mAnonymousGlobalScopes.Clear();
|
|
mozilla::DropJSObjects(this);
|
|
}
|
|
|
|
// This method isn't automatically forwarded safely because it's notxpcom, so
|
|
// the IDL binding doesn't know what value to return.
|
|
NS_IMETHODIMP_(bool)
|
|
nsInProcessTabChildGlobal::MarkForCC()
|
|
{
|
|
MarkScopesForCC();
|
|
return mMessageManager ? mMessageManager->MarkForCC() : false;
|
|
}
|
|
|
|
nsresult
|
|
nsInProcessTabChildGlobal::Init()
|
|
{
|
|
#ifdef DEBUG
|
|
nsresult rv =
|
|
#endif
|
|
InitTabChildGlobal();
|
|
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
|
|
"Couldn't initialize nsInProcessTabChildGlobal");
|
|
mMessageManager = new nsFrameMessageManager(this,
|
|
nullptr,
|
|
dom::ipc::MM_CHILD);
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsInProcessTabChildGlobal)
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsInProcessTabChildGlobal,
|
|
DOMEventTargetHelper)
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMessageManager)
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal)
|
|
tmp->TraverseHostObjectURIs(cb);
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(nsInProcessTabChildGlobal,
|
|
DOMEventTargetHelper)
|
|
tmp->nsMessageManagerScriptExecutor::Trace(aCallbacks, aClosure);
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsInProcessTabChildGlobal,
|
|
DOMEventTargetHelper)
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMessageManager)
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal)
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAnonymousGlobalScopes)
|
|
tmp->UnlinkHostObjectURIs();
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsInProcessTabChildGlobal)
|
|
NS_INTERFACE_MAP_ENTRY(nsIMessageListenerManager)
|
|
NS_INTERFACE_MAP_ENTRY(nsIMessageSender)
|
|
NS_INTERFACE_MAP_ENTRY(nsISyncMessageSender)
|
|
NS_INTERFACE_MAP_ENTRY(nsIContentFrameMessageManager)
|
|
NS_INTERFACE_MAP_ENTRY(nsIInProcessContentFrameMessageManager)
|
|
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
|
|
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentFrameMessageManager)
|
|
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsInProcessTabChildGlobal, DOMEventTargetHelper)
|
|
NS_IMPL_RELEASE_INHERITED(nsInProcessTabChildGlobal, DOMEventTargetHelper)
|
|
|
|
void
|
|
nsInProcessTabChildGlobal::CacheFrameLoader(nsIFrameLoader* aFrameLoader)
|
|
{
|
|
mFrameLoader = aFrameLoader;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsInProcessTabChildGlobal::GetContent(nsIDOMWindow** aContent)
|
|
{
|
|
*aContent = nullptr;
|
|
if (!mDocShell) {
|
|
return NS_OK;
|
|
}
|
|
|
|
nsCOMPtr<nsIDOMWindow> window = mDocShell->GetWindow();
|
|
window.swap(*aContent);
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsInProcessTabChildGlobal::GetDocShell(nsIDocShell** aDocShell)
|
|
{
|
|
NS_IF_ADDREF(*aDocShell = mDocShell);
|
|
return NS_OK;
|
|
}
|
|
|
|
void
|
|
nsInProcessTabChildGlobal::FireUnloadEvent()
|
|
{
|
|
// We're called from nsDocument::MaybeInitializeFinalizeFrameLoaders, so it
|
|
// should be safe to run script.
|
|
MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
|
|
|
|
// Don't let the unload event propagate to chrome event handlers.
|
|
mPreventEventsEscaping = true;
|
|
DOMEventTargetHelper::DispatchTrustedEvent(NS_LITERAL_STRING("unload"));
|
|
|
|
// Allow events fired during docshell destruction (pagehide, unload) to
|
|
// propagate to the <browser> element since chrome code depends on this.
|
|
mPreventEventsEscaping = false;
|
|
}
|
|
|
|
void
|
|
nsInProcessTabChildGlobal::DisconnectEventListeners()
|
|
{
|
|
if (mDocShell) {
|
|
nsCOMPtr<nsPIDOMWindow> win = mDocShell->GetWindow();
|
|
if (win) {
|
|
MOZ_ASSERT(win->IsOuterWindow());
|
|
win->SetChromeEventHandler(win->GetChromeEventHandler());
|
|
}
|
|
}
|
|
if (mListenerManager) {
|
|
mListenerManager->Disconnect();
|
|
}
|
|
|
|
mDocShell = nullptr;
|
|
}
|
|
|
|
void
|
|
nsInProcessTabChildGlobal::Disconnect()
|
|
{
|
|
mChromeMessageManager = nullptr;
|
|
mOwner = nullptr;
|
|
if (mMessageManager) {
|
|
static_cast<nsFrameMessageManager*>(mMessageManager.get())->Disconnect();
|
|
mMessageManager = nullptr;
|
|
}
|
|
}
|
|
|
|
NS_IMETHODIMP_(nsIContent *)
|
|
nsInProcessTabChildGlobal::GetOwnerContent()
|
|
{
|
|
return mOwner;
|
|
}
|
|
|
|
nsresult
|
|
nsInProcessTabChildGlobal::PreHandleEvent(EventChainPreVisitor& aVisitor)
|
|
{
|
|
aVisitor.mForceContentDispatch = true;
|
|
aVisitor.mCanHandle = true;
|
|
|
|
#ifdef DEBUG
|
|
if (mOwner) {
|
|
nsCOMPtr<nsIFrameLoaderOwner> owner = do_QueryInterface(mOwner);
|
|
RefPtr<nsFrameLoader> fl = owner->GetFrameLoader();
|
|
if (fl) {
|
|
NS_ASSERTION(this == fl->GetTabChildGlobalAsEventTarget(),
|
|
"Wrong event target!");
|
|
NS_ASSERTION(fl->mMessageManager == mChromeMessageManager,
|
|
"Wrong message manager!");
|
|
}
|
|
}
|
|
#endif
|
|
|
|
if (mPreventEventsEscaping) {
|
|
aVisitor.mParentTarget = nullptr;
|
|
return NS_OK;
|
|
}
|
|
|
|
if (mIsBrowserOrAppFrame &&
|
|
(!mOwner || !nsContentUtils::IsInChromeDocshell(mOwner->OwnerDoc()))) {
|
|
if (mOwner) {
|
|
nsPIDOMWindow* innerWindow = mOwner->OwnerDoc()->GetInnerWindow();
|
|
if (innerWindow) {
|
|
aVisitor.mParentTarget = innerWindow->GetParentTarget();
|
|
}
|
|
}
|
|
} else {
|
|
aVisitor.mParentTarget = mOwner;
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
nsresult
|
|
nsInProcessTabChildGlobal::InitTabChildGlobal()
|
|
{
|
|
// If you change this, please change GetCompartmentName() in XPCJSRuntime.cpp
|
|
// accordingly.
|
|
nsAutoCString id;
|
|
id.AssignLiteral("inProcessTabChildGlobal");
|
|
nsIURI* uri = mOwner->OwnerDoc()->GetDocumentURI();
|
|
if (uri) {
|
|
nsAutoCString u;
|
|
uri->GetSpec(u);
|
|
id.AppendLiteral("?ownedBy=");
|
|
id.Append(u);
|
|
}
|
|
nsISupports* scopeSupports = NS_ISUPPORTS_CAST(EventTarget*, this);
|
|
NS_ENSURE_STATE(InitChildGlobalInternal(scopeSupports, id));
|
|
return NS_OK;
|
|
}
|
|
|
|
class nsAsyncScriptLoad : public nsRunnable
|
|
{
|
|
public:
|
|
nsAsyncScriptLoad(nsInProcessTabChildGlobal* aTabChild, const nsAString& aURL,
|
|
bool aRunInGlobalScope)
|
|
: mTabChild(aTabChild), mURL(aURL), mRunInGlobalScope(aRunInGlobalScope) {}
|
|
|
|
NS_IMETHOD Run()
|
|
{
|
|
mTabChild->LoadFrameScript(mURL, mRunInGlobalScope);
|
|
return NS_OK;
|
|
}
|
|
RefPtr<nsInProcessTabChildGlobal> mTabChild;
|
|
nsString mURL;
|
|
bool mRunInGlobalScope;
|
|
};
|
|
|
|
void
|
|
nsInProcessTabChildGlobal::LoadFrameScript(const nsAString& aURL, bool aRunInGlobalScope)
|
|
{
|
|
if (!nsContentUtils::IsSafeToRunScript()) {
|
|
nsContentUtils::AddScriptRunner(new nsAsyncScriptLoad(this, aURL, aRunInGlobalScope));
|
|
return;
|
|
}
|
|
if (!mInitialized) {
|
|
mInitialized = true;
|
|
Init();
|
|
}
|
|
bool tmp = mLoadingScript;
|
|
mLoadingScript = true;
|
|
LoadScriptInternal(aURL, aRunInGlobalScope);
|
|
mLoadingScript = tmp;
|
|
}
|
|
|
|
already_AddRefed<nsIFrameLoader>
|
|
nsInProcessTabChildGlobal::GetFrameLoader()
|
|
{
|
|
nsCOMPtr<nsIFrameLoaderOwner> owner = do_QueryInterface(mOwner);
|
|
nsCOMPtr<nsIFrameLoader> fl = owner ? owner->GetFrameLoader() : nullptr;
|
|
if (!fl) {
|
|
fl = mFrameLoader;
|
|
}
|
|
return fl.forget();
|
|
}
|