mirror of
				https://github.com/mozilla/gecko-dev.git
				synced 2025-11-04 02:09:05 +02:00 
			
		
		
		
	Bug 1723838 - WebIDL bindings for the 'dns' WebExtensions API namespace. r=willdurand,webidl,smaug
Differential Revision: https://phabricator.services.mozilla.com/D167594
This commit is contained in:
		
							parent
							
								
									fb2f3314d9
								
							
						
					
					
						commit
						487ce9d828
					
				
					 15 changed files with 180 additions and 14 deletions
				
			
		| 
						 | 
					@ -1687,6 +1687,11 @@ DOMInterfaces = {
 | 
				
			||||||
    'nativeType': 'mozilla::extensions::ExtensionMockAPI',
 | 
					    'nativeType': 'mozilla::extensions::ExtensionMockAPI',
 | 
				
			||||||
},
 | 
					},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					'ExtensionDns': {
 | 
				
			||||||
 | 
					    'headerFile': 'mozilla/extensions/ExtensionDns.h',
 | 
				
			||||||
 | 
					    'nativeType': 'mozilla::extensions::ExtensionDns',
 | 
				
			||||||
 | 
					},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
'ExtensionEventManager': {
 | 
					'ExtensionEventManager': {
 | 
				
			||||||
    'headerFile': 'mozilla/extensions/ExtensionEventManager.h',
 | 
					    'headerFile': 'mozilla/extensions/ExtensionEventManager.h',
 | 
				
			||||||
    'nativeType': 'mozilla::extensions::ExtensionEventManager',
 | 
					    'nativeType': 'mozilla::extensions::ExtensionEventManager',
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,6 +35,11 @@ interface ExtensionBrowser {
 | 
				
			||||||
   Func="mozilla::extensions::ExtensionAlarms::IsAllowed"]
 | 
					   Func="mozilla::extensions::ExtensionAlarms::IsAllowed"]
 | 
				
			||||||
  readonly attribute ExtensionAlarms alarms;
 | 
					  readonly attribute ExtensionAlarms alarms;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // `browser.dns` API namespace
 | 
				
			||||||
 | 
					  [Replaceable, SameObject, BinaryName="GetExtensionDns",
 | 
				
			||||||
 | 
					   Func="mozilla::extensions::ExtensionDns::IsAllowed"]
 | 
				
			||||||
 | 
					  readonly attribute ExtensionDns dns;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // `browser.runtime` API namespace
 | 
					  // `browser.runtime` API namespace
 | 
				
			||||||
  [Replaceable, SameObject, BinaryName="GetExtensionRuntime",
 | 
					  [Replaceable, SameObject, BinaryName="GetExtensionRuntime",
 | 
				
			||||||
   Func="mozilla::extensions::ExtensionRuntime::IsAllowed"]
 | 
					   Func="mozilla::extensions::ExtensionRuntime::IsAllowed"]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										30
									
								
								dom/webidl/ExtensionDns.webidl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								dom/webidl/ExtensionDns.webidl
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,30 @@
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 *  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 -- dns
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *  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 "dns" WebExtensions API
 | 
				
			||||||
 | 
					[Exposed=(ServiceWorker), LegacyNoInterfaceObject]
 | 
				
			||||||
 | 
					interface ExtensionDns {
 | 
				
			||||||
 | 
					  // API methods.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  [Throws, WebExtensionStub="AsyncAmbiguous"]
 | 
				
			||||||
 | 
					  any resolve(any... args);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -1110,6 +1110,7 @@ WEBIDL_FILES += [
 | 
				
			||||||
WEBIDL_FILES += [
 | 
					WEBIDL_FILES += [
 | 
				
			||||||
    "ExtensionAlarms.webidl",
 | 
					    "ExtensionAlarms.webidl",
 | 
				
			||||||
    "ExtensionBrowser.webidl",
 | 
					    "ExtensionBrowser.webidl",
 | 
				
			||||||
 | 
					    "ExtensionDns.webidl",
 | 
				
			||||||
    "ExtensionEventManager.webidl",
 | 
					    "ExtensionEventManager.webidl",
 | 
				
			||||||
    # ExtensionMockAPI is not a real WebExtensions API, and it is only enabled in tests.
 | 
					    # ExtensionMockAPI is not a real WebExtensions API, and it is only enabled in tests.
 | 
				
			||||||
    "ExtensionMockAPI.webidl",
 | 
					    "ExtensionMockAPI.webidl",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -100,7 +100,7 @@ add_task(async function startup() {
 | 
				
			||||||
  await AddonTestUtils.promiseStartupManager();
 | 
					  await AddonTestUtils.promiseStartupManager();
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_task(async function test_dns_resolve() {
 | 
					async function test_dns_resolve() {
 | 
				
			||||||
  let extension = getExtension();
 | 
					  let extension = getExtension();
 | 
				
			||||||
  await extension.startup();
 | 
					  await extension.startup();
 | 
				
			||||||
  await extension.awaitMessage("ready");
 | 
					  await extension.awaitMessage("ready");
 | 
				
			||||||
| 
						 | 
					@ -137,9 +137,9 @@ add_task(async function test_dns_resolve() {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  await extension.unload();
 | 
					  await extension.unload();
 | 
				
			||||||
});
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_task(async function test_dns_resolve_socks() {
 | 
					async function test_dns_resolve_socks() {
 | 
				
			||||||
  let extension = getExtension();
 | 
					  let extension = getExtension();
 | 
				
			||||||
  await extension.startup();
 | 
					  await extension.startup();
 | 
				
			||||||
  await extension.awaitMessage("ready");
 | 
					  await extension.awaitMessage("ready");
 | 
				
			||||||
| 
						 | 
					@ -173,4 +173,13 @@ add_task(async function test_dns_resolve_socks() {
 | 
				
			||||||
    `expected error ${result.message}`
 | 
					    `expected error ${result.message}`
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
  await extension.unload();
 | 
					  await extension.unload();
 | 
				
			||||||
});
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					add_task(test_dns_resolve);
 | 
				
			||||||
 | 
					add_task(
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    // TODO(Bug 1748313): remove the skip_if once we have introduced the proxy API namespace.
 | 
				
			||||||
 | 
					    skip_if: () => ExtensionTestUtils.isInBackgroundServiceWorkerTests(),
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  test_dns_resolve_socks
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,6 +20,7 @@ prefs =
 | 
				
			||||||
[test_ext_alarms_replaces.js]
 | 
					[test_ext_alarms_replaces.js]
 | 
				
			||||||
[test_ext_background_service_worker.js]
 | 
					[test_ext_background_service_worker.js]
 | 
				
			||||||
[test_ext_contentscript_dynamic_registration.js]
 | 
					[test_ext_contentscript_dynamic_registration.js]
 | 
				
			||||||
 | 
					[test_ext_dns.js]
 | 
				
			||||||
[test_ext_runtime_getBackgroundPage.js]
 | 
					[test_ext_runtime_getBackgroundPage.js]
 | 
				
			||||||
[test_ext_scripting_contentScripts.js]
 | 
					[test_ext_scripting_contentScripts.js]
 | 
				
			||||||
[test_ext_scripting_contentScripts_css.js]
 | 
					[test_ext_scripting_contentScripts_css.js]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,8 +9,7 @@
 | 
				
			||||||
#include "mozilla/dom/{{ webidl_name }}Binding.h"
 | 
					#include "mozilla/dom/{{ webidl_name }}Binding.h"
 | 
				
			||||||
#include "nsIGlobalObject.h"
 | 
					#include "nsIGlobalObject.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace mozilla {
 | 
					namespace mozilla::extensions {
 | 
				
			||||||
namespace extensions {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
NS_IMPL_CYCLE_COLLECTING_ADDREF({{ webidl_name }});
 | 
					NS_IMPL_CYCLE_COLLECTING_ADDREF({{ webidl_name }});
 | 
				
			||||||
NS_IMPL_CYCLE_COLLECTING_RELEASE({{ webidl_name }})
 | 
					NS_IMPL_CYCLE_COLLECTING_RELEASE({{ webidl_name }})
 | 
				
			||||||
| 
						 | 
					@ -51,5 +50,4 @@ ExtensionEventManager* {{ webidl_name}}::OnEVENTNAME() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}  // namespace extensions
 | 
					}  // namespace mozilla::extensions
 | 
				
			||||||
}  // namespace mozilla
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,9 +20,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class nsIGlobalObject;
 | 
					class nsIGlobalObject;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace mozilla {
 | 
					namespace mozilla::extensions {
 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace extensions {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ExtensionEventManager;
 | 
					class ExtensionEventManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,7 +66,6 @@ class {{ webidl_name }} final : public nsISupports,
 | 
				
			||||||
  // RefPtr<ExtensionEventManager> mOnEVENTNAMEEventMgr;
 | 
					  // RefPtr<ExtensionEventManager> mOnEVENTNAMEEventMgr;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}  // namespace extensions
 | 
					}  // namespace mozilla::extensions
 | 
				
			||||||
}  // namespace mozilla
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif  // mozilla_extensions_{{ webidl_name }}_h
 | 
					#endif  // mozilla_extensions_{{ webidl_name }}_h
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
/* 
 | 
					/*
 | 
				
			||||||
 *  THIS IS AN AUTOGENERATED FILE.  DO NOT EDIT
 | 
					 *  THIS IS AN AUTOGENERATED FILE.  DO NOT EDIT
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *  The content of this file has been generated based on the WebExtensions API
 | 
					 *  The content of this file has been generated based on the WebExtensions API
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,7 @@
 | 
				
			||||||
#include "mozilla/dom/ExtensionPortBinding.h"  // ExtensionPortDescriptor
 | 
					#include "mozilla/dom/ExtensionPortBinding.h"  // ExtensionPortDescriptor
 | 
				
			||||||
#include "mozilla/dom/WorkerScope.h"           // GetWorkerPrivateFromContext
 | 
					#include "mozilla/dom/WorkerScope.h"           // GetWorkerPrivateFromContext
 | 
				
			||||||
#include "mozilla/extensions/ExtensionAlarms.h"
 | 
					#include "mozilla/extensions/ExtensionAlarms.h"
 | 
				
			||||||
 | 
					#include "mozilla/extensions/ExtensionDns.h"
 | 
				
			||||||
#include "mozilla/extensions/ExtensionMockAPI.h"
 | 
					#include "mozilla/extensions/ExtensionMockAPI.h"
 | 
				
			||||||
#include "mozilla/extensions/ExtensionPort.h"
 | 
					#include "mozilla/extensions/ExtensionPort.h"
 | 
				
			||||||
#include "mozilla/extensions/ExtensionRuntime.h"
 | 
					#include "mozilla/extensions/ExtensionRuntime.h"
 | 
				
			||||||
| 
						 | 
					@ -32,6 +33,7 @@ NS_INTERFACE_MAP_END
 | 
				
			||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ExtensionBrowser)
 | 
					NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ExtensionBrowser)
 | 
				
			||||||
  NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal)
 | 
					  NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal)
 | 
				
			||||||
  NS_IMPL_CYCLE_COLLECTION_UNLINK(mExtensionAlarms)
 | 
					  NS_IMPL_CYCLE_COLLECTION_UNLINK(mExtensionAlarms)
 | 
				
			||||||
 | 
					  NS_IMPL_CYCLE_COLLECTION_UNLINK(mExtensionDns)
 | 
				
			||||||
  NS_IMPL_CYCLE_COLLECTION_UNLINK(mExtensionMockAPI)
 | 
					  NS_IMPL_CYCLE_COLLECTION_UNLINK(mExtensionMockAPI)
 | 
				
			||||||
  NS_IMPL_CYCLE_COLLECTION_UNLINK(mExtensionRuntime)
 | 
					  NS_IMPL_CYCLE_COLLECTION_UNLINK(mExtensionRuntime)
 | 
				
			||||||
  NS_IMPL_CYCLE_COLLECTION_UNLINK(mExtensionScripting)
 | 
					  NS_IMPL_CYCLE_COLLECTION_UNLINK(mExtensionScripting)
 | 
				
			||||||
| 
						 | 
					@ -44,6 +46,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 | 
				
			||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ExtensionBrowser)
 | 
					NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ExtensionBrowser)
 | 
				
			||||||
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal)
 | 
					  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal)
 | 
				
			||||||
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mExtensionAlarms)
 | 
					  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mExtensionAlarms)
 | 
				
			||||||
 | 
					  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mExtensionDns)
 | 
				
			||||||
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mExtensionMockAPI)
 | 
					  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mExtensionMockAPI)
 | 
				
			||||||
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mExtensionRuntime)
 | 
					  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mExtensionRuntime)
 | 
				
			||||||
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mExtensionScripting)
 | 
					  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mExtensionScripting)
 | 
				
			||||||
| 
						 | 
					@ -197,6 +200,14 @@ ExtensionAlarms* ExtensionBrowser::GetExtensionAlarms() {
 | 
				
			||||||
  return mExtensionAlarms;
 | 
					  return mExtensionAlarms;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ExtensionDns* ExtensionBrowser::GetExtensionDns() {
 | 
				
			||||||
 | 
					  if (!mExtensionDns) {
 | 
				
			||||||
 | 
					    mExtensionDns = new ExtensionDns(mGlobal, this);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return mExtensionDns;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ExtensionMockAPI* ExtensionBrowser::GetExtensionMockAPI() {
 | 
					ExtensionMockAPI* ExtensionBrowser::GetExtensionMockAPI() {
 | 
				
			||||||
  if (!mExtensionMockAPI) {
 | 
					  if (!mExtensionMockAPI) {
 | 
				
			||||||
    mExtensionMockAPI = new ExtensionMockAPI(mGlobal, this);
 | 
					    mExtensionMockAPI = new ExtensionMockAPI(mGlobal, this);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,6 +21,7 @@ class ErrorResult;
 | 
				
			||||||
namespace extensions {
 | 
					namespace extensions {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ExtensionAlarms;
 | 
					class ExtensionAlarms;
 | 
				
			||||||
 | 
					class ExtensionDns;
 | 
				
			||||||
class ExtensionMockAPI;
 | 
					class ExtensionMockAPI;
 | 
				
			||||||
class ExtensionPort;
 | 
					class ExtensionPort;
 | 
				
			||||||
class ExtensionRuntime;
 | 
					class ExtensionRuntime;
 | 
				
			||||||
| 
						 | 
					@ -103,6 +104,7 @@ class ExtensionBrowser final : public nsISupports, public nsWrapperCache {
 | 
				
			||||||
  nsIGlobalObject* GetParentObject() const;
 | 
					  nsIGlobalObject* GetParentObject() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ExtensionAlarms* GetExtensionAlarms();
 | 
					  ExtensionAlarms* GetExtensionAlarms();
 | 
				
			||||||
 | 
					  ExtensionDns* GetExtensionDns();
 | 
				
			||||||
  ExtensionMockAPI* GetExtensionMockAPI();
 | 
					  ExtensionMockAPI* GetExtensionMockAPI();
 | 
				
			||||||
  ExtensionRuntime* GetExtensionRuntime();
 | 
					  ExtensionRuntime* GetExtensionRuntime();
 | 
				
			||||||
  ExtensionScripting* GetExtensionScripting();
 | 
					  ExtensionScripting* GetExtensionScripting();
 | 
				
			||||||
| 
						 | 
					@ -118,6 +120,7 @@ class ExtensionBrowser final : public nsISupports, public nsWrapperCache {
 | 
				
			||||||
  JS::Heap<JS::Value> mLastError;
 | 
					  JS::Heap<JS::Value> mLastError;
 | 
				
			||||||
  bool mCheckedLastError;
 | 
					  bool mCheckedLastError;
 | 
				
			||||||
  RefPtr<ExtensionAlarms> mExtensionAlarms;
 | 
					  RefPtr<ExtensionAlarms> mExtensionAlarms;
 | 
				
			||||||
 | 
					  RefPtr<ExtensionDns> mExtensionDns;
 | 
				
			||||||
  RefPtr<ExtensionMockAPI> mExtensionMockAPI;
 | 
					  RefPtr<ExtensionMockAPI> mExtensionMockAPI;
 | 
				
			||||||
  RefPtr<ExtensionRuntime> mExtensionRuntime;
 | 
					  RefPtr<ExtensionRuntime> mExtensionRuntime;
 | 
				
			||||||
  RefPtr<ExtensionScripting> mExtensionScripting;
 | 
					  RefPtr<ExtensionScripting> mExtensionScripting;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										40
									
								
								toolkit/components/extensions/webidl-api/ExtensionDns.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								toolkit/components/extensions/webidl-api/ExtensionDns.cpp
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,40 @@
 | 
				
			||||||
 | 
					/* 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 "ExtensionDns.h"
 | 
				
			||||||
 | 
					#include "ExtensionEventManager.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "mozilla/dom/ExtensionDnsBinding.h"
 | 
				
			||||||
 | 
					#include "nsIGlobalObject.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace mozilla::extensions {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					NS_IMPL_CYCLE_COLLECTING_ADDREF(ExtensionDns);
 | 
				
			||||||
 | 
					NS_IMPL_CYCLE_COLLECTING_RELEASE(ExtensionDns)
 | 
				
			||||||
 | 
					NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ExtensionDns, mGlobal, mExtensionBrowser);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ExtensionDns)
 | 
				
			||||||
 | 
					  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
 | 
				
			||||||
 | 
					  NS_INTERFACE_MAP_ENTRY(nsISupports)
 | 
				
			||||||
 | 
					NS_INTERFACE_MAP_END
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ExtensionDns::ExtensionDns(nsIGlobalObject* aGlobal,
 | 
				
			||||||
 | 
					                           ExtensionBrowser* aExtensionBrowser)
 | 
				
			||||||
 | 
					    : mGlobal(aGlobal), mExtensionBrowser(aExtensionBrowser) {
 | 
				
			||||||
 | 
					  MOZ_DIAGNOSTIC_ASSERT(mGlobal);
 | 
				
			||||||
 | 
					  MOZ_DIAGNOSTIC_ASSERT(mExtensionBrowser);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* static */
 | 
				
			||||||
 | 
					bool ExtensionDns::IsAllowed(JSContext* aCx, JSObject* aGlobal) { return true; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					JSObject* ExtensionDns::WrapObject(JSContext* aCx,
 | 
				
			||||||
 | 
					                                   JS::Handle<JSObject*> aGivenProto) {
 | 
				
			||||||
 | 
					  return dom::ExtensionDns_Binding::Wrap(aCx, this, aGivenProto);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					nsIGlobalObject* ExtensionDns::GetParentObject() const { return mGlobal; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}  // namespace mozilla::extensions
 | 
				
			||||||
							
								
								
									
										63
									
								
								toolkit/components/extensions/webidl-api/ExtensionDns.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								toolkit/components/extensions/webidl-api/ExtensionDns.h
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -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_ExtensionDns_h
 | 
				
			||||||
 | 
					#define mozilla_extensions_ExtensionDns_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::extensions {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class ExtensionEventManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class ExtensionDns final : public nsISupports,
 | 
				
			||||||
 | 
					                           public nsWrapperCache,
 | 
				
			||||||
 | 
					                           public ExtensionAPINamespace {
 | 
				
			||||||
 | 
					 public:
 | 
				
			||||||
 | 
					  ExtensionDns(nsIGlobalObject* aGlobal, ExtensionBrowser* aExtensionBrowser);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // ExtensionAPIBase methods
 | 
				
			||||||
 | 
					  nsIGlobalObject* GetGlobalObject() const override { return mGlobal; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ExtensionBrowser* GetExtensionBrowser() const override {
 | 
				
			||||||
 | 
					    return mExtensionBrowser;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  nsString GetAPINamespace() const override { return u"dns"_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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
 | 
				
			||||||
 | 
					  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(ExtensionDns)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 private:
 | 
				
			||||||
 | 
					  ~ExtensionDns() = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  nsCOMPtr<nsIGlobalObject> mGlobal;
 | 
				
			||||||
 | 
					  RefPtr<ExtensionBrowser> mExtensionBrowser;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}  // namespace mozilla::extensions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif  // mozilla_extensions_ExtensionDns_h
 | 
				
			||||||
| 
						 | 
					@ -60,6 +60,7 @@ WEBIDL_PRIMITIVE_TYPES = set([
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# NOTE: Please keep this table in alphabetic order.
 | 
					# NOTE: Please keep this table in alphabetic order.
 | 
				
			||||||
WEBEXT_STUBS_MAPPING = {
 | 
					WEBEXT_STUBS_MAPPING = {
 | 
				
			||||||
 | 
					    "dns.resolve": "AsyncAmbiguous",
 | 
				
			||||||
    "runtime.connect": "ReturnsPort",
 | 
					    "runtime.connect": "ReturnsPort",
 | 
				
			||||||
    "runtime.connectNative": "ReturnsPort",
 | 
					    "runtime.connectNative": "ReturnsPort",
 | 
				
			||||||
    "runtime.getURL": "ReturnsString",
 | 
					    "runtime.getURL": "ReturnsString",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,6 +28,7 @@ EXPORTS.mozilla.extensions += [
 | 
				
			||||||
# WebExtensions API namespaces.
 | 
					# WebExtensions API namespaces.
 | 
				
			||||||
UNIFIED_SOURCES += [
 | 
					UNIFIED_SOURCES += [
 | 
				
			||||||
    "ExtensionAlarms.cpp",
 | 
					    "ExtensionAlarms.cpp",
 | 
				
			||||||
 | 
					    "ExtensionDns.cpp",
 | 
				
			||||||
    "ExtensionRuntime.cpp",
 | 
					    "ExtensionRuntime.cpp",
 | 
				
			||||||
    "ExtensionScripting.cpp",
 | 
					    "ExtensionScripting.cpp",
 | 
				
			||||||
    "ExtensionTest.cpp",
 | 
					    "ExtensionTest.cpp",
 | 
				
			||||||
| 
						 | 
					@ -35,6 +36,7 @@ UNIFIED_SOURCES += [
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EXPORTS.mozilla.extensions += [
 | 
					EXPORTS.mozilla.extensions += [
 | 
				
			||||||
    "ExtensionAlarms.h",
 | 
					    "ExtensionAlarms.h",
 | 
				
			||||||
 | 
					    "ExtensionDns.h",
 | 
				
			||||||
    "ExtensionRuntime.h",
 | 
					    "ExtensionRuntime.h",
 | 
				
			||||||
    "ExtensionScripting.h",
 | 
					    "ExtensionScripting.h",
 | 
				
			||||||
    "ExtensionTest.h",
 | 
					    "ExtensionTest.h",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue