mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-13 18:57:29 +09:00
Issue #1691 - Part 8: Fix --enable-debug builds and continue dynamic module import changes. https://bugzilla.mozilla.org/show_bug.cgi?id=1342012 Support import from timeout handlers by associating the initiating script with the compiled JSScript. Fix error message that covers all import() failures that don't throw a JS exception. https://bugzilla.mozilla.org/show_bug.cgi?id=1331662 Partial - Replace nsJSUtils::EvaluateString calls by ExecutionContext scopes. Left EvaluateString() in nsXBLProtoImplField.cpp until ExecutionContext errors can be fixed.
(cherry picked from commit 22fcfc77971a9bb204df664c474681f4dcf54211)
This commit is contained in:
parent
c69a47c393
commit
1109559a5d
20 changed files with 166 additions and 24 deletions
|
|
@ -10,6 +10,7 @@
|
|||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/dom/FunctionBinding.h"
|
||||
#include "mozilla/dom/ModuleScript.h"
|
||||
#include "nsAXPCNativeCallContext.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
|
@ -44,6 +45,7 @@ public:
|
|||
nsTArray<JS::Heap<JS::Value>>&& aArguments,
|
||||
ErrorResult& aError);
|
||||
nsJSScriptTimeoutHandler(JSContext* aCx, nsGlobalWindow* aWindow,
|
||||
LoadedScript* aInitiatingScript,
|
||||
const nsAString& aExpression, bool* aAllowEval,
|
||||
ErrorResult& aError);
|
||||
nsJSScriptTimeoutHandler(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
|
||||
|
|
@ -77,6 +79,10 @@ public:
|
|||
*aColumn = mColumn;
|
||||
}
|
||||
|
||||
virtual LoadedScript* GetInitiatingScript() override {
|
||||
return mInitiatingScript;
|
||||
}
|
||||
|
||||
virtual void MarkForCC() override
|
||||
{
|
||||
if (mFunction) {
|
||||
|
|
@ -104,6 +110,9 @@ private:
|
|||
// it should be used, else use mExpr.
|
||||
nsString mExpr;
|
||||
RefPtr<Function> mFunction;
|
||||
|
||||
// Initiating script for use when evaluating mExpr on the main thread.
|
||||
RefPtr<LoadedScript> mInitiatingScript;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -112,6 +121,8 @@ private:
|
|||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsJSScriptTimeoutHandler)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSScriptTimeoutHandler)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFunction)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mInitiatingScript)
|
||||
tmp->ReleaseJSObjects();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsJSScriptTimeoutHandler)
|
||||
|
|
@ -151,6 +162,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsJSScriptTimeoutHandler)
|
|||
if (tmp->mFunction) {
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFunction)
|
||||
}
|
||||
if (tmp->mInitiatingScript) {
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInitiatingScript)
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsJSScriptTimeoutHandler)
|
||||
|
|
@ -243,12 +257,14 @@ nsJSScriptTimeoutHandler::nsJSScriptTimeoutHandler(JSContext* aCx,
|
|||
|
||||
nsJSScriptTimeoutHandler::nsJSScriptTimeoutHandler(JSContext* aCx,
|
||||
nsGlobalWindow *aWindow,
|
||||
LoadedScript* aInitiatingScript,
|
||||
const nsAString& aExpression,
|
||||
bool* aAllowEval,
|
||||
ErrorResult& aError)
|
||||
: mLineNo(0)
|
||||
, mColumn(0)
|
||||
, mExpr(aExpression)
|
||||
, mInitiatingScript(aInitiatingScript)
|
||||
{
|
||||
if (!aWindow->GetContextInternal() || !aWindow->FastGetGlobalJSObject()) {
|
||||
// This window was already closed, or never properly initialized,
|
||||
|
|
@ -352,9 +368,11 @@ already_AddRefed<nsIScriptTimeoutHandler>
|
|||
NS_CreateJSTimeoutHandler(JSContext* aCx, nsGlobalWindow *aWindow,
|
||||
const nsAString& aExpression, ErrorResult& aError)
|
||||
{
|
||||
LoadedScript* script = ScriptLoader::GetActiveScript(aCx);
|
||||
|
||||
bool allowEval = false;
|
||||
RefPtr<nsJSScriptTimeoutHandler> handler =
|
||||
new nsJSScriptTimeoutHandler(aCx, aWindow, aExpression, &allowEval, aError);
|
||||
new nsJSScriptTimeoutHandler(aCx, aWindow, script, aExpression, &allowEval, aError);
|
||||
if (aError.Failed() || !allowEval) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue