script: improve spec compliance of the iframe load event steps (#40100)

Prevent the running of the iframe load event steps for the initial
about:blank document. Part of
https://github.com/servo/servo/issues/31973

Testing:
/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/iframe-nosrc.html
Fixes: It is expected that the intermittent issue of 34819 will go away,
but I will leave it open so we can close it when we realize it isn't
being mentioned by PR's anymore.

https://github.com/servo/servo/issues/34819

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
This commit is contained in:
Gregory Terzian
2025-11-03 15:08:37 +08:00
committed by GitHub
parent 0cb310e46c
commit f174c53fee
3 changed files with 86 additions and 28 deletions

View File

@@ -80,6 +80,7 @@ use crate::dom::node::{
use crate::dom::nodelist::{NodeList, RadioListMode};
use crate::dom::radionodelist::RadioNodeList;
use crate::dom::submitevent::SubmitEvent;
use crate::dom::types::HTMLIFrameElement;
use crate::dom::virtualmethods::VirtualMethods;
use crate::dom::window::Window;
use crate::links::{LinkRelations, get_element_target};
@@ -1061,6 +1062,17 @@ impl HTMLFormElement {
load_data.referrer = referrer;
load_data.referrer_policy = referrer_policy;
// Note the pending form navigation if this is an iframe;
// necessary for deciding whether to run the iframe load event steps.
if let Some(window_proxy) = target.undiscarded_window_proxy() {
if let Some(frame) = window_proxy
.frame_element()
.and_then(|e| e.downcast::<HTMLIFrameElement>())
{
frame.note_pending_navigation()
}
}
// 4. Queue an element task on the DOM manipulation task source
// given the form element and the following steps:
let form = Trusted::new(self);