cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtan...@apache.org
Subject js commit: makes a lot more sense to use the userAgent to figure out what BlackBerry platform we are on
Date Mon, 12 Nov 2012 16:59:26 GMT
Updated Branches:
  refs/heads/master 68f55ca15 -> 1fd563856


makes a lot more sense to use the userAgent to figure out what BlackBerry platform we are
on


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/1fd56385
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/1fd56385
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/1fd56385

Branch: refs/heads/master
Commit: 1fd5638561b1e15938ebea92c75dc3673e81851b
Parents: 68f55ca
Author: Gord Tanner <gtanner@gmail.com>
Authored: Mon Nov 12 11:59:15 2012 -0500
Committer: Gord Tanner <gtanner@gmail.com>
Committed: Mon Nov 12 11:59:15 2012 -0500

----------------------------------------------------------------------
 lib/blackberry/platform.js       |    9 ++++++---
 test/blackberry/test.platform.js |   25 ++++++-------------------
 2 files changed, 12 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/1fd56385/lib/blackberry/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/platform.js b/lib/blackberry/platform.js
index 5ca3e32..2f568a5 100644
--- a/lib/blackberry/platform.js
+++ b/lib/blackberry/platform.js
@@ -22,14 +22,17 @@
 module.exports = {
     id: "blackberry",
     runtime: function () {
-        if (window.webworks) {
+        if (navigator.userAgent.indexOf("BB10") > -1) {
             return 'qnx';
         }
-        var version = blackberry.system.softwareVersion;
-        if (version.match(/^BlackBerry/)) {
+        else if (navigator.userAgent.indexOf("PlayBook") > -1) {
             return 'air';
         }
+        else if (navigator.userAgent.indexOf("BlackBerry") > -1) {
+            return 'java';
+        }
         else {
+            console.log("Unknown user agent?!?!? defaulting to java");
             return 'java';
         }
     },

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/1fd56385/test/blackberry/test.platform.js
----------------------------------------------------------------------
diff --git a/test/blackberry/test.platform.js b/test/blackberry/test.platform.js
index 4d909af..ff8da83 100644
--- a/test/blackberry/test.platform.js
+++ b/test/blackberry/test.platform.js
@@ -23,31 +23,18 @@ describe("blackberry platform", function () {
     var platform = require('cordova/blackberryplatform');
 
     describe("when getting the runtime", function () {
-        beforeEach(function () {
-            global.blackberry = {
-                system: {
-                    softwareVersion: ""
-                }
-            };
-        });
-
-        afterEach(function () {
-            delete global.blackberry;
-        });
-
-        it("returns qnx if webworks exists on window", function () {
-            window.webworks = {};
+        it("returns qnx for the bb10 user agent", function () {
+            navigator.userAgent = "Mozilla/5.0 (BB10; Touch) AppleWebKit/537.1+ (KHTML, like
Gecko) Version/10.0.0.1337 Mobile Safari/537.1+";
             expect(platform.runtime()).toBe("qnx");
-            delete window.webworks;
         });
 
-        it("returns air if softwareVersion starts with BlackBerry", function () {
-            blackberry.system.softwareVersion = "BlackBerry PlayBook OS"
+        it("returns air for the playbook user agent", function () {
+            navigator.userAgent = "Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US)
AppleWebKit/536.2+ (KHTML, like Gecko) Version/7.2.1.0 Safari/536.2+";
             expect(platform.runtime()).toBe("air");
         });
 
-        it("returns java if software version is anything else", function () {
-            blackberry.system.softwareVersion = "7.0"
+        it("returns java for a blackberry user agent", function () {
+            navigator.userAgent = "Mozilla/5.0 (BlackBerry; U; BlackBerry 9100; en) AppleWebKit/534.3+
(KHTML, like Gecko) Version/6.0.0.286 Mobile Safari/534.3+";
             expect(platform.runtime()).toBe("java");
         });
     });


Mime
View raw message