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 2020/04/15 09:46:52 UTC

[royale-asjs] branch develop updated (f3be6ef -> dfa105d)

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

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


    from f3be6ef  support late label changes in FormItem.  Should fix #797
     new d45d476  Fix for #805. I am not sure why the original code inside mx.core.Application is like it is, so leaving it mainly as is, but avoiding multi-dispatch of 'preinitialize'
     new cb4df56  Fix for ExternalInterface calls with member access
     new be2846e  Fix for URLLoader not honouring the 'contentType' setting of the URLRequest passed in. This fixes issues in mx.rpc HttpService classes.
     new 4f1f5ea  Fix for Boolean primitive type specifically appearing as a Function and not a class
     new dfa105d  XML fixes for appendChild when passed an XMLList. Tests for what happens with different node types from source. Tests include some variations observed in flash player (browser vs. standalone).

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../royale/org/apache/royale/utils/Language.as     |   2 +-
 .../src/main/royale/mx/core/Application.as         |  13 +--
 .../main/royale/mx/external/ExternalInterface.as   |  15 ++-
 .../main/royale/org/apache/royale/net/URLLoader.as |   9 +-
 .../royale/org/apache/royale/net/URLRequest.as     |   2 +-
 frameworks/projects/XML/src/main/royale/XML.as     |  46 ++++++--
 .../royale/flexUnitTests/xml/XMLNamespaceTest.as   |  17 ++-
 .../flexUnitTests/xml/XMLTesterGeneralTest.as      | 119 +++++++++++++++++++++
 8 files changed, 199 insertions(+), 24 deletions(-)


[royale-asjs] 01/05: Fix for #805. I am not sure why the original code inside mx.core.Application is like it is, so leaving it mainly as is, but avoiding multi-dispatch of 'preinitialize'

Posted by gr...@apache.org.
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

commit d45d47636fec97c2da79309a74ba7e0bef86b8af
Author: greg-dove <gr...@gmail.com>
AuthorDate: Wed Apr 15 20:05:09 2020 +1200

    Fix for #805.
    I am not sure why the original code inside mx.core.Application is like it is, so leaving it mainly as is, but avoiding multi-dispatch of 'preinitialize'
---
 .../MXRoyale/src/main/royale/mx/core/Application.as         | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/core/Application.as b/frameworks/projects/MXRoyale/src/main/royale/mx/core/Application.as
index 69f1194..9f669f9 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/Application.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/Application.as
@@ -64,6 +64,7 @@ import mx.events.utils.KeyboardEventConverter;
 import mx.events.utils.MouseEventConverter;
 import mx.managers.FocusManager;
 import mx.managers.ISystemManager;
+import mx.events.FlexEvent;
 
 COMPILE::JS {
     import org.apache.royale.core.ElementWrapper;
@@ -371,7 +372,7 @@ public class Application extends Container implements IStrand, IParent, IEventDi
 		FocusEventConverter.setupAllConverters(stage);
 		KeyboardEventConverter.setupAllConverters(stage);
 		
-		if (dispatchEvent(new org.apache.royale.events.Event("preinitialize", false, true)))
+		if (initialized || dispatchEvent(new org.apache.royale.events.Event("preinitialize", false, true)))
 			this.initializeApplication();
 		else
 			addEventListener(flash.events.Event.ENTER_FRAME, enterFrameHandler);
@@ -381,7 +382,7 @@ public class Application extends Container implements IStrand, IParent, IEventDi
 	COMPILE::SWF
 	private function enterFrameHandler(event:flash.events.Event):void
 	{
-		if (dispatchEvent(new org.apache.royale.events.Event("preinitialize", false, true)))
+		if (initialized || dispatchEvent(new org.apache.royale.events.Event("preinitialize", false, true)))
 		{
 			removeEventListener(flash.events.Event.ENTER_FRAME, enterFrameHandler);
 			this.initializeApplication();
@@ -456,7 +457,7 @@ public class Application extends Container implements IStrand, IParent, IEventDi
         
 		this.initManagers();
 
-        dispatchEvent(new org.apache.royale.events.Event("applicationComplete"));
+        dispatchEvent(new FlexEvent("applicationComplete"));
     }
 	
 	//--------------------------------------------------------------------------
@@ -606,7 +607,7 @@ public class Application extends Container implements IStrand, IParent, IEventDi
 	COMPILE::JS
 	public function start():void
 	{
-		if (dispatchEvent(new org.apache.royale.events.Event("preinitialize", false, true)))
+		if (initialized || dispatchEvent(new FlexEvent("preinitialize", false, true)))
 			initializeApplication();
 		else {			
 			startupTimer = new Timer(34, 0);
@@ -621,7 +622,7 @@ public class Application extends Container implements IStrand, IParent, IEventDi
 	COMPILE::JS
 	protected function handleStartupTimer(event:Event):void
 	{
-		if (dispatchEvent(new org.apache.royale.events.Event("preinitialize", false, true)))
+		if (initialized || dispatchEvent(new FlexEvent("preinitialize", false, true)))
 		{
 			startupTimer.stop();
 			initializeApplication();
@@ -655,7 +656,7 @@ public class Application extends Container implements IStrand, IParent, IEventDi
 //			
 //			dispatchEvent(new org.apache.royale.events.Event("viewChanged"));
 //		}
-		dispatchEvent(new org.apache.royale.events.Event("applicationComplete"));
+		dispatchEvent(new FlexEvent("applicationComplete"));
 	}
 	
     COMPILE::JS


[royale-asjs] 02/05: Fix for ExternalInterface calls with member access

Posted by gr...@apache.org.
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

commit cb4df561ede120049ea33f4ef0866207ea6a57cb
Author: greg-dove <gr...@gmail.com>
AuthorDate: Wed Apr 15 20:05:48 2020 +1200

    Fix for ExternalInterface calls with member access
---
 .../src/main/royale/mx/external/ExternalInterface.as      | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/external/ExternalInterface.as b/frameworks/projects/MXRoyale/src/main/royale/mx/external/ExternalInterface.as
index e27e64f..7899ca8 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/external/ExternalInterface.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/external/ExternalInterface.as
@@ -168,7 +168,20 @@ package mx.external
             COMPILE::JS
             {
                 // find a function with the name...
-                var fnc : Function = window[functionName];
+                var fnc : Function;
+                if (functionName) {
+                    var base:Object = window;
+                    var dotIdx:int = functionName.indexOf('.');
+                    if (dotIdx != -1) {
+                        while(dotIdx != -1) {
+                            base = base[functionName.substr(0, dotIdx)];
+                            functionName = functionName.substr(dotIdx + 1);
+                            dotIdx = functionName.indexOf('.');
+                        }
+                    }
+                    fnc = base[functionName];
+                }
+
                 if (fnc)
                 {
                     return fnc.apply(null, args);


[royale-asjs] 04/05: Fix for Boolean primitive type specifically appearing as a Function and not a class

Posted by gr...@apache.org.
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

commit 4f1f5eaa9d27c64e012889853b77771b69cfe5a5
Author: greg-dove <gr...@gmail.com>
AuthorDate: Wed Apr 15 20:10:18 2020 +1200

    Fix for Boolean primitive type specifically appearing as a Function and not a class
---
 .../Language/src/main/royale/org/apache/royale/utils/Language.as        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/frameworks/projects/Language/src/main/royale/org/apache/royale/utils/Language.as b/frameworks/projects/Language/src/main/royale/org/apache/royale/utils/Language.as
index 086d772..2735eec 100644
--- a/frameworks/projects/Language/src/main/royale/org/apache/royale/utils/Language.as
+++ b/frameworks/projects/Language/src/main/royale/org/apache/royale/utils/Language.as
@@ -544,7 +544,7 @@ package org.apache.royale.utils
                             return typeof v == 'function'
                                     && v.prototype
                                     && v.prototype['constructor'] == v
-                                    && (v.prototype.ROYALE_CLASS_INFO || v.constructor == _synthType || Object.getOwnPropertyNames(v).join().replace(excludeName,'') != isFunc )
+                                    && (v.prototype.ROYALE_CLASS_INFO || v.constructor == _synthType || v == Boolean || Object.getOwnPropertyNames(v).join().replace(excludeName,'') != isFunc )
                         };
                         snythTypeInst = typeStore['Class'] = new _synthType('Class',
                                 function():void{throw new TypeError('Error #1115: Class is not a constructor.')},


[royale-asjs] 05/05: XML fixes for appendChild when passed an XMLList. Tests for what happens with different node types from source. Tests include some variations observed in flash player (browser vs. standalone).

Posted by gr...@apache.org.
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

commit dfa105d8993cbc1df37d5cc16cf59cfe5cbd8df6
Author: greg-dove <gr...@gmail.com>
AuthorDate: Wed Apr 15 21:46:11 2020 +1200

    XML fixes for appendChild when passed an XMLList. Tests for what happens with different node types from source.
    Tests include some variations observed in flash player (browser vs. standalone).
---
 frameworks/projects/XML/src/main/royale/XML.as     |  46 ++++++--
 .../royale/flexUnitTests/xml/XMLNamespaceTest.as   |  17 ++-
 .../flexUnitTests/xml/XMLTesterGeneralTest.as      | 119 +++++++++++++++++++++
 3 files changed, 172 insertions(+), 10 deletions(-)

diff --git a/frameworks/projects/XML/src/main/royale/XML.as b/frameworks/projects/XML/src/main/royale/XML.as
index f876507..de0278c 100644
--- a/frameworks/projects/XML/src/main/royale/XML.as
+++ b/frameworks/projects/XML/src/main/royale/XML.as
@@ -918,22 +918,48 @@ package
 			//normalize();
 			return this;
 		}
-		
+
+		/**
+		 *
+		 * @royaleignorecoercion XML
+		 */
 		private function appendChildInternal(child:*):void
 		{
+			var kind:String;
+			var alreadyPresent:int
+			var children:Array = getChildren();
 			if(child is XMLList)
 			{
 				var len:int = child.length();
 				for(var i:int=0; i<len; i++)
 				{
-					appendChildInternal(child[0]);
+					//reproduce swf behavior... leaves a phantom child in the source
+					var childItem:XML = child[i] as XML;
+					kind = childItem.getNodeRef();
+					if (kind == ATTRIBUTE) {
+						var name:String = childItem.localName();
+						var content:String = '<'+name+'>'+childItem.toString()+'</'+name+'>';
+						childItem = new XML(content)
+					} else {
+						alreadyPresent = children.indexOf(childItem);
+						if (alreadyPresent != -1) children.splice(alreadyPresent, 1);
+					}
+					childItem.setParent(this, true);
+					children.push(childItem);
 				}
 			}
 			else
 			{
 				assertType(child,XML,"Type must be XML");
-				child.setParent(this);
-				getChildren().push(child);
+				kind = child.getNodeRef();
+				if (kind == ATTRIBUTE) {
+					child = new XML(child.toString());
+				} else {
+					alreadyPresent = children.indexOf(child);
+					if (alreadyPresent != -1) children.splice(alreadyPresent, 1);
+				}
+				(child as XML).setParent(this);
+				children.push(child);
 			}
 		}
 		
@@ -2754,13 +2780,17 @@ package
 			}
 			
 		}
-		
-		public function setParent(parent:XML):void
+
+		/**
+		 * @private
+		 * @royalesuppressexport
+		 */
+		public function setParent(parent:XML, keep:Boolean=false):void
 		{
 			if(parent == _parent)
 				return;
 			var oldParent:XML = _parent;
-			if(oldParent)
+			if(oldParent && !keep)
 				oldParent.removeChild(this);
 			_parent = parent;
 		}
@@ -2909,7 +2939,7 @@ package
 			
 			if(str.indexOf("@") == 0)
 				return toAttributeName(name);
-			
+
 			return new QName(str);
 		}
 		
diff --git a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLNamespaceTest.as b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLNamespaceTest.as
index f4dbc8a..dc970c7 100644
--- a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLNamespaceTest.as
+++ b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLNamespaceTest.as
@@ -23,6 +23,10 @@ package flexUnitTests.xml
     import flexUnitTests.xml.support.NamespaceTest;
     
     import org.apache.royale.test.asserts.*;
+
+    COMPILE::SWF{
+        import flash.system.Capabilities;
+    }
     
    // import testshim.RoyaleUnitTestRunner;
     
@@ -101,6 +105,15 @@ package flexUnitTests.xml
             //something for js, indicating javascript 'playerversion' is consistent with more recent flash player versions:
             return 30;
         }
+
+        public function getPlayerType():String{
+            COMPILE::SWF{
+                return Capabilities.playerType;
+            }
+            COMPILE::JS{
+                return 'Browser';
+            }
+        }
         
     
         [Test]
@@ -114,12 +127,12 @@ package flexUnitTests.xml
             //account for what appears to be a player bug in a range of player versions (not verified on Mac)
             // Javascript conforms to the latest swf behavior
             
-            var permitEmptyString:Boolean  = /*playerVersion >= 11.2 &&*/ playerVersion <= 20.0;
+            var permitEmptyString:Boolean  = /*playerVersion >= 11.2 &&*/ playerVersion <= 20.0 || getPlayerType() == 'StandAlone';
             var prefix:* = ns.prefix;
             var testIsOK:Boolean = permitEmptyString ? prefix === '' || prefix === undefined : prefix === undefined;
             
             //assertStrictlyEquals(ns.prefix, undefined, 'unexpected prefix value ');
-            assertTrue(testIsOK, 'unexpected prefix value ');
+            assertTrue(testIsOK, playerVersion+' unexpected prefix value :'+prefix);
             
             var uri:String = ns.uri;
             testIsOK = permitEmptyString ? uri == '' || uri == 'test' : uri == 'test';
diff --git a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
index 0a7b9a9..fd6c175 100644
--- a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
+++ b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
@@ -1155,6 +1155,125 @@ package flexUnitTests.xml
             assertEquals(xml.@myAtt1,'myAttTestVal', 'unexpected attributes value');
 
         }
+
+
+        [Test]
+        public function testAppendChildContentTransfer():void{
+            var source:XML = <source att='attribute'><dog/><cat/><rat/><pig/><cow/><hen/></source>;
+            var sourceChildren:XMLList = source.children();
+            var attList:XMLList = source.@att;
+            var att:XML = attList[0];
+            var orig1:XML = sourceChildren[0];
+            var dest:XML = <dest/>;
+
+            assertTrue(orig1.parent() === source, 'unexpected parent');
+            assertTrue(att.parent() === source, 'unexpected parent');
+            dest.appendChild(sourceChildren);
+            //element was re-parented:
+            assertFalse(orig1.parent() === source, 'unexpected parent');
+            //attribute was not moved:
+            assertTrue(att.parent() === source, 'unexpected parent');
+            assertTrue(orig1.parent() === dest, 'unexpected parent');
+
+            //at this point the actual nodes are present in both xml trees when iterating downwards,
+            //but the 'parent()' evaluation only resolves to the latest parent
+            //this is the swf behavior, but may not conform to standard
+
+            assertEquals(source.toXMLString(),
+                    '<source att="attribute">\n' +
+                    '  <dog/>\n' +
+                    '  <cat/>\n' +
+                    '  <rat/>\n' +
+                    '  <pig/>\n' +
+                    '  <cow/>\n' +
+                    '  <hen/>\n' +
+                    '</source>', 'unexpected source toXMLString')
+
+            assertEquals(dest.toXMLString(),
+                    '<dest>\n' +
+                    '  <dog/>\n' +
+                    '  <cat/>\n' +
+                    '  <rat/>\n' +
+                    '  <pig/>\n' +
+                    '  <cow/>\n' +
+                    '  <hen/>\n' +
+                    '</dest>', 'unexpected dest toXMLString')
+
+            dest.appendChild(attList);
+            //swf has a strange variation here:
+            var appendedAtt1:String = isJS ? '  <att>attribute</att>\n' : '  <att xmlns="flexUnitTests.xml:XMLTesterGeneralTest">attribute</att>\n'
+
+            assertEquals(dest.toXMLString(),
+                    '<dest>\n' +
+                    '  <dog/>\n' +
+                    '  <cat/>\n' +
+                    '  <rat/>\n' +
+                    '  <pig/>\n' +
+                    '  <cow/>\n' +
+                    '  <hen/>\n' +
+                    appendedAtt1 +
+                    '</dest>', 'unexpected dest toXMLString');
+
+            dest.appendChild(att);
+
+            assertEquals(dest.toXMLString(),
+                    '<dest>\n' +
+                    '  <dog/>\n' +
+                    '  <cat/>\n' +
+                    '  <rat/>\n' +
+                    '  <pig/>\n' +
+                    '  <cow/>\n' +
+                    '  <hen/>\n' +
+                    appendedAtt1 +
+                    '  attribute\n' +
+                    '</dest>', 'unexpected dest toXMLString');
+
+
+            dest.appendChild(orig1);
+
+
+            //the source remains unchanged
+            assertEquals(source.toXMLString(),
+                    '<source att="attribute">\n' +
+                    '  <dog/>\n' +
+                    '  <cat/>\n' +
+                    '  <rat/>\n' +
+                    '  <pig/>\n' +
+                    '  <cow/>\n' +
+                    '  <hen/>\n' +
+                    '</source>', 'unexpected source toXMLString');
+
+            //this is effectively a re-ordering inside dest
+            var expected1:String =     '<dest>\n' +
+                    '  <cat/>\n' +
+                    '  <rat/>\n' +
+                    '  <pig/>\n' +
+                    '  <cow/>\n' +
+                    '  <hen/>\n' +
+                    appendedAtt1 +
+                    '  attribute\n' +
+                    '  <dog/>\n' +
+                    '</dest>'
+
+            var expected2:String = '<dest>\n' +
+                    '  <dog/>\n' + //this seems to be the case in standalone debug player
+                    '  <cat/>\n' +
+                    '  <rat/>\n' +
+                    '  <pig/>\n' +
+                    '  <cow/>\n' +
+                    '  <hen/>\n' +
+                    appendedAtt1 +
+                    '  attribute\n' +
+                    '  <dog/>\n' +
+                    '</dest>'
+
+
+            var actual:String = dest.toXMLString();
+
+            assertTrue(actual==expected1 || actual==expected2
+                   , 'unexpected dest toXMLString');
+
+        }
         
         //@todo - Passes in Swf, fails in browser:
         /*[Test]


[royale-asjs] 03/05: Fix for URLLoader not honouring the 'contentType' setting of the URLRequest passed in. This fixes issues in mx.rpc HttpService classes.

Posted by gr...@apache.org.
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

commit be2846e172f2bfc320b410d50ba3ae6051912a63
Author: greg-dove <gr...@gmail.com>
AuthorDate: Wed Apr 15 20:07:40 2020 +1200

    Fix for URLLoader not honouring the 'contentType' setting of the URLRequest passed in. This fixes issues in mx.rpc HttpService classes.
---
 .../Network/src/main/royale/org/apache/royale/net/URLLoader.as   | 9 ++++-----
 .../Network/src/main/royale/org/apache/royale/net/URLRequest.as  | 2 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLLoader.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLLoader.as
index 381e8a5..d4bc969 100644
--- a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLLoader.as
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLLoader.as
@@ -218,14 +218,13 @@ package org.apache.royale.net
                         element.setRequestHeader(header.name, header.value);
                     }
                 }
-                
-                /*
-                if (request.method != HTTPConstants.GET &&
+
+                if (request.contentType && request.method != HTTPConstants.GET &&
                     !sawContentType && contentData) {
                     element.setRequestHeader(
-                        HTTPHeader.CONTENT_TYPE, _contentType);
+                        HTTPHeader.CONTENT_TYPE, request.contentType);
                 }
-                */
+
                 if (_corsCredentialsChecker != null) {
                     element.withCredentials = _corsCredentialsChecker(url);
                 }
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLRequest.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLRequest.as
index 512d726..1b39a7e 100644
--- a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLRequest.as
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLRequest.as
@@ -89,7 +89,7 @@ package org.apache.royale.net
             {
                 this.url = url;
             }
-            this.requestHeaders = [];
+            this._requestHeaders = [];
         }
 
 		/**