зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1688040 - part4.1: Initial WebIDL-based bindings for browser.test API namespace r=baku
Differential Revision: https://phabricator.services.mozilla.com/D102642
This commit is contained in:
Родитель
b1588941b3
Коммит
c86c10833d
|
@ -1612,6 +1612,11 @@ DOMInterfaces = {
|
|||
'nativeType': 'mozilla::extensions::ExtensionPort',
|
||||
},
|
||||
|
||||
'ExtensionTest': {
|
||||
'headerFile': 'mozilla/extensions/ExtensionTest.h',
|
||||
'nativeType': 'mozilla::extensions::ExtensionTest',
|
||||
},
|
||||
|
||||
####################################
|
||||
# Test Interfaces of various sorts #
|
||||
####################################
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT
|
||||
*
|
||||
* The content of this file has been generated based on the WebExtensions API
|
||||
* JSONSchema using the following command:
|
||||
*
|
||||
* export SCRIPT_DIR="toolkit/components/extensions/webidl-api"
|
||||
* mach python $SCRIPT_DIR/GenerateWebIDLBindings.py -- test
|
||||
*
|
||||
* More info about generating webidl API bindings for WebExtensions API at:
|
||||
*
|
||||
* https://firefox-source-docs.mozilla.org/toolkit/components/extensions/webextensions/webidl_bindings.html
|
||||
*/
|
||||
|
||||
/* 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/.
|
||||
*
|
||||
* You are granted a license to use, reproduce and create derivative works of
|
||||
* this document.
|
||||
*/
|
||||
|
||||
// WebIDL definition for the "test" WebExtensions API
|
||||
[Exposed=(ServiceWorker), LegacyNoInterfaceObject]
|
||||
interface ExtensionTest {
|
||||
// API methods.
|
||||
|
||||
[Throws, WebExtensionStub="NotImplementedNoReturn"]
|
||||
void withHandlingUserInput(Function callback);
|
||||
|
||||
[Throws, WebExtensionStub="NoReturn"]
|
||||
void notifyFail(DOMString message);
|
||||
|
||||
[Throws, WebExtensionStub="NoReturn"]
|
||||
void notifyPass(optional DOMString message);
|
||||
|
||||
[Throws, WebExtensionStub="NoReturn"]
|
||||
void log(DOMString message);
|
||||
|
||||
[Throws, WebExtensionStub="NoReturn"]
|
||||
void sendMessage(any... args);
|
||||
|
||||
[Throws, WebExtensionStub="NoReturn"]
|
||||
void fail(optional any message);
|
||||
|
||||
[Throws, WebExtensionStub="NoReturn"]
|
||||
void succeed(optional any message);
|
||||
|
||||
[Throws, WebExtensionStub="NoReturn"]
|
||||
void assertTrue(any... args);
|
||||
|
||||
[Throws, WebExtensionStub="NoReturn"]
|
||||
void assertFalse(any... args);
|
||||
|
||||
[Throws, WebExtensionStub="NotImplementedNoReturn"]
|
||||
void assertEq(any... args);
|
||||
|
||||
[Throws, WebExtensionStub="NotImplementedAsync"]
|
||||
any assertRejects(Promise<any> promise, any expectedError, optional DOMString message, optional Function callback);
|
||||
|
||||
[Throws, WebExtensionStub="NotImplementedNoReturn"]
|
||||
void assertThrows(Function func, any expectedError, optional DOMString message);
|
||||
|
||||
// API events.
|
||||
|
||||
[Replaceable, SameObject]
|
||||
readonly attribute ExtensionEventManager onMessage;
|
||||
};
|
|
@ -1063,6 +1063,7 @@ WEBIDL_FILES += [
|
|||
# ExtensionMockAPI is not a real WebExtensions API, and it is only enabled in tests.
|
||||
"ExtensionMockAPI.webidl",
|
||||
"ExtensionPort.webidl",
|
||||
"ExtensionTest.webidl",
|
||||
]
|
||||
|
||||
# We only expose our prefable test interfaces in debug builds, just to be on
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/* 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 "ExtensionTest.h"
|
||||
#include "ExtensionEventManager.h"
|
||||
|
||||
#include "mozilla/dom/ExtensionTestBinding.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace extensions {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(ExtensionTest);
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(ExtensionTest)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ExtensionTest, mGlobal,
|
||||
mOnMessageEventMgr);
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ExtensionTest)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
ExtensionTest::ExtensionTest(nsIGlobalObject* aGlobal,
|
||||
ExtensionBrowser* aExtensionBrowser)
|
||||
: mGlobal(aGlobal) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mGlobal);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool ExtensionTest::IsAllowed(JSContext* aCx, JSObject* aGlobal) {
|
||||
return true;
|
||||
}
|
||||
|
||||
JSObject* ExtensionTest::WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) {
|
||||
return dom::ExtensionTest_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
nsIGlobalObject* ExtensionTest::GetParentObject() const { return mGlobal; }
|
||||
|
||||
ExtensionEventManager* ExtensionTest::OnMessage() {
|
||||
if (!mOnMessageEventMgr) {
|
||||
mOnMessageEventMgr = CreateEventManager(u"onMessage"_ns);
|
||||
}
|
||||
|
||||
return mOnMessageEventMgr;
|
||||
}
|
||||
|
||||
} // namespace extensions
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,63 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_extensions_ExtensionTest_h
|
||||
#define mozilla_extensions_ExtensionTest_h
|
||||
|
||||
#include "js/TypeDecls.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
#include "ExtensionAPIBase.h"
|
||||
#include "ExtensionBrowser.h"
|
||||
|
||||
class nsIGlobalObject;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace extensions {
|
||||
|
||||
class ExtensionEventManager;
|
||||
|
||||
class ExtensionTest final : public nsISupports,
|
||||
public nsWrapperCache,
|
||||
public ExtensionAPINamespace {
|
||||
nsCOMPtr<nsIGlobalObject> mGlobal;
|
||||
RefPtr<ExtensionEventManager> mOnMessageEventMgr;
|
||||
|
||||
~ExtensionTest() = default;
|
||||
|
||||
public:
|
||||
ExtensionTest(nsIGlobalObject* aGlobal, ExtensionBrowser* aExtensionBrowser);
|
||||
|
||||
// ExtensionAPIBase methods
|
||||
nsIGlobalObject* GetGlobalObject() const override { return mGlobal; }
|
||||
|
||||
nsString GetAPINamespace() const override { return u"test"_ns; }
|
||||
|
||||
// nsWrapperCache interface methods
|
||||
JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
// DOM bindings methods
|
||||
static bool IsAllowed(JSContext* aCx, JSObject* aGlobal);
|
||||
|
||||
nsIGlobalObject* GetParentObject() const;
|
||||
|
||||
ExtensionEventManager* OnMessage();
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ExtensionTest)
|
||||
};
|
||||
|
||||
} // namespace extensions
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_extensions_ExtensionTest_h
|
|
@ -47,7 +47,12 @@ WEBEXT_TYPES_MAPPING = {
|
|||
# "namespace.methodName": "WebExtensionStubName",
|
||||
#
|
||||
# NOTE: Please keep this table in alphabetic order.
|
||||
WEBEXT_STUBS_MAPPING = {}
|
||||
WEBEXT_STUBS_MAPPING = {
|
||||
"test.assertEq": "NotImplementedNoReturn",
|
||||
"test.assertRejects": "NotImplementedAsync",
|
||||
"test.assertThrows": "NotImplementedNoReturn",
|
||||
"test.withHandlingUserInput": "NotImplementedNoReturn",
|
||||
}
|
||||
|
||||
# Mapping table for the directories where the JSON API schema will be loaded
|
||||
# from.
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
with Files("**"):
|
||||
BUG_COMPONENT = ("WebExtensions", "General")
|
||||
|
||||
# WebExtensions API objects and request handling internals.
|
||||
UNIFIED_SOURCES += [
|
||||
"ExtensionAPIBase.cpp",
|
||||
"ExtensionAPIRequest.cpp",
|
||||
|
@ -24,6 +25,15 @@ EXPORTS.mozilla.extensions += [
|
|||
"ExtensionPort.h",
|
||||
]
|
||||
|
||||
# WebExtensions API namespaces.
|
||||
UNIFIED_SOURCES += [
|
||||
"ExtensionTest.cpp",
|
||||
]
|
||||
|
||||
EXPORTS.mozilla.extensions += [
|
||||
"ExtensionTest.h",
|
||||
]
|
||||
|
||||
# The following is not a real WebExtensions API, it is a test WebIDL
|
||||
# interface that includes a collection of the cases useful to unit
|
||||
# test the API request forwarding mechanism without tying it to
|
||||
|
|
Загрузка…
Ссылка в новой задаче