dart-sdk/tools/dom
Nicholas Shahan 4c2edfd5b9 [html] Make cancel() always return synchronously
Before Null Safety, `_EventStreamSubscription.cancel()` used a trick
to run with synchronous timing even though it was typed to return a
`Future`. During the migration of the SDK to support Null Safety it
kept the synchronous timing in weak mode, but was changed to
asynchronous in sound mode so that the behavior matched the method
signature. In hindsight, changing the timing when opting into Null
Safety is problematic:

* A shared package has no control over what mode it runs in. Libraries
  may be opted in and run their tests with sound null safety but the
  apps they are used in could still be running in weak mode. This
  results in library unit tests that behave differently than the
  production app that deploys the code.

* This codepath can be triggered by EventTarget.dispatchEvent() from
  dart:html which should have synchronous timings for the event
  listeners before returning to the calling code. The asynchronous
  timing when running with sound null safety is inconsistent with the
  browser API.

This change reverses that migration decision and keeps the synchronous
timing in both modes. To support this in sound mode it returns a
special future value that is internal to the SDK and known to be used
for synchronous timing.

This change also removes the workaround introduced in DDC to avoid
warning/failing when `_EventStreamSubscription.cancel()` returned
null and the extra warnings/errors features were enabled in weak
null safety mode.

Change-Id: I6b08a2ada5b10120bea787ad59d1d58e6e181de5
Fixes: https://github.com/dart-lang/sdk/issues/44157
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175323
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-12-09 01:44:38 +00:00
..
docs [dart:html] Add track event to RTCPeerConnection 2020-06-12 00:42:36 +00:00
idl/dart [dart:html] Make browser-incompatible attributes nullable 2020-05-16 03:47:12 +00:00
new_scripts Mass format python with yapf 2019-08-05 20:34:31 +00:00
scripts [dart:html] Remove added types from promise dict 2020-09-14 23:23:47 +00:00
src [html] Make cancel() always return synchronously 2020-12-09 01:44:38 +00:00
templates [html] update templates for code accidentally changed in the generated code 2020-09-25 21:34:54 +00:00
.gitignore
dom.json Fixed a number of dart:html P1 issues. 2019-01-15 17:21:50 +00:00
dom.py Mass format python with yapf 2019-08-05 20:34:31 +00:00
PRESUBMIT.py Mass format python with yapf 2019-08-05 20:34:31 +00:00