[ 
https://issues.apache.org/jira/browse/CB-10451?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15122031#comment-15122031
 ] 

ASF GitHub Bot commented on CB-10451:
-------------------------------------

Github user sgrebnov commented on the pull request:

    
https://github.com/apache/cordova-plugin-inappbrowser/pull/145#issuecomment-176320293
  
    setTimeout is required to support the following scenario. On ios, android 
and other platforms functionality creates InAppBrowser on native side, so ln2 
happens before webview is created and events are triggered. As a quick fix on 
Windows I made open method async so that it works (this is what docs recommend 
to use so we should support this). Since I made open async I made async other 
methods so that their functionality is triggered after open.
    ```
    ln1: var ref  = cordova.InAppBrowser.open()
    ln2: ref.addEventListener('startload', function() {..})
    ln3: ref.close()
    ```
    
    PS. Thank you for the setImmediate tip - will update the code


> InAppBrowser: loadstart event is not triggered on Windows
> ---------------------------------------------------------
>
>                 Key: CB-10451
>                 URL: https://issues.apache.org/jira/browse/CB-10451
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin InAppBrowser
>            Reporter: Sergey Grebnov
>            Assignee: Sergey Grebnov
>              Labels: Windows, triaged
>
> The following unit test fails as 'loadstart' callback is not called on 
> Windows. Main reason is that it is called internally when we do open before 
> we attach event handler. But this is what docs recommend and what other 
> people uses. We should make open method async (Windows proxy or 
> inappbrowser.js) so that handler could be added this way
> {code}
> it("inappbrowser.spec.4 should support loadstart and loadstop events", 
> function (done) {
>             var onLoadStart = jasmine.createSpy('loadstart event 
> callback').and.callFake(function (evt) {
>                 verifyEvent(evt, 'loadstart');
>             });
>             iabInsance = cordova.InAppBrowser.open(url, '_blank');
>             iabInsance.addEventListener('loadstart', onLoadStart);
>             iabInsance.addEventListener('loadstop', function (evt) {
>                 verifyEvent(evt, 'loadstop');
>                 expect(onLoadStart).toHaveBeenCalled();
>                 done();
>             });
>         });
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to