summaryrefslogtreecommitdiffstats
path: root/dom/bindings
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /dom/bindings
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/bindings')
-rw-r--r--dom/bindings/BindingUtils.cpp65
-rw-r--r--dom/bindings/Bindings.conf4
-rw-r--r--dom/bindings/Codegen.py24
-rw-r--r--dom/bindings/DOMString.h5
-rw-r--r--dom/bindings/Errors.msg1
-rw-r--r--dom/bindings/FakeString.h2
-rw-r--r--dom/bindings/mach_commands.py2
-rw-r--r--dom/bindings/test/TestFunctions.cpp10
8 files changed, 61 insertions, 52 deletions
diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp
index 11d12dd364..198db3b5e2 100644
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -770,19 +770,31 @@ bool LegacyFactoryFunctionJSNative(JSContext* cx, unsigned argc,
->mNative(cx, argc, vp);
}
-static JSObject* CreateLegacyFactoryFunction(JSContext* cx, jsid name,
- const JSNativeHolder* nativeHolder,
- unsigned ctorNargs) {
- JSFunction* fun = js::NewFunctionByIdWithReserved(
- cx, LegacyFactoryFunctionJSNative, ctorNargs, JSFUN_CONSTRUCTOR, name);
+// This creates a JSFunction and sets its length and name properties in the
+// order that ECMAScript's CreateBuiltinFunction does.
+static JSObject* CreateBuiltinFunctionForConstructor(
+ JSContext* aCx, JSNative aNative, size_t aNativeReservedSlot,
+ void* aNativeReserved, unsigned int aNargs, jsid aName,
+ JS::Handle<JSObject*> aProto) {
+ JSFunction* fun = js::NewFunctionByIdWithReservedAndProto(
+ aCx, aNative, aProto, aNargs, JSFUN_CONSTRUCTOR, aName);
if (!fun) {
return nullptr;
}
- JSObject* constructor = JS_GetFunctionObject(fun);
- js::SetFunctionNativeReserved(
- constructor, LEGACY_FACTORY_FUNCTION_NATIVE_HOLDER_RESERVED_SLOT,
- JS::PrivateValue(const_cast<JSNativeHolder*>(nativeHolder)));
+ JS::Rooted<JSObject*> constructor(aCx, JS_GetFunctionObject(fun));
+ js::SetFunctionNativeReserved(constructor, aNativeReservedSlot,
+ JS::PrivateValue(aNativeReserved));
+
+ // Eagerly force creation of the .length and .name properties, because
+ // SpiderMonkey creates them lazily (see
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1629803).
+ bool unused;
+ if (!JS_HasProperty(aCx, constructor, "length", &unused) ||
+ !JS_HasProperty(aCx, constructor, "name", &unused)) {
+ return nullptr;
+ }
+
return constructor;
}
@@ -936,29 +948,12 @@ static JSObject* CreateInterfaceObject(
JS::Rooted<jsid> nameId(cx, JS::PropertyKey::NonIntAtom(name));
- JS::Rooted<JSObject*> constructor(cx);
- {
- JSFunction* fun = js::NewFunctionByIdWithReservedAndProto(
- cx, InterfaceObjectJSNative, interfaceProto, ctorNargs,
- JSFUN_CONSTRUCTOR, nameId);
- if (!fun) {
- return nullptr;
- }
-
- constructor = JS_GetFunctionObject(fun);
- }
-
- js::SetFunctionNativeReserved(
- constructor, INTERFACE_OBJECT_INFO_RESERVED_SLOT,
- JS::PrivateValue(const_cast<DOMInterfaceInfo*>(interfaceInfo)));
-
- // Eagerly force creation of the .length and .name properties, because they
- // need to be defined before the .prototype property (CreateBuiltinFunction
- // called from the WebIDL spec sets them, and then the .prototype property is
- // defined in the WebIDL spec itself).
- bool unused;
- if (!JS_HasProperty(cx, constructor, "length", &unused) ||
- !JS_HasProperty(cx, constructor, "name", &unused)) {
+ JS::Rooted<JSObject*> constructor(
+ cx, CreateBuiltinFunctionForConstructor(
+ cx, InterfaceObjectJSNative, INTERFACE_OBJECT_INFO_RESERVED_SLOT,
+ const_cast<DOMInterfaceInfo*>(interfaceInfo), ctorNargs, nameId,
+ interfaceProto));
+ if (!constructor) {
return nullptr;
}
@@ -1001,7 +996,11 @@ static JSObject* CreateInterfaceObject(
nameId = JS::PropertyKey::NonIntAtom(fname);
JS::Rooted<JSObject*> legacyFactoryFunction(
- cx, CreateLegacyFactoryFunction(cx, nameId, &lff.mHolder, lff.mNargs));
+ cx, CreateBuiltinFunctionForConstructor(
+ cx, LegacyFactoryFunctionJSNative,
+ LEGACY_FACTORY_FUNCTION_NATIVE_HOLDER_RESERVED_SLOT,
+ const_cast<JSNativeHolder*>(&lff.mHolder), lff.mNargs, nameId,
+ nullptr));
if (!legacyFactoryFunction ||
!JS_DefineProperty(cx, legacyFactoryFunction, "prototype", proto,
JSPROP_PERMANENT | JSPROP_READONLY) ||
diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf
index d735bcc2ee..19dd6d2e8d 100644
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -415,6 +415,10 @@ DOMInterfaces = {
'wrapperCache': False,
},
+'InspectorCSSParser': {
+ 'wrapperCache': False,
+},
+
'IntersectionObserver': {
'nativeType': 'mozilla::dom::DOMIntersectionObserver',
},
diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py
index a6a49f9b2f..de9444b42f 100644
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -8937,10 +8937,12 @@ def wrapTypeIntoCurrentCompartment(type, value, isMember=True):
return CGList(memberWraps) if len(memberWraps) != 0 else None
if type.isUnion():
- memberWraps = []
+ origValue = value
+ origType = type
if type.nullable():
type = type.inner
value = "%s.Value()" % value
+ memberWraps = []
for member in type.flatMemberTypes:
memberName = getUnionMemberName(member)
memberWrap = wrapTypeIntoCurrentCompartment(
@@ -8949,7 +8951,12 @@ def wrapTypeIntoCurrentCompartment(type, value, isMember=True):
if memberWrap:
memberWrap = CGIfWrapper(memberWrap, "%s.Is%s()" % (value, memberName))
memberWraps.append(memberWrap)
- return CGList(memberWraps, "else ") if len(memberWraps) != 0 else None
+ if len(memberWraps) == 0:
+ return None
+ wrapCode = CGList(memberWraps, "else ")
+ if origType.nullable():
+ wrapCode = CGIfWrapper(wrapCode, "!%s.IsNull()" % origValue)
+ return wrapCode
if (
type.isUndefined()
@@ -8996,7 +9003,8 @@ class CGPerSignatureCall(CGThing):
actual return value (e.g. this is an attribute setter) or an
IDLType if there's an IDL type involved (including |void|).
2) An argument list, which is allowed to be empty.
- 3) A name of a native method to call.
+ 3) A name of a native method to call. It is ignored for methods
+ annotated with the "[WebExtensionStub=...]" extended attribute.
4) Whether or not this method is static. Note that this only controls how
the method is called (|self->nativeMethodName(...)| vs
|nativeMethodName(...)|).
@@ -9370,7 +9378,7 @@ class CGPerSignatureCall(CGThing):
nativeMethodName,
argsPre,
args,
- ] = self.processWebExtensionStubAttribute(idlNode, cgThings)
+ ] = self.processWebExtensionStubAttribute(cgThings)
else:
args = self.getArguments()
@@ -9439,9 +9447,9 @@ class CGPerSignatureCall(CGThing):
def getArguments(self):
return list(zip(self.arguments, self.getArgumentNames()))
- def processWebExtensionStubAttribute(self, idlNode, cgThings):
+ def processWebExtensionStubAttribute(self, cgThings):
nativeMethodName = "CallWebExtMethod"
- stubNameSuffix = idlNode.getExtendedAttribute("WebExtensionStub")
+ stubNameSuffix = self.idlNode.getExtendedAttribute("WebExtensionStub")
if isinstance(stubNameSuffix, list):
nativeMethodName += stubNameSuffix[0]
@@ -9454,7 +9462,7 @@ class CGPerSignatureCall(CGThing):
if singleVariadicArg:
argsPre = [
"cx",
- 'u"%s"_ns' % idlNode.identifier.name,
+ 'u"%s"_ns' % self.idlNode.identifier.name,
"Constify(%s)" % "arg0",
]
args = []
@@ -9462,7 +9470,7 @@ class CGPerSignatureCall(CGThing):
argsPre = [
"cx",
- 'u"%s"_ns' % idlNode.identifier.name,
+ 'u"%s"_ns' % self.idlNode.identifier.name,
"Constify(%s)" % "args_sequence",
]
args = []
diff --git a/dom/bindings/DOMString.h b/dom/bindings/DOMString.h
index c5404f5351..e87d820777 100644
--- a/dom/bindings/DOMString.h
+++ b/dom/bindings/DOMString.h
@@ -169,8 +169,7 @@ class MOZ_STACK_CLASS DOMString {
if (MOZ_UNLIKELY(aString.IsVoid())) {
SetNull();
} else if (!aString.IsEmpty()) {
- nsStringBuffer* buf = nsStringBuffer::FromString(aString);
- if (buf) {
+ if (nsStringBuffer* buf = aString.GetStringBuffer()) {
SetKnownLiveStringBuffer(buf, aString.Length());
} else if (aString.IsLiteral()) {
SetLiteralInternal(aString.BeginReading(), aString.Length());
@@ -236,7 +235,7 @@ class MOZ_STACK_CLASS DOMString {
auto chars = static_cast<char16_t*>(buf->Data());
if (chars[len] == '\0') {
// Safe to share the buffer.
- buf->ToString(len, aString);
+ aString.Assign(buf, len);
} else {
// We need to copy, unfortunately.
aString.Assign(chars, len);
diff --git a/dom/bindings/Errors.msg b/dom/bindings/Errors.msg
index 2b0807891f..73a9364b7e 100644
--- a/dom/bindings/Errors.msg
+++ b/dom/bindings/Errors.msg
@@ -60,6 +60,7 @@ MSG_DEF(MSG_INVALID_REFERRER_URL, 2, true, JSEXN_TYPEERR, "{0}Invalid referrer U
MSG_DEF(MSG_FETCH_BODY_CONSUMED_ERROR, 1, true, JSEXN_TYPEERR, "{0}Body has already been consumed.")
MSG_DEF(MSG_RESPONSE_INVALID_STATUSTEXT_ERROR, 1, true, JSEXN_TYPEERR, "{0}Response statusText may not contain newline or carriage return.")
MSG_DEF(MSG_FETCH_FAILED, 1, true, JSEXN_TYPEERR, "{0}NetworkError when attempting to fetch resource.")
+MSG_DEF(MSG_FETCH_PARTIAL, 1, true, JSEXN_TYPEERR, "{0}Content-Length header of network response exceeds response Body.")
MSG_DEF(MSG_FETCH_BODY_WRONG_TYPE, 1, true, JSEXN_TYPEERR, "{0}Can't convert value to Uint8Array while consuming Body")
MSG_DEF(MSG_INVALID_ZOOMANDPAN_VALUE_ERROR, 1, true, JSEXN_RANGEERR, "{0}Invalid zoom and pan value.")
MSG_DEF(MSG_INVALID_TRANSFORM_ANGLE_ERROR, 1, true, JSEXN_RANGEERR, "{0}Invalid transform angle.")
diff --git a/dom/bindings/FakeString.h b/dom/bindings/FakeString.h
index f51f7890d9..e7221db868 100644
--- a/dom/bindings/FakeString.h
+++ b/dom/bindings/FakeString.h
@@ -51,7 +51,7 @@ struct FakeString {
// depend upon aString's data. aString should outlive this instance of
// FakeString.
void ShareOrDependUpon(const AString& aString) {
- RefPtr<nsStringBuffer> sharedBuffer = nsStringBuffer::FromString(aString);
+ RefPtr<nsStringBuffer> sharedBuffer = aString.GetStringBuffer();
if (!sharedBuffer) {
InitData(aString.BeginReading(), aString.Length());
if (!aString.IsTerminated()) {
diff --git a/dom/bindings/mach_commands.py b/dom/bindings/mach_commands.py
index 6f6b29bcbf..eb6865ea86 100644
--- a/dom/bindings/mach_commands.py
+++ b/dom/bindings/mach_commands.py
@@ -6,7 +6,7 @@ import os
import sys
from mach.decorators import Command, CommandArgument
-from mozbuild.util import mkdir
+from mozbuild.dirutils import mkdir
def get_test_parser():
diff --git a/dom/bindings/test/TestFunctions.cpp b/dom/bindings/test/TestFunctions.cpp
index a91121eaa7..59d4554020 100644
--- a/dom/bindings/test/TestFunctions.cpp
+++ b/dom/bindings/test/TestFunctions.cpp
@@ -66,8 +66,7 @@ void TestFunctions::GetStringDataAsDOMString(const Optional<uint32_t>& aLength,
length = mStringData.Length();
}
- nsStringBuffer* buf = nsStringBuffer::FromString(mStringData);
- if (buf) {
+ if (nsStringBuffer* buf = mStringData.GetStringBuffer()) {
aString.SetKnownLiveStringBuffer(buf, length);
return;
}
@@ -134,7 +133,7 @@ StringType TestFunctions::GetStringType(const nsAString& aString) {
return StringType::Literal;
}
- if (nsStringBuffer::FromString(aString)) {
+ if (aString.GetStringBuffer()) {
return StringType::Stringbuffer;
}
@@ -146,9 +145,8 @@ StringType TestFunctions::GetStringType(const nsAString& aString) {
}
bool TestFunctions::StringbufferMatchesStored(const nsAString& aString) {
- return nsStringBuffer::FromString(aString) &&
- nsStringBuffer::FromString(aString) ==
- nsStringBuffer::FromString(mStringData);
+ return aString.GetStringBuffer() &&
+ aString.GetStringBuffer() == mStringData.GetStringBuffer();
}
void TestFunctions::TestThrowNsresult(ErrorResult& aError) {