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

Originator:greg
Number:rdar://30298722 Date Originated:2017-01-31
Status:Resolved Resolved:2017-02-06
Product:iOS + SDK Product Version:10.3 / 14E5230e
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.

Steps to Reproduce:

1. Unzip the attached "JavaScriptPathBug_iOS.zip" file <https://smilesoftware.com/static/bugs/JavaScriptPathBug_iOS.zip>
2. Open JavaScriptPathBug_iOS.xcodeproj contained within in Xcode 8.3 beta (8W109m)
3. Choose the iPhone 7 / 10.3 Simulator
4. Run the project
5. Dismiss the alert with text "direct alert"
*. You'll see "Hello world!" as the app content

6. Open Safari with the Develop menu enabled
7. Choose Develop -> Simulator -> JS Bug -> JavaScriptBug.html
8. 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 Simulator.png" file)

Expected Result:

Expected to see second alert with text "indirect alert from separate JavaScript file" after step 5 above.

Actual Result:

Found in steps to reproduce.

Can also reproduce on iPad mini Retina running 10.3 beta (14E5230e).

Functions properly on iPhone 7 Simulator running 10.2.

Functions properly on iPhone 7 hardware running 10.2.1 (14D27).

Hardware:

iPad mini Retina (MF086LL/A)

iOS:

10.3 (14E5230e)

Comments:

If you visit the Build Settings and change the Product Name from "JS Bug" to "JS_Bug"–that is, eliminate the space–you'll find that this will work properly on 10.3 as well.

Related to: rdar://30288608

Comments

Resolved in 10.3 beta 2

This appears to be resolved in 10.3 beta 2 (14E5239e).


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!