New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for nomodule content attribute on script elements #4611
Conversation
Notifying @Ms2ger, @ayg, @gsnedders, @jdm, @jgraham, @sideshowbarker, @zcorpan, and @zqzhang. (Learn how reviewing works.) |
|
||
test(() => { | ||
assert_false(document.getElementById('moduleWithoutNomodule').noModule); | ||
}, 'noModule IDL attribute must return true on a parser created module script element with nomodule content attribute'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test name is wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest removing all "must return X" from the test names; they tend to get out of sync and there is little value in stating the pass condition in the test name IMO. The assertion message will say what was expected if the test fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done that (removing must return X).
assert_equals(loaded, true); | ||
assert_equals(errored, false); | ||
}); | ||
}, 'An external classic script element dynamically inserted after noModule was set to false must run.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test doesn't actually set noModule
to false; suggest "without setting noModule" or so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that was a bug. Fixed by adding the assignment.
element.onerror = () => { errored = true; } | ||
setTimeout(resolve, 200); | ||
}).then(() => { | ||
assert_equals(window.executed, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't the first test set window.executed
to true? Maybe they should use different properties or be separate test files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nomodule-set-on-async-classic-script.html looks like it tries to address this; is this file an earlier version of that one? If so, I guess this file should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, you're right. Removed this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to remove this file.
assert_equals(typeof exportedCocoa, 'object'); | ||
assert_equals(exportedCocoa.taste(), 'awesome'); | ||
}); | ||
}, 'An inline module script with nomodule content attribute must run'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/inline/external/
|
||
test(() => { | ||
assert_true(executed); | ||
}, 'An inline classic script with nomodule content attribute must run'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/with/without/
assert_true(executed); | ||
assert_true(loaded); | ||
assert_false(errored); | ||
}, 'A synchronously loaded external classic script with nomodule content attribute must run'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/with/without/
@@ -0,0 +1 @@ | |||
window.executed = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could set document.currentScript.executed = true
instead, to avoid keeping track of ordering in tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document.currentScript doesn't work for module scripts, does it?
FAIL: 20/10 says https://travis-ci.org/w3c/web-platform-tests/jobs/194747170 @jgraham what is the cause there? |
@sideshowbarker says the cause is duplicate test names. |
d38e369
to
f1e53e2
Compare
Ping reviewers. I've pushed a new commit after rebasing. |
assert_true(loaded); | ||
assert_false(errored); | ||
}); | ||
}, 'An asynchronously loaded classic script without noModule set to false must run'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/without/with/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, fixed.
assert_false(loaded); | ||
assert_false(errored); | ||
}); | ||
}, 'An asynchronously loaded classic script without noModule set to true must not run'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/without/with/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<!-- Load this script synchronously to ensure test cases below can load it in 200ms --> | ||
<script src="resources/set-window-executed.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these should be set-script-executed.js
(or rename the file to set-window-executed.js
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
f1e53e2
to
c240d2e
Compare
LGTM except this comment appears to be unaddressed: |
This feature is being added in whatwg/html#2261 Converted the tests in https://trac.webkit.org/r211078 to use testharness.js, refined the test for IDL attribute reflecting content attribute, and re-organized tests.
c240d2e
to
aedf8ac
Compare
Oh strange. Removed for sure this time. |
Thanks so much!! |
@rniwa we run this test in automation at Mozilla and there are intermittent failures (we set this to expect failure and it intermittently passes) as documented in https://bugzilla.mozilla.org/show_bug.cgi?id=1344486. Is there more we can do to make this test stable? |
You could add a feature check and fail the test early if |
This feature is being added in whatwg/html#2261
Converted the tests in https://trac.webkit.org/r211078 to use testharness.js,
refined the test for IDL attribute reflecting content attribute, and re-organized tests.