Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23327] iOS: Webview request send out beforeload event is excuted on Webview (Parity)

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2017-01-10T09:46:04.000+0000
Affected Version/sRelease 5.4.0, Release 5.2.2
Fix Version/sRelease 6.1.0
ComponentsAndroid, iOS
LabelsCiti, supportTeam
ReporterMostafizur Rahman
AssigneeVijay Singh
Created2016-05-05T14:07:17.000+0000
Updated2017-01-10T22:17:33.000+0000

Description

*Scenario:* Customer's want to prevent any unauthorized request. In newly developed features we can block URL by adding blacklistedURLs property. But its only helpful if we have URL list but if we don't have any predefined URL then it will not helpful. If stopLoading() stop loading content then customer need like stop request function which is stop sending request. 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:*
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(); 
*Test steps:* Run test code in classic project 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
Capture.PNG2016-05-10T10:52:43.000+000095826
screen_using_blacklistedurl.png2016-05-10T10:52:39.000+0000231869

Comments

  1. Ashraf Abu 2016-05-10

    Just want to check, this is for iOS, correct?
  2. Chee Kiat Ng 2016-05-11

    [~apetkov] Once Ash and the rest determine the approach, can you work on this fix?
  3. Ajith Rohini 2016-05-13

    Had the call with client (Rajeev & Koushik) with Ash and Angel from our end and we came to the agreement that we will have the feature ready buy next Wednesday May18th
  4. Angel Petkov 2016-05-24

    Hello, the ticket for IOS is in progress now we've had feedback off the customers, they seem to be happy with the android implementation. The iOS feature should be finished by the end of this week, I apologize for the delay as I've been out the office and we have also been waiting on feedback of the Android implementation which seems to have gone smoothly. Again the iOS feature should be out shortly (end of this week) Thank you!
  5. Angel Petkov 2016-05-25

    Introduced onStopBlackListUrl * PR: https://github.com/appcelerator/titanium_mobile/pull/8019 * Custom Build: https://www.dropbox.com/s/v3ol1q4tddumzhs/mobilesdk-5.4.0-osx.zip?dl=0 _*Steps to Test:*_ Click the 9 or iOS library link. _*Expected Result:*_ Nothing should open and the event should be triggered with the event data loged. Demo Code:
       
       var win = Ti.UI.createWindow({
           backgroundColor : 'black',
           layout : 'vertical'
       });
       var webview = Titanium.UI.createWebView({
           blacklistedURLs :'IOS',
           url : 'https://developer.apple.com/library/'
       });
        
       webview.addEventListener('load', function(e) {
           Ti.API.warn("load = e.url=" + e.url);
       });
        
       webview.addEventListener('onStopBlacklistedUrl', function(e) {
               Ti.API.info(e);
       });
       
       win.add(webview);
       win.open();
       
  6. Angel Petkov 2016-05-27

    [~morahman] Yes, my mistake I was testing the flush of the array in the demo-code and forgot to remove it before adding it to Jira. My apologizes, could you test again thank you!
  7. Motiur Rahman 2016-05-27

    [~apetkov] , [~arohini], Now it works with the updated test case. Thanks.
  8. Ajith Rohini 2016-05-27

    Thanks [~morahman] !!
  9. Ajith Rohini 2016-05-30

    [~morahman], Client reported that its still not working. Did you test it with the build from the link below? PR: https://github.com/appcelerator/titanium_mobile/pull/8019 Custom Build: https://www.dropbox.com/s/v3ol1q4tddumzhs/mobilesdk-5.4.0-osx.zip?dl=0
  10. Jong Eun Lee 2016-06-08

    How about using stopBlackListUrl as event name instead of onStopBlackListUrl? If onStopBlackListUrl, the xml has onOnStopBlacklistedUrl name.
        <WebView id="webView" onOnStopBlacklistedUrl="onBlack"></WebView>
        
    onOn dosn't look good.
  11. Angel Petkov 2016-06-08

    [~yomybaby] Hello I appreciate the feedback and agree completely that it should be called stopBlackListUrl however this ticket is just for the iOS feature. I cannot rename it within this PR as the customBuild is already being used for testing by the customers. Once this feature is merged we will create a new ticket and rename the event for both iOS and Android.
  12. Ajith Rohini 2016-06-23

    [~apetkov], Any update on the fix for this issue ?
  13. Jong Eun Lee 2016-08-23

    Any news? :)
  14. Jong Eun Lee 2016-09-16

    I hope that this iOS code will be merged soon. Please :) Because Android has this feature already in 5.4.0.GA.
  15. Jong Eun Lee 2016-12-23

    this property for Android was included 5.4.0! Not yet on iOS. @apetkov Is there any reason? :)
  16. Vijay Singh 2017-01-09

    [~hansknoechel] PR: https://github.com/appcelerator/titanium_mobile/pull/8732 Test code -
        var win = Ti.UI.createWindow({
            backgroundColor : 'black',
            layout : 'vertical'
        });
        var webview = Titanium.UI.createWebView({
            url : 'https://developer.apple.com/library/'
        });
         
         webview.setBlacklistedURLs(['library']);
         
        webview.addEventListener('load', function(e) {
            Ti.API.warn("load = e.url=" + e.url);
        });
         
        webview.addEventListener('onStopBlacklistedUrl', function(e) {
                Ti.API.info(e);
        });
         
        win.add(webview);
        win.open();
        
  17. Samir Mohammed 2017-01-10

    Verified improvement with the test case provided by [~vijaysingh] application was no longer displaying the blacklisted URL. *Environment*
        Appcelerator Command-Line Interface, version 6.1.0
        iphone 6 plus (ios 9.3.4)
        Operating System Name: Mac OS X El Capitan
        Operating System Version: 10.11.6
        Node.js Version: 4.6.0
        npm: 4.2.8
        Titanium SDK Version: 6.1.0.v20170110133045
        Xcode: 8.2
        Appcelerator Studio: 4.8.1.201612050850
        

JSON Source