浏览代码

LibWeb: Generate binding for `HTMLObjectElement.contentWindow` attribute

This only required adding the appropriate definition to the IDL file,
as `NavigableContainer` already implements the logic that we need.
Tim Ledbetter 1 年之前
父节点
当前提交
c36ba450be

+ 2 - 0
Tests/LibWeb/Text/expected/HTML/HTMLObjectElement-contentWindow.txt

@@ -0,0 +1,2 @@
+object.contentWindow initial value should be null: true
+contentWindow.name should be the same as object.name PASS

+ 19 - 0
Tests/LibWeb/Text/input/HTML/HTMLObjectElement-contentWindow.html

@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script>
+    asyncTest(done => {        
+        const objectElement = document.createElement("object");
+        println(`object.contentWindow initial value should be null: ${objectElement.contentWindow === null}`);
+        objectElement.type = "text/html";
+        objectElement.name = "PASS"
+        // FIXME: about:srcdoc is being used here as a convenient way to load a blank document. This isn't cross browser compatible.
+        objectElement.data = "about:srcdoc";
+        objectElement.onload = () => {
+            println(`contentWindow.name should be the same as object.name ${objectElement.contentWindow.name}`);
+            document.body.removeChild(objectElement);
+            done();     
+        };
+
+        document.body.appendChild(objectElement);
+    });
+</script>

+ 1 - 1
Userland/Libraries/LibWeb/HTML/HTMLObjectElement.idl

@@ -14,7 +14,7 @@ interface HTMLObjectElement : HTMLElement {
     [CEReactions, Reflect] attribute DOMString width;
     [CEReactions, Reflect] attribute DOMString width;
     [CEReactions, Reflect] attribute DOMString height;
     [CEReactions, Reflect] attribute DOMString height;
     readonly attribute Document? contentDocument;
     readonly attribute Document? contentDocument;
-    // FIXME: readonly attribute WindowProxy? contentWindow;
+    readonly attribute WindowProxy? contentWindow;
     Document? getSVGDocument();
     Document? getSVGDocument();
 
 
     // FIXME: readonly attribute boolean willValidate;
     // FIXME: readonly attribute boolean willValidate;