Skip to content

Commit

Permalink
LibWeb: Set correct prototype for WorkerLocation
Browse files Browse the repository at this point in the history
  • Loading branch information
tcl3 committed Jul 28, 2024
1 parent 7f40a19 commit b779d62
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions Tests/LibWeb/Text/expected/Worker/Worker-location.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location global object URL final segment: Worker-location.js
11 changes: 11 additions & 0 deletions Tests/LibWeb/Text/input/Worker/Worker-location.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script src="../include.js"></script>
<script>
asyncTest(done => {
let work = new Worker("Worker-location.js");
work.onmessage = (evt) => {
const locationURL = new URL(evt.data);
println(`location global object URL final segment: ${locationURL.pathname.split('/').pop()}`);
done();
};
});
</script>
1 change: 1 addition & 0 deletions Tests/LibWeb/Text/input/Worker/Worker-location.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
postMessage(location.toString());
6 changes: 6 additions & 0 deletions Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions Userland/Libraries/LibWeb/HTML/WorkerLocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<WorkerGlobalScope> m_global_scope;
Expand Down

0 comments on commit b779d62

Please sign in to comment.