Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions jdk/test/javax/swing/JEditorPane/5076514/bug5076514.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2018, 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
Expand All @@ -22,13 +22,16 @@
*/

/* @test
@bug 5076514 8025430
@bug 5076514 8025430 8198321
@summary Tests if SecurityManager.checkPermission()
used for clipboard access with permission 'accessClipboard'
@run main bug5076514
@run main/othervm -Djava.awt.headless=true bug5076514
*/

import java.awt.GraphicsEnvironment;
import java.security.Permission;

import javax.swing.JEditorPane;

public class bug5076514 {
Expand All @@ -37,9 +40,13 @@ public class bug5076514 {

public static void main(String[] args) {
System.setSecurityManager(new MySecurityManager());

// no system clipboard in the headless mode
boolean expected = !GraphicsEnvironment.isHeadless();

JEditorPane editor = new JEditorPane();
editor.copy();
if (!isCheckPermissionCalled) {
if (isCheckPermissionCalled != expected) {
throw new RuntimeException("JEditorPane's clipboard operations "
+ "didn't call SecurityManager.checkPermission() with "
+ "permission 'accessClipboard' when there is a security"
Expand Down