cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject js commit: [ios] Get the vc header from the User-Agent instead of cordova.iOSVCAddr
Date Fri, 23 Nov 2012 02:36:59 GMT
Updated Branches:
  refs/heads/master ee4a70cce -> 05d4fd037


[ios] Get the vc header from the User-Agent instead of cordova.iOSVCAddr


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

Branch: refs/heads/master
Commit: 05d4fd03768ee60c0491dc1a908ca5c9e4bc1281
Parents: ee4a70c
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Thu Nov 22 21:36:16 2012 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Thu Nov 22 21:36:16 2012 -0500

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


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/05d4fd03/lib/ios/exec.js
----------------------------------------------------------------------
diff --git a/lib/ios/exec.js b/lib/ios/exec.js
index 2ff0d6c..1c2c1f2 100644
--- a/lib/ios/exec.js
+++ b/lib/ios/exec.js
@@ -38,6 +38,7 @@ var cordova = require('cordova'),
     execIframe,
     execXhr,
     requestCount = 0,
+    vcHeaderValue = null,
     commandQueue = [], // Contains pending JS->Native messages.
     isInContextOfEvalJs = 0;
 
@@ -125,7 +126,10 @@ function iOSExec() {
             // Changing 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', "/!gap_exec", true);
-            execXhr.setRequestHeader('vc', cordova.iOSVCAddr);
+            if (!vcHeaderValue) {
+                vcHeaderValue = /.*\((.*)\)/.exec(navigator.userAgent)[1];
+            }
+            execXhr.setRequestHeader('vc', vcHeaderValue);
             execXhr.setRequestHeader('rc', ++requestCount);
             if (shouldBundleCommandJson()) {
                 execXhr.setRequestHeader('cmds', iOSExec.nativeFetchMessages());

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/05d4fd03/test/ios/test.exec.js
----------------------------------------------------------------------
diff --git a/test/ios/test.exec.js b/test/ios/test.exec.js
index df4748e..1f59b71 100644
--- a/test/ios/test.exec.js
+++ b/test/ios/test.exec.js
@@ -35,11 +35,12 @@ describe('iOS exec', function () {
         failSpy.reset();
         mockxhr.install();
         exec.setJsToNativeBridgeMode(exec.jsToNativeModes.XHR_NO_PAYLOAD);
-        cordova.iOSVCAddr = VC_ADDR;
+        navigator = { userAgent: 'hi there (' + VC_ADDR + ')' };
     });
 
     afterEach(function() {
         expect(mockxhr.activeXhrs.length).toBe(0);
+        delete navigator;
     });
 
     afterEach(mockxhr.uninstall);


Mime
View raw message