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


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test name is wrong.

Copy link
Member

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.

Copy link
Contributor Author

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

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

Copy link
Contributor Author

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

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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

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

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

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

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?

Copy link
Contributor Author

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?

@zcorpan
Copy link
Member

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 commented Jan 24, 2017

@sideshowbarker says the cause is duplicate test names.

@rniwa
Copy link
Contributor Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/without/with/

Copy link
Contributor Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/without/with/

Copy link
Contributor Author

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

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@zcorpan
Copy link
Member

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
Copy link
Contributor Author

rniwa commented Jan 31, 2017

Oh strange. Removed for sure this time.

@domenic
Copy link
Member

domenic commented Jan 31, 2017

Thanks so much!!

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

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 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 August 22, 2019 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants