Bug 237912 - REGRESSION(r288307): instanceof value wrong in MutationObserver callback for Safari extensions
Summary: REGRESSION(r288307): instanceof value wrong in MutationObserver callback for ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Bindings (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Blocker
Assignee: Alexey Shvayka
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-03-15 11:42 PDT by Jeff Johnson
Modified: 2022-03-22 13:26 PDT (History)
8 users (show)

See Also:


Attachments
Sample Xcode project (324.10 KB, application/zip)
2022-03-15 11:42 PDT, Jeff Johnson
no flags Details
Patch (9.46 KB, patch)
2022-03-22 09:01 PDT, Alexey Shvayka
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Johnson 2022-03-15 11:42:12 PDT
Created attachment 454735 [details]
Sample Xcode project

This bug occurs with Safari Technology Release 141 (Safari 15.4, WebKit 16614.1.3.7) on macOS 11.6.5. The bug does not occur with Safari 15.3 or Safari 15.4 (released yesterday), only with Safari Technology Preview.

The bug is that JavaScript instanceof is returning false when it should return true in the callback of MutationObserver for Safari extensions, both Safari web extensions and Safari app extensions. This bug does not seem to affect scripts in the web pages, only extension scripts.

Attached is a sample Safari web extension Xcode project that demonstrates the bug. Just enable the extension, run it on any web site, such as cnn.com, and look at the console log. For HTML <div> elements, it should log true true for instanceof HTMLElement and instanceof HTMLDivElement, but it logs false false in Safari Technology Preview 141.

This bug is a massive problem for me, a showstopper for several of my Safari extensions in the App Store. It totally breaks essential functionality in my extensions.
Comment 1 Jeff Johnson 2022-03-15 11:44:40 PDT
Note that instanceof works correctly in the setTimeout function. It's only wrong in the MutationObserver callback.
Comment 2 Jeff Johnson 2022-03-15 12:10:15 PDT
I can also reproduce with Safari Technology Preview 141 on macOS 12.3 on Apple Silicon. Safari 15.4 (17613.1.17.1.6) is not affected.
Comment 3 Jon Davis 2022-03-15 13:39:52 PDT
Thank you for the bug report. I’ve cc’d some engineers to investigate.
Comment 4 Radar WebKit Bug Importer 2022-03-15 15:12:14 PDT
<rdar://problem/90333276>
Comment 5 Alexey Shvayka 2022-03-22 09:01:29 PDT
Created attachment 455377 [details]
Patch
Comment 6 EWS 2022-03-22 13:25:31 PDT
Committed r291694 (248736@main): <https://commits.webkit.org/248736@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 455377 [details].