WKWebView: JavaScripts fail to load from apps with spaces in their name

Originator:greg
Number:rdar://30288608 Date Originated:2017-01-31
Status:Duplicate Resolved:2017-02-06
Product:macOS Product Version:10.12.4 (16E144f)
Classification:Serious Bug Reproducible:Always
 
JavaScripts referenced by HTML loaded into a WKWebKitView by an application fail to load when the application name contains spaces.

This is a broad bug. If you quit Slack, rename it to "Slack X", and re-launch it (on 16E144f), it will simply show a blank window.

I've included a reductive case to demonstrate the issue as clearly as I can.

Steps to reproduce:

1. Start on a machine running 10.12.4 beta (16E144f)
2. Download and unzip the attached JavaScriptPathBug.zip file <https://smilesoftware.com/static/bugs/JavaScriptPathBug.zip>
3. Launch the JavaScriptPathBug app
*. You'll see both a direct then an indirect alert followed by "Hello, world!" in the window
4. Launch the "JavaScriptPathBug copy" app (a duplicate of the JavaScriptPathBug app but with a space in its name)
*. You'll only see the direct alert followed by "Hello, world!" in the window
5. Control-click on the window content and choose Inspect Element from the menu
6. Click Console, and you'll see the error: "Not allowed to load local resource <url>" followed by the error: "ReferenceError: Can't find variable: secondaryAlert" which is a consequence of the first error (see attached "Screen Shot 2017-01-31 at 10.00.59 AM.png" file)

Expected Result:

Expected that both "JavaScriptPathBug.app" and "JavaScriptPathBug copy.app" would behave identically.

Actual Result:

"JavaScriptPathBug copy.app" fails to load javaScriptBug.js.

Configuration:

MacBook Pro (Retina, 15-inch, Late 2013)
2.6 GHz Intel Core i7
16 GB 1600 MHz DDR3
NVIDIA GeForce GT 750M 2048 MB

macOS Version:

macOS 10.12.4 (16E144f)

Additional Notes:

Source is included in JavaScriptPathBug.zip for reference.

Comments

Considered duplicate of iOS bug

Closed as a duplicate of 30298722

Regression testing:

This problem appears to be new to 10.12.4, as it does NOT occur on 10.12.3 (16D32).


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!