diff --git a/common/security-features/resources/common.sub.js b/common/security-features/resources/common.sub.js index b43417b417c189..cdd20a9d8daece 100644 --- a/common/security-features/resources/common.sub.js +++ b/common/security-features/resources/common.sub.js @@ -286,9 +286,17 @@ function bindEvents2(resolveObject, resolveEventName, rejectObject, rejectEventN function createElement(tagName, attrs, parentNode, doBindEvents) { var element = document.createElement(tagName); - if (doBindEvents) + if (doBindEvents) { bindEvents(element); - + if (element.tagName == "IFRAME" && !('srcdoc' in attrs || 'src' in attrs)) { + // If we're loading a frame, ensure we spin the event loop after load to + // paper over the different event timing in Gecko vs Blink/WebKit + // see https://github.com/whatwg/html/issues/4965 + element.eventPromise = element.eventPromise.then(() => { + return new Promise(resolve => setTimeout(resolve, 0)) + }); + } + } // We set the attributes after binding to events to catch any // event-triggering attribute changes. E.g. form submission. // diff --git a/lint.whitelist b/lint.whitelist index be6ae4f0314942..48d7e9d6a747b9 100644 --- a/lint.whitelist +++ b/lint.whitelist @@ -282,6 +282,7 @@ GENERATE_TESTS: shadow-dom/untriaged/shadow-trees/upper-boundary-encapsulation/w GENERATE_TESTS: shadow-dom/untriaged/shadow-trees/upper-boundary-encapsulation/window-named-properties-003.html # Intentional use of setTimeout +SET TIMEOUT: common/security-features/resources/common.sub.js SET TIMEOUT: css/css-fonts/font-display/font-display.html SET TIMEOUT: css/css-fonts/font-display/font-display-change.html SET TIMEOUT: css/css-fonts/font-display/font-display-change-ref.html