Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py
- --- a/dom/bindings/Codegen.py
- +++ b/dom/bindings/Codegen.py
- @@ -2356,17 +2356,18 @@ class MethodDefiner(PropertyDefiner):
- # identifier. For now we check if the name starts with __
- # Ignore non-static methods for interfaces without a proto object
- if descriptor.interface.hasInterfacePrototypeObject() or static:
- methods = [m for m in descriptor.interface.members if
- m.isMethod() and m.isStatic() == static and
- MemberIsUnforgeable(m, descriptor) == unforgeable and
- (not crossOriginOnly or m.getExtendedAttribute("CrossOriginCallable")) and
- - not m.isIdentifierLess()]
- + not m.isIdentifierLess() and
- + not m.getExtendedAttribute("Unexposed")]
- else:
- methods = []
- self.chrome = []
- self.regular = []
- for m in methods:
- if m.identifier.name == 'QueryInterface':
- # QueryInterface is special, because instead of generating an
- # impl we just call out directly to our shared one.
- @@ -9638,21 +9639,29 @@ class CGMemberJITInfo(CGThing):
- $*{slotAssert}
- """,
- argTypesDecl=argTypesDecl,
- infoName=infoName,
- jitInfo=indent(jitInfoInitializer(True)),
- argTypes=argTypes,
- slotAssert=slotAssert)
- + # Unexposed things are meant to be used from C++ directly, so we make
- + # their jitinfo non-static. That way C++ can get at it.
- + if self.member.getExtendedAttribute("Unexposed"):
- + storageClass = "extern "
- + else:
- + storageClass = "static "
- +
- return fill(
- """
- - static const JSJitInfo ${infoName} = ${jitInfo};
- + ${storageClass}const JSJitInfo ${infoName} = ${jitInfo};
- $*{slotAssert}
- """,
- + storageClass=storageClass,
- infoName=infoName,
- jitInfo=jitInfoInitializer(False),
- slotAssert=slotAssert)
- def define(self):
- if self.member.isAttr():
- getterinfo = ("%s_getterinfo" %
- IDLToCIdentifier(self.member.identifier.name))
- diff --git a/dom/bindings/parser/WebIDL.py b/dom/bindings/parser/WebIDL.py
- --- a/dom/bindings/parser/WebIDL.py
- +++ b/dom/bindings/parser/WebIDL.py
- @@ -5264,17 +5264,18 @@ class IDLMethod(IDLInterfaceMember, IDLS
- identifier == "Pref" or
- identifier == "Deprecated" or
- identifier == "Func" or
- identifier == "SecureContext" or
- identifier == "BinaryName" or
- identifier == "NeedsSubjectPrincipal" or
- identifier == "NeedsCallerType" or
- identifier == "StaticClassOverride" or
- - identifier == "NonEnumerable"):
- + identifier == "NonEnumerable" or
- + identifier == "Unexposed"):
- # Known attributes that we don't need to do anything with here
- pass
- else:
- raise WebIDLError("Unknown extended attribute %s on method" % identifier,
- [attr.location])
- IDLInterfaceMember.handleExtendedAttribute(self, attr)
- def returnsPromise(self):
- diff --git a/dom/u2f/U2F.cpp b/dom/u2f/U2F.cpp
- --- a/dom/u2f/U2F.cpp
- +++ b/dom/u2f/U2F.cpp
- @@ -1,26 +1,24 @@
- /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
- /* vim: set ts=8 sts=2 et sw=2 tw=80: */
- /* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
- #include "mozilla/dom/U2F.h"
- -#include "mozilla/dom/PrimitiveConversions.h" // For ValueToPrimitive
- #include "mozilla/dom/WebCryptoCommon.h"
- #include "mozilla/ipc/PBackgroundChild.h"
- #include "mozilla/ipc/BackgroundChild.h"
- #include "mozilla/dom/WebAuthnTransactionChild.h"
- #include "mozilla/dom/WebAuthnUtil.h"
- #include "nsContentUtils.h"
- #include "nsIEffectiveTLDService.h"
- #include "nsNetUtil.h"
- #include "nsURLParsers.h"
- -#include "js/ForOfIterator.h" // For JS::ForOfIterator
- #ifdef OS_WIN
- # include "WinWebAuthnManager.h"
- #endif
- using namespace mozilla::ipc;
- // Forward decl because of nsHTMLDocument.h's complex dependency on
- @@ -291,25 +289,39 @@ void U2F::Register(const nsAString& aApp
- adjustedTimeoutMillis, excludeList,
- Nothing() /* no extra info for U2F */);
- MOZ_ASSERT(mTransaction.isNothing());
- mTransaction = Some(U2FTransaction(AsVariant(callback)));
- mChild->SendRequestRegister(mTransaction.ref().mId, info);
- }
- -// Implemented at end of file to avoid noise
- -static bool register_binding(JSContext* cx, unsigned argc, JS::Value* vp);
- +using binding_detail::GenericMethod;
- +using binding_detail::NormalThisPolicy;
- +using binding_detail::ThrowExceptions;
- +
- +// register_impl_methodinfo is generated by bindings.
- +namespace U2F_Binding {
- +extern JSJitInfo register_impl_methodinfo;
- +} // namespace U2F_Binding
- +
- +// We have 4 non-optional args.
- +static const JSFunctionSpec register_spec = JS_FNSPEC("register", (GenericMethod<NormalThisPolicy, ThrowExceptions>), &U2F_Binding::register_impl_methodinfo, 4, JSPROP_ENUMERATE, nullptr);
- void U2F::GetRegister(JSContext* aCx,
- JS::MutableHandle<JSObject*> aRegisterFunc,
- ErrorResult& aRv) {
- - // We have 4 non-optional args.
- - JSFunction* fun = JS_NewFunction(aCx, register_binding, /* nargs = */ 4,
- - /* flags = */ 0, "registerx");
- + JS::Rooted<JSString*> str(aCx, JS_AtomizeAndPinString(aCx, "register"));
- + if (!str) {
- + aRv.NoteJSContextException(aCx);
- + return;
- + }
- +
- + JS::Rooted<jsid> id(aCx, INTERNED_STRING_TO_JSID(aCx, str));
- + JSFunction* fun = JS::NewFunctionFromSpec(aCx, ®ister_spec, id);
- if (!fun) {
- aRv.NoteJSContextException(aCx);
- return;
- }
- aRegisterFunc.set(JS_GetFunctionObject(fun));
- }
- @@ -468,24 +480,34 @@ void U2F::Sign(const nsAString& aAppId,
- adjustedTimeoutMillis, permittedList,
- Nothing() /* no extra info for U2F */);
- MOZ_ASSERT(mTransaction.isNothing());
- mTransaction = Some(U2FTransaction(AsVariant(callback)));
- mChild->SendRequestSign(mTransaction.ref().mId, info);
- }
- -// Implemented at end of file to avoid noise
- -static bool sign_binding(JSContext* cx, unsigned argc, JS::Value* vp);
- +// sign_impl_methodinfo is generated by bindings.
- +namespace U2F_Binding{
- +extern JSJitInfo sign_impl_methodinfo;
- +} // namespace U2F_Binding
- +
- +// We have 4 non-optional args.
- +static const JSFunctionSpec sign_spec = JS_FNSPEC("sign", (GenericMethod<NormalThisPolicy, ThrowExceptions>), &U2F_Binding::sign_impl_methodinfo, 4, JSPROP_ENUMERATE, nullptr);
- void U2F::GetSign(JSContext* aCx, JS::MutableHandle<JSObject*> aSignFunc,
- ErrorResult& aRv) {
- - // We have 4 non-optional args.
- - JSFunction* fun = JS_NewFunction(aCx, sign_binding, /* nargs = */ 4,
- - /* flags = */ 0, "sign");
- + JS::Rooted<JSString*> str(aCx, JS_AtomizeAndPinString(aCx, "sign"));
- + if (!str) {
- + aRv.NoteJSContextException(aCx);
- + return;
- + }
- +
- + JS::Rooted<jsid> id(aCx, INTERNED_STRING_TO_JSID(aCx, str));
- + JSFunction* fun = JS::NewFunctionFromSpec(aCx, &sign_spec, id);
- if (!fun) {
- aRv.NoteJSContextException(aCx);
- return;
- }
- aSignFunc.set(JS_GetFunctionObject(fun));
- }
- @@ -611,272 +633,10 @@ void U2F::RequestAborted(const uint64_t&
- }
- void U2F::HandleVisibilityChange() {
- if (mTransaction.isSome()) {
- mTransaction.ref().mVisibilityChanged = true;
- }
- }
- -// clang-format off
- -
- -/**
- - * The register_binding and sign_binding implementations are copy/pasted from
- - * IDL method implementations with the following signatures:
- - *
- - * register_binding:
- - * void register(DOMString appId,
- - * sequence<RegisterRequest> registerRequests,
- - * sequence<RegisteredKey> registeredKeys,
- - * U2FRegisterCallback callback,
- - * optional long? opt_timeoutSeconds);
- - *
- - * sign_binding:
- - * void sign(DOMString appId,
- - * DOMString challenge,
- - * sequence<RegisteredKey> registeredKeys,
- - * U2FSignCallback callback,
- - * optional long? opt_timeoutSeconds);
- - *
- - * with a bit of boilerplate at the top to check for a valid "this" value.
- - */
- -using binding_detail::FastErrorResult;
- -
- -MOZ_CAN_RUN_SCRIPT static bool
- -register_binding(JSContext* cx, unsigned argc, JS::Value* vp)
- -{
- - JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
- - JS::Rooted<JS::Value> rootSelf(cx, args.thisv());
- - if (!rootSelf.isObject()) {
- - return ThrowInvalidThis(cx, args, false, "U2F");
- - }
- -
- - U2F* self;
- - { // Scope for rv
- - nsresult rv = UNWRAP_OBJECT(U2F, &rootSelf, self);
- - if (NS_FAILED(rv)) {
- - return ThrowInvalidThis(cx, args,
- - rv == NS_ERROR_XPC_SECURITY_MANAGER_VETO, "U2F");
- - }
- - }
- -
- - AUTO_PROFILER_LABEL_DYNAMIC_FAST(
- - "U2F", "register", DOM, cx,
- - uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
- - uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
- -
- - if (!args.requireAtLeast(cx, "U2F.register", 4)) {
- - return false;
- - }
- - binding_detail::FakeString arg0;
- - if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
- - return false;
- - }
- - binding_detail::AutoSequence<RegisterRequest> arg1;
- - if (args[1].isObject()) {
- - JS::ForOfIterator iter(cx);
- - if (!iter.init(args[1], JS::ForOfIterator::AllowNonIterable)) {
- - return false;
- - }
- - if (!iter.valueIsIterable()) {
- - ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 2 of U2F.register");
- - return false;
- - }
- - binding_detail::AutoSequence<RegisterRequest> &arr = arg1;
- - JS::Rooted<JS::Value> temp(cx);
- - while (true) {
- - bool done;
- - if (!iter.next(&temp, &done)) {
- - return false;
- - }
- - if (done) {
- - break;
- - }
- - RegisterRequest* slotPtr = arr.AppendElement(mozilla::fallible);
- - if (!slotPtr) {
- - JS_ReportOutOfMemory(cx);
- - return false;
- - }
- - RegisterRequest& slot = *slotPtr;
- - if (!slot.Init(cx, temp, "Element of argument 2 of U2F.register", false)) {
- - return false;
- - }
- - }
- - } else {
- - ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 2 of U2F.register");
- - return false;
- - }
- - binding_detail::AutoSequence<RegisteredKey> arg2;
- - if (args[2].isObject()) {
- - JS::ForOfIterator iter(cx);
- - if (!iter.init(args[2], JS::ForOfIterator::AllowNonIterable)) {
- - return false;
- - }
- - if (!iter.valueIsIterable()) {
- - ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 3 of U2F.register");
- - return false;
- - }
- - binding_detail::AutoSequence<RegisteredKey> &arr = arg2;
- - JS::Rooted<JS::Value> temp(cx);
- - while (true) {
- - bool done;
- - if (!iter.next(&temp, &done)) {
- - return false;
- - }
- - if (done) {
- - break;
- - }
- - RegisteredKey* slotPtr = arr.AppendElement(mozilla::fallible);
- - if (!slotPtr) {
- - JS_ReportOutOfMemory(cx);
- - return false;
- - }
- - RegisteredKey& slot = *slotPtr;
- - if (!slot.Init(cx, temp, "Element of argument 3 of U2F.register", false)) {
- - return false;
- - }
- - }
- - } else {
- - ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 3 of U2F.register");
- - return false;
- - }
- - RootedCallback<OwningNonNull<binding_detail::FastU2FRegisterCallback>> arg3(cx);
- - if (args[3].isObject()) {
- - if (JS::IsCallable(&args[3].toObject())) {
- - { // scope for tempRoot and tempGlobalRoot if needed
- - arg3 = new binding_detail::FastU2FRegisterCallback(&args[3].toObject(), JS::CurrentGlobalOrNull(cx));
- - }
- - } else {
- - ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 4 of U2F.register");
- - return false;
- - }
- - } else {
- - ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of U2F.register");
- - return false;
- - }
- - Optional<Nullable<int32_t>> arg4;
- - if (args.hasDefined(4)) {
- - arg4.Construct();
- - if (args[4].isNullOrUndefined()) {
- - arg4.Value().SetNull();
- - } else if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4.Value().SetValue())) {
- - return false;
- - }
- - }
- - FastErrorResult rv;
- - // NOTE: This assert does NOT call the function.
- - static_assert(mozilla::IsVoid<decltype(MOZ_KnownLive(self)->Register(NonNullHelper(Constify(arg0)), Constify(arg1), Constify(arg2), MOZ_KnownLive(NonNullHelper(arg3)), Constify(arg4), rv))>::value, "Should be returning void here");
- - MOZ_KnownLive(self)->Register(NonNullHelper(Constify(arg0)), Constify(arg1), Constify(arg2), MOZ_KnownLive(NonNullHelper(arg3)), Constify(arg4), rv);
- - if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
- - return false;
- - }
- - MOZ_ASSERT(!JS_IsExceptionPending(cx));
- - args.rval().setUndefined();
- - return true;
- -}
- -
- -MOZ_CAN_RUN_SCRIPT static bool
- -sign_binding(JSContext* cx, unsigned argc, JS::Value* vp)
- -{
- - JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
- - JS::Rooted<JS::Value> rootSelf(cx, args.thisv());
- - if (!rootSelf.isObject()) {
- - return ThrowInvalidThis(cx, args, false, "U2F");
- - }
- -
- - U2F* self;
- - { // Scope for rv
- - nsresult rv = UNWRAP_OBJECT(U2F, &rootSelf, self);
- - if (NS_FAILED(rv)) {
- - return ThrowInvalidThis(cx, args,
- - rv == NS_ERROR_XPC_SECURITY_MANAGER_VETO, "U2F");
- - }
- - }
- -
- - AUTO_PROFILER_LABEL_DYNAMIC_FAST(
- - "U2F", "sign", DOM, cx,
- - uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
- - uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
- -
- - if (!args.requireAtLeast(cx, "U2F.sign", 4)) {
- - return false;
- - }
- - binding_detail::FakeString arg0;
- - if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
- - return false;
- - }
- - binding_detail::FakeString arg1;
- - if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
- - return false;
- - }
- - binding_detail::AutoSequence<RegisteredKey> arg2;
- - if (args[2].isObject()) {
- - JS::ForOfIterator iter(cx);
- - if (!iter.init(args[2], JS::ForOfIterator::AllowNonIterable)) {
- - return false;
- - }
- - if (!iter.valueIsIterable()) {
- - ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 3 of U2F.sign");
- - return false;
- - }
- - binding_detail::AutoSequence<RegisteredKey> &arr = arg2;
- - JS::Rooted<JS::Value> temp(cx);
- - while (true) {
- - bool done;
- - if (!iter.next(&temp, &done)) {
- - return false;
- - }
- - if (done) {
- - break;
- - }
- - RegisteredKey* slotPtr = arr.AppendElement(mozilla::fallible);
- - if (!slotPtr) {
- - JS_ReportOutOfMemory(cx);
- - return false;
- - }
- - RegisteredKey& slot = *slotPtr;
- - if (!slot.Init(cx, temp, "Element of argument 3 of U2F.sign", false)) {
- - return false;
- - }
- - }
- - } else {
- - ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 3 of U2F.sign");
- - return false;
- - }
- - RootedCallback<OwningNonNull<binding_detail::FastU2FSignCallback>> arg3(cx);
- - if (args[3].isObject()) {
- - if (JS::IsCallable(&args[3].toObject())) {
- - { // scope for tempRoot and tempGlobalRoot if needed
- - arg3 = new binding_detail::FastU2FSignCallback(&args[3].toObject(), JS::CurrentGlobalOrNull(cx));
- - }
- - } else {
- - ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 4 of U2F.sign");
- - return false;
- - }
- - } else {
- - ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of U2F.sign");
- - return false;
- - }
- - Optional<Nullable<int32_t>> arg4;
- - if (args.hasDefined(4)) {
- - arg4.Construct();
- - if (args[4].isNullOrUndefined()) {
- - arg4.Value().SetNull();
- - } else if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4.Value().SetValue())) {
- - return false;
- - }
- - }
- - FastErrorResult rv;
- - // NOTE: This assert does NOT call the function.
- - static_assert(mozilla::IsVoid<decltype(MOZ_KnownLive(self)->Sign(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), Constify(arg2), MOZ_KnownLive(NonNullHelper(arg3)), Constify(arg4), rv))>::value, "Should be returning void here");
- - MOZ_KnownLive(self)->Sign(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), Constify(arg2), MOZ_KnownLive(NonNullHelper(arg3)), Constify(arg4), rv);
- - if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
- - return false;
- - }
- - MOZ_ASSERT(!JS_IsExceptionPending(cx));
- - args.rval().setUndefined();
- - return true;
- -}
- -
- -// clang-format on
- -
- } // namespace dom
- } // namespace mozilla
- diff --git a/dom/webidl/U2F.webidl b/dom/webidl/U2F.webidl
- --- a/dom/webidl/U2F.webidl
- +++ b/dom/webidl/U2F.webidl
- @@ -79,13 +79,29 @@ interface U2F {
- const unsigned short DEVICE_INELIGIBLE = 4;
- const unsigned short TIMEOUT = 5;
- // Returns a Function. It's readonly + [LenientSetter] to keep the Google
- // U2F polyfill from stomping on the value.
- [LenientSetter, Pure, Cached, Throws]
- readonly attribute object register;
- + // A way to generate the actual implementation of register()
- + [Unexposed, Throws, BinaryName="Register"]
- + void register_impl(DOMString appId,
- + sequence<RegisterRequest> registerRequests,
- + sequence<RegisteredKey> registeredKeys,
- + U2FRegisterCallback callback,
- + optional long? opt_timeoutSeconds);
- +
- // Returns a Function. It's readonly + [LenientSetter] to keep the Google
- // U2F polyfill from stomping on the value.
- [LenientSetter, Pure, Cached, Throws]
- readonly attribute object sign;
- +
- + // A way to generate the actual implementation of sign()
- + [Unexposed, Throws, BinaryName="Sign"]
- + void sign_impl (DOMString appId,
- + DOMString challenge,
- + sequence<RegisteredKey> registeredKeys,
- + U2FSignCallback callback,
- + optional long? opt_timeoutSeconds);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement