Backed out 18 changesets (bug 1311726) for failures on test_script_loader_js_cache.html . CLOSED TREE

Backed out changeset 1f9c13be6642 (bug 1311726)
Backed out changeset 2f4e89d930b0 (bug 1311726)
Backed out changeset 03f767c08221 (bug 1311726)
Backed out changeset b21e580a778f (bug 1311726)
Backed out changeset 4597b327e9be (bug 1311726)
Backed out changeset 558fec312301 (bug 1311726)
Backed out changeset b758abeed4cc (bug 1311726)
Backed out changeset a909be9fa973 (bug 1311726)
Backed out changeset 8db98e65b147 (bug 1311726)
Backed out changeset ee2e01e59950 (bug 1311726)
Backed out changeset 40c635fb36eb (bug 1311726)
Backed out changeset 6ba119a4e33e (bug 1311726)
Backed out changeset 1ad7d1308b5f (bug 1311726)
Backed out changeset dd2dbe11315d (bug 1311726)
Backed out changeset a8279e757309 (bug 1311726)
Backed out changeset 1de8b528723e (bug 1311726)
Backed out changeset f1e4c9199289 (bug 1311726)
Backed out changeset 23ea474c05ec (bug 1311726)
This commit is contained in:
Narcis Beleuzu
2021-12-08 12:46:07 +02:00
parent f0319391a8
commit dc53a1d420
9 changed files with 1297 additions and 1565 deletions

View File

@@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ScriptLoadRequest.h"
#include "GeckoProfiler.h"
#include "mozilla/dom/Document.h"
#include "mozilla/HoldDropJSObjects.h"
@@ -14,7 +13,6 @@
#include "mozilla/Utf8.h" // mozilla::Utf8Unit
#include "js/OffThreadScriptCompilation.h"
#include "js/SourceText.h"
#include "ModuleLoadRequest.h"
#include "nsContentUtils.h"
@@ -24,8 +22,6 @@
#include "ScriptLoadRequest.h"
#include "ScriptSettings.h"
using JS::SourceText;
namespace mozilla {
namespace dom {
@@ -276,104 +272,6 @@ void ScriptLoadRequest::SetIsLoadRequest(nsIScriptElement* aElement) {
mFetchOptions->mIsPreload = false;
}
nsresult ScriptLoadRequest::GetScriptSource(JSContext* aCx,
MaybeSourceText* aMaybeSource) {
// If there's no script text, we try to get it from the element
if (mIsInline) {
nsAutoString inlineData;
GetScriptElement()->GetScriptText(inlineData);
size_t nbytes = inlineData.Length() * sizeof(char16_t);
JS::UniqueTwoByteChars chars(
static_cast<char16_t*>(JS_malloc(aCx, nbytes)));
if (!chars) {
return NS_ERROR_OUT_OF_MEMORY;
}
memcpy(chars.get(), inlineData.get(), nbytes);
SourceText<char16_t> srcBuf;
if (!srcBuf.init(aCx, std::move(chars), inlineData.Length())) {
return NS_ERROR_OUT_OF_MEMORY;
}
aMaybeSource->construct<SourceText<char16_t>>(std::move(srcBuf));
return NS_OK;
}
size_t length = ScriptTextLength();
if (IsUTF16Text()) {
JS::UniqueTwoByteChars chars;
chars.reset(ScriptText<char16_t>().extractOrCopyRawBuffer());
if (!chars) {
JS_ReportOutOfMemory(aCx);
return NS_ERROR_OUT_OF_MEMORY;
}
SourceText<char16_t> srcBuf;
if (!srcBuf.init(aCx, std::move(chars), length)) {
return NS_ERROR_OUT_OF_MEMORY;
}
aMaybeSource->construct<SourceText<char16_t>>(std::move(srcBuf));
return NS_OK;
}
MOZ_ASSERT(IsUTF8Text());
UniquePtr<Utf8Unit[], JS::FreePolicy> chars;
chars.reset(ScriptText<Utf8Unit>().extractOrCopyRawBuffer());
if (!chars) {
JS_ReportOutOfMemory(aCx);
return NS_ERROR_OUT_OF_MEMORY;
}
SourceText<Utf8Unit> srcBuf;
if (!srcBuf.init(aCx, std::move(chars), length)) {
return NS_ERROR_OUT_OF_MEMORY;
}
aMaybeSource->construct<SourceText<Utf8Unit>>(std::move(srcBuf));
return NS_OK;
}
void ScriptLoadRequest::GetProfilerLabel(nsACString& aOutString) {
if (!profiler_is_active()) {
aOutString.Append("<script> element");
return;
}
aOutString.Append("<script");
if (IsAsyncScript()) {
aOutString.Append(" async");
} else if (IsDeferredScript()) {
aOutString.Append(" defer");
}
if (IsModuleRequest()) {
aOutString.Append(" type=\"module\"");
}
nsAutoCString url;
if (mURI) {
mURI->GetAsciiSpec(url);
} else {
url = "<unknown>";
}
if (mIsInline) {
if (GetParserCreated() != NOT_FROM_PARSER) {
aOutString.Append("> inline at line ");
aOutString.AppendInt(mLineNo);
aOutString.Append(" of ");
} else {
aOutString.Append("> inline (dynamically created) in ");
}
aOutString.Append(url);
} else {
aOutString.Append(" src=\"");
aOutString.Append(url);
aOutString.Append("\">");
}
}
//////////////////////////////////////////////////////////////
// ScriptLoadRequestList
//////////////////////////////////////////////////////////////