cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sgreb...@apache.org
Subject [4/6] cordova-plugin-inappbrowser git commit: CB-7690 InAppBrowser loadstart/loadstop events issues
Date Thu, 13 Nov 2014 06:39:12 GMT
CB-7690 InAppBrowser loadstart/loadstop events issues

Subscribing to events before navigating


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/3f80b0b5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/3f80b0b5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/3f80b0b5

Branch: refs/heads/master
Commit: 3f80b0b59c4ec45141fd66b2d723e427e2ca53ad
Parents: 71b43d3
Author: daserge <daserge@yandex.ru>
Authored: Wed Oct 15 03:23:26 2014 +0400
Committer: sgrebnov <v-segreb@microsoft.com>
Committed: Wed Nov 12 22:35:10 2014 -0800

----------------------------------------------------------------------
 src/windows/InAppBrowserProxy.js |  6 +++---
 tests/tests.js                   | 21 ++++++++++++---------
 www/inappbrowser.js              |  8 +++++++-
 3 files changed, 22 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/3f80b0b5/src/windows/InAppBrowserProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/InAppBrowserProxy.js b/src/windows/InAppBrowserProxy.js
index 1d17bc5..5842212 100644
--- a/src/windows/InAppBrowserProxy.js
+++ b/src/windows/InAppBrowserProxy.js
@@ -120,14 +120,14 @@ var IAB = {
             popup.style.width = "100%";
             popup.style.height = "100%";
 
+            // start listening for navigation events
+            attachNavigationEvents(popup, win);
+
             if (isWebViewAvailable) {
                 strUrl = strUrl.replace("ms-appx://", "ms-appx-web://");
             }
             popup.src = strUrl;
 
-            // start listening for navigation events
-            attachNavigationEvents(popup, win);
-
             browserWrap.appendChild(popup);
         }
     },

http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/3f80b0b5/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 4a9e5ef..1587b99 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -29,11 +29,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
     function doOpen(url, target, params, numExpectedRedirects) {
         numExpectedRedirects = numExpectedRedirects || 0;
         console.log("Opening " + url);
-        var iab = window.open(url, target, params);
-        if (!iab) {
-            alert('window.open returned ' + iab);
-            return;
-        }
+
         var counts;
         var lastLoadStartURL;
         var wasReset = false;
@@ -48,6 +44,17 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         }
         reset();
 
+        var iab = window.open(url, target, params, {
+            loaderror: logEvent,
+            loadstart: logEvent,
+            loadstop: logEvent,
+            exit: logEvent
+        });
+        if (!iab) {
+            alert('window.open returned ' + iab);
+            return;
+        }
+        
         function logEvent(e) {
             console.log('IAB event=' + JSON.stringify(e));
             counts[e.type]++;
@@ -85,10 +92,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
                 }
             }
         }
-        iab.addEventListener('loaderror', logEvent);
-        iab.addEventListener('loadstart', logEvent);
-        iab.addEventListener('loadstop', logEvent);
-        iab.addEventListener('exit', logEvent);
 
         return iab;
     }

http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/3f80b0b5/www/inappbrowser.js
----------------------------------------------------------------------
diff --git a/www/inappbrowser.js b/www/inappbrowser.js
index 4211563..a85f27e 100644
--- a/www/inappbrowser.js
+++ b/www/inappbrowser.js
@@ -77,7 +77,7 @@ InAppBrowser.prototype = {
     }
 };
 
-module.exports = function(strUrl, strWindowName, strWindowFeatures) {
+module.exports = function(strUrl, strWindowName, strWindowFeatures, callbacks) {
     // Don't catch calls that write to existing frames (e.g. named iframes).
     if (window.frames && window.frames[strWindowName]) {
         var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
@@ -86,6 +86,12 @@ module.exports = function(strUrl, strWindowName, strWindowFeatures) {
 
     strUrl = urlutil.makeAbsolute(strUrl);
     var iab = new InAppBrowser();
+
+    callbacks = callbacks || {};
+    for (var callbackName in callbacks) {
+        iab.addEventListener(callbackName, callbacks[callbackName]);
+    }
+
     var cb = function(eventname) {
        iab._eventHandler(eventname);
     };


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message