From 8aabec1c94251b859f227dd2d6e69f7426117723 Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 31 Aug 2020 14:08:10 +0100 Subject: [PATCH] LibWeb: Expose window.self and window.frames "self" is a way to refer to the global object that will work in both a window context and a web worker context. "frames" apparently used to return a list of frame objects according to MDN, but it now just returns the window object. --- Libraries/LibWeb/Bindings/WindowObject.cpp | 2 ++ .../LibWeb/Tests/Window/window.window_frames_self.js | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 Libraries/LibWeb/Tests/Window/window.window_frames_self.js diff --git a/Libraries/LibWeb/Bindings/WindowObject.cpp b/Libraries/LibWeb/Bindings/WindowObject.cpp index b2843531a8..ff4a6cf45b 100644 --- a/Libraries/LibWeb/Bindings/WindowObject.cpp +++ b/Libraries/LibWeb/Bindings/WindowObject.cpp @@ -59,6 +59,8 @@ void WindowObject::initialize() GlobalObject::initialize(); define_property("window", this, JS::Attribute::Enumerable); + define_property("frames", this, JS::Attribute::Enumerable); + define_property("self", this, JS::Attribute::Enumerable); define_native_property("document", document_getter, document_setter, JS::Attribute::Enumerable); define_native_function("alert", alert); define_native_function("confirm", confirm); diff --git a/Libraries/LibWeb/Tests/Window/window.window_frames_self.js b/Libraries/LibWeb/Tests/Window/window.window_frames_self.js new file mode 100644 index 0000000000..1d7799843e --- /dev/null +++ b/Libraries/LibWeb/Tests/Window/window.window_frames_self.js @@ -0,0 +1,8 @@ +loadPage("file:///res/html/misc/blank.html"); + +afterInitialPageLoad(() => { + test("window.{window,frames,self} all return the Window object", () => { + expect(window.window).toBe(window.frames); + expect(window.window).toBe(window.self); + }); +});