| 1 | /* |
| 2 | This file is part of the WebKit open source project. |
| 3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Library General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Library General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Library General Public License |
| 16 | along with this library; see the file COPYING.LIB. If not, write to |
| 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | Boston, MA 02110-1301, USA. |
| 19 | */ |
| 20 | |
| 21 | #include "config.h" |
| 22 | #include "JSNavigator.h" |
| 23 | |
| 24 | #include "Document.h" |
| 25 | #include "JSBlob.h" |
| 26 | #include "JSDOMAttribute.h" |
| 27 | #include "JSDOMBinding.h" |
| 28 | #include "JSDOMConstructorNotConstructable.h" |
| 29 | #include "JSDOMConvertBoolean.h" |
| 30 | #include "JSDOMConvertBufferSource.h" |
| 31 | #include "JSDOMConvertDictionary.h" |
| 32 | #include "JSDOMConvertInterface.h" |
| 33 | #include "JSDOMConvertNullable.h" |
| 34 | #include "JSDOMConvertSequences.h" |
| 35 | #include "JSDOMConvertStrings.h" |
| 36 | #include "JSDOMConvertUnion.h" |
| 37 | #include "JSDOMExceptionHandling.h" |
| 38 | #include "JSDOMFormData.h" |
| 39 | #include "JSDOMGlobalObject.h" |
| 40 | #include "JSDOMMimeTypeArray.h" |
| 41 | #include "JSDOMOperation.h" |
| 42 | #include "JSDOMOperationReturningPromise.h" |
| 43 | #include "JSDOMPluginArray.h" |
| 44 | #include "JSDOMWrapperCache.h" |
| 45 | #include "JSMediaCapabilities.h" |
| 46 | #include "JSReadableStream.h" |
| 47 | #include "JSShareData.h" |
| 48 | #include "JSURLSearchParams.h" |
| 49 | #include "JSVRDisplay.h" |
| 50 | #include "NavigatorBeacon.h" |
| 51 | #include "NavigatorMediaCapabilities.h" |
| 52 | #include "NavigatorWebDriver.h" |
| 53 | #include "NavigatorWebVR.h" |
| 54 | #include "Quirks.h" |
| 55 | #include "RuntimeEnabledFeatures.h" |
| 56 | #include "ScriptExecutionContext.h" |
| 57 | #include "Settings.h" |
| 58 | #include <JavaScriptCore/FunctionPrototype.h> |
| 59 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 60 | #include <JavaScriptCore/JSArray.h> |
| 61 | #include <JavaScriptCore/JSCInlines.h> |
| 62 | #include <wtf/GetPtr.h> |
| 63 | #include <wtf/PointerPreparations.h> |
| 64 | #include <wtf/URL.h> |
| 65 | #include <wtf/Variant.h> |
| 66 | |
| 67 | #if ENABLE(ENCRYPTED_MEDIA) |
| 68 | #include "JSMediaKeySystemConfiguration.h" |
| 69 | #include "NavigatorEME.h" |
| 70 | #endif |
| 71 | |
| 72 | #if ENABLE(GEOLOCATION) |
| 73 | #include "JSGeolocation.h" |
| 74 | #include "NavigatorGeolocation.h" |
| 75 | #endif |
| 76 | |
| 77 | #if ENABLE(MEDIA_STREAM) |
| 78 | #include "JSMediaDevices.h" |
| 79 | #include "NavigatorMediaDevices.h" |
| 80 | #endif |
| 81 | |
| 82 | #if ENABLE(SERVICE_WORKER) |
| 83 | #include "JSServiceWorkerContainer.h" |
| 84 | #endif |
| 85 | |
| 86 | #if ENABLE(WEBGPU) |
| 87 | #include "JSWebGPU.h" |
| 88 | #include "NavigatorGPU.h" |
| 89 | #endif |
| 90 | |
| 91 | #if ENABLE(WEB_AUTHN) |
| 92 | #include "JSCredentialsContainer.h" |
| 93 | #include "NavigatorCredentials.h" |
| 94 | #endif |
| 95 | |
| 96 | |
| 97 | namespace WebCore { |
| 98 | using namespace JSC; |
| 99 | |
| 100 | // Functions |
| 101 | |
| 102 | JSC::EncodedJSValue JSC_HOST_CALL jsNavigatorPrototypeFunctionJavaEnabled(JSC::ExecState*); |
| 103 | JSC::EncodedJSValue JSC_HOST_CALL jsNavigatorPrototypeFunctionGetStorageUpdates(JSC::ExecState*); |
| 104 | JSC::EncodedJSValue JSC_HOST_CALL jsNavigatorPrototypeFunctionSendBeacon(JSC::ExecState*); |
| 105 | #if ENABLE(ENCRYPTED_MEDIA) |
| 106 | JSC::EncodedJSValue JSC_HOST_CALL jsNavigatorPrototypeFunctionRequestMediaKeySystemAccess(JSC::ExecState*); |
| 107 | #endif |
| 108 | JSC::EncodedJSValue JSC_HOST_CALL jsNavigatorPrototypeFunctionGetVRDisplays(JSC::ExecState*); |
| 109 | JSC::EncodedJSValue JSC_HOST_CALL jsNavigatorPrototypeFunctionShare(JSC::ExecState*); |
| 110 | |
| 111 | // Attributes |
| 112 | |
| 113 | JSC::EncodedJSValue jsNavigatorConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 114 | bool setJSNavigatorConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 115 | JSC::EncodedJSValue jsNavigatorPlugins(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 116 | JSC::EncodedJSValue jsNavigatorMimeTypes(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 117 | JSC::EncodedJSValue jsNavigatorCookieEnabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 118 | #if ENABLE(NAVIGATOR_STANDALONE) |
| 119 | JSC::EncodedJSValue jsNavigatorStandalone(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 120 | #endif |
| 121 | #if ENABLE(WEB_AUTHN) |
| 122 | JSC::EncodedJSValue jsNavigatorCredentials(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 123 | #endif |
| 124 | #if ENABLE(GEOLOCATION) |
| 125 | JSC::EncodedJSValue jsNavigatorGeolocation(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 126 | #endif |
| 127 | JSC::EncodedJSValue jsNavigatorMediaCapabilities(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 128 | #if ENABLE(MEDIA_STREAM) |
| 129 | JSC::EncodedJSValue jsNavigatorMediaDevices(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 130 | #endif |
| 131 | JSC::EncodedJSValue jsNavigatorWebdriver(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 132 | #if ENABLE(WEBGPU) |
| 133 | JSC::EncodedJSValue jsNavigatorGpu(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 134 | #endif |
| 135 | JSC::EncodedJSValue jsNavigatorActiveVRDisplays(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 136 | JSC::EncodedJSValue jsNavigatorAppCodeName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 137 | JSC::EncodedJSValue jsNavigatorAppName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 138 | JSC::EncodedJSValue jsNavigatorAppVersion(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 139 | JSC::EncodedJSValue jsNavigatorPlatform(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 140 | JSC::EncodedJSValue jsNavigatorProduct(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 141 | JSC::EncodedJSValue jsNavigatorProductSub(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 142 | JSC::EncodedJSValue jsNavigatorUserAgent(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 143 | JSC::EncodedJSValue jsNavigatorVendor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 144 | JSC::EncodedJSValue jsNavigatorVendorSub(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 145 | JSC::EncodedJSValue jsNavigatorLanguage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 146 | JSC::EncodedJSValue jsNavigatorLanguages(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 147 | JSC::EncodedJSValue jsNavigatorOnLine(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 148 | #if ENABLE(SERVICE_WORKER) |
| 149 | JSC::EncodedJSValue jsNavigatorServiceWorker(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 150 | #endif |
| 151 | |
| 152 | class JSNavigatorPrototype : public JSC::JSNonFinalObject { |
| 153 | public: |
| 154 | using Base = JSC::JSNonFinalObject; |
| 155 | static JSNavigatorPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 156 | { |
| 157 | JSNavigatorPrototype* ptr = new (NotNull, JSC::allocateCell<JSNavigatorPrototype>(vm.heap)) JSNavigatorPrototype(vm, globalObject, structure); |
| 158 | ptr->finishCreation(vm); |
| 159 | return ptr; |
| 160 | } |
| 161 | |
| 162 | DECLARE_INFO; |
| 163 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 164 | { |
| 165 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 166 | } |
| 167 | |
| 168 | private: |
| 169 | JSNavigatorPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 170 | : JSC::JSNonFinalObject(vm, structure) |
| 171 | { |
| 172 | } |
| 173 | |
| 174 | void finishCreation(JSC::VM&); |
| 175 | }; |
| 176 | |
| 177 | using JSNavigatorConstructor = JSDOMConstructorNotConstructable<JSNavigator>; |
| 178 | |
| 179 | template<> JSValue JSNavigatorConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 180 | { |
| 181 | UNUSED_PARAM(vm); |
| 182 | return globalObject.functionPrototype(); |
| 183 | } |
| 184 | |
| 185 | template<> void JSNavigatorConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 186 | { |
| 187 | putDirect(vm, vm.propertyNames->prototype, JSNavigator::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 188 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("Navigator"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 189 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 190 | } |
| 191 | |
| 192 | template<> const ClassInfo JSNavigatorConstructor::s_info = { "Navigator" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSNavigatorConstructor) }; |
| 193 | |
| 194 | /* Hash table for prototype */ |
| 195 | |
| 196 | static const HashTableValue JSNavigatorPrototypeTableValues[] = |
| 197 | { |
| 198 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSNavigatorConstructor) } }, |
| 199 | { "plugins" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorPlugins), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 200 | { "mimeTypes" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorMimeTypes), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 201 | { "cookieEnabled" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorCookieEnabled), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 202 | #if ENABLE(NAVIGATOR_STANDALONE) |
| 203 | { "standalone" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorStandalone), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 204 | #else |
| 205 | { 0, 0, NoIntrinsic, { 0, 0 } }, |
| 206 | #endif |
| 207 | #if ENABLE(WEB_AUTHN) |
| 208 | { "credentials" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorCredentials), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 209 | #else |
| 210 | { 0, 0, NoIntrinsic, { 0, 0 } }, |
| 211 | #endif |
| 212 | #if ENABLE(GEOLOCATION) |
| 213 | { "geolocation" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorGeolocation), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 214 | #else |
| 215 | { 0, 0, NoIntrinsic, { 0, 0 } }, |
| 216 | #endif |
| 217 | { "mediaCapabilities" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorMediaCapabilities), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 218 | #if ENABLE(MEDIA_STREAM) |
| 219 | { "mediaDevices" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorMediaDevices), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 220 | #else |
| 221 | { 0, 0, NoIntrinsic, { 0, 0 } }, |
| 222 | #endif |
| 223 | { "webdriver" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorWebdriver), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 224 | #if ENABLE(WEBGPU) |
| 225 | { "gpu" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorGpu), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 226 | #else |
| 227 | { 0, 0, NoIntrinsic, { 0, 0 } }, |
| 228 | #endif |
| 229 | { "activeVRDisplays" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorActiveVRDisplays), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 230 | { "appCodeName" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorAppCodeName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 231 | { "appName" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorAppName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 232 | { "appVersion" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorAppVersion), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 233 | { "platform" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorPlatform), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 234 | { "product" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorProduct), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 235 | { "productSub" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorProductSub), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 236 | { "userAgent" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorUserAgent), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 237 | { "vendor" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorVendor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 238 | { "vendorSub" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorVendorSub), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 239 | { "language" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorLanguage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 240 | { "languages" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorLanguages), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 241 | { "onLine" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorOnLine), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 242 | #if ENABLE(SERVICE_WORKER) |
| 243 | { "serviceWorker" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNavigatorServiceWorker), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 244 | #else |
| 245 | { 0, 0, NoIntrinsic, { 0, 0 } }, |
| 246 | #endif |
| 247 | { "javaEnabled" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNavigatorPrototypeFunctionJavaEnabled), (intptr_t) (0) } }, |
| 248 | { "getStorageUpdates" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNavigatorPrototypeFunctionGetStorageUpdates), (intptr_t) (0) } }, |
| 249 | { "sendBeacon" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNavigatorPrototypeFunctionSendBeacon), (intptr_t) (1) } }, |
| 250 | #if ENABLE(ENCRYPTED_MEDIA) |
| 251 | { "requestMediaKeySystemAccess" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNavigatorPrototypeFunctionRequestMediaKeySystemAccess), (intptr_t) (2) } }, |
| 252 | #else |
| 253 | { 0, 0, NoIntrinsic, { 0, 0 } }, |
| 254 | #endif |
| 255 | { "getVRDisplays" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNavigatorPrototypeFunctionGetVRDisplays), (intptr_t) (0) } }, |
| 256 | { "share" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNavigatorPrototypeFunctionShare), (intptr_t) (0) } }, |
| 257 | }; |
| 258 | |
| 259 | const ClassInfo JSNavigatorPrototype::s_info = { "NavigatorPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSNavigatorPrototype) }; |
| 260 | |
| 261 | void JSNavigatorPrototype::finishCreation(VM& vm) |
| 262 | { |
| 263 | Base::finishCreation(vm); |
| 264 | reifyStaticProperties(vm, JSNavigator::info(), JSNavigatorPrototypeTableValues, *this); |
| 265 | bool hasDisabledRuntimeProperties = false; |
| 266 | if (!downcast<Document>(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext())->settings().beaconAPIEnabled()) { |
| 267 | hasDisabledRuntimeProperties = true; |
| 268 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("sendBeacon" ), strlen("sendBeacon" )); |
| 269 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| 270 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| 271 | } |
| 272 | #if ENABLE(ENCRYPTED_MEDIA) |
| 273 | if (!(!downcast<Document>(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext())->quirks().hasBrokenEncryptedMediaAPISupportQuirk() && RuntimeEnabledFeatures::sharedFeatures().encryptedMediaAPIEnabled())) { |
| 274 | hasDisabledRuntimeProperties = true; |
| 275 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("requestMediaKeySystemAccess" ), strlen("requestMediaKeySystemAccess" )); |
| 276 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| 277 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| 278 | } |
| 279 | #endif |
| 280 | if (!RuntimeEnabledFeatures::sharedFeatures().webVREnabled()) { |
| 281 | hasDisabledRuntimeProperties = true; |
| 282 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("getVRDisplays" ), strlen("getVRDisplays" )); |
| 283 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| 284 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| 285 | } |
| 286 | if (!(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext() && RuntimeEnabledFeatures::sharedFeatures().webShareEnabled())) { |
| 287 | hasDisabledRuntimeProperties = true; |
| 288 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("share" ), strlen("share" )); |
| 289 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| 290 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| 291 | } |
| 292 | #if ENABLE(WEB_AUTHN) |
| 293 | if (!(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext() && RuntimeEnabledFeatures::sharedFeatures().webAuthenticationEnabled())) { |
| 294 | hasDisabledRuntimeProperties = true; |
| 295 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("credentials" ), strlen("credentials" )); |
| 296 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| 297 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| 298 | } |
| 299 | #endif |
| 300 | if (!downcast<Document>(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext())->settings().mediaCapabilitiesEnabled()) { |
| 301 | hasDisabledRuntimeProperties = true; |
| 302 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("mediaCapabilities" ), strlen("mediaCapabilities" )); |
| 303 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| 304 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| 305 | } |
| 306 | #if ENABLE(MEDIA_STREAM) |
| 307 | if (!((jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()|| jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->allowsMediaDevices()) && RuntimeEnabledFeatures::sharedFeatures().mediaDevicesEnabled())) { |
| 308 | hasDisabledRuntimeProperties = true; |
| 309 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("mediaDevices" ), strlen("mediaDevices" )); |
| 310 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| 311 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| 312 | } |
| 313 | #endif |
| 314 | #if ENABLE(WEBGPU) |
| 315 | if (!(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isDocument() && RuntimeEnabledFeatures::sharedFeatures().webGPUEnabled())) { |
| 316 | hasDisabledRuntimeProperties = true; |
| 317 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("gpu" ), strlen("gpu" )); |
| 318 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| 319 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| 320 | } |
| 321 | #endif |
| 322 | if (!RuntimeEnabledFeatures::sharedFeatures().webVREnabled()) { |
| 323 | hasDisabledRuntimeProperties = true; |
| 324 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("activeVRDisplays" ), strlen("activeVRDisplays" )); |
| 325 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| 326 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| 327 | } |
| 328 | #if ENABLE(SERVICE_WORKER) |
| 329 | if (!((jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()|| jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->hasServiceWorkerScheme()) && RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled())) { |
| 330 | hasDisabledRuntimeProperties = true; |
| 331 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("serviceWorker" ), strlen("serviceWorker" )); |
| 332 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| 333 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| 334 | } |
| 335 | #endif |
| 336 | if (hasDisabledRuntimeProperties && structure()->isDictionary()) |
| 337 | flattenDictionaryObject(vm); |
| 338 | } |
| 339 | |
| 340 | const ClassInfo JSNavigator::s_info = { "Navigator" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSNavigator) }; |
| 341 | |
| 342 | JSNavigator::JSNavigator(Structure* structure, JSDOMGlobalObject& globalObject, Ref<Navigator>&& impl) |
| 343 | : JSDOMWrapper<Navigator>(structure, globalObject, WTFMove(impl)) |
| 344 | { |
| 345 | } |
| 346 | |
| 347 | void JSNavigator::finishCreation(VM& vm) |
| 348 | { |
| 349 | Base::finishCreation(vm); |
| 350 | ASSERT(inherits(vm, info())); |
| 351 | |
| 352 | } |
| 353 | |
| 354 | JSObject* JSNavigator::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 355 | { |
| 356 | return JSNavigatorPrototype::create(vm, &globalObject, JSNavigatorPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 357 | } |
| 358 | |
| 359 | JSObject* JSNavigator::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 360 | { |
| 361 | return getDOMPrototype<JSNavigator>(vm, globalObject); |
| 362 | } |
| 363 | |
| 364 | JSValue JSNavigator::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 365 | { |
| 366 | return getDOMConstructor<JSNavigatorConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 367 | } |
| 368 | |
| 369 | void JSNavigator::destroy(JSC::JSCell* cell) |
| 370 | { |
| 371 | JSNavigator* thisObject = static_cast<JSNavigator*>(cell); |
| 372 | thisObject->JSNavigator::~JSNavigator(); |
| 373 | } |
| 374 | |
| 375 | template<> inline JSNavigator* IDLAttribute<JSNavigator>::cast(ExecState& state, EncodedJSValue thisValue) |
| 376 | { |
| 377 | return jsDynamicCast<JSNavigator*>(state.vm(), JSValue::decode(thisValue)); |
| 378 | } |
| 379 | |
| 380 | template<> inline JSNavigator* IDLOperation<JSNavigator>::cast(ExecState& state) |
| 381 | { |
| 382 | return jsDynamicCast<JSNavigator*>(state.vm(), state.thisValue()); |
| 383 | } |
| 384 | |
| 385 | EncodedJSValue jsNavigatorConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 386 | { |
| 387 | VM& vm = state->vm(); |
| 388 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 389 | auto* prototype = jsDynamicCast<JSNavigatorPrototype*>(vm, JSValue::decode(thisValue)); |
| 390 | if (UNLIKELY(!prototype)) |
| 391 | return throwVMTypeError(state, throwScope); |
| 392 | return JSValue::encode(JSNavigator::getConstructor(state->vm(), prototype->globalObject())); |
| 393 | } |
| 394 | |
| 395 | bool setJSNavigatorConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 396 | { |
| 397 | VM& vm = state->vm(); |
| 398 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 399 | auto* prototype = jsDynamicCast<JSNavigatorPrototype*>(vm, JSValue::decode(thisValue)); |
| 400 | if (UNLIKELY(!prototype)) { |
| 401 | throwVMTypeError(state, throwScope); |
| 402 | return false; |
| 403 | } |
| 404 | // Shadowing a built-in constructor |
| 405 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 406 | } |
| 407 | |
| 408 | static inline JSValue jsNavigatorPluginsGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 409 | { |
| 410 | UNUSED_PARAM(throwScope); |
| 411 | UNUSED_PARAM(state); |
| 412 | auto& impl = thisObject.wrapped(); |
| 413 | JSValue result = toJS<IDLInterface<DOMPluginArray>>(state, *thisObject.globalObject(), throwScope, impl.plugins()); |
| 414 | return result; |
| 415 | } |
| 416 | |
| 417 | EncodedJSValue jsNavigatorPlugins(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 418 | { |
| 419 | return IDLAttribute<JSNavigator>::get<jsNavigatorPluginsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "plugins" ); |
| 420 | } |
| 421 | |
| 422 | static inline JSValue jsNavigatorMimeTypesGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 423 | { |
| 424 | UNUSED_PARAM(throwScope); |
| 425 | UNUSED_PARAM(state); |
| 426 | auto& impl = thisObject.wrapped(); |
| 427 | JSValue result = toJS<IDLInterface<DOMMimeTypeArray>>(state, *thisObject.globalObject(), throwScope, impl.mimeTypes()); |
| 428 | return result; |
| 429 | } |
| 430 | |
| 431 | EncodedJSValue jsNavigatorMimeTypes(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 432 | { |
| 433 | return IDLAttribute<JSNavigator>::get<jsNavigatorMimeTypesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "mimeTypes" ); |
| 434 | } |
| 435 | |
| 436 | static inline JSValue jsNavigatorCookieEnabledGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 437 | { |
| 438 | UNUSED_PARAM(throwScope); |
| 439 | UNUSED_PARAM(state); |
| 440 | auto& impl = thisObject.wrapped(); |
| 441 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.cookieEnabled()); |
| 442 | return result; |
| 443 | } |
| 444 | |
| 445 | EncodedJSValue jsNavigatorCookieEnabled(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 446 | { |
| 447 | return IDLAttribute<JSNavigator>::get<jsNavigatorCookieEnabledGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "cookieEnabled" ); |
| 448 | } |
| 449 | |
| 450 | #if ENABLE(NAVIGATOR_STANDALONE) |
| 451 | static inline JSValue jsNavigatorStandaloneGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 452 | { |
| 453 | UNUSED_PARAM(throwScope); |
| 454 | UNUSED_PARAM(state); |
| 455 | auto& impl = thisObject.wrapped(); |
| 456 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.standalone()); |
| 457 | return result; |
| 458 | } |
| 459 | |
| 460 | EncodedJSValue jsNavigatorStandalone(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 461 | { |
| 462 | return IDLAttribute<JSNavigator>::get<jsNavigatorStandaloneGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "standalone" ); |
| 463 | } |
| 464 | |
| 465 | #endif |
| 466 | |
| 467 | #if ENABLE(WEB_AUTHN) |
| 468 | static inline JSValue jsNavigatorCredentialsGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 469 | { |
| 470 | UNUSED_PARAM(throwScope); |
| 471 | UNUSED_PARAM(state); |
| 472 | auto& impl = thisObject.wrapped(); |
| 473 | JSValue result = toJS<IDLInterface<CredentialsContainer>>(state, *thisObject.globalObject(), throwScope, WebCore::NavigatorCredentials::credentials(impl)); |
| 474 | return result; |
| 475 | } |
| 476 | |
| 477 | EncodedJSValue jsNavigatorCredentials(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 478 | { |
| 479 | return IDLAttribute<JSNavigator>::get<jsNavigatorCredentialsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "credentials" ); |
| 480 | } |
| 481 | |
| 482 | #endif |
| 483 | |
| 484 | #if ENABLE(GEOLOCATION) |
| 485 | static inline JSValue jsNavigatorGeolocationGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 486 | { |
| 487 | UNUSED_PARAM(throwScope); |
| 488 | UNUSED_PARAM(state); |
| 489 | auto& impl = thisObject.wrapped(); |
| 490 | JSValue result = toJS<IDLInterface<Geolocation>>(state, *thisObject.globalObject(), throwScope, WebCore::NavigatorGeolocation::geolocation(impl)); |
| 491 | return result; |
| 492 | } |
| 493 | |
| 494 | EncodedJSValue jsNavigatorGeolocation(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 495 | { |
| 496 | return IDLAttribute<JSNavigator>::get<jsNavigatorGeolocationGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "geolocation" ); |
| 497 | } |
| 498 | |
| 499 | #endif |
| 500 | |
| 501 | static inline JSValue jsNavigatorMediaCapabilitiesGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 502 | { |
| 503 | UNUSED_PARAM(throwScope); |
| 504 | UNUSED_PARAM(state); |
| 505 | auto& impl = thisObject.wrapped(); |
| 506 | JSValue result = toJS<IDLInterface<MediaCapabilities>>(state, *thisObject.globalObject(), throwScope, WebCore::NavigatorMediaCapabilities::mediaCapabilities(impl)); |
| 507 | return result; |
| 508 | } |
| 509 | |
| 510 | EncodedJSValue jsNavigatorMediaCapabilities(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 511 | { |
| 512 | return IDLAttribute<JSNavigator>::get<jsNavigatorMediaCapabilitiesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "mediaCapabilities" ); |
| 513 | } |
| 514 | |
| 515 | #if ENABLE(MEDIA_STREAM) |
| 516 | static inline JSValue jsNavigatorMediaDevicesGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 517 | { |
| 518 | UNUSED_PARAM(throwScope); |
| 519 | UNUSED_PARAM(state); |
| 520 | auto& impl = thisObject.wrapped(); |
| 521 | JSValue result = toJS<IDLInterface<MediaDevices>>(state, *thisObject.globalObject(), throwScope, WebCore::NavigatorMediaDevices::mediaDevices(impl)); |
| 522 | return result; |
| 523 | } |
| 524 | |
| 525 | EncodedJSValue jsNavigatorMediaDevices(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 526 | { |
| 527 | return IDLAttribute<JSNavigator>::get<jsNavigatorMediaDevicesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "mediaDevices" ); |
| 528 | } |
| 529 | |
| 530 | #endif |
| 531 | |
| 532 | static inline JSValue jsNavigatorWebdriverGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 533 | { |
| 534 | UNUSED_PARAM(throwScope); |
| 535 | UNUSED_PARAM(state); |
| 536 | auto& impl = thisObject.wrapped(); |
| 537 | JSValue result = toJS<IDLBoolean>(state, throwScope, WebCore::NavigatorWebDriver::webdriver(impl)); |
| 538 | return result; |
| 539 | } |
| 540 | |
| 541 | EncodedJSValue jsNavigatorWebdriver(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 542 | { |
| 543 | return IDLAttribute<JSNavigator>::get<jsNavigatorWebdriverGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "webdriver" ); |
| 544 | } |
| 545 | |
| 546 | #if ENABLE(WEBGPU) |
| 547 | static inline JSValue jsNavigatorGpuGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 548 | { |
| 549 | UNUSED_PARAM(throwScope); |
| 550 | UNUSED_PARAM(state); |
| 551 | auto& impl = thisObject.wrapped(); |
| 552 | JSValue result = toJS<IDLInterface<WebGPU>>(state, *thisObject.globalObject(), throwScope, WebCore::NavigatorGPU::gpu(impl)); |
| 553 | return result; |
| 554 | } |
| 555 | |
| 556 | EncodedJSValue jsNavigatorGpu(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 557 | { |
| 558 | return IDLAttribute<JSNavigator>::get<jsNavigatorGpuGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "gpu" ); |
| 559 | } |
| 560 | |
| 561 | #endif |
| 562 | |
| 563 | static inline JSValue jsNavigatorActiveVRDisplaysGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 564 | { |
| 565 | UNUSED_PARAM(throwScope); |
| 566 | UNUSED_PARAM(state); |
| 567 | auto& impl = thisObject.wrapped(); |
| 568 | JSValue result = toJS<IDLFrozenArray<IDLInterface<VRDisplay>>>(state, *thisObject.globalObject(), throwScope, WebCore::NavigatorWebVR::activeVRDisplays(impl)); |
| 569 | return result; |
| 570 | } |
| 571 | |
| 572 | EncodedJSValue jsNavigatorActiveVRDisplays(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 573 | { |
| 574 | return IDLAttribute<JSNavigator>::get<jsNavigatorActiveVRDisplaysGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "activeVRDisplays" ); |
| 575 | } |
| 576 | |
| 577 | static inline JSValue jsNavigatorAppCodeNameGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 578 | { |
| 579 | UNUSED_PARAM(throwScope); |
| 580 | UNUSED_PARAM(state); |
| 581 | auto& impl = thisObject.wrapped(); |
| 582 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.appCodeName()); |
| 583 | return result; |
| 584 | } |
| 585 | |
| 586 | EncodedJSValue jsNavigatorAppCodeName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 587 | { |
| 588 | return IDLAttribute<JSNavigator>::get<jsNavigatorAppCodeNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "appCodeName" ); |
| 589 | } |
| 590 | |
| 591 | static inline JSValue jsNavigatorAppNameGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 592 | { |
| 593 | UNUSED_PARAM(throwScope); |
| 594 | UNUSED_PARAM(state); |
| 595 | auto& impl = thisObject.wrapped(); |
| 596 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.appName()); |
| 597 | return result; |
| 598 | } |
| 599 | |
| 600 | EncodedJSValue jsNavigatorAppName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 601 | { |
| 602 | return IDLAttribute<JSNavigator>::get<jsNavigatorAppNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "appName" ); |
| 603 | } |
| 604 | |
| 605 | static inline JSValue jsNavigatorAppVersionGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 606 | { |
| 607 | UNUSED_PARAM(throwScope); |
| 608 | UNUSED_PARAM(state); |
| 609 | auto& impl = thisObject.wrapped(); |
| 610 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.appVersion()); |
| 611 | return result; |
| 612 | } |
| 613 | |
| 614 | EncodedJSValue jsNavigatorAppVersion(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 615 | { |
| 616 | return IDLAttribute<JSNavigator>::get<jsNavigatorAppVersionGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "appVersion" ); |
| 617 | } |
| 618 | |
| 619 | static inline JSValue jsNavigatorPlatformGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 620 | { |
| 621 | UNUSED_PARAM(throwScope); |
| 622 | UNUSED_PARAM(state); |
| 623 | auto& impl = thisObject.wrapped(); |
| 624 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.platform()); |
| 625 | return result; |
| 626 | } |
| 627 | |
| 628 | EncodedJSValue jsNavigatorPlatform(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 629 | { |
| 630 | return IDLAttribute<JSNavigator>::get<jsNavigatorPlatformGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "platform" ); |
| 631 | } |
| 632 | |
| 633 | static inline JSValue jsNavigatorProductGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 634 | { |
| 635 | UNUSED_PARAM(throwScope); |
| 636 | UNUSED_PARAM(state); |
| 637 | auto& impl = thisObject.wrapped(); |
| 638 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.product()); |
| 639 | return result; |
| 640 | } |
| 641 | |
| 642 | EncodedJSValue jsNavigatorProduct(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 643 | { |
| 644 | return IDLAttribute<JSNavigator>::get<jsNavigatorProductGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "product" ); |
| 645 | } |
| 646 | |
| 647 | static inline JSValue jsNavigatorProductSubGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 648 | { |
| 649 | UNUSED_PARAM(throwScope); |
| 650 | UNUSED_PARAM(state); |
| 651 | auto& impl = thisObject.wrapped(); |
| 652 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.productSub()); |
| 653 | return result; |
| 654 | } |
| 655 | |
| 656 | EncodedJSValue jsNavigatorProductSub(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 657 | { |
| 658 | return IDLAttribute<JSNavigator>::get<jsNavigatorProductSubGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "productSub" ); |
| 659 | } |
| 660 | |
| 661 | static inline JSValue jsNavigatorUserAgentGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 662 | { |
| 663 | UNUSED_PARAM(throwScope); |
| 664 | UNUSED_PARAM(state); |
| 665 | auto& impl = thisObject.wrapped(); |
| 666 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.userAgent()); |
| 667 | return result; |
| 668 | } |
| 669 | |
| 670 | EncodedJSValue jsNavigatorUserAgent(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 671 | { |
| 672 | return IDLAttribute<JSNavigator>::get<jsNavigatorUserAgentGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "userAgent" ); |
| 673 | } |
| 674 | |
| 675 | static inline JSValue jsNavigatorVendorGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 676 | { |
| 677 | UNUSED_PARAM(throwScope); |
| 678 | UNUSED_PARAM(state); |
| 679 | auto& impl = thisObject.wrapped(); |
| 680 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.vendor()); |
| 681 | return result; |
| 682 | } |
| 683 | |
| 684 | EncodedJSValue jsNavigatorVendor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 685 | { |
| 686 | return IDLAttribute<JSNavigator>::get<jsNavigatorVendorGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "vendor" ); |
| 687 | } |
| 688 | |
| 689 | static inline JSValue jsNavigatorVendorSubGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 690 | { |
| 691 | UNUSED_PARAM(throwScope); |
| 692 | UNUSED_PARAM(state); |
| 693 | auto& impl = thisObject.wrapped(); |
| 694 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.vendorSub()); |
| 695 | return result; |
| 696 | } |
| 697 | |
| 698 | EncodedJSValue jsNavigatorVendorSub(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 699 | { |
| 700 | return IDLAttribute<JSNavigator>::get<jsNavigatorVendorSubGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "vendorSub" ); |
| 701 | } |
| 702 | |
| 703 | static inline JSValue jsNavigatorLanguageGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 704 | { |
| 705 | UNUSED_PARAM(throwScope); |
| 706 | UNUSED_PARAM(state); |
| 707 | auto& impl = thisObject.wrapped(); |
| 708 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.language()); |
| 709 | return result; |
| 710 | } |
| 711 | |
| 712 | EncodedJSValue jsNavigatorLanguage(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 713 | { |
| 714 | return IDLAttribute<JSNavigator>::get<jsNavigatorLanguageGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "language" ); |
| 715 | } |
| 716 | |
| 717 | static inline JSValue jsNavigatorLanguagesGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 718 | { |
| 719 | UNUSED_PARAM(throwScope); |
| 720 | UNUSED_PARAM(state); |
| 721 | auto& impl = thisObject.wrapped(); |
| 722 | JSValue result = toJS<IDLFrozenArray<IDLDOMString>>(state, *thisObject.globalObject(), throwScope, impl.languages()); |
| 723 | return result; |
| 724 | } |
| 725 | |
| 726 | EncodedJSValue jsNavigatorLanguages(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 727 | { |
| 728 | return IDLAttribute<JSNavigator>::get<jsNavigatorLanguagesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "languages" ); |
| 729 | } |
| 730 | |
| 731 | static inline JSValue jsNavigatorOnLineGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 732 | { |
| 733 | UNUSED_PARAM(throwScope); |
| 734 | UNUSED_PARAM(state); |
| 735 | auto& impl = thisObject.wrapped(); |
| 736 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.onLine()); |
| 737 | return result; |
| 738 | } |
| 739 | |
| 740 | EncodedJSValue jsNavigatorOnLine(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 741 | { |
| 742 | return IDLAttribute<JSNavigator>::get<jsNavigatorOnLineGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onLine" ); |
| 743 | } |
| 744 | |
| 745 | #if ENABLE(SERVICE_WORKER) |
| 746 | static inline JSValue jsNavigatorServiceWorkerGetter(ExecState& state, JSNavigator& thisObject, ThrowScope& throwScope) |
| 747 | { |
| 748 | UNUSED_PARAM(throwScope); |
| 749 | UNUSED_PARAM(state); |
| 750 | auto* context = jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject())->scriptExecutionContext(); |
| 751 | if (UNLIKELY(!context)) |
| 752 | return jsUndefined(); |
| 753 | auto& impl = thisObject.wrapped(); |
| 754 | JSValue result = toJS<IDLInterface<ServiceWorkerContainer>>(state, *thisObject.globalObject(), throwScope, impl.serviceWorker(*context)); |
| 755 | return result; |
| 756 | } |
| 757 | |
| 758 | EncodedJSValue jsNavigatorServiceWorker(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 759 | { |
| 760 | return IDLAttribute<JSNavigator>::get<jsNavigatorServiceWorkerGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "serviceWorker" ); |
| 761 | } |
| 762 | |
| 763 | #endif |
| 764 | |
| 765 | static inline JSC::EncodedJSValue jsNavigatorPrototypeFunctionJavaEnabledBody(JSC::ExecState* state, typename IDLOperation<JSNavigator>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 766 | { |
| 767 | UNUSED_PARAM(state); |
| 768 | UNUSED_PARAM(throwScope); |
| 769 | auto& impl = castedThis->wrapped(); |
| 770 | return JSValue::encode(toJS<IDLBoolean>(impl.javaEnabled())); |
| 771 | } |
| 772 | |
| 773 | EncodedJSValue JSC_HOST_CALL jsNavigatorPrototypeFunctionJavaEnabled(ExecState* state) |
| 774 | { |
| 775 | return IDLOperation<JSNavigator>::call<jsNavigatorPrototypeFunctionJavaEnabledBody>(*state, "javaEnabled" ); |
| 776 | } |
| 777 | |
| 778 | static inline JSC::EncodedJSValue jsNavigatorPrototypeFunctionGetStorageUpdatesBody(JSC::ExecState* state, typename IDLOperation<JSNavigator>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 779 | { |
| 780 | UNUSED_PARAM(state); |
| 781 | UNUSED_PARAM(throwScope); |
| 782 | auto& impl = castedThis->wrapped(); |
| 783 | impl.getStorageUpdates(); |
| 784 | return JSValue::encode(jsUndefined()); |
| 785 | } |
| 786 | |
| 787 | EncodedJSValue JSC_HOST_CALL jsNavigatorPrototypeFunctionGetStorageUpdates(ExecState* state) |
| 788 | { |
| 789 | return IDLOperation<JSNavigator>::call<jsNavigatorPrototypeFunctionGetStorageUpdatesBody>(*state, "getStorageUpdates" ); |
| 790 | } |
| 791 | |
| 792 | static inline JSC::EncodedJSValue jsNavigatorPrototypeFunctionSendBeaconBody(JSC::ExecState* state, typename IDLOperation<JSNavigator>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 793 | { |
| 794 | UNUSED_PARAM(state); |
| 795 | UNUSED_PARAM(throwScope); |
| 796 | auto& impl = castedThis->wrapped(); |
| 797 | if (UNLIKELY(state->argumentCount() < 1)) |
| 798 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 799 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
| 800 | if (UNLIKELY(!context)) |
| 801 | return JSValue::encode(jsUndefined()); |
| 802 | ASSERT(context->isDocument()); |
| 803 | auto& document = downcast<Document>(*context); |
| 804 | auto url = convert<IDLUSVString>(*state, state->uncheckedArgument(0)); |
| 805 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 806 | auto data = state->argument(1).isUndefined() ? WTF::nullopt : convert<IDLNullable<IDLUnion<IDLInterface<Blob>, IDLArrayBufferView, IDLArrayBuffer, IDLInterface<DOMFormData>, IDLInterface<URLSearchParams>, IDLInterface<ReadableStream>, IDLUSVString>>>(*state, state->uncheckedArgument(1)); |
| 807 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 808 | return JSValue::encode(toJS<IDLBoolean>(*state, throwScope, WebCore::NavigatorBeacon::sendBeacon(impl, document, WTFMove(url), WTFMove(data)))); |
| 809 | } |
| 810 | |
| 811 | EncodedJSValue JSC_HOST_CALL jsNavigatorPrototypeFunctionSendBeacon(ExecState* state) |
| 812 | { |
| 813 | return IDLOperation<JSNavigator>::call<jsNavigatorPrototypeFunctionSendBeaconBody>(*state, "sendBeacon" ); |
| 814 | } |
| 815 | |
| 816 | #if ENABLE(ENCRYPTED_MEDIA) |
| 817 | static inline JSC::EncodedJSValue jsNavigatorPrototypeFunctionRequestMediaKeySystemAccessBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSNavigator>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 818 | { |
| 819 | UNUSED_PARAM(state); |
| 820 | UNUSED_PARAM(throwScope); |
| 821 | auto& impl = castedThis->wrapped(); |
| 822 | if (UNLIKELY(state->argumentCount() < 2)) |
| 823 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 824 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
| 825 | if (UNLIKELY(!context)) |
| 826 | return JSValue::encode(jsUndefined()); |
| 827 | ASSERT(context->isDocument()); |
| 828 | auto& document = downcast<Document>(*context); |
| 829 | auto keySystem = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
| 830 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 831 | auto supportedConfiguration = convert<IDLSequence<IDLDictionary<MediaKeySystemConfiguration>>>(*state, state->uncheckedArgument(1)); |
| 832 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 833 | WebCore::NavigatorEME::requestMediaKeySystemAccess(impl, document, WTFMove(keySystem), WTFMove(supportedConfiguration), WTFMove(promise)); |
| 834 | return JSValue::encode(jsUndefined()); |
| 835 | } |
| 836 | |
| 837 | EncodedJSValue JSC_HOST_CALL jsNavigatorPrototypeFunctionRequestMediaKeySystemAccess(ExecState* state) |
| 838 | { |
| 839 | return IDLOperationReturningPromise<JSNavigator>::call<jsNavigatorPrototypeFunctionRequestMediaKeySystemAccessBody, PromiseExecutionScope::WindowOnly>(*state, "requestMediaKeySystemAccess" ); |
| 840 | } |
| 841 | |
| 842 | #endif |
| 843 | |
| 844 | static inline JSC::EncodedJSValue jsNavigatorPrototypeFunctionGetVRDisplaysBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSNavigator>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 845 | { |
| 846 | UNUSED_PARAM(state); |
| 847 | UNUSED_PARAM(throwScope); |
| 848 | auto& impl = castedThis->wrapped(); |
| 849 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
| 850 | if (UNLIKELY(!context)) |
| 851 | return JSValue::encode(jsUndefined()); |
| 852 | ASSERT(context->isDocument()); |
| 853 | auto& document = downcast<Document>(*context); |
| 854 | WebCore::NavigatorWebVR::getVRDisplays(impl, document, WTFMove(promise)); |
| 855 | return JSValue::encode(jsUndefined()); |
| 856 | } |
| 857 | |
| 858 | EncodedJSValue JSC_HOST_CALL jsNavigatorPrototypeFunctionGetVRDisplays(ExecState* state) |
| 859 | { |
| 860 | return IDLOperationReturningPromise<JSNavigator>::call<jsNavigatorPrototypeFunctionGetVRDisplaysBody, PromiseExecutionScope::WindowOnly>(*state, "getVRDisplays" ); |
| 861 | } |
| 862 | |
| 863 | static inline JSC::EncodedJSValue jsNavigatorPrototypeFunctionShareBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSNavigator>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 864 | { |
| 865 | UNUSED_PARAM(state); |
| 866 | UNUSED_PARAM(throwScope); |
| 867 | auto& impl = castedThis->wrapped(); |
| 868 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
| 869 | if (UNLIKELY(!context)) |
| 870 | return JSValue::encode(jsUndefined()); |
| 871 | auto shareData = convert<IDLDictionary<ShareData>>(*state, state->argument(0)); |
| 872 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 873 | impl.share(*context, WTFMove(shareData), WTFMove(promise)); |
| 874 | return JSValue::encode(jsUndefined()); |
| 875 | } |
| 876 | |
| 877 | EncodedJSValue JSC_HOST_CALL jsNavigatorPrototypeFunctionShare(ExecState* state) |
| 878 | { |
| 879 | return IDLOperationReturningPromise<JSNavigator>::call<jsNavigatorPrototypeFunctionShareBody, PromiseExecutionScope::WindowOnly>(*state, "share" ); |
| 880 | } |
| 881 | |
| 882 | void JSNavigator::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| 883 | { |
| 884 | auto* thisObject = jsCast<JSNavigator*>(cell); |
| 885 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 886 | Base::visitChildren(thisObject, visitor); |
| 887 | thisObject->visitAdditionalChildren(visitor); |
| 888 | } |
| 889 | |
| 890 | void JSNavigator::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor) |
| 891 | { |
| 892 | auto* thisObject = jsCast<JSNavigator*>(cell); |
| 893 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 894 | Base::visitOutputConstraints(thisObject, visitor); |
| 895 | thisObject->visitAdditionalChildren(visitor); |
| 896 | } |
| 897 | |
| 898 | void JSNavigator::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 899 | { |
| 900 | auto* thisObject = jsCast<JSNavigator*>(cell); |
| 901 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 902 | if (thisObject->scriptExecutionContext()) |
| 903 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 904 | Base::heapSnapshot(cell, builder); |
| 905 | } |
| 906 | |
| 907 | bool JSNavigatorOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 908 | { |
| 909 | auto* jsNavigator = jsCast<JSNavigator*>(handle.slot()->asCell()); |
| 910 | Frame* root = WTF::getPtr(jsNavigator->wrapped().frame()); |
| 911 | if (!root) |
| 912 | return false; |
| 913 | if (UNLIKELY(reason)) |
| 914 | *reason = "Reachable from Frame" ; |
| 915 | return visitor.containsOpaqueRoot(root); |
| 916 | } |
| 917 | |
| 918 | void JSNavigatorOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 919 | { |
| 920 | auto* jsNavigator = static_cast<JSNavigator*>(handle.slot()->asCell()); |
| 921 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 922 | uncacheWrapper(world, &jsNavigator->wrapped(), jsNavigator); |
| 923 | } |
| 924 | |
| 925 | #if ENABLE(BINDING_INTEGRITY) |
| 926 | #if PLATFORM(WIN) |
| 927 | #pragma warning(disable: 4483) |
| 928 | extern "C" { extern void (*const __identifier("??_7Navigator@WebCore@@6B@" )[])(); } |
| 929 | #else |
| 930 | extern "C" { extern void* _ZTVN7WebCore9NavigatorE[]; } |
| 931 | #endif |
| 932 | #endif |
| 933 | |
| 934 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<Navigator>&& impl) |
| 935 | { |
| 936 | |
| 937 | #if ENABLE(BINDING_INTEGRITY) |
| 938 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 939 | #if PLATFORM(WIN) |
| 940 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7Navigator@WebCore@@6B@" )); |
| 941 | #else |
| 942 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore9NavigatorE[2]); |
| 943 | #endif |
| 944 | |
| 945 | // If this fails Navigator does not have a vtable, so you need to add the |
| 946 | // ImplementationLacksVTable attribute to the interface definition |
| 947 | static_assert(std::is_polymorphic<Navigator>::value, "Navigator is not polymorphic" ); |
| 948 | |
| 949 | // If you hit this assertion you either have a use after free bug, or |
| 950 | // Navigator has subclasses. If Navigator has subclasses that get passed |
| 951 | // to toJS() we currently require Navigator you to opt out of binding hardening |
| 952 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 953 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 954 | #endif |
| 955 | return createWrapper<Navigator>(globalObject, WTFMove(impl)); |
| 956 | } |
| 957 | |
| 958 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, Navigator& impl) |
| 959 | { |
| 960 | return wrap(state, globalObject, impl); |
| 961 | } |
| 962 | |
| 963 | Navigator* JSNavigator::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 964 | { |
| 965 | if (auto* wrapper = jsDynamicCast<JSNavigator*>(vm, value)) |
| 966 | return &wrapper->wrapped(); |
| 967 | return nullptr; |
| 968 | } |
| 969 | |
| 970 | } |
| 971 | |