cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeffheif...@apache.org
Subject git commit: Fixes a bug where cordova prepare bombs on a config missing a content element - Changes an undefined check to falsey to cover random null value returned from elementtree
Date Wed, 02 Oct 2013 00:12:06 GMT
Updated Branches:
  refs/heads/master dff71fee6 -> b51be5bc2


Fixes a bug where cordova prepare bombs on a config missing a content
element
  - Changes an undefined check to falsey to cover random null value
    returned from elementtree

  Tested By: David Kemp <drkemp@google.com> via Medic


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

Branch: refs/heads/master
Commit: b51be5bc24f1f7fa8d65123bb58c44730e50da71
Parents: dff71fe
Author: Jeffrey Heifetz <jheifetz@blackberry.com>
Authored: Tue Oct 1 20:06:08 2013 -0400
Committer: Jeffrey Heifetz <jheifetz@blackberry.com>
Committed: Tue Oct 1 20:06:08 2013 -0400

----------------------------------------------------------------------
 spec/config_parser.spec.js                    | 15 +++++++++++----
 spec/fixtures/templates/no_content_config.xml | 19 +++++++++++++++++++
 src/config_parser.js                          |  2 +-
 3 files changed, 31 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b51be5bc/spec/config_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/config_parser.spec.js b/spec/config_parser.spec.js
index 544075d..daa0aa8 100644
--- a/spec/config_parser.spec.js
+++ b/spec/config_parser.spec.js
@@ -22,9 +22,8 @@ var path = require('path'),
     config_parser = require('../src/config_parser'),
     et = require('elementtree'),
     xml = path.join(__dirname, '..', 'templates', 'config.xml'),
-    util = require('../src/util');
-
-var xml_contents = fs.readFileSync(xml, 'utf-8');
+    util = require('../src/util'),
+    xml_contents = fs.readFileSync(xml, 'utf-8');
 
 describe('config.xml parser', function () {
     var readFile, update;
@@ -41,7 +40,7 @@ describe('config.xml parser', function () {
         expect(cfg).toBeDefined();
         expect(cfg.doc).toBeDefined();
     });
-    
+
     describe('methods', function() {
         var cfg;
         beforeEach(function() {
@@ -88,6 +87,14 @@ describe('config.xml parser', function () {
                 cfg.content('batman.html');
                 expect(update).toHaveBeenCalled();
             });
+            it('should not error out if there is no content element', function () {
+                readFile.andCallThrough();
+                var no_content_xml = path.join(__dirname, "fixtures", "templates", "no_content_config.xml"),
+                    no_content_xml_contents = fs.readFileSync(no_content_xml, "utf-8");
+                readFile.andReturn(no_content_xml_contents);
+                var no_content_cfg = new config_parser(no_content_xml);
+                expect(no_content_cfg.content()).toEqual('index.html');
+            });
         });
 
         describe('app name', function() {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b51be5bc/spec/fixtures/templates/no_content_config.xml
----------------------------------------------------------------------
diff --git a/spec/fixtures/templates/no_content_config.xml b/spec/fixtures/templates/no_content_config.xml
new file mode 100644
index 0000000..a66b224
--- /dev/null
+++ b/spec/fixtures/templates/no_content_config.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<widget xmlns     = "http://www.w3.org/ns/widgets"
+        xmlns:cdv = "http://cordova.apache.org/ns/1.0"
+        id        = "io.cordova.hellocordova"
+        version   = "0.0.1">
+    <name>Hello Cordova</name>
+
+    <description>
+        A sample Apache Cordova application that responds to the deviceready event.
+    </description>
+
+    <author href="http://cordova.io" email="dev@callback.apache.org">
+        Apache Cordova Team
+    </author>
+
+    <access origin="*" />
+    <preference name="fullscreen" value="true" />
+    <preference name="webviewbounce" value="true" />
+</widget>

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b51be5bc/src/config_parser.js
----------------------------------------------------------------------
diff --git a/src/config_parser.js b/src/config_parser.js
index 6e40054..b5cd95f 100644
--- a/src/config_parser.js
+++ b/src/config_parser.js
@@ -53,7 +53,7 @@ config_parser.prototype = {
             content.attrib.src = src;
             this.update();
         } else {
-            if (content === undefined) {
+            if (!content) {
                 content = new et.Element('content');
                 content.attrib.src = 'index.html';
                 this.doc.getroot().append(content);


Mime
View raw message