Skip to content

Commit

Permalink
Don't assume sync dispatch of iframe load event in tests
Browse files Browse the repository at this point in the history
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

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1598674
gecko-commit: 2b978939b653b8531e27dc20fa12587db6f3338a
gecko-integration-branch: autoland
gecko-reviewers: bzbarsky
  • Loading branch information
jgraham committed Nov 24, 2019
1 parent d854782 commit ff1ea7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions common/security-features/resources/common.sub.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down
1 change: 1 addition & 0 deletions lint.whitelist
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ff1ea7c

Please sign in to comment.