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 2013/01/15 16:58:57 UTC

js commit: Add a random query parameter to xhr bridge to avoid caches.

Updated Branches:
  refs/heads/master 099a51d15 -> ba7edf04b


Add a random query parameter to xhr bridge to avoid caches.

Fixes https://issues.apache.org/jira/browse/CB-2094 (I think)


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

Branch: refs/heads/master
Commit: ba7edf04ba6403588ba22995c0b9b62d58ceeca8
Parents: 099a51d
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jan 15 10:58:07 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jan 15 10:58:07 2013 -0500

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


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/ba7edf04/lib/ios/exec.js
----------------------------------------------------------------------
diff --git a/lib/ios/exec.js b/lib/ios/exec.js
index f8bff52..390ea3e 100644
--- a/lib/ios/exec.js
+++ b/lib/ios/exec.js
@@ -162,7 +162,8 @@ function iOSExec() {
             execXhr = execXhr || new XMLHttpRequest();
             // 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);
+            // Add a timestamp to the query param to prevent caching.
+            execXhr.open('HEAD', "/!gap_exec?" + +new Date, true);
             if (!vcHeaderValue) {
                 vcHeaderValue = /.*\((.*)\)/.exec(navigator.userAgent)[1];
             }

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/ba7edf04/test/ios/test.exec.js
----------------------------------------------------------------------
diff --git a/test/ios/test.exec.js b/test/ios/test.exec.js
index 1f59b71..bf279e6 100644
--- a/test/ios/test.exec.js
+++ b/test/ios/test.exec.js
@@ -48,7 +48,7 @@ describe('iOS exec', function () {
     function expectXhr() {
         expect(mockxhr.activeXhrs.length).toBeGreaterThan(0, 'expected an XHR to have been sent.');
         var mockXhr = mockxhr.activeXhrs[0];
-        expect(mockXhr.url).toBe('/!gap_exec');
+        expect(mockXhr.url).toMatch(/^\/!gap_exec\\?/);
         expect(mockXhr.requestHeaders['vc']).toBe(VC_ADDR, 'missing vc header');
         expect(mockXhr.requestHeaders['rc']).toBeDefined('missing rc header.');
         expect(mockXhr.requestHeaders['cmds']).not.toBeDefined();