Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8230492: font-family not set in HTMLEditor if font name has a number in it #27

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -689,7 +689,7 @@ private void populateToolbars() {
});

fontFamilyComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
executeCommand(FONT_FAMILY.getCommand(), ("".equals(newValue)) ? "''" : newValue);
executeCommand(FONT_FAMILY.getCommand(), "'" + newValue + "'");
});

fontSizeComboBox = new ComboBox<String>();
@@ -1139,7 +1139,7 @@ private void applyTextFormatting() {
String font = fontFamilyComboBox.getValue().toString();

executeCommand(FORMAT.getCommand(), format);
executeCommand(FONT_FAMILY.getCommand(), font);
executeCommand(FONT_FAMILY.getCommand(), "'" + font + "'");
}
}

@@ -31,9 +31,12 @@
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.Event;
import javafx.scene.control.ComboBox;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.text.Font;
import javafx.scene.web.HTMLEditor;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
@@ -84,6 +87,12 @@ public static void setupOnce() {
new Thread(() -> Application.launch(HTMLEditorTestApp.class,
(String[]) null)).start();

// Used by selectFontFamilysWithSpace() for JDK-8230492
Font.loadFont(
HTMLEditorTest.class.getResource("WebKit_Layout_Tests_2.ttf").toExternalForm(),
10
);

assertTrue("Timeout waiting for FX runtime to start", Util.await(launchLatch));
}

@@ -294,4 +303,55 @@ public void checkStyleProperty() throws Exception {
assertNotNull("result must have a valid reference ", result.get());
assertEquals("document.body.style.fontWeight must be bold ", "bold", result.get());
}

/**
* @test
* @bug 8230492
* Summary Check font-family change on font name with numbers
*/
@Test
public void selectFontFamilyWithSpace() {
final CountDownLatch editorStateLatch = new CountDownLatch(1);
final AtomicReference<String> result = new AtomicReference<>();

Util.runAndWait(() -> {
webView.getEngine().getLoadWorker().stateProperty().
addListener((observable, oldValue, newValue) -> {
if (newValue == SUCCEEDED) {
htmlEditor.requestFocus();
}
});

htmlEditor.setHtmlText("<body>Sample Text</body>");

webView.focusedProperty().
addListener((observable, oldValue, newValue) -> {
if (newValue) {
ComboBox<String> fontFamilyComboBox = null;
int i = 0;
for (Node comboBox : htmlEditor.lookupAll(".font-menu-button")) {
// 0 - Format, 1 - Font Family, 2 - Font Size
if (i == 1) {
assertTrue("fontFamilyComboBox must be ComboBox",
comboBox instanceof ComboBox);
fontFamilyComboBox = (ComboBox<String>) comboBox;
assertNotNull("fontFamilyComboBox must not be null",
fontFamilyComboBox);
}
i++;
}
webView.getEngine().
executeScript("document.execCommand('selectAll', false, 'true');");
fontFamilyComboBox.getSelectionModel().select("WebKit Layout Tests 2");
result.set(htmlEditor.getHtmlText());
editorStateLatch.countDown();
}
});
});

assertTrue("Timeout when waiting for focus change ", Util.await(editorStateLatch));
assertNotNull("result must have a valid reference ", result.get());
assertTrue("font-family must be 'WebKit Layout Test 2' ", result.get().
contains("font-family: &quot;WebKit Layout Tests 2&quot;"));
}
}
Binary file not shown.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.