From b779d625c65924eed4ec1b3250f3925dc4bb2fc1 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Sun, 28 Jul 2024 19:14:45 +0100 Subject: [PATCH] LibWeb: Set correct prototype for `WorkerLocation` --- Tests/LibWeb/Text/expected/Worker/Worker-location.txt | 1 + Tests/LibWeb/Text/input/Worker/Worker-location.html | 11 +++++++++++ Tests/LibWeb/Text/input/Worker/Worker-location.js | 1 + Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp | 6 ++++++ Userland/Libraries/LibWeb/HTML/WorkerLocation.h | 1 + 5 files changed, 20 insertions(+) create mode 100644 Tests/LibWeb/Text/expected/Worker/Worker-location.txt create mode 100644 Tests/LibWeb/Text/input/Worker/Worker-location.html create mode 100644 Tests/LibWeb/Text/input/Worker/Worker-location.js diff --git a/Tests/LibWeb/Text/expected/Worker/Worker-location.txt b/Tests/LibWeb/Text/expected/Worker/Worker-location.txt new file mode 100644 index 000000000000..a755bb81df22 --- /dev/null +++ b/Tests/LibWeb/Text/expected/Worker/Worker-location.txt @@ -0,0 +1 @@ +location global object URL final segment: Worker-location.js diff --git a/Tests/LibWeb/Text/input/Worker/Worker-location.html b/Tests/LibWeb/Text/input/Worker/Worker-location.html new file mode 100644 index 000000000000..197493de833f --- /dev/null +++ b/Tests/LibWeb/Text/input/Worker/Worker-location.html @@ -0,0 +1,11 @@ + + diff --git a/Tests/LibWeb/Text/input/Worker/Worker-location.js b/Tests/LibWeb/Text/input/Worker/Worker-location.js new file mode 100644 index 000000000000..7e7005adfa43 --- /dev/null +++ b/Tests/LibWeb/Text/input/Worker/Worker-location.js @@ -0,0 +1 @@ +postMessage(location.toString()); diff --git a/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp b/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp index 272292f2c8f8..418a20f13104 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp @@ -142,6 +142,12 @@ WorkerLocation::WorkerLocation(WorkerGlobalScope& global_scope) WorkerLocation::~WorkerLocation() = default; +void WorkerLocation::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + WEB_SET_PROTOTYPE_FOR_INTERFACE(WorkerLocation); +} + void WorkerLocation::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/HTML/WorkerLocation.h b/Userland/Libraries/LibWeb/HTML/WorkerLocation.h index 372f1ba7d977..1d7bf75f7d06 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerLocation.h +++ b/Userland/Libraries/LibWeb/HTML/WorkerLocation.h @@ -31,6 +31,7 @@ class WorkerLocation : public Bindings::PlatformObject { private: explicit WorkerLocation(WorkerGlobalScope&); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::NonnullGCPtr m_global_scope;