| 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 "JSSecurityPolicyViolationEvent.h" |
| 23 | |
| 24 | #include "JSDOMAttribute.h" |
| 25 | #include "JSDOMBinding.h" |
| 26 | #include "JSDOMConstructor.h" |
| 27 | #include "JSDOMConvertBoolean.h" |
| 28 | #include "JSDOMConvertInterface.h" |
| 29 | #include "JSDOMConvertNumbers.h" |
| 30 | #include "JSDOMConvertStrings.h" |
| 31 | #include "JSDOMExceptionHandling.h" |
| 32 | #include "JSDOMWrapperCache.h" |
| 33 | #include "ScriptExecutionContext.h" |
| 34 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 35 | #include <JavaScriptCore/JSCInlines.h> |
| 36 | #include <wtf/GetPtr.h> |
| 37 | #include <wtf/PointerPreparations.h> |
| 38 | #include <wtf/URL.h> |
| 39 | |
| 40 | |
| 41 | namespace WebCore { |
| 42 | using namespace JSC; |
| 43 | |
| 44 | template<> SecurityPolicyViolationEvent::Init convertDictionary<SecurityPolicyViolationEvent::Init>(ExecState& state, JSValue value) |
| 45 | { |
| 46 | VM& vm = state.vm(); |
| 47 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 48 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 49 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 50 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 51 | throwTypeError(&state, throwScope); |
| 52 | return { }; |
| 53 | } |
| 54 | SecurityPolicyViolationEvent::Init result; |
| 55 | JSValue bubblesValue; |
| 56 | if (isNullOrUndefined) |
| 57 | bubblesValue = jsUndefined(); |
| 58 | else { |
| 59 | bubblesValue = object->get(&state, Identifier::fromString(&state, "bubbles" )); |
| 60 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 61 | } |
| 62 | if (!bubblesValue.isUndefined()) { |
| 63 | result.bubbles = convert<IDLBoolean>(state, bubblesValue); |
| 64 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 65 | } else |
| 66 | result.bubbles = false; |
| 67 | JSValue cancelableValue; |
| 68 | if (isNullOrUndefined) |
| 69 | cancelableValue = jsUndefined(); |
| 70 | else { |
| 71 | cancelableValue = object->get(&state, Identifier::fromString(&state, "cancelable" )); |
| 72 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 73 | } |
| 74 | if (!cancelableValue.isUndefined()) { |
| 75 | result.cancelable = convert<IDLBoolean>(state, cancelableValue); |
| 76 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 77 | } else |
| 78 | result.cancelable = false; |
| 79 | JSValue composedValue; |
| 80 | if (isNullOrUndefined) |
| 81 | composedValue = jsUndefined(); |
| 82 | else { |
| 83 | composedValue = object->get(&state, Identifier::fromString(&state, "composed" )); |
| 84 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 85 | } |
| 86 | if (!composedValue.isUndefined()) { |
| 87 | result.composed = convert<IDLBoolean>(state, composedValue); |
| 88 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 89 | } else |
| 90 | result.composed = false; |
| 91 | JSValue blockedURIValue; |
| 92 | if (isNullOrUndefined) |
| 93 | blockedURIValue = jsUndefined(); |
| 94 | else { |
| 95 | blockedURIValue = object->get(&state, Identifier::fromString(&state, "blockedURI" )); |
| 96 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 97 | } |
| 98 | if (!blockedURIValue.isUndefined()) { |
| 99 | result.blockedURI = convert<IDLUSVString>(state, blockedURIValue); |
| 100 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 101 | } else |
| 102 | result.blockedURI = emptyString(); |
| 103 | JSValue columnNumberValue; |
| 104 | if (isNullOrUndefined) |
| 105 | columnNumberValue = jsUndefined(); |
| 106 | else { |
| 107 | columnNumberValue = object->get(&state, Identifier::fromString(&state, "columnNumber" )); |
| 108 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 109 | } |
| 110 | if (!columnNumberValue.isUndefined()) { |
| 111 | result.columnNumber = convert<IDLLong>(state, columnNumberValue); |
| 112 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 113 | } else |
| 114 | result.columnNumber = 0; |
| 115 | JSValue documentURIValue; |
| 116 | if (isNullOrUndefined) |
| 117 | documentURIValue = jsUndefined(); |
| 118 | else { |
| 119 | documentURIValue = object->get(&state, Identifier::fromString(&state, "documentURI" )); |
| 120 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 121 | } |
| 122 | if (!documentURIValue.isUndefined()) { |
| 123 | result.documentURI = convert<IDLUSVString>(state, documentURIValue); |
| 124 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 125 | } else |
| 126 | result.documentURI = emptyString(); |
| 127 | JSValue effectiveDirectiveValue; |
| 128 | if (isNullOrUndefined) |
| 129 | effectiveDirectiveValue = jsUndefined(); |
| 130 | else { |
| 131 | effectiveDirectiveValue = object->get(&state, Identifier::fromString(&state, "effectiveDirective" )); |
| 132 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 133 | } |
| 134 | if (!effectiveDirectiveValue.isUndefined()) { |
| 135 | result.effectiveDirective = convert<IDLDOMString>(state, effectiveDirectiveValue); |
| 136 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 137 | } else |
| 138 | result.effectiveDirective = emptyString(); |
| 139 | JSValue lineNumberValue; |
| 140 | if (isNullOrUndefined) |
| 141 | lineNumberValue = jsUndefined(); |
| 142 | else { |
| 143 | lineNumberValue = object->get(&state, Identifier::fromString(&state, "lineNumber" )); |
| 144 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 145 | } |
| 146 | if (!lineNumberValue.isUndefined()) { |
| 147 | result.lineNumber = convert<IDLLong>(state, lineNumberValue); |
| 148 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 149 | } else |
| 150 | result.lineNumber = 0; |
| 151 | JSValue originalPolicyValue; |
| 152 | if (isNullOrUndefined) |
| 153 | originalPolicyValue = jsUndefined(); |
| 154 | else { |
| 155 | originalPolicyValue = object->get(&state, Identifier::fromString(&state, "originalPolicy" )); |
| 156 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 157 | } |
| 158 | if (!originalPolicyValue.isUndefined()) { |
| 159 | result.originalPolicy = convert<IDLDOMString>(state, originalPolicyValue); |
| 160 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 161 | } else |
| 162 | result.originalPolicy = emptyString(); |
| 163 | JSValue referrerValue; |
| 164 | if (isNullOrUndefined) |
| 165 | referrerValue = jsUndefined(); |
| 166 | else { |
| 167 | referrerValue = object->get(&state, Identifier::fromString(&state, "referrer" )); |
| 168 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 169 | } |
| 170 | if (!referrerValue.isUndefined()) { |
| 171 | result.referrer = convert<IDLDOMString>(state, referrerValue); |
| 172 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 173 | } else |
| 174 | result.referrer = emptyString(); |
| 175 | JSValue sourceFileValue; |
| 176 | if (isNullOrUndefined) |
| 177 | sourceFileValue = jsUndefined(); |
| 178 | else { |
| 179 | sourceFileValue = object->get(&state, Identifier::fromString(&state, "sourceFile" )); |
| 180 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 181 | } |
| 182 | if (!sourceFileValue.isUndefined()) { |
| 183 | result.sourceFile = convert<IDLUSVString>(state, sourceFileValue); |
| 184 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 185 | } else |
| 186 | result.sourceFile = emptyString(); |
| 187 | JSValue statusCodeValue; |
| 188 | if (isNullOrUndefined) |
| 189 | statusCodeValue = jsUndefined(); |
| 190 | else { |
| 191 | statusCodeValue = object->get(&state, Identifier::fromString(&state, "statusCode" )); |
| 192 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 193 | } |
| 194 | if (!statusCodeValue.isUndefined()) { |
| 195 | result.statusCode = convert<IDLUnsignedShort>(state, statusCodeValue); |
| 196 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 197 | } else |
| 198 | result.statusCode = 0; |
| 199 | JSValue violatedDirectiveValue; |
| 200 | if (isNullOrUndefined) |
| 201 | violatedDirectiveValue = jsUndefined(); |
| 202 | else { |
| 203 | violatedDirectiveValue = object->get(&state, Identifier::fromString(&state, "violatedDirective" )); |
| 204 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 205 | } |
| 206 | if (!violatedDirectiveValue.isUndefined()) { |
| 207 | result.violatedDirective = convert<IDLDOMString>(state, violatedDirectiveValue); |
| 208 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 209 | } else |
| 210 | result.violatedDirective = emptyString(); |
| 211 | return result; |
| 212 | } |
| 213 | |
| 214 | // Attributes |
| 215 | |
| 216 | JSC::EncodedJSValue jsSecurityPolicyViolationEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 217 | bool setJSSecurityPolicyViolationEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 218 | JSC::EncodedJSValue jsSecurityPolicyViolationEventDocumentURI(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 219 | JSC::EncodedJSValue jsSecurityPolicyViolationEventReferrer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 220 | JSC::EncodedJSValue jsSecurityPolicyViolationEventBlockedURI(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 221 | JSC::EncodedJSValue jsSecurityPolicyViolationEventViolatedDirective(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 222 | JSC::EncodedJSValue jsSecurityPolicyViolationEventEffectiveDirective(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 223 | JSC::EncodedJSValue jsSecurityPolicyViolationEventOriginalPolicy(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 224 | JSC::EncodedJSValue jsSecurityPolicyViolationEventSourceFile(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 225 | JSC::EncodedJSValue jsSecurityPolicyViolationEventStatusCode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 226 | JSC::EncodedJSValue jsSecurityPolicyViolationEventLineNumber(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 227 | JSC::EncodedJSValue jsSecurityPolicyViolationEventColumnNumber(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 228 | |
| 229 | class JSSecurityPolicyViolationEventPrototype : public JSC::JSNonFinalObject { |
| 230 | public: |
| 231 | using Base = JSC::JSNonFinalObject; |
| 232 | static JSSecurityPolicyViolationEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 233 | { |
| 234 | JSSecurityPolicyViolationEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSSecurityPolicyViolationEventPrototype>(vm.heap)) JSSecurityPolicyViolationEventPrototype(vm, globalObject, structure); |
| 235 | ptr->finishCreation(vm); |
| 236 | return ptr; |
| 237 | } |
| 238 | |
| 239 | DECLARE_INFO; |
| 240 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 241 | { |
| 242 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 243 | } |
| 244 | |
| 245 | private: |
| 246 | JSSecurityPolicyViolationEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 247 | : JSC::JSNonFinalObject(vm, structure) |
| 248 | { |
| 249 | } |
| 250 | |
| 251 | void finishCreation(JSC::VM&); |
| 252 | }; |
| 253 | |
| 254 | using JSSecurityPolicyViolationEventConstructor = JSDOMConstructor<JSSecurityPolicyViolationEvent>; |
| 255 | |
| 256 | template<> EncodedJSValue JSC_HOST_CALL JSSecurityPolicyViolationEventConstructor::construct(ExecState* state) |
| 257 | { |
| 258 | VM& vm = state->vm(); |
| 259 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 260 | UNUSED_PARAM(throwScope); |
| 261 | auto* castedThis = jsCast<JSSecurityPolicyViolationEventConstructor*>(state->jsCallee()); |
| 262 | ASSERT(castedThis); |
| 263 | if (UNLIKELY(state->argumentCount() < 1)) |
| 264 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 265 | auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
| 266 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 267 | auto eventInitDict = convert<IDLDictionary<SecurityPolicyViolationEvent::Init>>(*state, state->argument(1)); |
| 268 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 269 | auto object = SecurityPolicyViolationEvent::create(WTFMove(type), WTFMove(eventInitDict)); |
| 270 | return JSValue::encode(toJSNewlyCreated<IDLInterface<SecurityPolicyViolationEvent>>(*state, *castedThis->globalObject(), WTFMove(object))); |
| 271 | } |
| 272 | |
| 273 | template<> JSValue JSSecurityPolicyViolationEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 274 | { |
| 275 | return JSEvent::getConstructor(vm, &globalObject); |
| 276 | } |
| 277 | |
| 278 | template<> void JSSecurityPolicyViolationEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 279 | { |
| 280 | putDirect(vm, vm.propertyNames->prototype, JSSecurityPolicyViolationEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 281 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("SecurityPolicyViolationEvent"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 282 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 283 | } |
| 284 | |
| 285 | template<> const ClassInfo JSSecurityPolicyViolationEventConstructor::s_info = { "SecurityPolicyViolationEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSecurityPolicyViolationEventConstructor) }; |
| 286 | |
| 287 | /* Hash table for prototype */ |
| 288 | |
| 289 | static const HashTableValue JSSecurityPolicyViolationEventPrototypeTableValues[] = |
| 290 | { |
| 291 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSecurityPolicyViolationEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSecurityPolicyViolationEventConstructor) } }, |
| 292 | { "documentURI" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSecurityPolicyViolationEventDocumentURI), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 293 | { "referrer" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSecurityPolicyViolationEventReferrer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 294 | { "blockedURI" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSecurityPolicyViolationEventBlockedURI), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 295 | { "violatedDirective" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSecurityPolicyViolationEventViolatedDirective), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 296 | { "effectiveDirective" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSecurityPolicyViolationEventEffectiveDirective), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 297 | { "originalPolicy" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSecurityPolicyViolationEventOriginalPolicy), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 298 | { "sourceFile" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSecurityPolicyViolationEventSourceFile), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 299 | { "statusCode" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSecurityPolicyViolationEventStatusCode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 300 | { "lineNumber" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSecurityPolicyViolationEventLineNumber), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 301 | { "columnNumber" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSecurityPolicyViolationEventColumnNumber), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 302 | }; |
| 303 | |
| 304 | const ClassInfo JSSecurityPolicyViolationEventPrototype::s_info = { "SecurityPolicyViolationEventPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSecurityPolicyViolationEventPrototype) }; |
| 305 | |
| 306 | void JSSecurityPolicyViolationEventPrototype::finishCreation(VM& vm) |
| 307 | { |
| 308 | Base::finishCreation(vm); |
| 309 | reifyStaticProperties(vm, JSSecurityPolicyViolationEvent::info(), JSSecurityPolicyViolationEventPrototypeTableValues, *this); |
| 310 | } |
| 311 | |
| 312 | const ClassInfo JSSecurityPolicyViolationEvent::s_info = { "SecurityPolicyViolationEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSecurityPolicyViolationEvent) }; |
| 313 | |
| 314 | JSSecurityPolicyViolationEvent::JSSecurityPolicyViolationEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SecurityPolicyViolationEvent>&& impl) |
| 315 | : JSEvent(structure, globalObject, WTFMove(impl)) |
| 316 | { |
| 317 | } |
| 318 | |
| 319 | void JSSecurityPolicyViolationEvent::finishCreation(VM& vm) |
| 320 | { |
| 321 | Base::finishCreation(vm); |
| 322 | ASSERT(inherits(vm, info())); |
| 323 | |
| 324 | } |
| 325 | |
| 326 | JSObject* JSSecurityPolicyViolationEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 327 | { |
| 328 | return JSSecurityPolicyViolationEventPrototype::create(vm, &globalObject, JSSecurityPolicyViolationEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject))); |
| 329 | } |
| 330 | |
| 331 | JSObject* JSSecurityPolicyViolationEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 332 | { |
| 333 | return getDOMPrototype<JSSecurityPolicyViolationEvent>(vm, globalObject); |
| 334 | } |
| 335 | |
| 336 | JSValue JSSecurityPolicyViolationEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 337 | { |
| 338 | return getDOMConstructor<JSSecurityPolicyViolationEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 339 | } |
| 340 | |
| 341 | template<> inline JSSecurityPolicyViolationEvent* IDLAttribute<JSSecurityPolicyViolationEvent>::cast(ExecState& state, EncodedJSValue thisValue) |
| 342 | { |
| 343 | return jsDynamicCast<JSSecurityPolicyViolationEvent*>(state.vm(), JSValue::decode(thisValue)); |
| 344 | } |
| 345 | |
| 346 | EncodedJSValue jsSecurityPolicyViolationEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 347 | { |
| 348 | VM& vm = state->vm(); |
| 349 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 350 | auto* prototype = jsDynamicCast<JSSecurityPolicyViolationEventPrototype*>(vm, JSValue::decode(thisValue)); |
| 351 | if (UNLIKELY(!prototype)) |
| 352 | return throwVMTypeError(state, throwScope); |
| 353 | return JSValue::encode(JSSecurityPolicyViolationEvent::getConstructor(state->vm(), prototype->globalObject())); |
| 354 | } |
| 355 | |
| 356 | bool setJSSecurityPolicyViolationEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 357 | { |
| 358 | VM& vm = state->vm(); |
| 359 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 360 | auto* prototype = jsDynamicCast<JSSecurityPolicyViolationEventPrototype*>(vm, JSValue::decode(thisValue)); |
| 361 | if (UNLIKELY(!prototype)) { |
| 362 | throwVMTypeError(state, throwScope); |
| 363 | return false; |
| 364 | } |
| 365 | // Shadowing a built-in constructor |
| 366 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 367 | } |
| 368 | |
| 369 | static inline JSValue jsSecurityPolicyViolationEventDocumentURIGetter(ExecState& state, JSSecurityPolicyViolationEvent& thisObject, ThrowScope& throwScope) |
| 370 | { |
| 371 | UNUSED_PARAM(throwScope); |
| 372 | UNUSED_PARAM(state); |
| 373 | auto& impl = thisObject.wrapped(); |
| 374 | JSValue result = toJS<IDLUSVString>(state, throwScope, impl.documentURI()); |
| 375 | return result; |
| 376 | } |
| 377 | |
| 378 | EncodedJSValue jsSecurityPolicyViolationEventDocumentURI(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 379 | { |
| 380 | return IDLAttribute<JSSecurityPolicyViolationEvent>::get<jsSecurityPolicyViolationEventDocumentURIGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "documentURI" ); |
| 381 | } |
| 382 | |
| 383 | static inline JSValue jsSecurityPolicyViolationEventReferrerGetter(ExecState& state, JSSecurityPolicyViolationEvent& thisObject, ThrowScope& throwScope) |
| 384 | { |
| 385 | UNUSED_PARAM(throwScope); |
| 386 | UNUSED_PARAM(state); |
| 387 | auto& impl = thisObject.wrapped(); |
| 388 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.referrer()); |
| 389 | return result; |
| 390 | } |
| 391 | |
| 392 | EncodedJSValue jsSecurityPolicyViolationEventReferrer(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 393 | { |
| 394 | return IDLAttribute<JSSecurityPolicyViolationEvent>::get<jsSecurityPolicyViolationEventReferrerGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "referrer" ); |
| 395 | } |
| 396 | |
| 397 | static inline JSValue jsSecurityPolicyViolationEventBlockedURIGetter(ExecState& state, JSSecurityPolicyViolationEvent& thisObject, ThrowScope& throwScope) |
| 398 | { |
| 399 | UNUSED_PARAM(throwScope); |
| 400 | UNUSED_PARAM(state); |
| 401 | auto& impl = thisObject.wrapped(); |
| 402 | JSValue result = toJS<IDLUSVString>(state, throwScope, impl.blockedURI()); |
| 403 | return result; |
| 404 | } |
| 405 | |
| 406 | EncodedJSValue jsSecurityPolicyViolationEventBlockedURI(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 407 | { |
| 408 | return IDLAttribute<JSSecurityPolicyViolationEvent>::get<jsSecurityPolicyViolationEventBlockedURIGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "blockedURI" ); |
| 409 | } |
| 410 | |
| 411 | static inline JSValue jsSecurityPolicyViolationEventViolatedDirectiveGetter(ExecState& state, JSSecurityPolicyViolationEvent& thisObject, ThrowScope& throwScope) |
| 412 | { |
| 413 | UNUSED_PARAM(throwScope); |
| 414 | UNUSED_PARAM(state); |
| 415 | auto& impl = thisObject.wrapped(); |
| 416 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.violatedDirective()); |
| 417 | return result; |
| 418 | } |
| 419 | |
| 420 | EncodedJSValue jsSecurityPolicyViolationEventViolatedDirective(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 421 | { |
| 422 | return IDLAttribute<JSSecurityPolicyViolationEvent>::get<jsSecurityPolicyViolationEventViolatedDirectiveGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "violatedDirective" ); |
| 423 | } |
| 424 | |
| 425 | static inline JSValue jsSecurityPolicyViolationEventEffectiveDirectiveGetter(ExecState& state, JSSecurityPolicyViolationEvent& thisObject, ThrowScope& throwScope) |
| 426 | { |
| 427 | UNUSED_PARAM(throwScope); |
| 428 | UNUSED_PARAM(state); |
| 429 | auto& impl = thisObject.wrapped(); |
| 430 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.effectiveDirective()); |
| 431 | return result; |
| 432 | } |
| 433 | |
| 434 | EncodedJSValue jsSecurityPolicyViolationEventEffectiveDirective(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 435 | { |
| 436 | return IDLAttribute<JSSecurityPolicyViolationEvent>::get<jsSecurityPolicyViolationEventEffectiveDirectiveGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "effectiveDirective" ); |
| 437 | } |
| 438 | |
| 439 | static inline JSValue jsSecurityPolicyViolationEventOriginalPolicyGetter(ExecState& state, JSSecurityPolicyViolationEvent& thisObject, ThrowScope& throwScope) |
| 440 | { |
| 441 | UNUSED_PARAM(throwScope); |
| 442 | UNUSED_PARAM(state); |
| 443 | auto& impl = thisObject.wrapped(); |
| 444 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.originalPolicy()); |
| 445 | return result; |
| 446 | } |
| 447 | |
| 448 | EncodedJSValue jsSecurityPolicyViolationEventOriginalPolicy(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 449 | { |
| 450 | return IDLAttribute<JSSecurityPolicyViolationEvent>::get<jsSecurityPolicyViolationEventOriginalPolicyGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "originalPolicy" ); |
| 451 | } |
| 452 | |
| 453 | static inline JSValue jsSecurityPolicyViolationEventSourceFileGetter(ExecState& state, JSSecurityPolicyViolationEvent& thisObject, ThrowScope& throwScope) |
| 454 | { |
| 455 | UNUSED_PARAM(throwScope); |
| 456 | UNUSED_PARAM(state); |
| 457 | auto& impl = thisObject.wrapped(); |
| 458 | JSValue result = toJS<IDLUSVString>(state, throwScope, impl.sourceFile()); |
| 459 | return result; |
| 460 | } |
| 461 | |
| 462 | EncodedJSValue jsSecurityPolicyViolationEventSourceFile(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 463 | { |
| 464 | return IDLAttribute<JSSecurityPolicyViolationEvent>::get<jsSecurityPolicyViolationEventSourceFileGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "sourceFile" ); |
| 465 | } |
| 466 | |
| 467 | static inline JSValue jsSecurityPolicyViolationEventStatusCodeGetter(ExecState& state, JSSecurityPolicyViolationEvent& thisObject, ThrowScope& throwScope) |
| 468 | { |
| 469 | UNUSED_PARAM(throwScope); |
| 470 | UNUSED_PARAM(state); |
| 471 | auto& impl = thisObject.wrapped(); |
| 472 | JSValue result = toJS<IDLUnsignedShort>(state, throwScope, impl.statusCode()); |
| 473 | return result; |
| 474 | } |
| 475 | |
| 476 | EncodedJSValue jsSecurityPolicyViolationEventStatusCode(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 477 | { |
| 478 | return IDLAttribute<JSSecurityPolicyViolationEvent>::get<jsSecurityPolicyViolationEventStatusCodeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "statusCode" ); |
| 479 | } |
| 480 | |
| 481 | static inline JSValue jsSecurityPolicyViolationEventLineNumberGetter(ExecState& state, JSSecurityPolicyViolationEvent& thisObject, ThrowScope& throwScope) |
| 482 | { |
| 483 | UNUSED_PARAM(throwScope); |
| 484 | UNUSED_PARAM(state); |
| 485 | auto& impl = thisObject.wrapped(); |
| 486 | JSValue result = toJS<IDLLong>(state, throwScope, impl.lineNumber()); |
| 487 | return result; |
| 488 | } |
| 489 | |
| 490 | EncodedJSValue jsSecurityPolicyViolationEventLineNumber(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 491 | { |
| 492 | return IDLAttribute<JSSecurityPolicyViolationEvent>::get<jsSecurityPolicyViolationEventLineNumberGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "lineNumber" ); |
| 493 | } |
| 494 | |
| 495 | static inline JSValue jsSecurityPolicyViolationEventColumnNumberGetter(ExecState& state, JSSecurityPolicyViolationEvent& thisObject, ThrowScope& throwScope) |
| 496 | { |
| 497 | UNUSED_PARAM(throwScope); |
| 498 | UNUSED_PARAM(state); |
| 499 | auto& impl = thisObject.wrapped(); |
| 500 | JSValue result = toJS<IDLLong>(state, throwScope, impl.columnNumber()); |
| 501 | return result; |
| 502 | } |
| 503 | |
| 504 | EncodedJSValue jsSecurityPolicyViolationEventColumnNumber(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 505 | { |
| 506 | return IDLAttribute<JSSecurityPolicyViolationEvent>::get<jsSecurityPolicyViolationEventColumnNumberGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "columnNumber" ); |
| 507 | } |
| 508 | |
| 509 | void JSSecurityPolicyViolationEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 510 | { |
| 511 | auto* thisObject = jsCast<JSSecurityPolicyViolationEvent*>(cell); |
| 512 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 513 | if (thisObject->scriptExecutionContext()) |
| 514 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 515 | Base::heapSnapshot(cell, builder); |
| 516 | } |
| 517 | |
| 518 | #if ENABLE(BINDING_INTEGRITY) |
| 519 | #if PLATFORM(WIN) |
| 520 | #pragma warning(disable: 4483) |
| 521 | extern "C" { extern void (*const __identifier("??_7SecurityPolicyViolationEvent@WebCore@@6B@" )[])(); } |
| 522 | #else |
| 523 | extern "C" { extern void* _ZTVN7WebCore28SecurityPolicyViolationEventE[]; } |
| 524 | #endif |
| 525 | #endif |
| 526 | |
| 527 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<SecurityPolicyViolationEvent>&& impl) |
| 528 | { |
| 529 | |
| 530 | #if ENABLE(BINDING_INTEGRITY) |
| 531 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 532 | #if PLATFORM(WIN) |
| 533 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7SecurityPolicyViolationEvent@WebCore@@6B@" )); |
| 534 | #else |
| 535 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore28SecurityPolicyViolationEventE[2]); |
| 536 | #endif |
| 537 | |
| 538 | // If this fails SecurityPolicyViolationEvent does not have a vtable, so you need to add the |
| 539 | // ImplementationLacksVTable attribute to the interface definition |
| 540 | static_assert(std::is_polymorphic<SecurityPolicyViolationEvent>::value, "SecurityPolicyViolationEvent is not polymorphic" ); |
| 541 | |
| 542 | // If you hit this assertion you either have a use after free bug, or |
| 543 | // SecurityPolicyViolationEvent has subclasses. If SecurityPolicyViolationEvent has subclasses that get passed |
| 544 | // to toJS() we currently require SecurityPolicyViolationEvent you to opt out of binding hardening |
| 545 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 546 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 547 | #endif |
| 548 | return createWrapper<SecurityPolicyViolationEvent>(globalObject, WTFMove(impl)); |
| 549 | } |
| 550 | |
| 551 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, SecurityPolicyViolationEvent& impl) |
| 552 | { |
| 553 | return wrap(state, globalObject, impl); |
| 554 | } |
| 555 | |
| 556 | |
| 557 | } |
| 558 | |