You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2019/08/22 21:05:07 UTC

[royale-asjs] branch develop updated: Fix runtime error in XML namespaceDeclarations method. Added new XML tests (for related compiler-jx fixes) to child and descendant e4x queries using namespaces.

This is an automated email from the ASF dual-hosted git repository.

gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new 2483039  Fix runtime error in XML namespaceDeclarations method. Added new XML tests (for related compiler-jx fixes) to child and descendant e4x queries using namespaces.
2483039 is described below

commit 24830390eec25b1c0408b0c6be407eda41a8b3f6
Author: greg-dove <gr...@gmail.com>
AuthorDate: Fri Aug 23 08:11:38 2019 +1200

    Fix runtime error in XML namespaceDeclarations method. Added new XML tests (for related compiler-jx fixes) to child and descendant e4x queries using namespaces.
---
 frameworks/projects/XML/src/main/royale/XML.as     |   5 +-
 .../XML/src/test/royale/flexUnitTests/XMLTester.as |   4 +-
 .../royale/flexUnitTests/xml/XMLNamespaceTest.as   | 149 +++++++++++++++++++++
 .../src/main/royale/flexUnitTests/XMLTester.as     |   4 +-
 .../royale/flexUnitTests/xml/XMLNamespaceTest.as   | 149 +++++++++++++++++++++
 5 files changed, 306 insertions(+), 5 deletions(-)

diff --git a/frameworks/projects/XML/src/main/royale/XML.as b/frameworks/projects/XML/src/main/royale/XML.as
index 844d7d2..31287f4 100644
--- a/frameworks/projects/XML/src/main/royale/XML.as
+++ b/frameworks/projects/XML/src/main/royale/XML.as
@@ -1602,7 +1602,6 @@ package
 				  b. Let i = i + 1
 				10. Return a
 			*/
-			var i:int;
 			var retVal:Array = [];
 			if(_nodeKind == "text" || _nodeKind == "comment" || _nodeKind == "processing-instruction" || _nodeKind ==  "attribute")
 				return retVal;
@@ -1613,11 +1612,11 @@ package
 				var parentNS:Array = parent.inScopeNamespaces();
 				var idx:int;
 				var pIdx:int;
-				for(pIdx=0;i<parentNS.length;pIdx++)
+				for(pIdx=0;pIdx<parentNS.length;pIdx++)
 				{
 					var uri:String = parentNS[pIdx].uri;
 					var prefix:String = parentNS[pIdx].prefix;
-					for(idx=0;i<declaredNS.length;idx++)
+					for(idx=0;idx<declaredNS.length;idx++)
 					{
 						if(declaredNS[idx].uri == uri && declaredNS[idx].prefix == prefix)
 						{
diff --git a/frameworks/projects/XML/src/test/royale/flexUnitTests/XMLTester.as b/frameworks/projects/XML/src/test/royale/flexUnitTests/XMLTester.as
index 333a875..33f103c 100644
--- a/frameworks/projects/XML/src/test/royale/flexUnitTests/XMLTester.as
+++ b/frameworks/projects/XML/src/test/royale/flexUnitTests/XMLTester.as
@@ -30,7 +30,7 @@ package flexUnitTests
         public function XMLTester()
         {
             // for JS, force-link these classes in the output
-            var arr:Array = [XMLTesterGeneralTest, XMLTesterStringifyTest, XMLListTesterGeneralTest];
+            var arr:Array = [XMLTesterGeneralTest, XMLTesterStringifyTest, XMLListTesterGeneralTest, XMLNamespaceTest];
         }
         
         // in JS, using a class as a type won't include the class in
@@ -46,6 +46,8 @@ package flexUnitTests
         public var xmlTesterStringifyTest:XMLTesterStringifyTest;
     
         public var xmlListTesterGeneralTest:XMLListTesterGeneralTest;
+    
+        public var xmlNamespaceTest:XMLNamespaceTest;
         
     }
 }
diff --git a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLNamespaceTest.as b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLNamespaceTest.as
new file mode 100644
index 0000000..bf99838
--- /dev/null
+++ b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLNamespaceTest.as
@@ -0,0 +1,149 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package flexUnitTests.xml
+{
+    
+    
+    import org.apache.royale.test.asserts.*;
+    
+   // import testshim.RoyaleUnitTestRunner;
+    
+    /**
+     * @royalesuppresspublicvarwarning
+     */
+    public class XMLNamespaceTest
+    {
+    
+        public static var ATOM_NS:Namespace = new Namespace("http://www.w3.org/2005/Atom");
+
+        
+        public static var isJS:Boolean = COMPILE::JS;
+    
+        private var settings:Object;
+        
+        private var source:String;
+        
+        [Before]
+        public function setUp():void
+        {
+            settings = XML.settings();
+            source = '<xml><?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?>\n' +
+                    '<?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?>\n' +
+                    '<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"> \n' +
+                    '\t<channel> \n' +
+                    '\t\t<title>anonymized name</title> \n' +
+                    '\t\t<link>http://www.anonymizedname.com</link> \n' +
+                    '\t\t<description>code is beautiful</description> \n' +
+                    '\t\t<language>en-us</language> \n' +
+                    '\t\t<pubDate>Thu, 27 Sep 2018 12:27:44 -0700</pubDate> \n' +
+                    '\t\t<lastBuildDate>Thu, 27 Sep 2018 12:27:44 -0700</lastBuildDate> \n' +
+                    '\t\t<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/AnonymizedName" />\n' +
+                    '\t\t<feedburner:info uri="anonymizedname" />\n' +
+                    '\t\t<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" />\n' +
+                    '\t\t<link random="this is a random link with default namespace" xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" />\n' +
+                    '\t\t<item> \n' +
+                    '\t\t\t<title>Twitch Live Firefox Extension</title> \n' +
+                    '\t\t\t<link>http://feedproxy.google.com/~r/AnonymizedName/~3/bgP9j-roaZQ/</link> \n' +
+                    '\t\t\t<pubDate>Thu, 27 Sep 2018 09:00:00 -0700</pubDate> \n' +
+                    '\t\t\t<author>anonymizedname@gmail.com (Anonymized Name)</author> \n' +
+                    '\t\t\t<guid isPermaLink="false">http://www.anonymizedname.com/blog/2018/09/27/twitch-live-firefox-extension/</guid> \n' +
+                    '\t\t\t<description>&lt;p&gt;I have ported my Twitch Live browser extension for Google Chrome to Firefox. Twitch Live is a toolbar extension that makes it easy to see when your favoritie streamers on Twitch are live.&lt;/p&gt; &lt;p&gt;&lt;img src="/blog/images/posts/twitchlivefirefox/screenshot.png" alt="Drawing" style="width: 798px;"/&gt;&lt;/p&gt; &lt;p&gt;There are options to open streams in a new window or tab, to enable notifications, as well as filter out vod c [...]
+                    '\t\t\t<feedburner:origLink>http://www.anonymizedname.com/blog/2018/09/27/twitch-live-firefox-extension/</feedburner:origLink>\n' +
+                    '\t\t</item> \n' +
+                    '\t</channel> \n' +
+                    '</rss></xml>';
+        }
+        
+        [After]
+        public function tearDown():void
+        {
+            source=null;
+            XML.setSettings(settings);
+        }
+        
+        [BeforeClass]
+        public static function setUpBeforeClass():void
+        {
+        }
+        
+        [AfterClass]
+        public static function tearDownAfterClass():void
+        {
+        }
+    
+    
+        private var atom:Namespace = ATOM_NS;
+        
+        
+        [Test]
+        public function testChildQueryWithNamespace():void{
+            
+            var xml:XML = new XML(source);
+            
+            var atomLinks:XMLList = xml.rss.channel.atom::link;
+            assertEquals(atomLinks.length(),2, 'unexpected results from namespace based child query');
+            
+            //@todo:
+            //RoyaleUnitTestRunner.consoleOut('atomLinks');
+            //RoyaleUnitTestRunner.consoleOut(atomLinks.toString());
+            //SWF Output includes ancestor namespaces:
+            /*
+            <atom10:link rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/AnonymizedName" xmlns:atom10="http://www.w3.org/2005/Atom" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"/>
+            <atom10:link rel="hub" href="http://pubsubhubbub.appspot.com/" xmlns:atom10="http://www.w3.org/2005/Atom" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"/>
+           
+             */
+            //JS Output does not (yet) include ancestor namespaces:
+            /*
+            <atom10:link rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/AnonymizedName" xmlns:atom10="http://www.w3.org/2005/Atom"/>
+            <atom10:link rel="hub" href="http://pubsubhubbub.appspot.com/" xmlns:atom10="http://www.w3.org/2005/Atom"/>
+            
+            */
+            
+        }
+    
+    
+        [Test]
+        public function testDescendantsQueryWithNamespace():void{
+        
+            var xml:XML = new XML(source);
+        
+            var atomLinks:XMLList = xml..atom::link;
+            assertEquals(atomLinks.length(),2, 'unexpected results from namespace based child query');
+        
+            //@todo:
+           // RoyaleUnitTestRunner.consoleOut('dscendants atomLinks');
+            //RoyaleUnitTestRunner.consoleOut(atomLinks.toString());
+            //SWF Output includes ancestor namespaces:
+            /*
+            <atom10:link rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/AnonymizedName" xmlns:atom10="http://www.w3.org/2005/Atom" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"/>
+            <atom10:link rel="hub" href="http://pubsubhubbub.appspot.com/" xmlns:atom10="http://www.w3.org/2005/Atom" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"/>
+           
+             */
+            //JS Output does not (yet) include ancestor namespaces:
+            /*
+            <atom10:link rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/AnonymizedName" xmlns:atom10="http://www.w3.org/2005/Atom"/>
+            <atom10:link rel="hub" href="http://pubsubhubbub.appspot.com/" xmlns:atom10="http://www.w3.org/2005/Atom"/>
+            
+            */
+        
+        }
+        
+        
+    }
+}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/XMLTester.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/XMLTester.as
index 3504295..29be565 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/XMLTester.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/XMLTester.as
@@ -30,7 +30,7 @@ package flexUnitTests
         public function XMLTester()
         {
             // for JS, force-link these classes in the output
-            var arr:Array = [XMLTesterGeneralTest, XMLTesterStringifyTest, XMLListTesterGeneralTest];
+            var arr:Array = [XMLTesterGeneralTest, XMLTesterStringifyTest, XMLListTesterGeneralTest, XMLNamespaceTest];
         }
         
         // in JS, using a class as a type won't include the class in
@@ -47,5 +47,7 @@ package flexUnitTests
     
         public var xmlListTesterGeneralTest:XMLListTesterGeneralTest;
         
+        public var xmlNamespaceTest:XMLNamespaceTest;
+        
     }
 }
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/xml/XMLNamespaceTest.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/xml/XMLNamespaceTest.as
new file mode 100644
index 0000000..45cb405
--- /dev/null
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/xml/XMLNamespaceTest.as
@@ -0,0 +1,149 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package flexUnitTests.xml
+{
+    
+    
+    import org.apache.royale.test.asserts.*;
+    
+    import testshim.RoyaleUnitTestRunner;
+    
+    /**
+     * @royalesuppresspublicvarwarning
+     */
+    public class XMLNamespaceTest
+    {
+    
+        public static var ATOM_NS:Namespace = new Namespace("http://www.w3.org/2005/Atom");
+
+        
+        public static var isJS:Boolean = COMPILE::JS;
+    
+        private var settings:Object;
+        
+        private var source:String;
+        
+        [Before]
+        public function setUp():void
+        {
+            settings = XML.settings();
+            source = '<xml><?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?>\n' +
+                    '<?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?>\n' +
+                    '<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"> \n' +
+                    '\t<channel> \n' +
+                    '\t\t<title>anonymized name</title> \n' +
+                    '\t\t<link>http://www.anonymizedname.com</link> \n' +
+                    '\t\t<description>code is beautiful</description> \n' +
+                    '\t\t<language>en-us</language> \n' +
+                    '\t\t<pubDate>Thu, 27 Sep 2018 12:27:44 -0700</pubDate> \n' +
+                    '\t\t<lastBuildDate>Thu, 27 Sep 2018 12:27:44 -0700</lastBuildDate> \n' +
+                    '\t\t<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/AnonymizedName" />\n' +
+                    '\t\t<feedburner:info uri="anonymizedname" />\n' +
+                    '\t\t<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" />\n' +
+                    '\t\t<link random="this is a random link with default namespace" xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" />\n' +
+                    '\t\t<item> \n' +
+                    '\t\t\t<title>Twitch Live Firefox Extension</title> \n' +
+                    '\t\t\t<link>http://feedproxy.google.com/~r/AnonymizedName/~3/bgP9j-roaZQ/</link> \n' +
+                    '\t\t\t<pubDate>Thu, 27 Sep 2018 09:00:00 -0700</pubDate> \n' +
+                    '\t\t\t<author>anonymizedname@gmail.com (Anonymized Name)</author> \n' +
+                    '\t\t\t<guid isPermaLink="false">http://www.anonymizedname.com/blog/2018/09/27/twitch-live-firefox-extension/</guid> \n' +
+                    '\t\t\t<description>&lt;p&gt;I have ported my Twitch Live browser extension for Google Chrome to Firefox. Twitch Live is a toolbar extension that makes it easy to see when your favoritie streamers on Twitch are live.&lt;/p&gt; &lt;p&gt;&lt;img src="/blog/images/posts/twitchlivefirefox/screenshot.png" alt="Drawing" style="width: 798px;"/&gt;&lt;/p&gt; &lt;p&gt;There are options to open streams in a new window or tab, to enable notifications, as well as filter out vod c [...]
+                    '\t\t\t<feedburner:origLink>http://www.anonymizedname.com/blog/2018/09/27/twitch-live-firefox-extension/</feedburner:origLink>\n' +
+                    '\t\t</item> \n' +
+                    '\t</channel> \n' +
+                    '</rss></xml>';
+        }
+        
+        [After]
+        public function tearDown():void
+        {
+            source=null;
+            XML.setSettings(settings);
+        }
+        
+        [BeforeClass]
+        public static function setUpBeforeClass():void
+        {
+        }
+        
+        [AfterClass]
+        public static function tearDownAfterClass():void
+        {
+        }
+    
+    
+        private var atom:Namespace = ATOM_NS;
+        
+        
+        [Test]
+        public function testChildQueryWithNamespace():void{
+            
+            var xml:XML = new XML(source);
+            
+            var atomLinks:XMLList = xml.rss.channel.atom::link;
+            assertEquals(atomLinks.length(),2, 'unexpected results from namespace based child query');
+            
+            //@todo:
+            //RoyaleUnitTestRunner.consoleOut('atomLinks');
+            //RoyaleUnitTestRunner.consoleOut(atomLinks.toString());
+            //SWF Output includes ancestor namespaces:
+            /*
+            <atom10:link rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/AnonymizedName" xmlns:atom10="http://www.w3.org/2005/Atom" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"/>
+            <atom10:link rel="hub" href="http://pubsubhubbub.appspot.com/" xmlns:atom10="http://www.w3.org/2005/Atom" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"/>
+           
+             */
+            //JS Output does not (yet) include ancestor namespaces:
+            /*
+            <atom10:link rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/AnonymizedName" xmlns:atom10="http://www.w3.org/2005/Atom"/>
+            <atom10:link rel="hub" href="http://pubsubhubbub.appspot.com/" xmlns:atom10="http://www.w3.org/2005/Atom"/>
+            
+            */
+            
+        }
+    
+    
+        [Test]
+        public function testDescendantsQueryWithNamespace():void{
+        
+            var xml:XML = new XML(source);
+        
+            var atomLinks:XMLList = xml..atom::link;
+            assertEquals(atomLinks.length(),2, 'unexpected results from namespace based child query');
+        
+            //@todo:
+            RoyaleUnitTestRunner.consoleOut('dscendants atomLinks');
+            RoyaleUnitTestRunner.consoleOut(atomLinks.toString());
+            //SWF Output includes ancestor namespaces:
+            /*
+            <atom10:link rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/AnonymizedName" xmlns:atom10="http://www.w3.org/2005/Atom" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"/>
+            <atom10:link rel="hub" href="http://pubsubhubbub.appspot.com/" xmlns:atom10="http://www.w3.org/2005/Atom" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"/>
+           
+             */
+            //JS Output does not (yet) include ancestor namespaces:
+            /*
+            <atom10:link rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/AnonymizedName" xmlns:atom10="http://www.w3.org/2005/Atom"/>
+            <atom10:link rel="hub" href="http://pubsubhubbub.appspot.com/" xmlns:atom10="http://www.w3.org/2005/Atom"/>
+            
+            */
+        
+        }
+        
+        
+    }
+}