changeset 9970:c46f3715c611 jdk-9+131

8156078: Stage alwaysOnTop property not reset to false if permission is denied Reviewed-by: kcr
author ckyang
date Fri, 05 Aug 2016 10:08:28 -0700
parents d687ea9817fa
children 1f37dfbe7019 b52e1e2cd728
files modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java tests/system/src/test/java/test/robot/helloworld/CustomSecurityManagerTest.java
diffstat 2 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java	Fri Aug 05 09:53:11 2016 -0700
+++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java	Fri Aug 05 10:08:28 2016 -0700
@@ -73,6 +73,7 @@
     private boolean isAppletStage = false; // true if this is an embedded applet window
     private boolean isPopupStage = false;
     private boolean isInFullScreen = false;
+    private boolean isAlwaysOnTop = false;
 
     // A flag to indicate whether a call was generated from
     // an allowed input event handler.
@@ -620,14 +621,23 @@
         // The securityDialog flag takes precedence over alwaysOnTop
         if (securityDialog) return;
 
+        if (isAlwaysOnTop == alwaysOnTop) {
+            return;
+        }
+
         if (alwaysOnTop) {
             if (hasPermission(SET_WINDOW_ALWAYS_ON_TOP_PERMISSION)) {
                 platformWindow.setLevel(Level.FLOATING);
+            } else {
+                alwaysOnTop = false;
+                if (stageListener != null) {
+                    stageListener.changedAlwaysOnTop(alwaysOnTop);
+                }
             }
         } else {
             platformWindow.setLevel(Level.NORMAL);
         }
-
+        isAlwaysOnTop = alwaysOnTop;
     }
 
     @Override public void setResizable(boolean resizable) {
--- a/tests/system/src/test/java/test/robot/helloworld/CustomSecurityManagerTest.java	Fri Aug 05 09:53:11 2016 -0700
+++ b/tests/system/src/test/java/test/robot/helloworld/CustomSecurityManagerTest.java	Fri Aug 05 10:08:28 2016 -0700
@@ -124,6 +124,12 @@
             System.setSecurityManager(null);
         }
         runAndWait(() -> {
+            boolean propertyState = testStage1.alwaysOnTopProperty().get();
+            if (expectedOnTop) {
+                assertTrue(propertyState);
+            } else {
+                assertFalse(propertyState);
+            }
             Color color = getColor(testScene1, WIDTH / 2, HEIGHT / 2);
             if (expectedOnTop) {
                 assertColorEquals(Color.RED, color, TOLERANCE);