فهرست منبع

LibWeb: Fire iframe load event on document close

This matches the behavior of other browsers.
Tim Ledbetter 9 ماه پیش
والد
کامیت
e1eeb93cc6

+ 1 - 0
Tests/LibWeb/Text/expected/HTML/document-close-iframe-load-event.txt

@@ -0,0 +1 @@
+Onload event fired

+ 15 - 0
Tests/LibWeb/Text/input/HTML/document-close-iframe-load-event.html

@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script>
+    asyncTest(done => {
+        const iframe = document.createElement('iframe');
+        document.body.appendChild(iframe);
+        iframe.contentDocument.open();
+        iframe.onload = () => {
+            println("Onload event fired");
+            iframe.remove();
+            done();
+        };
+        iframe.contentDocument.close();
+    });
+</script>

+ 3 - 0
Userland/Libraries/LibWeb/DOM/Document.cpp

@@ -705,6 +705,9 @@ WebIDL::ExceptionOr<void> Document::close()
     // FIXME: 6. Run the tokenizer, processing resulting tokens as they are emitted, and stopping when the tokenizer reaches the explicit "EOF" character or spins the event loop.
     // FIXME: 6. Run the tokenizer, processing resulting tokens as they are emitted, and stopping when the tokenizer reaches the explicit "EOF" character or spins the event loop.
     m_parser->run();
     m_parser->run();
 
 
+    // AD-HOC: This ensures that a load event is fired if the node navigable's container is an iframe.
+    completely_finish_loading();
+
     return {};
     return {};
 }
 }