Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

test(*): fix tests involving submit on Chrome 60 #16141

Closed
wants to merge 2 commits into from

Conversation

gkalpak
Copy link
Member

@gkalpak gkalpak commented Aug 2, 2017

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Test fix.

What is the current behavior? (You can also link to an open issue here)
Some tests involving submit fail on Windows with Chrome 60.

What is the new behavior (if this is a feature change)?
All tests pass.

Does this PR introduce a breaking change?
No

Please check if the PR fulfills these requirements

Other information:
On Chrome 60 (at least on Windows) the submit event when clicking on a submit button is not fired on the form element, unless it is already part of the DOM.

@@ -420,15 +423,18 @@ describe('form', function() {
inject(function($timeout) {
doc = jqLite('<div>' +
'<form ng-submit="submitMe()">' +
'<button ng-click="destroy()"></button>' +
'<button type="submit" ng-click="destroy()"></button>' +
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this necessary? I think if there's no other button, then the first button is the submit button

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it is not necessary. Just making it more explicit for people that might not know.

@@ -386,6 +386,9 @@ describe('form', function() {
doc = jqLite('<form ng-submit="submitMe()">' +
'<input type="submit" value="submit">' +
'</form>');
// Support: Chrome 60+ (on Windows)
// We need to add the form to the DOM in order for `submit` events to be properly fired.
window.document.body.appendChild(doc[0]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't all of these memory leaks? Or is there some global cleanup between tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

We empty body before each test.

@@ -460,6 +466,7 @@ describe('form', function() {
.runs(function() {
expect(doc.html()).toBe('');
expect(destroyed).toBe(true);
expect(reloadPrevented).toBe('never called');
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this unrelated to the other changes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes 😁

Copy link
Contributor

Choose a reason for hiding this comment

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

The test results disagree with this expectation
👀
⭕️

And based on the description I also would expect that this is true.

Copy link
Member Author

@gkalpak gkalpak Aug 2, 2017

Choose a reason for hiding this comment

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

They agree locally (probably a Windows thing) 😕

Copy link
Member Author

Choose a reason for hiding this comment

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

So, it turns out the cause is again that Chrome 60+ on Windows does not fire submit events if the form is not attached to the DOM. Changed the expectation to verify that the submit event is eithr never fired or (if fired) the reload is prevented.

Copy link
Contributor

@Narretz Narretz left a comment

Choose a reason for hiding this comment

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

LGTM. We should obviously try to test on Chrome 60 on Travis some time soon.

@Narretz
Copy link
Contributor

Narretz commented Aug 3, 2017

Looks like chrome 60 is not yet available

@gkalpak gkalpak force-pushed the test-fix-submit-on-Windows branch from dca8e13 to 0e2f4d8 Compare August 3, 2017 19:13
@gkalpak
Copy link
Member Author

gkalpak commented Aug 3, 2017

Yeah. Trying 59 😃

On Chrome 60 (at least on Windows) the `submit` event when clicking on a submit
button is not fired on the form element, unless it is already part of the DOM.
@gkalpak gkalpak force-pushed the test-fix-submit-on-Windows branch 2 times, most recently from 611631a to 527fe6f Compare August 4, 2017 00:15
@gkalpak gkalpak force-pushed the test-fix-submit-on-Windows branch from 527fe6f to 4a3c001 Compare August 4, 2017 08:01
@gkalpak
Copy link
Member Author

gkalpak commented Aug 4, 2017

Also updated to latest version for Chrome (59) and Firefox (54) available on Saucelabs.
Merging...

gkalpak added a commit that referenced this pull request Aug 4, 2017
@gkalpak gkalpak closed this in 56ac2a7 Aug 4, 2017
@gkalpak gkalpak deleted the test-fix-submit-on-Windows branch February 7, 2018 15:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants