changeset 6494:9604915644c1

RT-36197: Create regression tests that run JavaFX apps with a security manager Reviewed-by: felipe, ckyang
author kcr
date Tue, 18 Mar 2014 14:17:08 -0700
parents 15fdfaeb91f6
children 579fbfe34c8c
files tests/system/src/test/java/sandbox/Constants.java tests/system/src/test/java/sandbox/SandboxAppTest.java tests/system/src/test/java/sandbox/app/FXApp.java tests/system/src/test/java/sandbox/app/FXNonApp.java tests/system/src/test/java/sandbox/app/JFXPanelApp.java tests/system/src/test/java/sandbox/app/JFXPanelImplicitExitApp.java tests/system/src/test/java/sandbox/app/Util.java tests/system/src/test/resources/sandbox/app/test.css tests/system/src/test/resources/sandbox/app/test.fxml tests/system/src/test/resources/sandbox/app/test.html tests/system/src/test/resources/sandbox/test.policy
diffstat 11 files changed, 746 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/system/src/test/java/sandbox/Constants.java	Tue Mar 18 14:17:08 2014 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2014, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+package sandbox;
+
+/**
+ * Global constants for sandbox tests.
+ */
+public class Constants {
+
+    // Test timeout in milliseconds
+    public static final int TIMEOUT = 8000;
+
+    // Time in milliseconds to show the stage
+    public static final int SHOWTIME = 2500;
+
+    // Error exit codes. Note that 0 and 1 are reserved for normal exit and
+    // failure to launch java, respectively
+    public static final int ERROR_NONE = 2;
+
+    public static final int ERROR_TIMEOUT = 3;
+    public static final int ERROR_SECURITY_EXCEPTION = 4;
+    public static final int ERROR_NO_SECURITY_EXCEPTION = 5;
+    public static final int ERROR_UNEXPECTED_EXCEPTION = 6;
+
+    // No need to ever create an instance of this class
+    private Constants() {}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/system/src/test/java/sandbox/SandboxAppTest.java	Tue Mar 18 14:17:08 2014 -0700
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2014, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+package sandbox;
+
+import com.sun.javafx.PlatformUtil;
+import java.io.File;
+import junit.framework.AssertionFailedError;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static sandbox.Constants.*;
+
+/**
+ * Unit test for running JavaFX apps in a sandbox with a restrictive
+ * security manager.
+ */
+public class SandboxAppTest {
+
+    private static final String className = SandboxAppTest.class.getName();
+    private static final String pkgName = className.substring(0, className.lastIndexOf("."));
+
+    private String getJfxrtDir(final String classpath) {
+        final String jfxrt = "jfxrt.jar";
+        String cp = classpath;
+        int idx = cp.replace('\\', '/').indexOf("/" + jfxrt);
+        assertTrue("No " + jfxrt + " in classpath", idx >= 0);
+        cp = cp.substring(0, idx);
+        idx = cp.lastIndexOf(File.pathSeparator);
+        if (idx >= 0) {
+            cp = cp.substring(idx, cp.length());
+        }
+        return cp;
+    }
+
+    private static String getTestPolicyFile() {
+        return SandboxAppTest.class.getResource("test.policy").toExternalForm();
+    }
+
+    private void runSandboxedApp(String appName) throws Exception {
+        runSandboxedApp(appName, ERROR_NONE);
+    }
+
+    private void runSandboxedApp(String appName, int exitCode) throws Exception {
+        final String testAppName = pkgName + ".app." + appName;
+        final String classpath = System.getProperty("java.class.path");
+        final String jfxrtDir = getJfxrtDir(classpath);
+        final String testPolicy = getTestPolicyFile();
+        ProcessBuilder builder;
+        builder = new ProcessBuilder("java",
+                "-Djava.ext.dirs=" + jfxrtDir,
+                "-Djava.security.manager",
+                "-Djava.security.policy=" + testPolicy,
+                "-cp", classpath,
+                testAppName);
+        builder.redirectError(ProcessBuilder.Redirect.INHERIT);
+        builder.redirectOutput(ProcessBuilder.Redirect.INHERIT);
+        Process process = builder.start();
+        int retVal = process.waitFor();
+        switch (retVal) {
+            case 0:
+            case ERROR_NONE:
+                assertEquals(testAppName + ": Unexpected 'success' exit code;",
+                        exitCode, retVal);
+                break;
+
+            case 1:
+                throw new AssertionFailedError(testAppName
+                        + ": unable to launch java application");
+
+            case ERROR_TIMEOUT:
+                throw new AssertionFailedError(testAppName
+                        + ": Application timeout");
+            case ERROR_SECURITY_EXCEPTION:
+                throw new AssertionFailedError(testAppName
+                        + ": Application failed with a security exception");
+            case ERROR_NO_SECURITY_EXCEPTION:
+                throw new AssertionFailedError(testAppName
+                        + ": Application did not get expected security exception");
+            case ERROR_UNEXPECTED_EXCEPTION:
+                throw new AssertionFailedError(testAppName
+                        + ": Application failed with unexpected exception");
+
+           default:
+                throw new AssertionFailedError(testAppName
+                        + ": Unexpected error exit: " + retVal);
+        }
+    }
+
+    // TEST CASES
+
+    @Test (timeout=10000)
+    public void testFXApp() throws Exception {
+        runSandboxedApp("FXApp");
+    }
+
+    @Test (timeout=10000)
+    public void testFXNonApp() throws Exception {
+        runSandboxedApp("FXNonApp");
+    }
+
+    @Test (timeout=10000)
+    public void testJFXPanelApp() throws Exception {
+        runSandboxedApp("JFXPanelApp");
+    }
+
+    @Test (timeout=10000)
+    public void testJFXPanelImplicitExitApp() throws Exception {
+        // Test skipped on Mac OS X due to 8037776
+        if (PlatformUtil.isMac()) {
+            System.err.println("*** Skipping test on Mac OS X");
+            return;
+        }
+        runSandboxedApp("JFXPanelImplicitExitApp", 0);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/system/src/test/java/sandbox/app/FXApp.java	Tue Mar 18 14:17:08 2014 -0700
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2014, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+package sandbox.app;
+
+import javafx.animation.KeyFrame;
+import javafx.animation.Timeline;
+import javafx.application.Application;
+import javafx.scene.Scene;
+import javafx.stage.Stage;
+import javafx.util.Duration;
+
+import static sandbox.Constants.*;
+
+/**
+ * FX application to test running with a security manager installed. Note that
+ * the toolkit will be initialized by the Java 8 launcher.
+ */
+public class FXApp extends Application {
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) {
+        Util.setupTimeoutThread();
+
+        try {
+            try {
+                // Ensure that we are running with a restrictive
+                // security manager
+                System.getProperty("sun.something");
+                System.err.println("*** Did not get expected security exception");
+                System.exit(ERROR_NO_SECURITY_EXCEPTION);
+            } catch (SecurityException ex) {
+                // This is expected
+            }
+            Application.launch(args);
+        } catch (SecurityException ex) {
+            ex.printStackTrace(System.err);
+            System.exit(ERROR_SECURITY_EXCEPTION);
+        } catch (RuntimeException ex) {
+            ex.printStackTrace(System.err);
+            Throwable cause = ex.getCause();
+            if (cause instanceof ExceptionInInitializerError) {
+                cause = cause.getCause();
+                if (cause instanceof SecurityException) {
+                    System.exit(ERROR_SECURITY_EXCEPTION);
+                }
+            }
+            System.exit(ERROR_UNEXPECTED_EXCEPTION);
+        } catch (Error | Exception t) {
+            t.printStackTrace(System.err);
+            System.exit(ERROR_UNEXPECTED_EXCEPTION);
+        }
+    }
+
+    @Override
+    public void start(final Stage stage) {
+        try {
+            Scene scene = Util.createScene();
+            stage.setScene(scene);
+            stage.setX(0);
+            stage.setY(0);
+            stage.show();
+
+            // Hide the stage after the specified amount of time
+            KeyFrame kf = new KeyFrame(Duration.millis(SHOWTIME), e -> {
+                stage.hide();
+            });
+            Timeline timeline = new Timeline(kf);
+            timeline.play();
+        } catch (SecurityException ex) {
+            ex.printStackTrace(System.err);
+            System.exit(ERROR_SECURITY_EXCEPTION);
+        } catch (Error | Exception ex) {
+            ex.printStackTrace(System.err);
+            System.exit(ERROR_UNEXPECTED_EXCEPTION);
+        }
+    }
+
+    @Override public void stop() {
+        System.exit(ERROR_NONE);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/system/src/test/java/sandbox/app/FXNonApp.java	Tue Mar 18 14:17:08 2014 -0700
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2014, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+package sandbox.app;
+
+/**
+ * FX application to test running with a security manager installed. Note that
+ * since this class does not extend Application, the toolkit will not yet be
+ * initialized prior to main being called.
+ */
+public class FXNonApp {
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) {
+        FXApp.main(args);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/system/src/test/java/sandbox/app/JFXPanelApp.java	Tue Mar 18 14:17:08 2014 -0700
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2014, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+package sandbox.app;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.util.concurrent.atomic.AtomicReference;
+import javafx.application.Platform;
+import javafx.embed.swing.JFXPanel;
+import javafx.scene.Scene;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+import javax.swing.Timer;
+
+import static sandbox.Constants.*;
+
+/**
+ * JFXPanel application to test running with a security manager installed.
+ * The main program in this class will run the test such that the application
+ * will be shutdown by an explicit call to System.exit().
+ */
+public class JFXPanelApp {
+
+    private void initApp(final boolean implicitExit) throws Exception {
+        final JFrame frame = new JFrame("JFXPanel Test");
+        frame.setLayout(new BorderLayout());
+
+        JPanel swingPanel = new JPanel();
+        swingPanel.setLayout(new FlowLayout());
+        frame.getContentPane().add(swingPanel, BorderLayout.NORTH);
+
+        JButton swingButton = new JButton("Swing Button");
+        swingButton.addActionListener(e -> System.err.println("Hi"));
+        swingPanel.add(swingButton);
+
+        // Create javafx panel
+        final JFXPanel jfxPanel = new JFXPanel();
+        jfxPanel.setPreferredSize(new Dimension(400,300));
+        frame.getContentPane().add(jfxPanel, BorderLayout.CENTER);
+
+        // create JavaFX scene
+        createScene(jfxPanel);
+        if (!implicitExit) {
+            Platform.setImplicitExit(false);
+        }
+
+        // show frame
+        frame.pack();
+        frame.setVisible(true);
+
+        // Hide the frame after the specified amount of time
+        Timer timer = new Timer(SHOWTIME, e -> {
+            if (implicitExit) {
+                frame.setVisible(false);
+                frame.dispose();
+            } else {
+                System.exit(ERROR_NONE);
+            }
+        });
+        timer.setRepeats(false);
+        timer.start();
+    }
+
+    private void createScene(final JFXPanel jfxPanel) throws Exception {
+        final AtomicReference<Throwable> err = new AtomicReference<>(null);
+        Platform.runLater(() -> {
+            try {
+                final Scene scene = Util.createScene();
+                jfxPanel.setScene(scene);
+            } catch (Error | Exception t) {
+                err.set(t);
+            }
+        });
+        Throwable t = err.get();
+        if (t instanceof Error) {
+            throw (Error)t;
+        } else if (t instanceof Exception) {
+            throw (Exception)t;
+        }
+    }
+
+    public JFXPanelApp(boolean implicitExit) {
+        try {
+            try {
+                // Ensure that we are running with a restrictive
+                // security manager
+                System.getProperty("sun.something");
+                System.err.println("*** Did not get expected security exception");
+                System.exit(ERROR_NO_SECURITY_EXCEPTION);
+            } catch (SecurityException ex) {
+                // This is expected
+            }
+            initApp(implicitExit);
+        } catch (SecurityException ex) {
+            ex.printStackTrace(System.err);
+            System.exit(ERROR_SECURITY_EXCEPTION);
+        } catch (ExceptionInInitializerError ex) {
+            Throwable cause = ex.getCause();
+            if (cause instanceof SecurityException) {
+                System.exit(ERROR_SECURITY_EXCEPTION);
+            }
+            System.exit(ERROR_UNEXPECTED_EXCEPTION);
+        } catch (Error | Exception ex) {
+            ex.printStackTrace(System.err);
+            System.exit(ERROR_UNEXPECTED_EXCEPTION);
+        }
+    }
+
+    public static void runTest(final boolean implicitExit) {
+        Util.setupTimeoutThread();
+        SwingUtilities.invokeLater(() -> new JFXPanelApp(implicitExit));
+    }
+
+    public static void main(String[] args) {
+        runTest(false);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/system/src/test/java/sandbox/app/JFXPanelImplicitExitApp.java	Tue Mar 18 14:17:08 2014 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2014, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+package sandbox.app;
+
+/**
+ * JFXPanel application to test running with a security manager installed.
+ * The main program in this class will run the test such that the application
+ * will implicitly exit when the JFrame is disposed.
+ */
+public class JFXPanelImplicitExitApp {
+
+    public static void main(String[] args) {
+        JFXPanelApp.runTest(true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/system/src/test/java/sandbox/app/Util.java	Tue Mar 18 14:17:08 2014 -0700
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2014, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+package sandbox.app;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.scene.control.Label;
+import javafx.scene.layout.VBox;
+import javafx.scene.paint.Color;
+import javafx.scene.web.WebEngine;
+import javafx.scene.web.WebView;
+
+import static sandbox.Constants.*;
+
+/**
+ *
+ * @author kcr
+ */
+public class Util {
+    private static final int WIDTH = 400;
+    private static final int HEIGHT = 300;
+
+    private static final String CSS_FILE_NAME = "test.css";
+    private static final String FXML_FILE_NAME = "test.fxml";
+    private static final String HTML_FILE_NAME = "test.html";
+
+    // Convert the requested resource name into a URL string, and verify
+    // that the resource can be accessed.
+    private static URL toURL(String resourceName) throws Exception {
+        URL url = FXApp.class.getResource(resourceName);
+        URLConnection conn = url.openConnection();
+        InputStream stream = conn.getInputStream();
+        stream.close();
+        return url;
+    }
+
+    // Create a JavaFX scene and populate it with content
+    public static Scene createScene() throws Exception {
+        VBox root = new VBox(10);
+        Scene scene = new Scene(root, WIDTH, HEIGHT);
+        scene.setFill(Color.WHITE);
+
+        final String styleSheet = toURL(CSS_FILE_NAME).toExternalForm();
+        scene.getStylesheets().clear();
+        scene.getStylesheets().add(styleSheet);
+
+        Label label = new Label();
+        label.setText("Label");
+
+        final URL fxmlFile = toURL(FXML_FILE_NAME);
+        Parent fxmlRoot = (Parent)FXMLLoader.load(fxmlFile);
+
+        final String webURLString = toURL(HTML_FILE_NAME).toExternalForm();
+        WebView webView = new WebView();
+        WebEngine webEngine = webView.getEngine();
+        webEngine.load(webURLString);
+
+        root.getChildren().addAll(label, fxmlRoot, webView);
+        return scene;
+    }
+
+    public static void setupTimeoutThread() {
+        // Timeout thread
+        Thread th = new Thread(() -> {
+            try {
+                Thread.sleep(TIMEOUT);
+            } catch (InterruptedException ex) {
+            }
+            System.exit(ERROR_TIMEOUT);
+        });
+        th.setDaemon(true);
+        th.start();
+    }
+
+    // No need to ever create an instance of this class
+    private Util() {}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/system/src/test/resources/sandbox/app/test.css	Tue Mar 18 14:17:08 2014 -0700
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2014, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+.label {
+    -fx-font-size: 35;
+    -fx-text-fill: green;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/system/src/test/resources/sandbox/app/test.fxml	Tue Mar 18 14:17:08 2014 -0700
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+/*
+ * Copyright (c) 2014, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+-->
+
+<?import java.lang.*?>
+<?import java.util.*?>
+<?import java.net.*?>
+<?import javafx.collections.*?>
+<?import javafx.scene.*?>
+<?import javafx.scene.control.*?>
+<?import javafx.scene.layout.*?>
+<?import javafx.scene.text.*?>
+
+<Group id="Sample" xmlns:fx="http://javafx.com/fxml">
+    <children>
+        <Text fill="RED" text="FXML Text">
+          <font>
+              <Font size="31.0"/>
+          </font>
+        </Text>
+    </children>
+</Group>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/system/src/test/resources/sandbox/app/test.html	Tue Mar 18 14:17:08 2014 -0700
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<!--
+/*
+ * Copyright (c) 2014, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+-->
+
+<html>
+  <head>
+    <title></title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+  </head>
+  <body>
+    <P style="font-size: 40; color: blue">WebView Text</P>
+  </body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/system/src/test/resources/sandbox/test.policy	Tue Mar 18 14:17:08 2014 -0700
@@ -0,0 +1,7 @@
+// Policy file for sandbox tests
+// Use as follows: -Djava.security.policy=test.policy
+
+// Grant permission to read resource files
+grant {
+    permission java.io.FilePermission "<<ALL FILES>>", "read";
+};