mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 05:42:43 +00:00
* Prepare for windows event loop * More progress * Update libuv.zig * wip * Make compiling each dependency a shell script * Bump mimalloc * Add the build scripts * Update settings.json * Fix a bunch of compiler warnings * Remove more warnings * more warnings * cmake works * Update JSSQLStatement.h * put it in the zig file * Fix usockets warnings * Fixup * Fix one of the compiler errors * chunk * draw the rest of the owl * theres more * Rename Process -> BunProcess Works around a Windows issue * Add musl polyfill for memmem on Windows * More * 12 mb * Fix getenvZ * fix variosu issues * Add fast-ish path for bun install on Windows * Update windows.zig * Update windows.zig * Fix build issue * it works * hmmm * Rename file * Fixups * Update wtf-bindings.cpp * Update src/bun.js/bindings/headers-handwritten.h Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> * further! * more * Update .gitignore * hm * quite a lot of fixes * Update CMakeLists.txt * zig fmt * Many more things are starting to work. * reb * regenaret * Update JSSink.h * fixup * fetch works * Bun.serve() and much of the event loop works now * Make require() work * bun install progress * more things work * use less std.os * Fixes * small fixes * Bump * Bummp * Undo that change * We have to bump the version of Debian because libarchive has a higher minimum requirement * ok * some clenaup * windows * Update bun.zig * fixup * avoid duplicate symbols * avoid undefined symbols * bump * Remove issue template for install It's not used, and use the bug issue instead. * Add types for cp and cpSync * Add types for watchFile and unwatchFile * Add bun-types to 'bun fmt' script * Update nodejs compat docs cp/cpSync/watchFile/unwatchFile (#4525) * feat(fetch) rejectUnauthorized and checkServerIdentity (#4514) * enable root certs on fetch * rebase * fix lookup * some fixes and improvements * fmt * more fixes * more fixes * check detached onHandshake * fix promise case * fix cert non-Native * add fetch tls tests * more one test * churn * Update feature_flags.zig * Update response.zig * Revert "avoid undefined symbols" This reverts commitca835b726f. * Revert "avoid duplicate symbols" This reverts commit4ac6ca8700. * Update feature_flags.zig * Set permissions * more * Update mimalloc * Fix sqlite test failures * Fix some test failures * Make sure we remove libusockets is removed * hm * [dave]: fix webcrypto crash * bump * Update index.ts * windows zig compiles * cmake on mac works * progress * yay * bun run build * fix * ok * oops * asdfasfdafdsafda * fghjkl * git ignore * wow * Process -> BunProcess * hmm * blah * finalize merge * now it only has linker errors on mac * sdfadsf * g * getting farther * sxdcvbnmk, * adfhjskfjdhkas * a * fgh * update build dot zig * asdfg * theoretical -DCANARY flag we can use * asdf * cool * okay * colorterm * New build workflow * Fix script * Use sudo * More sudo * Tweak dependencies * Another sudo attempt * Tweak script * 16.0 -> 16 * Tweak script * Tweak script * Tweak script * Tweak script * Tweak script * bun install * ssh into github actions * add more to ssh * Fix postinstal * Skip llvm * New dockerfile * Build * More changes to Dockerfile * chaos chaos chaos * okay * a * more cmake nonsense * add unified sources code (does not work) * stuff * prepare for CI builds * ok * yay * yeah * make this more stable simply by trying again if it fails, 5 times, then lose. it fixes the stability issue i was running into L O L * messing with ci * x * a * clean dependencies before build * oops * this is not going to work but its closer * not gonna work either * a * a * did i do it * a * a * work around weird fs+Bun.build issues * properly pass debug flag correctly * idk im sorry * lose * maybe * run the tests please * a * fix zlib script * a * hi * prevent stupid ci issue * i totally didnt leave in a syntax error on cmakelists * a * lol * relax * 😭 * a * SO SILLY * 😡 one line mistake * one character diff * fix linking symbols missing * work on dependency scripts * does this work now? * fix mac build * a * bump! * woops * add macos baseline build * . * fix sqlite and also enable $assert/$debug support in builtin functions * okay * oops * zig upgrade lol * Merge * Fix spawn test issue * Set a timeout * yeah * etc * mi --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: Dylan Conway <dylan.conway567@gmail.com> Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Co-authored-by: Ashcon Partovi <ashcon@partovi.net> Co-authored-by: Birk Skyum <74932975+birkskyum@users.noreply.github.com> Co-authored-by: dave caruso <me@paperdave.net>
427 lines
21 KiB
C++
427 lines
21 KiB
C++
/*
|
|
This file is part of the WebKit open source project.
|
|
This file has been generated by generate-bindings.pl. DO NOT MODIFY!
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Library General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Library General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Library General Public License
|
|
along with this library; see the file COPYING.LIB. If not, write to
|
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#include "config.h"
|
|
#include "JSBroadcastChannel.h"
|
|
|
|
#include "ActiveDOMObject.h"
|
|
#include "EventNames.h"
|
|
#include "ExtendedDOMClientIsoSubspaces.h"
|
|
#include "ExtendedDOMIsoSubspaces.h"
|
|
#include "IDLTypes.h"
|
|
#include "JSDOMAttribute.h"
|
|
#include "JSDOMBinding.h"
|
|
#include "JSDOMConstructor.h"
|
|
#include "JSDOMConvertAny.h"
|
|
#include "JSDOMConvertBase.h"
|
|
#include "JSDOMConvertInterface.h"
|
|
#include "JSDOMConvertStrings.h"
|
|
#include "JSDOMExceptionHandling.h"
|
|
#include "JSDOMGlobalObjectInlines.h"
|
|
#include "JSDOMOperation.h"
|
|
#include "JSDOMWrapperCache.h"
|
|
#include "JSEventListener.h"
|
|
#include "ScriptExecutionContext.h"
|
|
#include "WebCoreJSClientData.h"
|
|
#include <JavaScriptCore/HeapAnalyzer.h>
|
|
#include <JavaScriptCore/JSCInlines.h>
|
|
#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
|
|
#include <JavaScriptCore/SlotVisitorMacros.h>
|
|
#include <JavaScriptCore/SubspaceInlines.h>
|
|
#include <wtf/GetPtr.h>
|
|
#include <wtf/PointerPreparations.h>
|
|
#include <wtf/URL.h>
|
|
|
|
namespace WebCore {
|
|
using namespace JSC;
|
|
|
|
// Functions
|
|
|
|
static JSC_DECLARE_HOST_FUNCTION(jsBroadcastChannelPrototypeFunction_postMessage);
|
|
static JSC_DECLARE_HOST_FUNCTION(jsBroadcastChannelPrototypeFunction_close);
|
|
static JSC_DECLARE_HOST_FUNCTION(jsBroadcastChannelPrototypeFunction_ref);
|
|
static JSC_DECLARE_HOST_FUNCTION(jsBroadcastChannelPrototypeFunction_unref);
|
|
|
|
// Attributes
|
|
|
|
static JSC_DECLARE_CUSTOM_GETTER(jsBroadcastChannelConstructor);
|
|
static JSC_DECLARE_CUSTOM_GETTER(jsBroadcastChannel_name);
|
|
static JSC_DECLARE_CUSTOM_GETTER(jsBroadcastChannel_onmessage);
|
|
static JSC_DECLARE_CUSTOM_SETTER(setJSBroadcastChannel_onmessage);
|
|
static JSC_DECLARE_CUSTOM_GETTER(jsBroadcastChannel_onmessageerror);
|
|
static JSC_DECLARE_CUSTOM_SETTER(setJSBroadcastChannel_onmessageerror);
|
|
|
|
class JSBroadcastChannelPrototype final : public JSC::JSNonFinalObject {
|
|
public:
|
|
using Base = JSC::JSNonFinalObject;
|
|
static JSBroadcastChannelPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
|
|
{
|
|
JSBroadcastChannelPrototype* ptr = new (NotNull, JSC::allocateCell<JSBroadcastChannelPrototype>(vm)) JSBroadcastChannelPrototype(vm, globalObject, structure);
|
|
ptr->finishCreation(vm);
|
|
return ptr;
|
|
}
|
|
|
|
DECLARE_INFO;
|
|
template<typename CellType, JSC::SubspaceAccess>
|
|
static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
|
|
{
|
|
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBroadcastChannelPrototype, Base);
|
|
return &vm.plainObjectSpace();
|
|
}
|
|
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
|
|
{
|
|
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
|
|
}
|
|
|
|
private:
|
|
JSBroadcastChannelPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
|
|
: JSC::JSNonFinalObject(vm, structure)
|
|
{
|
|
}
|
|
|
|
void finishCreation(JSC::VM&);
|
|
};
|
|
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBroadcastChannelPrototype, JSBroadcastChannelPrototype::Base);
|
|
|
|
using JSBroadcastChannelDOMConstructor = JSDOMConstructor<JSBroadcastChannel>;
|
|
|
|
template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSBroadcastChannelDOMConstructor::construct(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
|
|
{
|
|
VM& vm = lexicalGlobalObject->vm();
|
|
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
|
auto* castedThis = jsCast<JSBroadcastChannelDOMConstructor*>(callFrame->jsCallee());
|
|
ASSERT(castedThis);
|
|
if (UNLIKELY(callFrame->argumentCount() < 1))
|
|
return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
|
|
auto* context = castedThis->scriptExecutionContext();
|
|
if (UNLIKELY(!context))
|
|
return throwConstructorScriptExecutionContextUnavailableError(*lexicalGlobalObject, throwScope, "BroadcastChannel");
|
|
EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
|
|
auto name = convert<IDLDOMString>(*lexicalGlobalObject, argument0.value());
|
|
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
|
|
auto object = BroadcastChannel::create(*context, WTFMove(name));
|
|
if constexpr (IsExceptionOr<decltype(object)>)
|
|
RETURN_IF_EXCEPTION(throwScope, {});
|
|
static_assert(TypeOrExceptionOrUnderlyingType<decltype(object)>::isRef);
|
|
auto jsValue = toJSNewlyCreated<IDLInterface<BroadcastChannel>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, WTFMove(object));
|
|
if constexpr (IsExceptionOr<decltype(object)>)
|
|
RETURN_IF_EXCEPTION(throwScope, {});
|
|
setSubclassStructureIfNeeded<BroadcastChannel>(lexicalGlobalObject, callFrame, asObject(jsValue));
|
|
RETURN_IF_EXCEPTION(throwScope, {});
|
|
return JSValue::encode(jsValue);
|
|
}
|
|
JSC_ANNOTATE_HOST_FUNCTION(JSBroadcastChannelDOMConstructorConstruct, JSBroadcastChannelDOMConstructor::construct);
|
|
|
|
template<> const ClassInfo JSBroadcastChannelDOMConstructor::s_info = { "BroadcastChannel"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBroadcastChannelDOMConstructor) };
|
|
|
|
template<> JSValue JSBroadcastChannelDOMConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
|
|
{
|
|
return JSEventTarget::getConstructor(vm, &globalObject);
|
|
}
|
|
|
|
template<> void JSBroadcastChannelDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
|
|
{
|
|
putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
|
|
JSString* nameString = jsNontrivialString(vm, "BroadcastChannel"_s);
|
|
m_originalName.set(vm, this, nameString);
|
|
putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
|
|
putDirect(vm, vm.propertyNames->prototype, JSBroadcastChannel::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
|
|
}
|
|
|
|
/* Hash table for prototype */
|
|
|
|
static const HashTableValue JSBroadcastChannelPrototypeTableValues[] = {
|
|
{ "constructor"_s, static_cast<unsigned>(PropertyAttribute::DontEnum), NoIntrinsic, { HashTableValue::GetterSetterType, jsBroadcastChannelConstructor, 0 } },
|
|
{ "name"_s, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute, NoIntrinsic, { HashTableValue::GetterSetterType, jsBroadcastChannel_name, 0 } },
|
|
{ "onmessage"_s, JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute, NoIntrinsic, { HashTableValue::GetterSetterType, jsBroadcastChannel_onmessage, setJSBroadcastChannel_onmessage } },
|
|
{ "onmessageerror"_s, JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute, NoIntrinsic, { HashTableValue::GetterSetterType, jsBroadcastChannel_onmessageerror, setJSBroadcastChannel_onmessageerror } },
|
|
{ "postMessage"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsBroadcastChannelPrototypeFunction_postMessage, 1 } },
|
|
{ "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsBroadcastChannelPrototypeFunction_close, 0 } },
|
|
{ "ref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsBroadcastChannelPrototypeFunction_ref, 0 } },
|
|
{ "unref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsBroadcastChannelPrototypeFunction_unref, 0 } },
|
|
};
|
|
|
|
const ClassInfo JSBroadcastChannelPrototype::s_info = { "BroadcastChannel"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBroadcastChannelPrototype) };
|
|
|
|
void JSBroadcastChannelPrototype::finishCreation(VM& vm)
|
|
{
|
|
Base::finishCreation(vm);
|
|
reifyStaticProperties(vm, JSBroadcastChannel::info(), JSBroadcastChannelPrototypeTableValues, *this);
|
|
JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
|
|
}
|
|
|
|
const ClassInfo JSBroadcastChannel::s_info = { "BroadcastChannel"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBroadcastChannel) };
|
|
|
|
JSBroadcastChannel::JSBroadcastChannel(Structure* structure, JSDOMGlobalObject& globalObject, Ref<BroadcastChannel>&& impl)
|
|
: JSEventTarget(structure, globalObject, WTFMove(impl))
|
|
{
|
|
}
|
|
|
|
// static_assert(std::is_base_of<ActiveDOMObject, BroadcastChannel>::value, "Interface is marked as [ActiveDOMObject] but implementation class does not subclass ActiveDOMObject.");
|
|
|
|
JSObject* JSBroadcastChannel::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
|
|
{
|
|
auto* structure = JSBroadcastChannelPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject));
|
|
structure->setMayBePrototype(true);
|
|
return JSBroadcastChannelPrototype::create(vm, &globalObject, structure);
|
|
}
|
|
|
|
JSObject* JSBroadcastChannel::prototype(VM& vm, JSDOMGlobalObject& globalObject)
|
|
{
|
|
return getDOMPrototype<JSBroadcastChannel>(vm, globalObject);
|
|
}
|
|
|
|
JSValue JSBroadcastChannel::getConstructor(VM& vm, const JSGlobalObject* globalObject)
|
|
{
|
|
return getDOMConstructor<JSBroadcastChannelDOMConstructor, DOMConstructorID::BroadcastChannel>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
|
|
}
|
|
|
|
JSC_DEFINE_CUSTOM_GETTER(jsBroadcastChannelConstructor, (JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, PropertyName))
|
|
{
|
|
VM& vm = JSC::getVM(lexicalGlobalObject);
|
|
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
|
auto* prototype = jsDynamicCast<JSBroadcastChannelPrototype*>(JSValue::decode(thisValue));
|
|
if (UNLIKELY(!prototype))
|
|
return throwVMTypeError(lexicalGlobalObject, throwScope);
|
|
return JSValue::encode(JSBroadcastChannel::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
|
|
}
|
|
|
|
static inline JSValue jsBroadcastChannel_nameGetter(JSGlobalObject& lexicalGlobalObject, JSBroadcastChannel& thisObject)
|
|
{
|
|
auto& vm = JSC::getVM(&lexicalGlobalObject);
|
|
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
|
auto& impl = thisObject.wrapped();
|
|
RELEASE_AND_RETURN(throwScope, (toJS<IDLDOMString>(lexicalGlobalObject, throwScope, impl.name())));
|
|
}
|
|
|
|
JSC_DEFINE_CUSTOM_GETTER(jsBroadcastChannel_name, (JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, PropertyName attributeName))
|
|
{
|
|
return IDLAttribute<JSBroadcastChannel>::get<jsBroadcastChannel_nameGetter, CastedThisErrorBehavior::Assert>(*lexicalGlobalObject, thisValue, attributeName);
|
|
}
|
|
|
|
static inline JSValue jsBroadcastChannel_onmessageGetter(JSGlobalObject& lexicalGlobalObject, JSBroadcastChannel& thisObject)
|
|
{
|
|
UNUSED_PARAM(lexicalGlobalObject);
|
|
return eventHandlerAttribute(thisObject.wrapped(), eventNames().messageEvent, worldForDOMObject(thisObject));
|
|
}
|
|
|
|
JSC_DEFINE_CUSTOM_GETTER(jsBroadcastChannel_onmessage, (JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, PropertyName attributeName))
|
|
{
|
|
return IDLAttribute<JSBroadcastChannel>::get<jsBroadcastChannel_onmessageGetter, CastedThisErrorBehavior::Assert>(*lexicalGlobalObject, thisValue, attributeName);
|
|
}
|
|
|
|
static inline bool setJSBroadcastChannel_onmessageSetter(JSGlobalObject& lexicalGlobalObject, JSBroadcastChannel& thisObject, JSValue value)
|
|
{
|
|
auto& vm = JSC::getVM(&lexicalGlobalObject);
|
|
UNUSED_PARAM(vm);
|
|
setEventHandlerAttribute<JSEventListener>(thisObject.wrapped(), eventNames().messageEvent, value, thisObject);
|
|
vm.writeBarrier(&thisObject, value);
|
|
ensureStillAliveHere(value);
|
|
|
|
return true;
|
|
}
|
|
|
|
JSC_DEFINE_CUSTOM_SETTER(setJSBroadcastChannel_onmessage, (JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue encodedValue, PropertyName attributeName))
|
|
{
|
|
return IDLAttribute<JSBroadcastChannel>::set<setJSBroadcastChannel_onmessageSetter>(*lexicalGlobalObject, thisValue, encodedValue, attributeName);
|
|
}
|
|
|
|
static inline JSValue jsBroadcastChannel_onmessageerrorGetter(JSGlobalObject& lexicalGlobalObject, JSBroadcastChannel& thisObject)
|
|
{
|
|
UNUSED_PARAM(lexicalGlobalObject);
|
|
return eventHandlerAttribute(thisObject.wrapped(), eventNames().messageerrorEvent, worldForDOMObject(thisObject));
|
|
}
|
|
|
|
JSC_DEFINE_CUSTOM_GETTER(jsBroadcastChannel_onmessageerror, (JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, PropertyName attributeName))
|
|
{
|
|
return IDLAttribute<JSBroadcastChannel>::get<jsBroadcastChannel_onmessageerrorGetter, CastedThisErrorBehavior::Assert>(*lexicalGlobalObject, thisValue, attributeName);
|
|
}
|
|
|
|
static inline bool setJSBroadcastChannel_onmessageerrorSetter(JSGlobalObject& lexicalGlobalObject, JSBroadcastChannel& thisObject, JSValue value)
|
|
{
|
|
auto& vm = JSC::getVM(&lexicalGlobalObject);
|
|
UNUSED_PARAM(vm);
|
|
setEventHandlerAttribute<JSEventListener>(thisObject.wrapped(), eventNames().messageerrorEvent, value, thisObject);
|
|
vm.writeBarrier(&thisObject, value);
|
|
ensureStillAliveHere(value);
|
|
|
|
return true;
|
|
}
|
|
|
|
JSC_DEFINE_CUSTOM_SETTER(setJSBroadcastChannel_onmessageerror, (JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue encodedValue, PropertyName attributeName))
|
|
{
|
|
return IDLAttribute<JSBroadcastChannel>::set<setJSBroadcastChannel_onmessageerrorSetter>(*lexicalGlobalObject, thisValue, encodedValue, attributeName);
|
|
}
|
|
|
|
static inline JSC::EncodedJSValue jsBroadcastChannelPrototypeFunction_postMessageBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBroadcastChannel>::ClassParameter castedThis)
|
|
{
|
|
auto& vm = JSC::getVM(lexicalGlobalObject);
|
|
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
|
UNUSED_PARAM(throwScope);
|
|
UNUSED_PARAM(callFrame);
|
|
auto& impl = castedThis->wrapped();
|
|
if (UNLIKELY(callFrame->argumentCount() < 1))
|
|
return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
|
|
EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
|
|
auto message = convert<IDLAny>(*lexicalGlobalObject, argument0.value());
|
|
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
|
|
RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.postMessage(*jsCast<JSDOMGlobalObject*>(lexicalGlobalObject), WTFMove(message)); })));
|
|
}
|
|
|
|
JSC_DEFINE_HOST_FUNCTION(jsBroadcastChannelPrototypeFunction_postMessage, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
|
|
{
|
|
return IDLOperation<JSBroadcastChannel>::call<jsBroadcastChannelPrototypeFunction_postMessageBody>(*lexicalGlobalObject, *callFrame, "postMessage");
|
|
}
|
|
|
|
static inline JSC::EncodedJSValue jsBroadcastChannelPrototypeFunction_closeBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBroadcastChannel>::ClassParameter castedThis)
|
|
{
|
|
auto& vm = JSC::getVM(lexicalGlobalObject);
|
|
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
|
UNUSED_PARAM(throwScope);
|
|
UNUSED_PARAM(callFrame);
|
|
auto& impl = castedThis->wrapped();
|
|
impl.jsUnref(lexicalGlobalObject);
|
|
RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.close(); })));
|
|
}
|
|
|
|
JSC_DEFINE_HOST_FUNCTION(jsBroadcastChannelPrototypeFunction_close, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
|
|
{
|
|
return IDLOperation<JSBroadcastChannel>::call<jsBroadcastChannelPrototypeFunction_closeBody>(*lexicalGlobalObject, *callFrame, "close");
|
|
}
|
|
|
|
static inline JSC::EncodedJSValue jsBroadcastChannelPrototypeFunction_refBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBroadcastChannel>::ClassParameter castedThis)
|
|
{
|
|
auto& vm = JSC::getVM(lexicalGlobalObject);
|
|
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
|
UNUSED_PARAM(throwScope);
|
|
UNUSED_PARAM(callFrame);
|
|
auto& impl = castedThis->wrapped();
|
|
RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.jsRef(lexicalGlobalObject); })));
|
|
}
|
|
|
|
JSC_DEFINE_HOST_FUNCTION(jsBroadcastChannelPrototypeFunction_ref, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
|
|
{
|
|
return IDLOperation<JSBroadcastChannel>::call<jsBroadcastChannelPrototypeFunction_refBody>(*lexicalGlobalObject, *callFrame, "ref");
|
|
}
|
|
|
|
static inline JSC::EncodedJSValue jsBroadcastChannelPrototypeFunction_unrefBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBroadcastChannel>::ClassParameter castedThis)
|
|
{
|
|
auto& vm = JSC::getVM(lexicalGlobalObject);
|
|
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
|
UNUSED_PARAM(throwScope);
|
|
UNUSED_PARAM(callFrame);
|
|
auto& impl = castedThis->wrapped();
|
|
RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.jsUnref(lexicalGlobalObject); })));
|
|
}
|
|
|
|
JSC_DEFINE_HOST_FUNCTION(jsBroadcastChannelPrototypeFunction_unref, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
|
|
{
|
|
return IDLOperation<JSBroadcastChannel>::call<jsBroadcastChannelPrototypeFunction_unrefBody>(*lexicalGlobalObject, *callFrame, "unref");
|
|
}
|
|
|
|
JSC::GCClient::IsoSubspace* JSBroadcastChannel::subspaceForImpl(JSC::VM& vm)
|
|
{
|
|
return WebCore::subspaceForImpl<JSBroadcastChannel, UseCustomHeapCellType::No>(
|
|
vm,
|
|
[](auto& spaces) { return spaces.m_clientSubspaceForBroadcastChannel.get(); },
|
|
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForBroadcastChannel = std::forward<decltype(space)>(space); },
|
|
[](auto& spaces) { return spaces.m_subspaceForBroadcastChannel.get(); },
|
|
[](auto& spaces, auto&& space) { spaces.m_subspaceForBroadcastChannel = std::forward<decltype(space)>(space); });
|
|
}
|
|
|
|
void JSBroadcastChannel::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
|
|
{
|
|
auto* thisObject = jsCast<JSBroadcastChannel*>(cell);
|
|
analyzer.setWrappedObjectForCell(cell, &thisObject->wrapped());
|
|
if (thisObject->scriptExecutionContext())
|
|
analyzer.setLabelForCell(cell, "url "_s + thisObject->scriptExecutionContext()->url().string());
|
|
Base::analyzeHeap(cell, analyzer);
|
|
}
|
|
|
|
bool JSBroadcastChannelOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, AbstractSlotVisitor& visitor, const char** reason)
|
|
{
|
|
auto* jsBroadcastChannel = jsCast<JSBroadcastChannel*>(handle.slot()->asCell());
|
|
auto& wrapped = jsBroadcastChannel->wrapped();
|
|
if (/*!wrapped.isContextStopped() && */ wrapped.hasPendingActivity()) {
|
|
if (UNLIKELY(reason))
|
|
*reason = "ActiveDOMObject with pending activity";
|
|
return true;
|
|
}
|
|
UNUSED_PARAM(visitor);
|
|
UNUSED_PARAM(reason);
|
|
return false;
|
|
}
|
|
|
|
void JSBroadcastChannelOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
|
|
{
|
|
auto* jsBroadcastChannel = static_cast<JSBroadcastChannel*>(handle.slot()->asCell());
|
|
auto& world = *static_cast<DOMWrapperWorld*>(context);
|
|
uncacheWrapper(world, &jsBroadcastChannel->wrapped(), jsBroadcastChannel);
|
|
}
|
|
|
|
#if ENABLE(BINDING_INTEGRITY)
|
|
#if PLATFORM(WIN)
|
|
#pragma warning(disable : 4483)
|
|
extern "C" {
|
|
extern void (*const __identifier("??_7BroadcastChannel@WebCore@@6B@")[])();
|
|
}
|
|
#else
|
|
extern "C" {
|
|
extern void* _ZTVN7WebCore16BroadcastChannelE[];
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<BroadcastChannel>&& impl)
|
|
{
|
|
|
|
if constexpr (std::is_polymorphic_v<BroadcastChannel>) {
|
|
#if ENABLE(BINDING_INTEGRITY)
|
|
const void* actualVTablePointer = getVTablePointer(impl.ptr());
|
|
#if PLATFORM(WIN)
|
|
void* expectedVTablePointer = __identifier("??_7BroadcastChannel@WebCore@@6B@");
|
|
#else
|
|
void* expectedVTablePointer = &_ZTVN7WebCore16BroadcastChannelE[2];
|
|
#endif
|
|
|
|
// If you hit this assertion you either have a use after free bug, or
|
|
// BroadcastChannel has subclasses. If BroadcastChannel has subclasses that get passed
|
|
// to toJS() we currently require BroadcastChannel you to opt out of binding hardening
|
|
// by adding the SkipVTableValidation attribute to the interface IDL definition
|
|
RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
|
|
#endif
|
|
}
|
|
return createWrapper<BroadcastChannel>(globalObject, WTFMove(impl));
|
|
}
|
|
|
|
JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, BroadcastChannel& impl)
|
|
{
|
|
return wrap(lexicalGlobalObject, globalObject, impl);
|
|
}
|
|
|
|
BroadcastChannel* JSBroadcastChannel::toWrapped(JSC::VM&, JSC::JSValue value)
|
|
{
|
|
if (auto* wrapper = jsDynamicCast<JSBroadcastChannel*>(value))
|
|
return &wrapper->wrapped();
|
|
return nullptr;
|
|
}
|
|
|
|
}
|