You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2012/08/30 16:09:44 UTC

js commit: Fix broken bridge on iOS 4.2

Updated Branches:
  refs/heads/master 106f57ea9 -> b17e8cdf6


Fix broken bridge on iOS 4.2

-Sets the bridge mode to iframe for 4.X devices to work around the
problem.
https://issues.apache.org/jira/browse/CB-1296


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/b17e8cdf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/b17e8cdf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/b17e8cdf

Branch: refs/heads/master
Commit: b17e8cdf69b067f9fc7326164b5dbdea307ae85f
Parents: 106f57e
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Aug 30 10:07:58 2012 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Aug 30 10:09:23 2012 -0400

----------------------------------------------------------------------
 lib/ios/exec.js |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/b17e8cdf/lib/ios/exec.js
----------------------------------------------------------------------
diff --git a/lib/ios/exec.js b/lib/ios/exec.js
index 68456fb..10d33cf 100644
--- a/lib/ios/exec.js
+++ b/lib/ios/exec.js
@@ -14,7 +14,10 @@ var cordova = require('cordova'),
         XHR_WITH_PAYLOAD: 2,
         XHR_OPTIONAL_PAYLOAD: 3
     },
-    bridgeMode = jsToNativeModes.XHR_OPTIONAL_PAYLOAD,
+    // XHR mode does not work on iOS 4.2, so default to IFRAME_NAV for such devices.
+    // XHR mode's main advantage is working around a bug in -webkit-scroll, which 
+    // doesn't exist in 4.X devices anyways.
+    bridgeMode = navigator.userAgent.indexOf(' 4_') == -1 ? jsToNativeModes.XHR_OPTIONAL_PAYLOAD : jsToNativeModes.IFRAME_NAV,
     execIframe,
     execXhr;
 
@@ -92,6 +95,8 @@ function iOSExec() {
     if (cordova.commandQueue.length == 1 && !cordova.commandQueueFlushing) {
         if (bridgeMode) {
             execXhr = execXhr || new XMLHttpRequest();
+            // Changeing this to a GET will make the XHR reach the URIProtocol on 4.2.
+            // For some reason it still doesn't work though...
             execXhr.open('HEAD', "file:///!gap_exec", true);
             execXhr.setRequestHeader('vc', cordova.iOSVCAddr);
             if (shouldBundleCommandJson()) {