Worker: Abort all inflight tasks in Worklet::ContextDestroyed()

Before this CL, all inflight tasks can be retained in
Worklet::pending_tasks_set_ even after context destruction, and that causes
dcheck failures in the destructor of Worklet. This CL fixes it by aborting them
in Worklet::ContextDestroyed().

In addition, this CL adds test coverage of addModule() calls on a detached
iframe. In the tests, LayoutWorklet is used for testing main thread worklets
instead of PaintWorklet because PaintWorklet will be switched to
off-the-main-thread worklets (see

Bug: 962355
Change-Id: I7da71e7f4bdcbfa20125853832122a733c118a7a
Reviewed-by: Matt Falkenhagen <>
Commit-Queue: Hiroki Nakagawa <>
Cr-Commit-Position: refs/heads/master@{#662923}
2 files changed