Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-11012

Loadstart loadstop events do not fire for webview (target = _self)

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • None
    • Cordova 6.1.0

    Description

      Building a cordova app using Ionic.
      Loading a URL in webview using inappbrowser plugin but none of the events like loadstart, loadstop get fired.

      This is my app.js

       var ref = cordova.InAppBrowser.open('http://www.google.com','_self', 'location=no')
      
                ref.addEventListener('loadstart', function (event) {
                  console.log('loadstart fired');
                }, false);
      
                ref.addEventListener('loadstop', function (event) {
                  console.log('loadstop fired');
                }, false);
      
                ref.addEventListener('loaderror', function (event) {
                  console.log('loadstop fired');
                }, false);
      
                ref.addEventListener('exit', function (event) {
                  console.log('exit fired');
                }, false);
      
      

      CSP in index.html

       
         <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
      

      Console output is blank when _self is used

      Note: The events fire when target _blank is used.

      I/chromium( 2222): [INFO:CONSOLE(69)] "loadstart fired", source: file:///android_asset/www/src/app.js (69)
      I/chromium( 2222): [INFO:CONSOLE(73)] "loadstop fired", source: file:///android_asset/www/src/app.js (73) 
      I/chromium( 2222): [INFO:CONSOLE(73)] "loadstop fired", source: file:///android_asset/www/src/app.js (73)
      I/chromium( 2722): [INFO:library_loader_hooks.cc(130)] Chromium logging enabled: level = 0, default verbosity = 0
      I/chromium( 2222): [INFO:CONSOLE(73)] "loadstop fired", source: file:///android_asset/www/src/app.js (73)
      

      Attachments

        Issue Links

          Activity

            jcesarmobile jcesarmobile added a comment - - edited

            event listeners shouldn't work if you use _self.

            When you use _self you are loading the website inside the cordova webview, not the inAppBrowser webview, and then you are replacing all your existing code with the code from the website you load, so when your page finish loading, your code is gone and won't be executed.

            We should document that events only work when using _blank

            Are you the one who asked this?
            http://stackoverflow.com/questions/36038076/execute-script-in-cordova-webview/

            jcesarmobile jcesarmobile added a comment - - edited event listeners shouldn't work if you use _self. When you use _self you are loading the website inside the cordova webview, not the inAppBrowser webview, and then you are replacing all your existing code with the code from the website you load, so when your page finish loading, your code is gone and won't be executed. We should document that events only work when using _blank Are you the one who asked this? http://stackoverflow.com/questions/36038076/execute-script-in-cordova-webview/
            rohand Rohan added a comment -

            Yes. So there is no way we can inject javascript when using _self?

            rohand Rohan added a comment - Yes. So there is no way we can inject javascript when using _self?
            flavordaaave David added a comment - - edited

            I'm using "_blank" within my ionic2 app but the events still won't fire:

                var url = 'http://myURL.com';
                var browserRef = cordova.InAppBrowser.open(url, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
                browserRef.addEventListener('loadstart', event => {
                  console.log('loadstart event'); // not fired
                });
                browserRef.addEventListener('exit', event => {
                  console.log('exit event'); // not fired
                });
            
            flavordaaave David added a comment - - edited I'm using "_blank" within my ionic2 app but the events still won't fire: var url = 'http: //myURL.com' ; var browserRef = cordova.InAppBrowser.open(url, '_blank' , 'location=no,clearsessioncache=yes,clearcache=yes' ); browserRef.addEventListener( 'loadstart' , event => { console.log( 'loadstart event' ); // not fired }); browserRef.addEventListener( 'exit' , event => { console.log( 'exit event' ); // not fired });
            jcesarmobile jcesarmobile added a comment -

            flavordaaave, this issue is about _self, if it isn't working when you use _blank, file a new issue and provide more information (plugin version, platform version, OS were you tested, etc)

            jcesarmobile jcesarmobile added a comment - flavordaaave , this issue is about _self, if it isn't working when you use _blank, file a new issue and provide more information (plugin version, platform version, OS were you tested, etc)
            githubbot ASF GitHub Bot added a comment -

            GitHub user jcesarmobile opened a pull request:

            https://github.com/apache/cordova-plugin-inappbrowser/pull/175

            CB-11012: (docs) added some clarifications about InAppBrowser object and window

                1. Platforms affected

            Documentation

                1. What does this PR do?

            Add some clarifications of the InAppBrowser object ref and window to make clearer when you can use it's method

                1. What testing has been done on this change?
                  None
                1. Checklist

            You can merge this pull request into a Git repository by running:

            $ git pull https://github.com/jcesarmobile/cordova-plugin-inappbrowser CB-11012-document-events

            Alternatively you can review and apply these changes as the patch at:

            https://github.com/apache/cordova-plugin-inappbrowser/pull/175.patch

            To close this pull request, make a commit to your master/trunk branch
            with (at least) the following in the commit message:

            This closes #175


            commit 4d6e18e32355577507b52a5bdd7c4a48552015d3
            Author: Julio CĂ©sar <jcesarmobile@gmail.com>
            Date: 2016-07-17T11:13:57Z

            CB-11012 added some clarifications about InAppBrowser object


            githubbot ASF GitHub Bot added a comment - GitHub user jcesarmobile opened a pull request: https://github.com/apache/cordova-plugin-inappbrowser/pull/175 CB-11012 : (docs) added some clarifications about InAppBrowser object and window Platforms affected Documentation What does this PR do? Add some clarifications of the InAppBrowser object ref and window to make clearer when you can use it's method What testing has been done on this change? None Checklist [x] [ICLA] ( http://www.apache.org/licenses/icla.txt ) has been signed and submitted to secretary@apache.org. [x] [Reported an issue] ( http://cordova.apache.org/contribute/issues.html ) in the JIRA database [x] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected. [ ] Added automated test coverage as appropriate for this change. You can merge this pull request into a Git repository by running: $ git pull https://github.com/jcesarmobile/cordova-plugin-inappbrowser CB-11012 -document-events Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cordova-plugin-inappbrowser/pull/175.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #175 commit 4d6e18e32355577507b52a5bdd7c4a48552015d3 Author: Julio CĂ©sar <jcesarmobile@gmail.com> Date: 2016-07-17T11:13:57Z CB-11012 added some clarifications about InAppBrowser object

            Commit 6bdd538096085eae1c9aeec820d1ee748be259ce in cordova-plugin-inappbrowser's branch refs/heads/master from jcesarmobile
            [ https://git-wip-us.apache.org/repos/asf?p=cordova-plugin-inappbrowser.git;h=6bdd538 ]

            CB-11012 added some clarifications about InAppBrowser object

            This closes #175

            jira-bot ASF subversion and git services added a comment - Commit 6bdd538096085eae1c9aeec820d1ee748be259ce in cordova-plugin-inappbrowser's branch refs/heads/master from jcesarmobile [ https://git-wip-us.apache.org/repos/asf?p=cordova-plugin-inappbrowser.git;h=6bdd538 ] CB-11012 added some clarifications about InAppBrowser object This closes #175
            githubbot ASF GitHub Bot added a comment -

            Github user asfgit closed the pull request at:

            https://github.com/apache/cordova-plugin-inappbrowser/pull/175

            githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/cordova-plugin-inappbrowser/pull/175
            jcesarmobile jcesarmobile added a comment -

            Changed docs a bit to make it clearer that the InAppBrowser object and methods can only be used when the target '_blank' is used.

            jcesarmobile jcesarmobile added a comment - Changed docs a bit to make it clearer that the InAppBrowser object and methods can only be used when the target '_blank' is used.
            githubbot ASF GitHub Bot added a comment -

            Github user cordova-qa commented on the issue:

            https://github.com/apache/cordova-plugin-inappbrowser/pull/175

            Cordova CI Build has completed successfully.

            *Commit* - [Link](https://github.com/apache/cordova-plugin-inappbrowser/pull/175/commits/4d6e18e32355577507b52a5bdd7c4a48552015d3)
            *Dashboard* - [Link](http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53/)

            Builder Name Console Output Test Report Device Logs
            :---: :---: :---: :---:
            [Windows 8.1 Store]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-8.1-store/) [Link]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-8.1-store/console) [Link]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-8.1-store/testReport/) [Link]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-8.1-store/artifact/)
            [Windows 10 Store]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-10-store/) [Link]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-10-store/console) [Link]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-10-store/testReport/) [Link]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-10-store/artifact/)
            [Windows 8.1 Phone]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-8.1-phone/) [Link]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-8.1-phone/console) [Link]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-8.1-phone/testReport/) [Link]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-8.1-phone/artifact/)
            [iOS]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=ios/) [Link]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=ios/console) [Link]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=ios/testReport/) [Link]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=ios/artifact/)
            [Android]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=android/) [Link]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=android/console) [Link]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=android/testReport/) [Link]( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=android/artifact/)
            githubbot ASF GitHub Bot added a comment - Github user cordova-qa commented on the issue: https://github.com/apache/cordova-plugin-inappbrowser/pull/175 Cordova CI Build has completed successfully. * Commit * - [Link] ( https://github.com/apache/cordova-plugin-inappbrowser/pull/175/commits/4d6e18e32355577507b52a5bdd7c4a48552015d3 ) * Dashboard * - [Link] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53/ ) Builder Name Console Output Test Report Device Logs :---: :---: :---: :---: [Windows 8.1 Store] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-8.1-store/ ) [Link] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-8.1-store/console ) [Link] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-8.1-store/testReport/ ) [Link] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-8.1-store/artifact/ ) [Windows 10 Store] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-10-store/ ) [Link] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-10-store/console ) [Link] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-10-store/testReport/ ) [Link] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-10-store/artifact/ ) [Windows 8.1 Phone] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-8.1-phone/ ) [Link] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-8.1-phone/console ) [Link] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-8.1-phone/testReport/ ) [Link] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=windows-8.1-phone/artifact/ ) [iOS] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=ios/ ) [Link] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=ios/console ) [Link] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=ios/testReport/ ) [Link] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=ios/artifact/ ) [Android] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=android/ ) [Link] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=android/console ) [Link] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=android/testReport/ ) [Link] ( http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-inappbrowser-pr/53//PLATFORM=android/artifact/ )

            People

              jcesarmobile jcesarmobile
              rohand Rohan
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: