From e0c3f020d570730916191fb2bcf6ac912dab3a45 Mon Sep 17 00:00:00 2001 From: Nikhil Marathe Date: Wed, 18 Mar 2015 16:14:30 -0700 Subject: [PATCH] Bug 931249 - Patch 1.1 - Set baseURI when script is obtained from cache. r=khuey --HG-- extra : rebase_source : f8bd9b047518b3e5e220eddc3eab1f0918b83f6b --- dom/workers/ScriptLoader.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp index e1a671e0abd5..2afec68f8b3b 100644 --- a/dom/workers/ScriptLoader.cpp +++ b/dom/workers/ScriptLoader.cpp @@ -973,6 +973,7 @@ private: DataReceivedFromCache(uint32_t aIndex, const uint8_t* aString, uint32_t aStringLen) { + AssertIsOnMainThread(); MOZ_ASSERT(aIndex < mLoadInfos.Length()); ScriptLoadInfo& loadInfo = mLoadInfos[aIndex]; MOZ_ASSERT(loadInfo.mCacheStatus == ScriptLoadInfo::Cached); @@ -982,11 +983,18 @@ private: MOZ_ASSERT(!loadInfo.mScriptTextBuf); - DebugOnly rv = + nsresult rv = nsScriptLoader::ConvertToUTF16(nullptr, aString, aStringLen, NS_LITERAL_STRING("UTF-8"), parentDoc, loadInfo.mScriptTextBuf, loadInfo.mScriptTextLength); + if (NS_SUCCEEDED(rv) && IsMainWorkerScript()) { + nsCOMPtr finalURI; + rv = NS_NewURI(getter_AddRefs(finalURI), loadInfo.mFullURL, nullptr, nullptr); + if (NS_SUCCEEDED(rv)) { + mWorkerPrivate->SetBaseURI(finalURI); + } + } if (NS_SUCCEEDED(rv)) { DataReceived();