feat(cdk): implement waitForTasksOutsideAngular in ProtractorHarnessEnvironment#18361
Conversation
ProtractorHarnessEnvironment Fixes angular#17412
| // https://github.com/angular/components/issues/17412 | ||
| await browser.executeAsyncScript( | ||
| 'var callback = arguments[arguments.length - 1];' | ||
| + 'requestAnimationFrame(callback);'); |
There was a problem hiding this comment.
I think we need to spend more time thinking about this. e.g. requestAnimationFrame does not wait for macro tasks (as our task interceptor does in the testbed environment).
There was a problem hiding this comment.
It doesn't? My first attempt used setTimout, but I thought rAF waited for both micro and macro task queues to clear.
There was a problem hiding this comment.
If so, we could call the async script callback only after setTimeout(..., 1) and requestAnimationFrame have resolved.
There was a problem hiding this comment.
I think we should be able to use a similar strategy to what we did for the TestbedHarnessEnvironment, we'll just need to run the task interceptor as a browser script
There was a problem hiding this comment.
@LayZeeDK I might miss something here, but won't things like setTimeout and requestAnimationFrame never work here because we don't know what durations the macro tasks take? e.g. the component could have something like setTimeout(..., 300) inside.
This is why we need ZoneJS here since it can capture that information for us. I think what @mmalerba proposed seems right. I'm unsure how it will work yet, but it should be possible.
There was a problem hiding this comment.
Alright, so you want to patch the environment with zones or similar like the TestBed harness environment.
Two issues which might be an entirely separate discussion of their own:
- With ES2017+ bundles, it's not possible to intercept async-await.
- Can we support applications using NoopNgZone with the task interceptor?
There was a problem hiding this comment.
I think for this PR we should just focus on getting protractor working with es2015 and using NgZone. That's what we currently support for the TestbedHarnessEnvironment.
- Yeah, that is a separate issue that affects many parts of Angular, it is being tracked here: angular with tsconfig target ES2017 async/await will not work with zone.js angular#31730
- Currently we have not tested it with
NoopNgZoneand my guess is it won't work. If you have thoughts/ideas about this please feel free to open a new issue for the feature and discuss them there.
|
Is v9 going to be released without this implemented? |
At this point, most likely yes, this will have to go in a follow-up patch release |
|
Thanks for answering. How do we proceed from here? Do I close this PR? Open an issue? I don't have any immediate thoughts on baking the task interceptor into a Protractor environment. |
|
Ok, I'll close this PR. I created an issue to track this here: #18375 |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Implement
waitForTasksOutsideAngularinProtractorHarnessEnvironment.Fixes #17412 for Protractor.
How do we best test this? I see some CDK and Material directives and components using
setTimeoutandrequestAnimationFrame.