changeset 671:2f0f8d1d0753

Merge
author sundar
date Tue, 12 Nov 2013 10:23:42 +0530
parents d091499d67fc (diff) e65a98146b94 (current diff)
children 1db3d4e4d189 779e155419b8
files
diffstat 19 files changed, 690 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Mon Nov 11 14:25:01 2013 +0100
+++ b/.hgtags	Tue Nov 12 10:23:42 2013 +0530
@@ -219,3 +219,9 @@
 f35e1255024b66f7cf82517798f45f6e194e5567 jdk8-b107
 445ad3f6d3b4ba62ebc483323e1919110a304053 jdk8-b108
 6ec2f9e5ed5bd60c2900976e6a54fdcac2f37e9e jdk8-b109
+d49a8c2173f5f90c9a39cc4af8e03cfa8f35ee4c jdk8-b110
+75fd3486e584f20475c064a2cd4d01ac6406a511 jdk8-b111
+6a4fdb3bb4e34af4c5bb8db467bb01e13b1a7e31 jdk8-b112
+676cd7bf5e092356f7ee2116c8cf88cdc12377c7 jdk8-b113
+79f7b79bf97b71c9b5c9b103dbdef5f269eeb86d jdk8-b114
+f0d3ac2474ee755b1180ec71bcdfa190845b17eb jdk8-b115
--- a/make/build.xml	Mon Nov 11 14:25:01 2013 +0100
+++ b/make/build.xml	Tue Nov 12 10:23:42 2013 +0530
@@ -46,6 +46,16 @@
     <available property="asm.available" classname="jdk.internal.org.objectweb.asm.Type"/>
     <!-- check if testng.jar is avaiable -->
     <available property="testng.available" file="${file.reference.testng.jar}"/>
+    <!-- check if Jemmy ang testng.jar are avaiable -->
+    <condition property="jemmy.jfx.testng.available" value="true">
+      <and> 
+        <available file="${file.reference.jemmyfx.jar}"/>
+        <available file="${file.reference.jemmycore.jar}"/>
+        <available file="${file.reference.jemmyawtinput.jar}"/>
+        <available file="${file.reference.jfxrt.jar}"/>
+        <isset property="testng.available"/>
+      </and>
+    </condition>
 
     <!-- enable/disable make code coverage -->
     <condition property="cc.enabled">
@@ -351,6 +361,38 @@
       </java>
   </target>
 
+  <target name="check-jemmy.jfx.testng" unless="jemmy.jfx.testng.available">
+    <echo message="WARNING: Jemmy or JavaFX or TestNG not available, will not run tests. Please copy testng.jar, JemmyCore.jar, JemmyFX.jar, JemmyAWTInput.jar under test${file.separator}lib directory. And make sure you have jfxrt.jar in ${java.home}${file.separator}lib${file.separator}ext dir."/>
+  </target>
+
+  <target name="testjfx" depends="jar, check-jemmy.jfx.testng, compile-test" if="jemmy.jfx.testng.available">
+    <fileset id="test.classes" dir="${build.test.classes.dir}">
+       <include name="**/framework/*Test.class"/>
+    </fileset>
+    
+    <copy file="${file.reference.jfxrt.jar}" todir="dist"/>
+    
+    <condition property="jfx.prism.order" value="-Dprism.order=j2d" else=" ">
+		<not>
+            <os family="mac"/>
+        </not>
+	</condition>
+    
+    <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
+       verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
+      <jvmarg line="${ext.class.path}"/>
+      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
+      <propertyset>
+        <propertyref prefix="testjfx-test-sys-prop."/>
+        <mapper from="testjfx-test-sys-prop.*" to="*" type="glob"/>
+      </propertyset>
+      <sysproperty key="test.fork.jvm.options" value="${testjfx-test-sys-prop.test.fork.jvm.options} ${jfx.prism.order}"/>
+      <classpath>
+          <pathelement path="${testjfx.run.test.classpath}"/>
+      </classpath>
+    </testng>
+  </target>
+  
   <target name="test262" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
     <fileset id="test.classes" dir="${build.test.classes.dir}">
        <include name="**/framework/*Test.class"/>
--- a/make/project.properties	Mon Nov 11 14:25:01 2013 +0100
+++ b/make/project.properties	Tue Nov 12 10:23:42 2013 +0530
@@ -118,6 +118,7 @@
 test.external.dir=test/script/external
 test262.dir=${test.external.dir}/test262
 test262.suite.dir=${test262.dir}/test/suite
+testjfx.dir=${test.script.dir}/jfx
 
 test-sys-prop.test.dir=${test.dir}
 test-sys-prop.test.js.roots=${test.basic.dir} ${test.error.dir} ${test.sandbox.dir} ${test.trusted.dir}
@@ -208,6 +209,32 @@
     ${test262.dir}/test/harness/framework.js \
     ${test262.dir}/test/harness/sta.js
 
+# testjfx test root
+testjfx-test-sys-prop.test.js.roots=${testjfx.dir}   
+
+# execute testjfx tests in shared nashorn context or not?
+testjfx-test-sys-prop.test.js.shared.context=false
+
+# framework root for our script tests
+testjfx-test-sys-prop.test.js.framework=\
+    -fx \
+    ${test.script.dir}${file.separator}jfx.js
+
+file.reference.jemmyfx.jar=test${file.separator}lib${file.separator}JemmyFX.jar
+file.reference.jemmycore.jar=test${file.separator}lib${file.separator}JemmyCore.jar
+file.reference.jemmyawtinput.jar=test${file.separator}lib${file.separator}JemmyAWTInput.jar
+file.reference.jfxrt.jar=${java.home}${file.separator}lib${file.separator}ext${file.separator}jfxrt.jar
+testjfx.run.test.classpath=\
+    ${file.reference.jemmyfx.jar}${path.separator}\
+    ${file.reference.jemmycore.jar}${path.separator}\
+    ${file.reference.jemmyawtinput.jar}${path.separator}\
+    ${file.reference.testng.jar}${path.separator}\
+    ${nashorn.internal.tests.jar}${path.separator}\
+    ${nashorn.api.tests.jar}
+
+# testjfx VM options for script tests with @fork option
+testjfx-test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} -cp ${testjfx.run.test.classpath}
+
 run.test.classpath=\
     ${file.reference.testng.jar}:\
     ${nashorn.internal.tests.jar}:\
--- a/makefiles/BuildNashorn.gmk	Mon Nov 11 14:25:01 2013 +0100
+++ b/makefiles/BuildNashorn.gmk	Tue Nov 12 10:23:42 2013 +0530
@@ -37,35 +37,35 @@
 NASHORN_FULL_VERSION := $(FULL_VERSION)
 
 ifdef MILESTONE
-  ifeq ($(MILESTONE),internal)
+  ifeq ($(MILESTONE), internal)
     NASHORN_VERSION = $(FULL_VERSION)
   endif
 endif
 
 # Need to use source and target 7 for nasgen to work.
-$(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE_DEBUG,\
-    JVM:=$(JAVA),\
-    JAVAC:=$(NEW_JAVAC),\
-    FLAGS:=-g -source 7 -target 7 -bootclasspath $(JDK_CLASSES),\
-    SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
-    SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
+$(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE_DEBUG, \
+    JVM := $(JAVA), \
+    JAVAC := $(NEW_JAVAC), \
+    FLAGS := -g -source 7 -target 7 -bootclasspath $(JDK_CLASSES), \
+    SERVER_DIR := $(SJAVAC_SERVER_DIR), \
+    SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
 
 # Build nashorn into intermediate directory
-$(eval $(call SetupJavaCompilation,BUILD_NASHORN,\
-    SETUP:=GENERATE_NEWBYTECODE_DEBUG,\
-    SRC:=$(NASHORN_TOPDIR)/src,\
-    COPY:=.properties .js,\
-    BIN:=$(NASHORN_OUTPUTDIR)/nashorn_classes))
+$(eval $(call SetupJavaCompilation,BUILD_NASHORN, \
+    SETUP := GENERATE_NEWBYTECODE_DEBUG, \
+    SRC := $(NASHORN_TOPDIR)/src, \
+    COPY := .properties .js, \
+    BIN := $(NASHORN_OUTPUTDIR)/nashorn_classes))
 
 NASGEN_SRC := $(NASHORN_TOPDIR)/buildtools/nasgen/src
 ASM_SRC := $(JDK_TOPDIR)/src/share/classes/jdk/internal/org/objectweb/asm
 
 # Build nasgen
-$(eval $(call SetupJavaCompilation,BUILD_NASGEN,\
-    SETUP:=GENERATE_NEWBYTECODE_DEBUG,\
-    SRC:=$(NASGEN_SRC) $(ASM_SRC), \
-    BIN:=$(NASHORN_OUTPUTDIR)/nasgen_classes,\
-    ADD_JAVAC_FLAGS:=-cp $(NASHORN_OUTPUTDIR)/nashorn_classes))
+$(eval $(call SetupJavaCompilation,BUILD_NASGEN, \
+    SETUP := GENERATE_NEWBYTECODE_DEBUG, \
+    SRC := $(NASGEN_SRC) $(ASM_SRC), \
+    BIN := $(NASHORN_OUTPUTDIR)/nasgen_classes, \
+    ADD_JAVAC_FLAGS := -cp $(NASHORN_OUTPUTDIR)/nashorn_classes))
 
 # Nasgen needs nashorn classes
 $(BUILD_NASGEN): $(BUILD_NASHORN)
@@ -77,35 +77,36 @@
 	$(RM) -rf $(@D)/jdk $(@D)/netscape
 	$(CP) -R -p $(NASHORN_OUTPUTDIR)/nashorn_classes/* $(@D)/
 	$(FIXPATH) $(JAVA) \
-		-cp "$(NASHORN_OUTPUTDIR)/nasgen_classes$(PATH_SEP)$(NASHORN_OUTPUTDIR)/nashorn_classes" \
-		jdk.nashorn.internal.tools.nasgen.Main $(@D) jdk.nashorn.internal.objects $(@D)
+	    -cp "$(NASHORN_OUTPUTDIR)/nasgen_classes$(PATH_SEP)$(NASHORN_OUTPUTDIR)/nashorn_classes" \
+	    jdk.nashorn.internal.tools.nasgen.Main $(@D) jdk.nashorn.internal.objects $(@D)
 	$(TOUCH) $@
 
 # Version file needs to be processed with version numbers
 VERSION_FILE := $(NASHORN_OUTPUTDIR)/classes/jdk/nashorn/internal/runtime/resources/version.properties
+
 # Needs to happen after nasgen run since nasgen run deletes it
 $(VERSION_FILE): $(NASHORN_OUTPUTDIR)/classes/_the.nasgen.run
 $(VERSION_FILE): $(NASHORN_TOPDIR)/src/jdk/nashorn/internal/runtime/resources/version.properties-template
 	$(ECHO) Creating version.properties
 	$(MKDIR) -p $(@D)
 	$(CAT) $< | $(SED) -e 's/$$(FULL_VERSION)/$(NASHORN_FULL_VERSION)/g' \
-		-e 's/$$(RELEASE)/$(NASHORN_VERSION)/g' \
-		-e '/^#.*$$/d' -e '/^$$/d'  > $@
+	    -e 's/$$(RELEASE)/$(NASHORN_VERSION)/g' \
+	    -e '/^#.*$$/d' -e '/^$$/d'  > $@
 
 
-MANIFEST_ATTRIBUTES:=Name: jdk/nashorn/\nImplementation-Title: Oracle Nashorn\nImplementation-Version: $(NASHORN_FULL_VERSION)
+MANIFEST_ATTRIBUTES := Name: jdk/nashorn/\nImplementation-Title: Oracle Nashorn\nImplementation-Version: $(NASHORN_FULL_VERSION)
 
 # Create nashorn.jar from the final classes dir
-$(eval $(call SetupArchive,BUILD_NASHORN_JAR,\
+$(eval $(call SetupArchive,BUILD_NASHORN_JAR, \
     $(NASHORN_OUTPUTDIR)/classes/_the.nasgen.run \
-    $(VERSION_FILE),\
-    SRCS:=$(NASHORN_OUTPUTDIR)/classes,\
-    SUFFIXES:=.class .js .properties Factory,\
-    MANIFEST:=$(NASHORN_TOPDIR)/src/META-INF/MANIFEST.MF,\
-    EXTRA_MANIFEST_ATTR:=$(MANIFEST_ATTRIBUTES),\
-    SKIP_METAINF:=true,\
-    JAR:=$(NASHORN_JAR)))
+    $(VERSION_FILE), \
+    SRCS := $(NASHORN_OUTPUTDIR)/classes, \
+    SUFFIXES := .class .js .properties Factory, \
+    MANIFEST := $(NASHORN_TOPDIR)/src/META-INF/MANIFEST.MF, \
+    EXTRA_MANIFEST_ATTR := $(MANIFEST_ATTRIBUTES), \
+    SKIP_METAINF := true, \
+    JAR := $(NASHORN_JAR)))
 
 all: $(NASHORN_JAR)
-    
+
 .PHONY: all
--- a/makefiles/Makefile	Mon Nov 11 14:25:01 2013 +0100
+++ b/makefiles/Makefile	Tue Nov 12 10:23:42 2013 +0530
@@ -24,19 +24,19 @@
 #
 
 # Locate this Makefile
-ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
-    makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
+ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))), )
+  makefile_path := $(CURDIR)/$(lastword $(MAKEFILE_LIST))
 else
-    makefile_path:=$(lastword $(MAKEFILE_LIST))
+  makefile_path := $(lastword $(MAKEFILE_LIST))
 endif
-repo_dir:=$(patsubst %/makefiles/Makefile,%,$(makefile_path))
+repo_dir := $(patsubst %/makefiles/Makefile, %, $(makefile_path))
 
 # What is the name of this subsystem (langtools, corba, etc)?
-subsystem_name:=$(notdir $(repo_dir))
+subsystem_name := $(notdir $(repo_dir))
 
 # Try to locate top-level makefile
-top_level_makefile:=$(repo_dir)/../common/makefiles/Makefile
-ifneq ($(wildcard $(top_level_makefile)),)
+top_level_makefile := $(repo_dir)/../common/makefiles/Makefile
+ifneq ($(wildcard $(top_level_makefile)), )
   $(info Will run $(subsystem_name) target on top-level Makefile)
   $(info WARNING: This is a non-recommended way of building!)
   $(info ===================================================)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/jfx.js	Tue Nov 12 10:23:42 2013 +0530
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Base library for JavaFX canvas run by Nashorn testing.
+ * @subtest
+ * 
+ * 
+ */
+
+var System               = Java.type("java.lang.System");
+var AWTImage             = Java.type("org.jemmy.image.AWTImage");
+var PNGDecoder           = Java.type("org.jemmy.image.PNGDecoder");
+var JemmyFxRoot          = Java.type("org.jemmy.fx.Root");
+var AWTRobotCapturer     = Java.type("org.jemmy.image.AWTRobotCapturer");
+var ByWindowType         = Java.type("org.jemmy.fx.ByWindowType");
+var Scene                = Java.type("javafx.scene.Scene");
+var Stage                = Java.type("javafx.stage.Stage");
+var File                 = Java.type("java.io.File");
+var OSInfo               = Java.type("sun.awt.OSInfo");
+var OSType               = Java.type("sun.awt.OSInfo.OSType");
+var StringBuffer         = Java.type("java.lang.StringBuffer");
+var Paint                = Java.type("javafx.scene.paint.Paint");
+var Color                = Java.type("javafx.scene.paint.Color");
+var Image                = Java.type("javafx.scene.image.Image");
+var Canvas               = Java.type("javafx.scene.canvas.Canvas");
+var BorderPane           = Java.type("javafx.scene.layout.BorderPane");
+var StackPane            = Java.type("javafx.scene.layout.StackPane");
+var StrokeLineCap        = Java.type("javafx.scene.shape.StrokeLineCap");
+var Platform             = Java.type("javafx.application.Platform");
+var Runnable             = Java.type("java.lang.Runnable");
+var RunnableExtend       = Java.extend(Runnable);
+var AnimationTimer       = Java.type("javafx.animation.AnimationTimer");
+var AnimationTimerExtend = Java.extend(AnimationTimer);
+var Timer                = Java.type("java.util.Timer");
+var TimerTask            = Java.type("java.util.TimerTask");
+
+var TESTNAME = "test";
+var fsep = System.getProperty("file.separator");
+
+function checkImageAndExit() {
+    var raceTimer = new Timer(true);
+    var timerTask = new TimerTask() {
+        run: function run() {
+            var tmpdir = System.getProperty("java.io.tmpdir");
+            var timenow = (new Date()).getTime();
+            var scrShotTmp = tmpdir + fsep + "screenshot" + timenow +".png";
+            var goldenImageDir = __DIR__ + "jfx" + fsep + TESTNAME + fsep + "golden";
+            makeScreenShot(scrShotTmp);
+            var dupImg = isDuplicateImages(scrShotTmp, goldenImageDir);
+            (new File(scrShotTmp)).delete();
+            if (!dupImg) System.err.println("ERROR: screenshot does not match the golden image");
+            exit(0);
+        }
+    };
+    raceTimer.schedule(timerTask, 100);
+}
+
+function makeScreenShot(shootToImg) {
+   JemmyFxRoot.ROOT.getEnvironment().setImageCapturer(new AWTRobotCapturer());
+   var wrap = JemmyFxRoot.ROOT.lookup(new ByWindowType($STAGE.class)).lookup(Scene.class).wrap(0);
+   var imageJemmy = wrap.getScreenImage();
+   imageJemmy.save(shootToImg);
+}
+
+function isDuplicateImages(screenShot, goldenDir) {
+    var f1 = new File(screenShot);
+    var f2;
+    var sb = new StringBuffer(goldenDir);
+    if (OSInfo.getOSType() == OSType.WINDOWS) {
+        f2 = new File(sb.append(fsep + "windows.png").toString());
+    } else if (OSInfo.getOSType() == OSType.LINUX) {
+        f2 = new File(sb.append(fsep + "linux.png").toString());
+    } else if (OSInfo.getOSType() == OSType.MACOSX) {
+        f2 = new File(sb.append(fsep + "macosx.png").toString());
+    }
+    if (f1.exists() && f2.exists()) {
+        var image1 = new AWTImage(PNGDecoder.decode(f1.getAbsolutePath()));
+        var image2 = new AWTImage(PNGDecoder.decode(f2.getAbsolutePath()));
+        return image1.compareTo(image2) == null ? true : false;
+    }
+    return false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/jfx/flyingimage.js	Tue Nov 12 10:23:42 2013 +0530
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Testing JavaFX canvas run by Nashorn.
+ *
+ * @test/nocompare
+ * @run
+ * @fork
+ */
+
+TESTNAME = "flyingimage";
+
+var WIDTH = 800;
+var HEIGHT = 600;
+var canvas = new Canvas(WIDTH, HEIGHT);
+function fileToURL(file) {
+    return new File(file).toURI().toURL().toExternalForm();
+}
+var imageUrl = fileToURL(__DIR__ + "flyingimage/flyingimage.png");
+var img = new Image(imageUrl);
+var isFrameRendered = false;
+function renderFrame() {
+    var t = frame;
+    var gc = canvas.graphicsContext2D;
+    gc.setFill(Color.web("#cccccc"));
+    gc.fillRect(0, 0, WIDTH, HEIGHT);
+    gc.setStroke(Color.web("#000000"));
+    gc.setLineWidth(1);
+    gc.strokeRect(5, 5, WIDTH - 10, HEIGHT - 10);
+    var c = 200;
+    var msc= 0.5 * HEIGHT / img.height;
+    var sp0 = 0.003;
+    for (var h = 0; h < c; h++) {
+        gc.setTransform(1, 0, 0, 1, 0, 0);
+        var yh = h / (c - 1);
+        gc.translate((0.5 + Math.sin(t * sp0 + h * 0.1) / 3) * WIDTH, 25 + (HEIGHT * 3 / 4 - 40) * (yh * yh));
+        var sc = 30 / img.height + msc * yh * yh;
+        gc.rotate(90 * Math.sin(t * sp0 + h * 0.1 + Math.PI));
+        gc.scale(sc, sc);
+        gc.drawImage(img, -img.width / 2, -img.height / 2);
+    }
+    gc.setTransform(1, 0, 0, 1, 0, 0);
+    isFrameRendered = true;
+}
+var stack = new StackPane();
+var pane = new BorderPane();
+pane.setCenter(canvas);
+stack.getChildren().add(pane);
+$STAGE.scene = new Scene(stack);
+var frame = 0;
+var timer = new AnimationTimerExtend() {
+    handle: function handle(now) {
+        if (frame < 200) {
+            renderFrame();
+            frame++;
+        } else {
+            checkImageAndExit();        
+            timer.stop();
+        }
+    }
+};
+timer.start();
+ 
Binary file test/script/jfx/flyingimage/flyingimage.png has changed
Binary file test/script/jfx/flyingimage/golden/linux.png has changed
Binary file test/script/jfx/flyingimage/golden/macosx.png has changed
Binary file test/script/jfx/flyingimage/golden/windows.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/jfx/kaleidoscope.js	Tue Nov 12 10:23:42 2013 +0530
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Testing JavaFX canvas run by Nashorn.
+ *
+ * @test/nocompare
+ * @run
+ * @fork
+ */
+
+TESTNAME = "kaleidoscope";
+        
+var WIDTH = 800;
+var HEIGHT = 600;
+var canvas = new Canvas(WIDTH, HEIGHT);
+var context = canvas.graphicsContext2D;
+
+var x,y;
+var p_x,p_y;
+var a=0;
+var b=0;
+var angle=Math.PI/180*8;
+var color=0;
+var limit1=Math.PI*1.5;
+var limit2=Math.PI*1.79;
+var c=new Array(6);
+var d=new Array(6);
+var r,e;
+var fade;
+var prv_x,prv_y,prv_x2,prv_y2;
+var isFrameRendered = false;
+
+function renderFrame() {
+	if (!isFrameRendered) {
+        a=0.2*angle;
+		b=0.7*angle;
+		r=0;
+		fade=32;
+		for(var i=0;i<6;i++)
+			{
+			c[i]=1.0/(i+1)/2;
+			d[i]=1.0/(i+1)/2;
+			}
+		radius=Math.round((WIDTH+HEIGHT)/8);
+		e=radius*0.2;
+		p_x=Math.round(WIDTH/2);
+		p_y=Math.round(HEIGHT/2);
+		x=(radius*c[0])*Math.cos(a*d[1])+(radius*c[2])*Math.sin(a*d[3])+(radius*c[4])*Math.sin(a*d[5]);
+		y=(radius*c[5])*Math.sin(a*d[4])+(radius*c[3])*Math.cos(a*d[2])+(radius*c[1])*Math.cos(a*d[0]);
+        isFrameRendered = true;
+    }
+    anim();
+}
+
+function anim() {
+	var a1=Math.cos(a*2);
+	var a2=Math.cos(a*4);
+	var a3=Math.cos(a);
+	var a4=Math.sin(a);
+	if(b>limit1&&b<limit2) {
+		r+=radius*0.02*a1;
+		prv_x=x;
+		prv_y=y;
+		x=prv_x2+r*a3;
+		y=prv_y2+r*a4;
+	} else {
+		prv_x=x;
+		prv_y=y;
+		prv_x2=x;
+		prv_y2=y;
+		x=(radius*c[0])*Math.cos(a*d[1])+(radius*c[2])*Math.sin(a*d[3])+(radius*c[4])*Math.sin(a*d[5]);
+		y=(radius*c[5])*Math.sin(a*d[4])+(radius*c[3])*Math.cos(a*d[2])+(radius*c[1])*Math.cos(a*d[0]);
+	}
+	var c3=16*Math.cos(a*10);
+	var c1=Math.floor(56*Math.cos(a*angle*4)+c3);
+	var c2=Math.floor(56*Math.sin(a*angle*4)-c3);
+	context.lineCap=StrokeLineCap.ROUND;
+	context.setStroke(Paint.valueOf('rgba('+(192+c1)+','+(192+c2)+','+(192-c1)+','+(0.01-0.005*-a1)+')'));
+	context.lineWidth=e*1.4+e*0.8*a3;
+	draw_line(p_x,p_y,prv_x,prv_y,x,y);
+	context.lineWidth=e+e*0.8*a3;
+	draw_line(p_x,p_y,prv_x,prv_y,x,y);
+	context.setStroke(Paint.valueOf('rgba('+(192+c1)+','+(192+c2)+','+(192-c1)+','+(0.06-0.03*-a1)+')'));
+	context.lineWidth=e*0.6+e*0.35*a3;
+	draw_line(p_x,p_y,prv_x,prv_y,x,y);
+	context.setStroke(Paint.valueOf('rgba(0,0,0,0.06)'));
+	context.lineWidth=e*0.4+e*0.225*a3;
+	draw_line(p_x,p_y,prv_x,prv_y,x,y);
+	context.setStroke(Paint.valueOf('rgba('+(192+c1)+','+(192+c2)+','+(192-c1)+','+(0.1-0.075*-a1)+')'));
+	context.lineWidth=e*0.2+e*0.1*a3;
+	draw_line(p_x,p_y,prv_x,prv_y,x,y);
+	context.setStroke(Paint.valueOf('rgba(255,255,255,0.4)'));
+	context.lineWidth=e*(0.1-0.05*-a2);
+	draw_line(p_x,p_y,prv_x,prv_y,x,y);
+	a+=angle*Math.cos(b);
+	b+=angle*0.1;
+}
+
+function draw_line(x,y,x1,y1,x2,y2) {
+	context.beginPath();
+	context.moveTo(x+x1,y+y1);
+	context.lineTo(x+x2,y+y2);
+	context.moveTo(x-x1,y+y1);
+	context.lineTo(x-x2,y+y2);
+	context.moveTo(x-x1,y-y1);
+	context.lineTo(x-x2,y-y2);
+	context.moveTo(x+x1,y-y1);
+	context.lineTo(x+x2,y-y2);
+	context.moveTo(x+y1,y+x1);
+	context.lineTo(x+y2,y+x2);
+	context.moveTo(x-y1,y+x1);
+	context.lineTo(x-y2,y+x2);
+	context.moveTo(x-y1,y-x1);
+	context.lineTo(x-y2,y-x2);
+	context.moveTo(x+y1,y-x1);
+	context.lineTo(x+y2,y-x2);
+	context.moveTo(x,y+x2);
+	context.lineTo(x,y+x1);
+	context.moveTo(x,y-x2);
+	context.lineTo(x,y-x1);
+	context.moveTo(x+x2,y);
+	context.lineTo(x+x1,y);
+	context.moveTo(x-x2,y);
+	context.lineTo(x-x1,y);
+	context.stroke();
+	context.closePath();
+}
+
+var stack = new StackPane();
+var pane = new BorderPane();
+pane.setCenter(canvas);
+stack.getChildren().add(pane);
+$STAGE.scene = new Scene(stack);
+var frame = 0;
+var timer = new AnimationTimerExtend() {
+    handle: function handle(now) {
+        if (frame < 800) {
+            renderFrame();
+            frame++;
+        } else {
+            checkImageAndExit();
+            timer.stop();
+        }
+    }
+};
+timer.start();
Binary file test/script/jfx/kaleidoscope/golden/linux.png has changed
Binary file test/script/jfx/kaleidoscope/golden/macosx.png has changed
Binary file test/script/jfx/kaleidoscope/golden/windows.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/jfx/spread.js	Tue Nov 12 10:23:42 2013 +0530
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Testing JavaFX canvas run by Nashorn.
+ *
+ * @test/nocompare
+ * @run
+ * @fork
+ */
+ 
+TESTNAME = "spread";
+
+var WIDTH = 800;
+var HEIGHT = 600;
+var canvas = new Canvas(WIDTH, HEIGHT);
+var context = canvas.graphicsContext2D;
+
+/* "Spread" tech demo of canvas by Tom Theisen
+ *
+ * This will animate a sequence of branch structures in a canvas element.
+ * Each frame, a new direction is calculated, similar to the last frame.
+ */
+
+var start_width = 20;           // starting width of each branch
+var frame_time = 30;            // milliseconds per frame
+var straighten_factor = 0.95;   // value from 0 to 1, factor applied to direction_offset every frame
+var curviness = 0.2;            // amount of random direction change each frame
+
+var color_speed = 0.03;     // speed at which colors change when cycling is enabled
+var branch_shrink = 0.95;   // factor by which branches shrink every frame
+var min_width = 1;          // minimum WIDTH for branch, after which they are discontinued
+var branch_opacity = 0.4;   // opacity of lines drawn
+var branch_count = 3;       // branch count per tree
+var branch_bud_size = 0.5;  // ratio of original branch size at which branch will split
+var branch_bud_angle = 1;   // angle offset for split branch;
+
+var paper;                  // reference to graphics context
+var branches = Object();    // linked list of active branches
+var color_styles = [];      // pre-computed list of colors as styles. format: (r,g,b,a)    
+var direction_offset = 0;   // current direction offset in radians.  this is applied to all branches.
+var frame = 0;              // frame counter
+var timespent = 0;          // total time spent so far, used to calculate average frame render duration
+var frameratespan;          // html span element for updating performance number
+
+// preferences object, contains an attribute for each user setting
+var prefs = {
+    wrap: true,             // causes branches reaching edge of viewable area to appear on opposite side
+    fade: false,             // fade existing graphics on each frame
+    cycle: true,            // gradually change colors each frame
+    new_branch_frames: 20    // number of frames elapsed between each auto-generated tree
+};
+
+// create tree at the specified position with number of branches
+function create_tree(branches, start_width, position, branch_count) {
+    var angle_offset = Math.PI * 2 / branch_count;
+    for (var i = 0; i < branch_count; ++i) {
+        branch_add(branches, new Branch(position, angle_offset * i, start_width));
+    }
+}
+
+// add branch to collection
+function branch_add(branches, branch) {
+    branch.next = branches.next;
+    branches.next = branch;
+}
+
+// get the coordinates for the position of a new tree
+// use the center of the canvas
+function get_new_tree_center(width, height) {
+    return {
+        x: 0.5 * width, 
+        y: 0.5 * height 
+    };
+}
+
+// Branch constructor
+// position has x and y properties
+// direction is in radians
+function Branch(position, direction, width) {
+    this.x = position.x;
+    this.y = position.y;
+    this.width = width;
+    this.original_width = width;
+    this.direction = direction;
+}
+
+// update position, direction and width of a particular branch
+function branch_update(branches, branch, paper) {
+    paper.beginPath();
+    paper.lineWidth = branch.width;
+    paper.moveTo(branch.x, branch.y);
+    
+    branch.width *= branch_shrink;
+    branch.direction += direction_offset;
+    branch.x += Math.cos(branch.direction) * branch.width;
+    branch.y += Math.sin(branch.direction) * branch.width;
+    
+    paper.lineTo(branch.x, branch.y);
+    paper.stroke();
+    
+    if (prefs.wrap) wrap_branch(branch, WIDTH, HEIGHT);
+
+    if (branch.width < branch.original_width * branch_bud_size) {
+        branch.original_width *= branch_bud_size;
+        branch_add(branches, new Branch(branch, branch.direction + 1, branch.original_width));
+    }
+}
+
+function draw_frame() {
+    if (prefs.fade) {
+        paper.fillRect(0, 0, WIDTH, HEIGHT);
+    }
+
+    if (prefs.cycle) {
+        paper.setStroke(Paint.valueOf(color_styles[frame % color_styles.length]));
+    }
+
+    if (frame++ % prefs.new_branch_frames == 0) {
+        create_tree(branches, start_width, get_new_tree_center(WIDTH, HEIGHT), branch_count);
+    }
+    
+    direction_offset += (0.35 + (frame % 200) * 0.0015) * curviness - curviness / 2;
+    direction_offset *= straighten_factor;
+    
+    var branch = branches;
+    var prev_branch = branches;
+    while (branch = branch.next) {
+        branch_update(branches, branch, paper);
+        
+        if (branch.width < min_width) {
+            // remove branch from list
+            prev_branch.next = branch.next;
+        }
+        
+        prev_branch = branch;
+    }
+}
+
+// constrain branch position to visible area by "wrapping" from edge to edge
+function wrap_branch(branch, WIDTH, HEIGHT) {
+    branch.x = positive_mod(branch.x, WIDTH);
+    branch.y = positive_mod(branch.y, HEIGHT);
+}
+
+// for a < 0, b > 0, javascript returns a negative number for a % b
+// this is a variant of the % operator that adds b to the result in this case
+function positive_mod(a, b) {
+    // ECMA 262 11.5.3: Applying the % Operator 
+    // remainder operator does not convert operands to integers,
+    // although negative results are possible
+
+    return ((a % b) + b) % b;
+}
+
+// pre-compute color styles that will be used for color cycling
+function populate_colors(color_speed, color_styles, branch_opacity) {
+    // used in calculation of RGB values
+    var two_thirds_pi = Math.PI * 2 / 3;
+    var four_thirds_pi = Math.PI * 4 / 3;
+    var two_pi = Math.PI * 2;
+
+    // hue does represent hue, but not in the conventional HSL scheme
+    for(var hue = 0; hue < two_pi; hue += color_speed) {
+        var r = Math.floor(Math.sin(hue) * 128 + 128);
+        var g = Math.floor(Math.sin(hue + two_thirds_pi) * 128 + 128);
+        var b = Math.floor(Math.sin(hue + four_thirds_pi) * 128 + 128);
+        color = "rgba(" + [r, g, b, branch_opacity].join() + ")";
+
+        color_styles.push(color);
+    }
+}
+
+// apply initial settings to canvas object
+function setup_canvas() {
+    paper = canvas.graphicsContext2D;
+    paper.setFill(Paint.valueOf('rgb(0, 0, 0)'));
+    paper.fillRect(0, 0, WIDTH, HEIGHT);
+    paper.setFill(Paint.valueOf("rgba(0, 0, 0, 0.005)"));
+    paper.setStroke(Paint.valueOf("rgba(128, 128, 64, " + String(branch_opacity) + ")"));
+}
+
+populate_colors(color_speed, color_styles, branch_opacity);
+setup_canvas();
+
+var stack = new StackPane();
+var pane = new BorderPane();
+pane.setCenter(canvas);
+stack.getChildren().add(pane);
+$STAGE.scene = new Scene(stack);
+var timer = new AnimationTimerExtend() {
+    handle: function handle(now) {
+        if (frame < 200) {
+		    draw_frame();
+        } else {
+            checkImageAndExit();
+            timer.stop();
+        }
+    }
+};
+timer.start();
+
Binary file test/script/jfx/spread/golden/linux.png has changed
Binary file test/script/jfx/spread/golden/macosx.png has changed
Binary file test/script/jfx/spread/golden/windows.png has changed