Bug 1598674 - Don't assume sync dispatch of iframe load event in tests, r=bzbarsky

Blink and WebKit dispatch the load event of the iframe synchronously,
whereas Gecko and (currently) the spec assume it's async. This causes
a hang in some tests using this helper library because in Gecko a
subsequent load ends up running in the event dispatch of the initial
load event, and so the load event is suppressed and the tests are
unable to complete. In other browsers the event is not suppressed and
so the tests run.

Avoid this by ensuring that the event loop always spins after the
iframe load.

Differential Revision: https://phabricator.services.mozilla.com/D54343

--HG--
extra : moz-landing-system : lando
This commit is contained in:
James Graham 2019-11-23 15:51:06 +00:00
Родитель f7d5f84265
Коммит d4c5f507d1
2 изменённых файлов: 11 добавлений и 2 удалений

Просмотреть файл

@ -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.
//

Просмотреть файл

@ -292,6 +292,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