WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED DUPLICATE of
bug 5140
4879
Included Javascript included in a page loaded with [WebFrame loadHTMLString:] is ignored
https://bugs.webkit.org/show_bug.cgi?id=4879
Summary
Included Javascript included in a page loaded with [WebFrame loadHTMLString:]...
Dan Wood
Reported
2005-09-07 19:19:32 PDT
If your webview is populated from [WebFrame loadHTMLString:] instead of [WebFrame loadRequest:], then javascript that is included (e.g. <script src='http://....' />) is ignored. Steps to reproduce: * Launch SnippetEditor (Apple Sample Code) * Paste in the following lines: <html><body><h1>Weather</h1> <script src='
http://voap.weather.com/weather/oap/94501
? template=HOMEV&par=null&unit=0&key=dee4cdf9e236b73c2cca35ff802a0339'></script> </body></html> * Click Button: Update from Text Expected Results: you should see the headline and a weather.com display Actual result: You only see the headline Notes: If you save the above snippet to a file, specify the URL of that file, and then do "Update from URL", you *will* see the weather information.
Attachments
Add attachment
proposed patch, testcase, etc.
Colin Barrett
Comment 1
2005-11-16 13:26:58 PST
I'm interested in looking at this. Later in the week, probably. Lost & Invasion are on tonight ;-)
James Howard
Comment 2
2005-11-17 16:36:28 PST
This seems to be fixed in WebKit version 420+ (current cvs).
Dan Wood
Comment 3
2005-11-17 20:15:55 PST
I just checked with TOT as of 11/17/05 and my test case still fails. I believe that the bug is still a real bug.
Dan Wood
Comment 4
2005-11-17 20:19:54 PST
Whoops, you're right, my test case does work now with TOT. However I still seem to be having related problems with Sandvox which is supposed to be doing the same thing, so I may have to create a new test case.
Dan Wood
Comment 5
2005-11-17 21:03:23 PST
OK, here's a new test case that shows the problem in TOT 11/17/05. In SnippetEditor, paste in the following lines: <html> <head> </head> <body> <h1>Apple hot news feed</h1> <script src="
http://service.karelia.com/feed.js.php?url=http://www.apple.com/main/rss/hotnews/
hotnews.rss&h=oEPs7zbjQNvNVMqi6eooSO1AuCA=&max=99&k=c79e4f32899dbb4758 96e72281be7f8217eaa211" type="text/javascript" /> <p>END</p> </body> Click "Update from Text" button. RESULTS: No output from the script is included in the page generated. ANALYSIS: The delay indicates to me that the javascript is actually executed, but it is as if the output generated is not being put into the page's output stream. Pasting that same HTML into a test.html file and loading it from Safari, the JavaScript outputs just fine. NOTE: You can see the javascript that should be inserted into the output stream with CURL (after de-escaping the &s in the URL to load: curl -i "
http://service.karelia.com/feed.js.php?url=http://www.apple.com/main/rss/hotnews/
hotnews.rss&h=oEPs7zbjQNvNVMqi6eooSO1AuCA=&max=99&k=c79e4f32899dbb475896e72281be7f 8217eaa211"
mitz
Comment 6
2005-11-18 01:17:57 PST
The problem here is that in the loadHTMLString case, the loader decodes the script source as UTF-16 instead of ISO-8859-1. An easy workaround is to add specify the charset in the <script> tag. E.g., this works in the snippet editor: <html> <head> </head> <body> <h1>Apple hot news feed</h1> <script src="
http://service.karelia.com/feed.js.php?url=http://www.apple.com/main/rss/hotnews/
hotnews.rss&h=oEPs7zbjQNvNVMqi6eooSO1AuCA=&max=99&k=c79e4f32899dbb4758 96e72281be7f8217eaa211" type="text/javascript" charset="ISO-8859-1"/> <p>END</p> </body>
mitz
Comment 7
2005-11-18 01:39:45 PST
Another possible workaround is instead of -loadHTMLString:baseURL: to use - loadData:MIMEType:textEncodingName:baseURL: with data in the same encoding as you expect the script to be in. I'm not sure this is a bug.
Dan Wood
Comment 8
2005-11-18 09:10:32 PST
I filed a documentation bug on Radar <
rdar://4349353
> after some discussion with mitzpettel about how best to avoid this problem for future developers!
Dan Wood
Comment 9
2005-11-21 10:49:14 PST
*** This bug has been marked as a duplicate of
5140
***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug