cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [14/50] git commit: added "remove all access elements" functionality to config_parser. added whitelist support to blackberry
Date Wed, 28 Nov 2012 18:16:23 GMT
added "remove all access elements" functionality to config_parser. added whitelist support
to blackberry


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

Branch: refs/heads/master
Commit: bc4ad3f902feeaa41426f4b66f37c014e73f1fd4
Parents: 9e7b777
Author: Fil Maj <maj.fil@gmail.com>
Authored: Tue Nov 6 12:59:27 2012 -0800
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Tue Nov 6 12:59:27 2012 -0800

----------------------------------------------------------------------
 spec/config_parser.spec.js              |    6 ++++++
 spec/metadata/blackberry_parser.spec.js |   11 +++++++++++
 src/config_parser.js                    |    5 ++++-
 src/metadata/android_parser.js          |    4 +---
 src/metadata/blackberry_parser.js       |    5 +++++
 5 files changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bc4ad3f9/spec/config_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/config_parser.spec.js b/spec/config_parser.spec.js
index 1791beb..b2727ff 100644
--- a/spec/config_parser.spec.js
+++ b/spec/config_parser.spec.js
@@ -97,6 +97,12 @@ describe('config.xml parser', function () {
                 cfg.access.add('http://cordova.io');
                 expect(fs.readFileSync(xml, 'utf-8')).toMatch(/<access origin="http:\/\/cordova\.io/);
             });
+            it('should allow removing all access elements when no parameter is specified',
function() {
+                cfg.access.add('http://cordova.io');
+                cfg.access.remove();
+
+                expect(fs.readFileSync(xml, 'utf-8')).not.toMatch(/<access.*\/>/);
+            });
         });
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bc4ad3f9/spec/metadata/blackberry_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/blackberry_parser.spec.js b/spec/metadata/blackberry_parser.spec.js
index e7ffeed..bfd7bc8 100644
--- a/spec/metadata/blackberry_parser.spec.js
+++ b/spec/metadata/blackberry_parser.spec.js
@@ -60,6 +60,17 @@ describe('blackberry project parser', function() {
             var bb_cfg = new config_parser(blackberry_config);
             expect(bb_cfg.packageName()).toBe('sofa.king.awesome');
         });
+        it('should update the whitelist properly', function() {
+            config.access.remove('*');
+            config.access.add('http://blackberry.com');
+            config.access.add('http://rim.com');
+            project.update_from_config(config);
+
+            var bb_cfg = new config_parser(blackberry_config);
+            expect(bb_cfg.access.get().length).toEqual(2);
+            expect(bb_cfg.access.get()[0]).toEqual('http://blackberry.com');
+            expect(bb_cfg.access.get()[1]).toEqual('http://rim.com');
+        });
     });
 
     describe('update_www method', function() {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bc4ad3f9/src/config_parser.js
----------------------------------------------------------------------
diff --git a/src/config_parser.js b/src/config_parser.js
index ecd12e5..49aa2a4 100644
--- a/src/config_parser.js
+++ b/src/config_parser.js
@@ -38,7 +38,10 @@ access.prototype = {
     },
     remove:function(uri) {
         var self = this;
-        this.config.doc.findall('access[@origin="' + uri + '"]').forEach(function(a) {
+        var els = [];
+        if (uri) els = this.config.doc.findall('access[@origin="' + uri + '"]');
+        else els = this.config.doc.findall('access');
+        els.forEach(function(a) {
             self.config.doc.getroot().remove(0, a);
         });
         this.config.update();

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bc4ad3f9/src/metadata/android_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/android_parser.js b/src/metadata/android_parser.js
index f49cc8d..fae804f 100644
--- a/src/metadata/android_parser.js
+++ b/src/metadata/android_parser.js
@@ -45,9 +45,7 @@ module.exports.prototype = {
         // Update whitelist by changing res/xml/config.xml
         var android_cfg_xml = new config_parser(this.android_config);
         // clean out all existing access elements first
-        android_cfg_xml.access.get().forEach(function(uri) {
-            android_cfg_xml.access.remove(uri);
-        });
+        android_cfg_xml.access.remove();
         // add only the ones specified in the www/config.xml file
         config.access.get().forEach(function(uri) {
             android_cfg_xml.access.add(uri);

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bc4ad3f9/src/metadata/blackberry_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/blackberry_parser.js b/src/metadata/blackberry_parser.js
index d6cf21f..cfc3262 100644
--- a/src/metadata/blackberry_parser.js
+++ b/src/metadata/blackberry_parser.js
@@ -21,6 +21,11 @@ module.exports.prototype = {
 
         this.xml.name(config.name());
         this.xml.packageName(config.packageName());
+        this.xml.access.remove();
+        var self = this;
+        config.access.get().forEach(function(uri) {
+            self.xml.access.add(uri);
+        });
     },
     update_project:function(cfg, callback) {
         this.update_from_config(cfg);


Mime
View raw message