Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23186] Android: Webview request send out beforeload event is excuted on Webview

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-05-17T23:45:26.000+0000
Affected Version/sRelease 5.2.2
Fix Version/sRelease 5.4.0, Release 5.3.2
ComponentsAndroid
Labelsandroid
ReporterRakhi Mitro
AssigneeAshraf Abu
Created2016-04-11T08:41:54.000+0000
Updated2017-01-10T09:14:45.000+0000

Description

Just load any HTML url in webview and call the webview.stoploading in beforeload event of webview. Customer has blocked the "terms of use" and "privacy policy" links in "beforeload" event of the web view. The webView stops loading but the link is traced in Proxy. *Test code:* Sample code is attached. *Test steps:* * Import the app. * Click on "terms of use" and "privacy policy” links and see the requests on proxy. *Expected Behavior :* Webview.stoploading should have prevented the request for the link clicked. *Actual Behavior :* By clicking on "terms of use" and "privacy policy” links, requests are sent out on proxy(by the IP address)

Attachments

FileDateSize
AlloyDemo (1).zip2016-04-11T08:41:05.000+000010479415

Comments

  1. Chee Kiat Ng 2016-04-11

    More information will be greatly appreciated. Is this a regression? Does it work on Android < 6.0? Does it work correctly on iOS? Thanks.
  2. Rakhi Mitro 2016-04-11

    Let me check. Will keep you updated.
  3. Rakhi Mitro 2016-04-11

    [~cng] Tested and got the same result on Android 4.4.2 and iPad-iOS 8.4 device. Thanks
  4. Chee Kiat Ng 2016-04-11

    Ok so you mean this is an issue seen on both iOS and Android. I haven't opened the app to see in detail but, isn't it a bit odd to block elements of a html BEFORE load on a web view? that means the "terms of use" and "privacy policy" doesn't exist during the "beforeload" event because the html itself isn't loaded. so I don't think it's possible to block something that's not known until it's "loaded". So this may not be a valid issue for the SDK, but rather the implementation should be done in another way? it'll be much appreciated if you can verify this first. If you really can't, then I will get someone in the SDK team to investigate further. Thanks for your assistance.
  5. Ricardo Ramirez 2016-04-11

    Yes, but funny thing here is the proxy trace, it should not exist if the before load is blocking it, also this is happening for any webpage
  6. Ashraf Abu 2016-04-18

    Classic code to reproduce:-
       var win = Ti.UI.createWindow({
           backgroundColor : 'black',
           layout : 'vertical'
       });
       
       var webview = Titanium.UI.createWebView({url:'https://en.m.wikipedia.org/wiki/Main_Page'});
       
       webview.addEventListener('beforeload', function(e){
       	Ti.API.info("beforeload = e.url=" + e.url);
       	if(e.url.indexOf('wikimediafoundation.org/wiki/Terms_of_Use') > -1){
       		webview.stopLoading();
       		Ti.API.info("Inside TERMS OF USE");
       	} else if (e.url.indexOf('wikimediafoundation.org/wiki/Privacy_policy') > -1){
       		webview.stopLoading();
       		Ti.API.info("Inside privacy policy");
       	}
       });
       webview.addEventListener('load', function(e){
       	Ti.API.info("load = e.url=" + e.url);
       	
       });
       
       win.add(webview);
       
       win.open(); 
       
  7. Ashraf Abu 2016-04-18

    Based on this: http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.WebView-event-beforeload The request is already actually sent. The beforeload event is before it loads the content into the webview. stopLoading() stops the loading of the content into the webview. At this point, it has content and request is done. This is how it is behaving.
  8. Ashraf Abu 2016-04-18

    [~rmitro] As mentioned above, the behaviour is how it's suppose to work. Is there a need for the behaviour as mentioned in the ticket?
  9. Ashraf Abu 2016-04-21

    PR: https://github.com/appcelerator/titanium_mobile/pull/7954
  10. Ashraf Abu 2016-04-22

    PR merged.
  11. Nazmus Salahin 2016-05-05

    Hello, I have tested the issue with SDK 5.4.0.v20160429102159 and able to reproduce. *Steps:* 1. Import the test project. 2. Build and run on Android Device. 3. When the web page is loaded click on "terms of use" or "privacy policy”. 4. By clicking on "terms of use" and "privacy policy” links, requests are sent out on proxy although the corresponding pages are not loaded. When the links are clicked following log is produced in proxy server. *Proxy Server Log:*
        15:10:36.591592 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 74
        15:10:36.591631 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 46
        15:10:36.591669 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 42
        15:10:36.592342 IP 103.26.136.65 > 192.168.10.227: ICMP redirect text-lb.ulsfo.wikimedia.org to host gway.grameen.com, length 134
        15:10:36.837752 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 0
        15:10:36.837795 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 0
        15:10:36.837826 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 0
        15:10:36.837862 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 46
        15:10:36.839142 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 0
        15:10:36.839492 IP 103.26.136.65 > 192.168.10.227: ICMP redirect text-lb.ulsfo.wikimedia.org to host gway.grameen.com, length 60
        15:10:38.070015 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 75
        15:10:38.070251 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 42
        15:10:38.070639 IP 103.26.136.65 > 192.168.10.227: ICMP redirect text-lb.ulsfo.wikimedia.org to host gway.grameen.com, length 135
        15:10:38.315649 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 0
        15:10:39.014283 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 74
        15:10:39.014655 IP 103.26.136.65 > 192.168.10.227: ICMP redirect text-lb.ulsfo.wikimedia.org to host gway.grameen.com, length 134
        15:10:39.021317 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 42
        15:10:39.260555 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 1329
        15:10:39.260606 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 1329
        15:10:39.260787 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 1448
        15:10:39.260876 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 1083
        15:10:39.261004 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 1448
        15:10:39.261125 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 1448
        15:10:39.261404 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 1448
        15:10:39.263931 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 1448
        15:10:39.266198 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 1448
        15:10:39.268678 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 1448
        15:10:39.269335 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 0
        15:10:39.269372 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 0
        15:10:39.269434 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 0
        15:10:39.269462 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 0
        15:10:39.269668 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 0
        15:10:39.269861 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 0
        15:10:39.269925 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 0
        15:10:39.269952 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 0
        15:10:39.270871 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 0
        15:10:39.271018 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 1448
        15:10:39.271063 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 0
        15:10:39.272190 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 0
        15:10:39.273422 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 1448
        15:10:39.276725 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 0
        15:10:39.306144 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 0
        15:10:39.515558 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 1448
        15:10:39.515677 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 1448
        15:10:39.515723 IP text-lb.ulsfo.wikimedia.org.https > 192.168.10.227.50215: tcp 255
        15:10:39.525506 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 0
        15:10:39.526124 IP 103.26.136.65 > 192.168.10.227: ICMP redirect text-lb.ulsfo.wikimedia.org to host gway.grameen.com, length 60
        15:10:39.528029 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 0
        15:10:39.533544 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 0
        15:10:39.697530 IP 192.168.10.227.50215 > text-lb.ulsfo.wikimedia.org.https: tcp 75
        
    Thanks *Environment*: *Device info:* Nexus7 (android 6.0.1) *Node.js Version:* 0.12.7 *npm Version:* 2.11.3 *Titanium SDK:* 5.4.0.v20160429102159 *Java Development Kit Version:* 1.8.0_73 *Titanium CLI Version:* 5.0.5 *Appcelerator CLI Version:* 5.2.2 *Appcelerator Studio:* 4.5.0
  12. Ashraf Abu 2016-05-05

    [~nsalahin] Which code are you using?
  13. Ashraf Abu 2016-05-17

    Reopened the ticket for the improvement. PR: https://github.com/appcelerator/titanium_mobile/pull/8002
  14. Ashraf Abu 2016-05-18

    PR has been reviewed and merged.
  15. Ajith Rohini 2016-05-18

    [~msamah], Many thanks for your help. I am sure client will be happy and will keep you posted.
  16. Lokesh Choudhary 2016-07-13

    Verified the improvement. Works as expected. Closing. Environment: Appc Studio : 4.7.0.201607111053 Ti SDK : 5.4.0.v20160712013704 Ti CLI : 5.0.9 Alloy : 1.9.1 MAC El Capitan : 10.11.5 Appc NPM : 4.2.8-1 Appc CLI : 5.4.0-33 Node: 4.4.4 Nexus 6 - Android 6.0.1

JSON Source