Skip to content
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

Merged
merged 1 commit into from Jan 31, 2017

Conversation

@rniwa
Copy link
Contributor

@rniwa rniwa commented Jan 24, 2017

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.

@wpt-pr-bot
Copy link
Collaborator

@wpt-pr-bot wpt-pr-bot commented Jan 24, 2017


test(() => {
assert_false(document.getElementById('moduleWithoutNomodule').noModule);
}, 'noModule IDL attribute must return true on a parser created module script element with nomodule content attribute');
Copy link
Contributor

@Ms2ger Ms2ger Jan 24, 2017

Test name is wrong.

Copy link
Member

@zcorpan zcorpan Jan 24, 2017

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.

Copy link
Contributor Author

@rniwa rniwa Jan 24, 2017

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.');
Copy link
Member

@zcorpan zcorpan Jan 24, 2017

The test doesn't actually set noModule to false; suggest "without setting noModule" or so

Copy link
Contributor Author

@rniwa rniwa Jan 24, 2017

Oh that was a bug. Fixed by adding the assignment.

element.onerror = () => { errored = true; }
setTimeout(resolve, 200);
}).then(() => {
assert_equals(window.executed, false);
Copy link
Member

@zcorpan zcorpan Jan 24, 2017

Doesn't the first test set window.executed to true? Maybe they should use different properties or be separate test files?

Copy link
Member

@zcorpan zcorpan Jan 24, 2017

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.

Copy link
Contributor Author

@rniwa rniwa Jan 24, 2017

Oops, you're right. Removed this.

Copy link
Member

@zcorpan zcorpan Jan 26, 2017

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');
Copy link
Member

@zcorpan zcorpan Jan 24, 2017

s/inline/external/


test(() => {
assert_true(executed);
}, 'An inline classic script with nomodule content attribute must run');
Copy link
Member

@zcorpan zcorpan Jan 24, 2017

s/with/without/

assert_true(executed);
assert_true(loaded);
assert_false(errored);
}, 'A synchronously loaded external classic script with nomodule content attribute must run');
Copy link
Member

@zcorpan zcorpan Jan 24, 2017

s/with/without/

@@ -0,0 +1 @@
window.executed = true;
Copy link
Member

@zcorpan zcorpan Jan 24, 2017

Maybe this could set document.currentScript.executed = true instead, to avoid keeping track of ordering in tests?

Copy link
Contributor Author

@rniwa rniwa Jan 24, 2017

document.currentScript doesn't work for module scripts, does it?

@zcorpan
Copy link
Member

@zcorpan zcorpan commented Jan 24, 2017

FAIL: 20/10 says https://travis-ci.org/w3c/web-platform-tests/jobs/194747170

@jgraham what is the cause there?

@zcorpan
Copy link
Member

@zcorpan zcorpan commented Jan 24, 2017

@sideshowbarker says the cause is duplicate test names.

@rniwa rniwa force-pushed the add-nomodule-tests branch from d38e369 to f1e53e2 Jan 24, 2017
@rniwa
Copy link
Contributor Author

@rniwa rniwa commented Jan 26, 2017

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');
Copy link
Member

@zcorpan zcorpan Jan 26, 2017

s/without/with/

Copy link
Contributor Author

@rniwa rniwa Jan 30, 2017

Oops, fixed.

assert_false(loaded);
assert_false(errored);
});
}, 'An asynchronously loaded classic script without noModule set to true must not run');
Copy link
Member

@zcorpan zcorpan Jan 26, 2017

s/without/with/

Copy link
Contributor Author

@rniwa rniwa Jan 30, 2017

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>
Copy link
Member

@zcorpan zcorpan Jan 26, 2017

All of these should be set-script-executed.js (or rename the file to set-window-executed.js)

Copy link
Contributor Author

@rniwa rniwa Jan 30, 2017

Fixed

@rniwa rniwa force-pushed the add-nomodule-tests branch from f1e53e2 to c240d2e Jan 30, 2017
@zcorpan
Copy link
Member

@zcorpan zcorpan commented Jan 30, 2017

LGTM except this comment appears to be unaddressed:
#4611 (comment)

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.
@rniwa rniwa force-pushed the add-nomodule-tests branch from c240d2e to aedf8ac Jan 31, 2017
@rniwa
Copy link
Contributor Author

@rniwa rniwa commented Jan 31, 2017

Oh strange. Removed for sure this time.

@domenic
Copy link
Member

@domenic domenic commented Jan 31, 2017

Thanks so much!!

@domenic domenic merged commit c4725e5 into web-platform-tests:master Jan 31, 2017
1 check passed
@jmaher
Copy link
Contributor

@jmaher jmaher commented Mar 24, 2017

@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?

@zcorpan
Copy link
Member

@zcorpan zcorpan commented Mar 24, 2017

You could add a feature check and fail the test early if noModule is not supported.

@rniwa rniwa deleted the add-nomodule-tests branch Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants