mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
import change from rmottola/Arctic-Fox:
- Bug 1146557 P1 Fix CacheStorage and Cache to QI to nsISupports correctly. r=ehsan (b56ba80cd) - Bug 1146557 P2 Flip dom.caches.enabled to true on non-release builds. (b1ac38779) - Bug 1126014 - DomainPolicy support for e10s. r=mrbkap (484fa7f8d) - Bug 1092102 - Implement worker debugger runnables; (cfb3cb53d) - Bug 1092102 - Implement WorkerDebugger.initialize; (24f467b14) - Bug 1092102 - Implement WorkerDebugger.postMessage; (ad69a161d) - Bug 1092102 - Implement WorkerDebuggerGlobalScope.reportError; (f937913f2) - Bug 1092102 - Implement WorkerDebuggerGlobalScope.enterEventLoop; (d1d0ad392) - Bug 1092102 - Implement WorkerDebuggerGlobalScope.setImmediate (a22de0f0d) - Bug 1092102 - Implement WorkerDebuggerGlobalScope.createSandbox (d281de130) - Bug 1092102 followup: Add missing 'override' annotation on DebuggerImmediateRunnable::IsDebuggerRunnable(). (b4d053cfe) - Bug 1092102, followup 2: Add missing 'override' annotation to WorkerDebuggerSandboxPrivate::GetGlobalJSObject() (and 'virtual', for consistency). (72c9f3c84) - Bug 1092102 - Rename Suspend/Resume to Freeze/Thaw; (a7f2b5c11) - Bug 1092102 - Implement WorkerDebugger.isFrozen; (805ba0e9e)
This commit is contained in:
@@ -53,7 +53,8 @@ ChannelFromScriptURL(nsIPrincipal* principal,
|
||||
nsIIOService* ios,
|
||||
nsIScriptSecurityManager* secMan,
|
||||
const nsAString& aScriptURL,
|
||||
bool aIsWorkerScript,
|
||||
bool aIsMainScript,
|
||||
WorkerScriptType aWorkerScriptType,
|
||||
nsIChannel** aChannel)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
@@ -84,10 +85,22 @@ ChannelFromScriptURL(nsIPrincipal* principal,
|
||||
}
|
||||
}
|
||||
|
||||
// If this script loader is being used to make a new worker then we need
|
||||
// to do a same-origin check. Otherwise we need to clear the load with the
|
||||
// security manager.
|
||||
if (aIsWorkerScript) {
|
||||
if (aWorkerScriptType == DebuggerScript) {
|
||||
bool isChrome = false;
|
||||
NS_ENSURE_SUCCESS(uri->SchemeIs("chrome", &isChrome),
|
||||
NS_ERROR_DOM_SECURITY_ERR);
|
||||
|
||||
bool isResource = false;
|
||||
NS_ENSURE_SUCCESS(uri->SchemeIs("resource", &isResource),
|
||||
NS_ERROR_DOM_SECURITY_ERR);
|
||||
|
||||
if (!isChrome && !isResource) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
} else if (aIsMainScript) {
|
||||
// If this script loader is being used to make a new worker then we need
|
||||
// to do a same-origin check. Otherwise we need to clear the load with the
|
||||
// security manager.
|
||||
nsCString scheme;
|
||||
rv = uri->GetScheme(scheme);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@@ -190,6 +203,9 @@ private:
|
||||
~ScriptExecutorRunnable()
|
||||
{ }
|
||||
|
||||
virtual bool
|
||||
IsDebuggerRunnable() const override;
|
||||
|
||||
virtual bool
|
||||
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override;
|
||||
|
||||
@@ -214,7 +230,8 @@ class ScriptLoaderRunnable final : public WorkerFeature,
|
||||
WorkerPrivate* mWorkerPrivate;
|
||||
nsCOMPtr<nsIEventTarget> mSyncLoopTarget;
|
||||
nsTArray<ScriptLoadInfo> mLoadInfos;
|
||||
bool mIsWorkerScript;
|
||||
bool mIsMainScript;
|
||||
WorkerScriptType mWorkerScriptType;
|
||||
bool mCanceled;
|
||||
bool mCanceledMainThread;
|
||||
|
||||
@@ -224,14 +241,15 @@ public:
|
||||
ScriptLoaderRunnable(WorkerPrivate* aWorkerPrivate,
|
||||
nsIEventTarget* aSyncLoopTarget,
|
||||
nsTArray<ScriptLoadInfo>& aLoadInfos,
|
||||
bool aIsWorkerScript)
|
||||
bool aIsMainScript,
|
||||
WorkerScriptType aWorkerScriptType)
|
||||
: mWorkerPrivate(aWorkerPrivate), mSyncLoopTarget(aSyncLoopTarget),
|
||||
mIsWorkerScript(aIsWorkerScript), mCanceled(false),
|
||||
mCanceledMainThread(false)
|
||||
mIsMainScript(aIsMainScript), mWorkerScriptType(aWorkerScriptType),
|
||||
mCanceled(false), mCanceledMainThread(false)
|
||||
{
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
MOZ_ASSERT(aSyncLoopTarget);
|
||||
MOZ_ASSERT_IF(aIsWorkerScript, aLoadInfos.Length() == 1);
|
||||
MOZ_ASSERT_IF(aIsMainScript, aLoadInfos.Length() == 1);
|
||||
|
||||
mLoadInfos.SwapElements(aLoadInfos);
|
||||
}
|
||||
@@ -300,6 +318,12 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
IsMainWorkerScript() const
|
||||
{
|
||||
return mIsMainScript && mWorkerScriptType == WorkerScript;
|
||||
}
|
||||
|
||||
void
|
||||
CancelMainThread()
|
||||
{
|
||||
@@ -338,7 +362,7 @@ private:
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = mWorkerPrivate->GetLoadGroup();
|
||||
if (!principal) {
|
||||
NS_ASSERTION(parentWorker, "Must have a principal!");
|
||||
NS_ASSERTION(mIsWorkerScript, "Must have a principal for importScripts!");
|
||||
NS_ASSERTION(mIsMainScript, "Must have a principal for importScripts!");
|
||||
|
||||
principal = parentWorker->GetPrincipal();
|
||||
loadGroup = parentWorker->GetLoadGroup();
|
||||
@@ -348,7 +372,7 @@ private:
|
||||
|
||||
// Figure out our base URI.
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
if (mIsWorkerScript) {
|
||||
if (mIsMainScript) {
|
||||
if (parentWorker) {
|
||||
baseURI = parentWorker->GetBaseURI();
|
||||
NS_ASSERTION(baseURI, "Should have been set already!");
|
||||
@@ -367,7 +391,7 @@ private:
|
||||
nsCOMPtr<nsIDocument> parentDoc = mWorkerPrivate->GetDocument();
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
if (mIsWorkerScript) {
|
||||
if (IsMainWorkerScript()) {
|
||||
// May be null.
|
||||
channel = mWorkerPrivate->ForgetWorkerChannel();
|
||||
}
|
||||
@@ -383,8 +407,8 @@ private:
|
||||
|
||||
if (!channel) {
|
||||
rv = ChannelFromScriptURL(principal, baseURI, parentDoc, loadGroup, ios,
|
||||
secMan, loadInfo.mURL, mIsWorkerScript,
|
||||
getter_AddRefs(channel));
|
||||
secMan, loadInfo.mURL, mIsMainScript,
|
||||
mWorkerScriptType, getter_AddRefs(channel));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
@@ -489,7 +513,7 @@ private:
|
||||
|
||||
// Update the principal of the worker and its base URI if we just loaded the
|
||||
// worker's primary script.
|
||||
if (mIsWorkerScript) {
|
||||
if (IsMainWorkerScript()) {
|
||||
// Take care of the base URI first.
|
||||
mWorkerPrivate->SetBaseURI(finalURI);
|
||||
|
||||
@@ -572,7 +596,7 @@ private:
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
if (mIsWorkerScript) {
|
||||
if (IsMainWorkerScript()) {
|
||||
mWorkerPrivate->WorkerScriptLoaded();
|
||||
}
|
||||
|
||||
@@ -699,6 +723,15 @@ ScriptExecutorRunnable::ScriptExecutorRunnable(
|
||||
MOZ_ASSERT(aLastIndex < aScriptLoader.mLoadInfos.Length());
|
||||
}
|
||||
|
||||
bool
|
||||
ScriptExecutorRunnable::IsDebuggerRunnable() const
|
||||
{
|
||||
// ScriptExecutorRunnable is used to execute both worker and debugger scripts.
|
||||
// In the latter case, the runnable needs to be dispatched to the debugger
|
||||
// queue.
|
||||
return mScriptLoader.mWorkerScriptType == DebuggerScript;
|
||||
}
|
||||
|
||||
bool
|
||||
ScriptExecutorRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
||||
{
|
||||
@@ -757,6 +790,10 @@ ScriptExecutorRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
||||
options.setFileAndLine(filename.get(), 1)
|
||||
.setNoScriptRval(true);
|
||||
|
||||
if (mScriptLoader.mWorkerScriptType == DebuggerScript) {
|
||||
options.setVersion(JSVERSION_LATEST);
|
||||
}
|
||||
|
||||
JS::SourceBufferHolder srcBuf(loadInfo.mScriptTextBuf,
|
||||
loadInfo.mScriptTextLength,
|
||||
JS::SourceBufferHolder::GiveOwnership);
|
||||
@@ -814,7 +851,8 @@ ScriptExecutorRunnable::ShutdownScriptLoader(JSContext* aCx,
|
||||
|
||||
bool
|
||||
LoadAllScripts(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
|
||||
nsTArray<ScriptLoadInfo>& aLoadInfos, bool aIsWorkerScript)
|
||||
nsTArray<ScriptLoadInfo>& aLoadInfos, bool aIsMainScript,
|
||||
WorkerScriptType aWorkerScriptType)
|
||||
{
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
NS_ASSERTION(!aLoadInfos.IsEmpty(), "Bad arguments!");
|
||||
@@ -823,7 +861,7 @@ LoadAllScripts(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
|
||||
|
||||
nsRefPtr<ScriptLoaderRunnable> loader =
|
||||
new ScriptLoaderRunnable(aWorkerPrivate, syncLoop.EventTarget(),
|
||||
aLoadInfos, aIsWorkerScript);
|
||||
aLoadInfos, aIsMainScript, aWorkerScriptType);
|
||||
|
||||
NS_ASSERTION(aLoadInfos.IsEmpty(), "Should have swapped!");
|
||||
|
||||
@@ -863,7 +901,7 @@ ChannelFromScriptURLMainThread(nsIPrincipal* aPrincipal,
|
||||
NS_ASSERTION(secMan, "This should never be null!");
|
||||
|
||||
return ChannelFromScriptURL(aPrincipal, aBaseURI, aParentDoc, aLoadGroup,
|
||||
ios, secMan, aScriptURL, true, aChannel);
|
||||
ios, secMan, aScriptURL, true, WorkerScript, aChannel);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@@ -922,7 +960,8 @@ void ReportLoadError(JSContext* aCx, const nsAString& aURL,
|
||||
}
|
||||
|
||||
bool
|
||||
LoadWorkerScript(JSContext* aCx)
|
||||
LoadMainScript(JSContext* aCx, const nsAString& aScriptURL,
|
||||
WorkerScriptType aWorkerScriptType)
|
||||
{
|
||||
WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx);
|
||||
NS_ASSERTION(worker, "This should never be null!");
|
||||
@@ -930,14 +969,15 @@ LoadWorkerScript(JSContext* aCx)
|
||||
nsTArray<ScriptLoadInfo> loadInfos;
|
||||
|
||||
ScriptLoadInfo* info = loadInfos.AppendElement();
|
||||
info->mURL = worker->ScriptURL();
|
||||
info->mURL = aScriptURL;
|
||||
|
||||
return LoadAllScripts(aCx, worker, loadInfos, true);
|
||||
return LoadAllScripts(aCx, worker, loadInfos, true, aWorkerScriptType);
|
||||
}
|
||||
|
||||
void
|
||||
Load(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
|
||||
const Sequence<nsString>& aScriptURLs, ErrorResult& aRv)
|
||||
const nsTArray<nsString>& aScriptURLs, WorkerScriptType aWorkerScriptType,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
const uint32_t urlCount = aScriptURLs.Length();
|
||||
|
||||
@@ -957,7 +997,7 @@ Load(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
|
||||
loadInfos[index].mURL = aScriptURLs[index];
|
||||
}
|
||||
|
||||
if (!LoadAllScripts(aCx, aWorkerPrivate, loadInfos, false)) {
|
||||
if (!LoadAllScripts(aCx, aWorkerPrivate, loadInfos, false, aWorkerScriptType)) {
|
||||
// LoadAllScripts can fail if we're shutting down.
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user