< prev index next >

modules/javafx.web/src/test/java/test/javafx/scene/web/HistoryStateTest.java

Print this page

        

*** 29,38 **** --- 29,40 ---- import org.junit.Before; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; + import javafx.collections.ObservableList; + import javafx.scene.web.WebHistory; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue;
*** 159,165 **** --- 161,199 ---- throw new AssertionError(ex); } finally { assertEquals("history navigation using javascript failed", 2, historyListenerIndex.get()); } } + + // JDK-8204856 + @Test + public void testDocumentExistenceAfterPushState() { + final ObservableList<WebHistory.Entry> history = getEngine().getHistory().getEntries(); + final int initialHistorySize = history.size(); + + load(HistoryStateTest.class.getClassLoader().getResource( + resourcePath + initialLoadUrl).toExternalForm()); + assertNotNull(getEngine().getDocument()); + + executeScript("history.pushState('push', 'title', 'pushState.html')"); + assertNotNull("Document shouldn't be null after history.pushState", getEngine().getDocument()); + assertTrue("location must end with pushState.html", getEngine().getLocation().endsWith("pushState.html")); + assertEquals("history count should be incremented", initialHistorySize + 1, history.size()); + } + + // JDK-8204856 + @Test + public void testDocumentExistenceAfterReplaceState() { + final ObservableList<WebHistory.Entry> history = getEngine().getHistory().getEntries(); + final int initialHistorySize = history.size(); + + load(HistoryStateTest.class.getClassLoader().getResource( + resourcePath + initialLoadUrl).toExternalForm()); + assertNotNull(getEngine().getDocument()); + + executeScript("history.replaceState('push', 'title', 'replaceState.html')"); + assertNotNull("Document shouldn't be null after history.replaceState", getEngine().getDocument()); + assertTrue("location must end with replaceState.html", getEngine().getLocation().endsWith("replaceState.html")); + assertEquals("history count shouldn't be incremented", initialHistorySize, history.size()); + } }
< prev index next >