[TIMOB-7849] iOS: TiUIWebView beforeload event doesn't have the URL
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-03-06T11:30:27.000+0000 |
Affected Version/s | Release 1.8.2 |
Fix Version/s | Sprint 2012-05, Release 2.0.0 |
Components | iOS |
Labels | module_webview, qe-testadded |
Reporter | Taracque |
Assignee | Stephen Tramer |
Created | 2012-02-29T03:36:58.000+0000 |
Updated | 2013-11-25T08:50:59.000+0000 |
Description
When beforeload event called in TiUIWebView.m the URL is unknown. The beforeload event should be moved to shouldStartLoadWithRequest, to let beforeload know what url will be opened.
A suggested fix can be found here:
https://github.com/appcelerator/titanium_mobile/pull/538
I don't think it's a New feature. As the documentation clearly describes, that the URL is passed on beforeload event, I still think this is a bug. http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.WebView.beforeload-event.html
This issue is simply pending functional review on Taracque's existing PR here: https://github.com/appcelerator/titanium_mobile/pull/538
You can test this issue with this code: var webViewer = Titanium.UI.createWebView({ top:0, left:0, width:'100%', height:'100%' }); webViewer.addEventListener('beforeload',function(e){ alert("BEFORELOAD: " + e.url); }); webViewer.addEventListener('load', function(e){ alert("LOAD: " + e.url); }); var winFront = Titanium.UI.createWindow({ title:'TUiWebView', navBarHidden: true, backgroundColor:'#d6d6d6' }); winFront.add(webViewer); winFront.open(); webViewer.url="http://www.appcelerator.com/"; You will see, that beforeload alerts are displays the current url every time (which always can be read from webViewer.url property) , and load alert displays the new url. If you accept my patch, beforload handler can reject page before it actually loads depending on URL. The current implementation has no sense.
Closing issue Tested with Ti Studio build 1.0.9.201202141208 Ti Mob SDK 2.0.0.v20120307090205 OSX Lion 10.7.3 iPhone 4S OS 5.0 Expected behavior is shown
Anvil test case added. PR link: https://github.com/appcelerator/titanium_mobile/pull/5020