diff options
author | kcr <none@none> | 2017-10-25 10:45:42 -0700 |
---|---|---|
committer | kcr <none@none> | 2017-10-25 10:45:42 -0700 |
commit | d551ac53a9c48055c16d45965ca84b973e218978 (patch) | |
tree | 95b654b82726ca0b4d0ee8234b3cae4805bc4b67 | |
parent | 4d22a4ac22387629dbffe3e3ad37df00e6ce6744 (diff) | |
parent | b3c928315115ef410c4a765e9042ced9f75ce1ff (diff) | |
download | jdk8u_jfx-d551ac53a9c48055c16d45965ca84b973e218978.tar.gz |
Merge
48 files changed, 393 insertions, 186 deletions
@@ -67,11 +67,3 @@ apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/about/a .gitignore *.sdf -# ignore all compiled python objects -*.pyc - -# ignore cmake internal generated files -modules/web/src/main/native/__cmake_systeminformation - -# ignore icu data library -icudt*.dat @@ -485,6 +485,7 @@ e3cd10d417b7fa3590b747c616c9f440945ed001 8u141-b10 93056ba104b6785e6b372a145d71bce7a9896a9b 8u141-b12 7f8356d232541fbd58c5a98191fd0a8f0d219141 8u141-b13 d6db71e77bb1163dd6290dfda7f06cd827a02351 8u141-b14 +2991e8b097f37f8d5847bedee9025003af6011d3 8u172-b00 2991e8b097f37f8d5847bedee9025003af6011d3 8u162-b01 345860863e85d1384fd53e0a04862946b46b2c79 8u151-b01 ff23e24353931fc6c09c2262b5c99bbcae3c5913 8u151-b02 diff --git a/build.gradle b/build.gradle index f4522a5c1..0e1873667 100644 --- a/build.gradle +++ b/build.gradle @@ -2531,12 +2531,15 @@ project(":web") { def webkitOutputDir = cygpath("$buildDir/${t.name}") def webkitConfig = IS_DEBUG_NATIVE ? "Debug" : "Release" + File nativeBuildDir = new File("${webkitOutputDir}") + nativeBuildDir.mkdirs() + def compileNativeTask = task("compileNative${t.capital}", dependsOn: generateHeaders) << { println "Building Webkit configuration /$webkitConfig/ into $webkitOutputDir" exec { - workingDir("$projectDir/src/main/native") - commandLine("perl", "Tools/Scripts/set-webkit-configuration", "--$webkitConfig") + workingDir("$webkitOutputDir") + commandLine("perl", "$projectDir/src/main/native/Tools/Scripts/set-webkit-configuration", "--$webkitConfig") environment(["WEBKIT_OUTPUTDIR" : webkitOutputDir]) } @@ -2577,6 +2580,7 @@ project(":web") { environment([ "JAVA_HOME" : JDK_HOME, "WEBKIT_OUTPUTDIR" : webkitOutputDir, + "PYTHONDONTWRITEBYTECODE" : "1", ]) def targetCpuBitDepthSwitch = "" @@ -2586,7 +2590,7 @@ project(":web") { targetCpuBitDepthSwitch = "--32-bit" } - commandLine("perl", "Tools/Scripts/build-webkit", + commandLine("perl", "$projectDir/src/main/native/Tools/Scripts/build-webkit", "--java", "--icu-unicode", targetCpuBitDepthSwitch, "--cmakeargs=${cmakeArgs}") } diff --git a/build.properties b/build.properties index 10f200fae..64cd1330d 100644 --- a/build.properties +++ b/build.properties @@ -40,10 +40,10 @@ jfx.release.milestone=ea jfx.release.suffix=-ea # UPDATE THE FOLLOWING VALUES FOR A NEW RELEASE -jfx.release.name=8u162 +jfx.release.name=8u172 jfx.release.major.version=8 jfx.release.minor.version=0 -jfx.release.micro.version=162 +jfx.release.micro.version=172 ############################################################################## # diff --git a/buildSrc/win.gradle b/buildSrc/win.gradle index c2eb4d27c..556f17fc3 100644 --- a/buildSrc/win.gradle +++ b/buildSrc/win.gradle @@ -131,11 +131,12 @@ ext.WINDOWS_NATIVE_COMPILE_ENVIRONMENT = [ "LIBPATH" : WINDOWS_VS_LIBPATH, "DXSDK_DIR" : WINDOWS_DXSDK_DIR ]; +def msvcVer = System.getenv("MSVC_VER") ?: "14.10.25017" def msvcBinDir = "" if (winVsVer == 150) { msvcBinDir = (IS_64 - ? "$WINDOWS_VS_VSINSTALLDIR/VC/Tools/MSVC/14.10.25017/bin/HostX64/x64" - : "$WINDOWS_VS_VSINSTALLDIR/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86") + ? "$WINDOWS_VS_VSINSTALLDIR/VC/Tools/MSVC/$msvcVer/bin/HostX64/x64" + : "$WINDOWS_VS_VSINSTALLDIR/VC/Tools/MSVC/$msvcVer/bin/HostX86/x86") } else if (winVsVer <= 120) { msvcBinDir = (IS_64 ? "$WINDOWS_VS_VSINSTALLDIR/VC/BIN/amd64" @@ -172,9 +173,10 @@ ext.MC = cygpath("$winSdkBinDir/mt.exe") if (!file(RC).exists()) throw new GradleException("FAIL: cannot find RC: " + RC) if (!file(FXC).exists()) throw new GradleException("FAIL: cannot find FXC: " + FXC) +def msvcRedistVer = System.getenv("MSVC_REDIST_VER") ?: "14.10.25008" String msvcRedstDir = (IS_64 - ? "$WINDOWS_VS_VSINSTALLDIR/VC/Redist/MSVC/14.10.25008/x64" - : "$WINDOWS_VS_VSINSTALLDIR/VC/Redist/MSVC/14.10.25008/x86") + ? "$WINDOWS_VS_VSINSTALLDIR/VC/Redist/MSVC/$msvcRedistVer/x64" + : "$WINDOWS_VS_VSINSTALLDIR/VC/Redist/MSVC/$msvcRedistVer/x86") String winSdkDllDir = (IS_64 ? "$WINDOWS_VS_WINSDKDLLINSTALLDIR/x64" @@ -184,13 +186,14 @@ def WINDOWS_DLL_VER = WINDOWS_VS_VER ext.MSVCR = null ext.MSVCP = null +def windowsCRTVer = System.getenv("WINDOWS_CRT_VER") ?: "150" if (WINDOWS_VS_VER == "150") { WINDOWS_DLL_VER = "140" - ext.MSVCR = cygpath("${msvcRedstDir}/Microsoft.VC${WINDOWS_VS_VER}.CRT/vcruntime${WINDOWS_DLL_VER}.dll") - ext.MSVCP = cygpath("${msvcRedstDir}/Microsoft.VC${WINDOWS_VS_VER}.CRT/msvcp${WINDOWS_DLL_VER}.dll") + ext.MSVCR = cygpath("${msvcRedstDir}/Microsoft.VC${windowsCRTVer}.CRT/vcruntime${WINDOWS_DLL_VER}.dll") + ext.MSVCP = cygpath("${msvcRedstDir}/Microsoft.VC${windowsCRTVer}.CRT/msvcp${WINDOWS_DLL_VER}.dll") } -def vs2017DllPath = cygpath("${msvcRedstDir}/Microsoft.VC${WINDOWS_VS_VER}.CRT") +def vs2017DllPath = cygpath("${msvcRedstDir}/Microsoft.VC${windowsCRTVer}.CRT") if (file(vs2017DllPath).exists()) { def VS2017DLLs = [ "concrt140.dll", diff --git a/modules/graphics/src/main/java/com/sun/javafx/tk/Toolkit.java b/modules/graphics/src/main/java/com/sun/javafx/tk/Toolkit.java index c7efbedb2..719023a0a 100644 --- a/modules/graphics/src/main/java/com/sun/javafx/tk/Toolkit.java +++ b/modules/graphics/src/main/java/com/sun/javafx/tk/Toolkit.java @@ -151,9 +151,9 @@ public abstract class Toolkit { "ucrtbase", // Finally load VS 2017 DLLs in the following order - "concrt140", "vcruntime140", - "msvcp140" + "msvcp140", + "concrt140" }; private static String lookupToolkitClass(String name) { diff --git a/modules/graphics/src/main/native-font/coretext.c b/modules/graphics/src/main/native-font/coretext.c index adb0ed270..199a63e12 100644 --- a/modules/graphics/src/main/native-font/coretext.c +++ b/modules/graphics/src/main/native-font/coretext.c @@ -676,17 +676,36 @@ JNIEXPORT jint JNICALL OS_NATIVE(CTRunGetStringIndices) { CTRunRef run = (CTRunRef)runRef; const CFIndex* indices = CTRunGetStringIndicesPtr(run); + CFIndex count = CTRunGetGlyphCount(run); + if (count == 0) { + return 0; + } + + CFIndex* tempIndices = NULL; + if (!indices) { + tempIndices = (CFIndex*) malloc(count * sizeof(CFIndex)); + if (!tempIndices) { + return 0; + } + + CTRunGetStringIndices(run, CFRangeMake(0, 0), tempIndices); + indices = tempIndices; + } + int i = 0; if (indices) { jint* buffer = (*env)->GetPrimitiveArrayCritical(env, bufferRef, NULL); if (buffer) { - CFIndex count = CTRunGetGlyphCount(run); while(i < count) { buffer[start + i] = indices[i]; i++; } (*env)->ReleasePrimitiveArrayCritical(env, bufferRef, buffer, 0); } + + if (tempIndices) { + free(tempIndices); + } } return i; } diff --git a/modules/web/src/main/java/com/sun/javafx/webkit/PasteboardImpl.java b/modules/web/src/main/java/com/sun/javafx/webkit/PasteboardImpl.java index e1d01ae64..f53759609 100644 --- a/modules/web/src/main/java/com/sun/javafx/webkit/PasteboardImpl.java +++ b/modules/web/src/main/java/com/sun/javafx/webkit/PasteboardImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, 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 @@ -25,12 +25,17 @@ package com.sun.javafx.webkit; +import com.sun.javafx.webkit.UIClientImpl; import com.sun.webkit.Pasteboard; import com.sun.webkit.graphics.WCGraphicsManager; import com.sun.webkit.graphics.WCImageFrame; +import java.io.File; +import java.io.IOException; +import java.util.Arrays; import javafx.scene.image.Image; import javafx.scene.input.Clipboard; import javafx.scene.input.ClipboardContent; +import javax.imageio.ImageIO; final class PasteboardImpl implements Pasteboard { @@ -65,9 +70,21 @@ final class PasteboardImpl implements Pasteboard { Object platformImage = WCGraphicsManager.getGraphicsManager(). toPlatformImage(wcImage.getFrame()); Image fxImage = Image.impl_fromPlatformImage(platformImage); - ClipboardContent content = new ClipboardContent(); - content.putImage(fxImage); - clipboard.setContent(content); + if (fxImage != null) { + ClipboardContent content = new ClipboardContent(); + content.putImage(fxImage); + try { + File imageDump = File.createTempFile("jfx", ".png"); + imageDump.deleteOnExit(); + ImageIO.write(UIClientImpl.toBufferedImage(fxImage), + "png", + imageDump); + content.putFiles(Arrays.asList(imageDump)); + } catch (IOException | SecurityException e) { + // Nothing specific to be done as of now + } + clipboard.setContent(content); + } } @Override public void writeUrl(String url, String markup) { diff --git a/modules/web/src/main/java/com/sun/javafx/webkit/UIClientImpl.java b/modules/web/src/main/java/com/sun/javafx/webkit/UIClientImpl.java index c14016c13..c41f5595e 100644 --- a/modules/web/src/main/java/com/sun/javafx/webkit/UIClientImpl.java +++ b/modules/web/src/main/java/com/sun/javafx/webkit/UIClientImpl.java @@ -312,7 +312,7 @@ public final class UIClientImpl implements UIClient { @Override public void startDrag(WCImage image, int imageOffsetX, int imageOffsetY, int eventPosX, int eventPosY, - String[] mimeTypes, Object[] values + String[] mimeTypes, Object[] values, boolean isImageSource ){ content = new ClipboardContent(); for (int i = 0; i < mimeTypes.length; ++i) if (values[i] != null) { @@ -346,24 +346,26 @@ public final class UIClientImpl implements UIClient { //Image need to be created by target request only. //QuantumClipboard.putContent have to be rewritten in Glass manner //with postponed data requests (DelayedCallback data object). - Object platformImage = image.getWidth() > 0 && image.getHeight() > 0 ? - image.getPlatformImage() : null; - if (platformImage != null) { - try { - File temp = File.createTempFile("jfx", ".png"); - temp.deleteOnExit(); - ImageIO.write( - toBufferedImage(Image.impl_fromPlatformImage( - Toolkit.getToolkit().loadPlatformImage( - platformImage - ) - )), - "png", - temp); - content.put(DataFormat.FILES, Arrays.asList(temp)); - } catch (IOException | SecurityException e) { - //That is ok. It was just an attempt. - //e.printStackTrace(); + if (isImageSource) { + Object platformImage = image.getWidth() > 0 && image.getHeight() > 0 ? + image.getPlatformImage() : null; + if (platformImage != null) { + try { + File temp = File.createTempFile("jfx", ".png"); + temp.deleteOnExit(); + ImageIO.write( + toBufferedImage(Image.impl_fromPlatformImage( + Toolkit.getToolkit().loadPlatformImage( + platformImage + ) + )), + "png", + temp); + content.put(DataFormat.FILES, Arrays.asList(temp)); + } catch (IOException | SecurityException e) { + //That is ok. It was just an attempt. + //e.printStackTrace(); + } } } } diff --git a/modules/web/src/main/java/com/sun/javafx/webkit/drt/UIClientImpl.java b/modules/web/src/main/java/com/sun/javafx/webkit/drt/UIClientImpl.java index ba535eeb3..37cad2fbf 100644 --- a/modules/web/src/main/java/com/sun/javafx/webkit/drt/UIClientImpl.java +++ b/modules/web/src/main/java/com/sun/javafx/webkit/drt/UIClientImpl.java @@ -179,7 +179,7 @@ final class UIClientImpl implements UIClient { */ @Override public void startDrag(WCImage frame, int imageOffsetX, int imageOffsetY, - int eventPosX, int eventPosY, String[] mimeTypes, Object[] values) + int eventPosX, int eventPosY, String[] mimeTypes, Object[] values, boolean isImageSource) { throw new UnsupportedOperationException("Not supported yet"); } diff --git a/modules/web/src/main/java/com/sun/webkit/LoadListenerClient.java b/modules/web/src/main/java/com/sun/webkit/LoadListenerClient.java index c1e53471a..aeb07b20e 100644 --- a/modules/web/src/main/java/com/sun/webkit/LoadListenerClient.java +++ b/modules/web/src/main/java/com/sun/webkit/LoadListenerClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, 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 @@ -31,6 +31,7 @@ public interface LoadListenerClient { @Native public final static int PAGE_STARTED = 0; @Native public final static int PAGE_FINISHED = 1; @Native public final static int PAGE_REDIRECTED = 2; + @Native public final static int PAGE_REPLACED = 3; @Native public final static int LOAD_FAILED = 5; @Native public final static int LOAD_STOPPED = 6; @Native public final static int CONTENT_RECEIVED = 10; diff --git a/modules/web/src/main/java/com/sun/webkit/UIClient.java b/modules/web/src/main/java/com/sun/webkit/UIClient.java index 4da97a452..2cd28663e 100644 --- a/modules/web/src/main/java/com/sun/webkit/UIClient.java +++ b/modules/web/src/main/java/com/sun/webkit/UIClient.java @@ -50,8 +50,8 @@ public interface UIClient { WCImage frame, int imageOffsetX, int imageOffsetY, int eventPosX, int eventPosY, - String[] mimeTypes, - Object[] values); + String[] mimeTypes, Object[] values, + boolean isImageSource); public void confirmStartDrag(); public boolean isDragConfirmed(); } diff --git a/modules/web/src/main/java/com/sun/webkit/Utilities.java b/modules/web/src/main/java/com/sun/webkit/Utilities.java index c07ad8e80..09e913955 100644 --- a/modules/web/src/main/java/com/sun/webkit/Utilities.java +++ b/modules/web/src/main/java/com/sun/webkit/Utilities.java @@ -51,40 +51,6 @@ public abstract class Utilities { protected abstract PopupMenu createPopupMenu(); protected abstract ContextMenu createContextMenu(); - private static String fwkGetMIMETypeForExtension(String ext) { - return MimeTypeMapHolder.MIME_TYPE_MAP.get(ext); - } - - private static final class MimeTypeMapHolder { - private static final Map<String, String> MIME_TYPE_MAP = - createMimeTypeMap(); - - private static Map<String,String> createMimeTypeMap() { - Map<String, String> mimeTypeMap = new HashMap<String, String>(21); - mimeTypeMap.put("txt", "text/plain"); - mimeTypeMap.put("html", "text/html"); - mimeTypeMap.put("htm", "text/html"); - mimeTypeMap.put("css", "text/css"); - mimeTypeMap.put("xml", "text/xml"); - mimeTypeMap.put("xsl", "text/xsl"); - mimeTypeMap.put("js", "application/x-javascript"); - mimeTypeMap.put("xhtml", "application/xhtml+xml"); - mimeTypeMap.put("svg", "image/svg+xml"); - mimeTypeMap.put("svgz", "image/svg+xml"); - mimeTypeMap.put("gif", "image/gif"); - mimeTypeMap.put("jpg", "image/jpeg"); - mimeTypeMap.put("jpeg", "image/jpeg"); - mimeTypeMap.put("png", "image/png"); - mimeTypeMap.put("tif", "image/tiff"); - mimeTypeMap.put("tiff", "image/tiff"); - mimeTypeMap.put("ico", "image/ico"); - mimeTypeMap.put("cur", "image/ico"); - mimeTypeMap.put("bmp", "image/bmp"); - mimeTypeMap.put("mp3", "audio/mpeg"); - return mimeTypeMap; - } - } - private static Object fwkInvokeWithContext(final Method method, final Object instance, final Object[] args, diff --git a/modules/web/src/main/java/com/sun/webkit/WebPage.java b/modules/web/src/main/java/com/sun/webkit/WebPage.java index e6d3936cb..193249dc4 100644 --- a/modules/web/src/main/java/com/sun/webkit/WebPage.java +++ b/modules/web/src/main/java/com/sun/webkit/WebPage.java @@ -2262,18 +2262,17 @@ public final class WebPage { Object image, int imageOffsetX, int imageOffsetY, int eventPosX, int eventPosY, - String[] mimeTypes, - Object[] values) + String[] mimeTypes, Object[] values, + boolean isImageSource) { log.log(Level.FINER, "Start drag: "); - if (uiClient != null) { uiClient.startDrag( WCImage.getImage(image), imageOffsetX, imageOffsetY, eventPosX, eventPosY, - mimeTypes, - values); + mimeTypes, values, + isImageSource); } } diff --git a/modules/web/src/main/java/javafx/scene/web/WebEngine.java b/modules/web/src/main/java/javafx/scene/web/WebEngine.java index f86a51bbe..5972a0921 100644 --- a/modules/web/src/main/java/javafx/scene/web/WebEngine.java +++ b/modules/web/src/main/java/javafx/scene/web/WebEngine.java @@ -1379,7 +1379,6 @@ final public class WebEngine { if (frame != getMainFrame()) { return; } - switch (state) { case PAGE_STARTED: message.set("Loading " + url); @@ -1392,6 +1391,10 @@ final public class WebEngine { message.set("Loading " + url); updateLocation(url); break; + case PAGE_REPLACED: + message.set("Replaced " + url); + updateLocation(url); + break; case PAGE_FINISHED: message.set("Loading complete"); updateProgress(1.0); diff --git a/modules/web/src/main/native/Source/ThirdParty/icu/java/data/CMakeLists.txt b/modules/web/src/main/native/Source/ThirdParty/icu/java/data/CMakeLists.txt index 794bc6d33..af5d31456 100644 --- a/modules/web/src/main/native/Source/ThirdParty/icu/java/data/CMakeLists.txt +++ b/modules/web/src/main/native/Source/ThirdParty/icu/java/data/CMakeLists.txt @@ -1,6 +1,16 @@ include(ExternalProject) -set (ICU_DATA_BUILD_COMMAND bash icudata_wrapper.sh ${CMAKE_BINARY_DIR} ${CMAKE_BUILD_TYPE} ${ICU_JAVA_DATA_LIB} ${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}) +set (ICU_DATA_BUILD_COMMAND bash icudata_wrapper.sh ${CMAKE_BINARY_DIR} ${CMAKE_BUILD_TYPE} ${ICU_JAVA_DATA_LIB} ${CMAKE_C_FLAGS}) + +if (APPLE) + # Fixed in ICU 59.1 http://bugs.icu-project.org/trac/ticket/12643 + string (REPLACE "-std=c++1y" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + # Fixed in ICU 56.1 http://bugs.icu-project.org/trac/ticket/11435 + string (REPLACE "-fno-rtti" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + list(APPEND ICU_DATA_BUILD_COMMAND ${CMAKE_CXX_FLAGS} ${CMAKE_OSX_DEPLOYMENT_TARGET}) +else () + list(APPEND ICU_DATA_BUILD_COMMAND ${CMAKE_CXX_FLAGS}) +endif () add_custom_target(icudatagen ALL COMMAND ${ICU_DATA_BUILD_COMMAND} diff --git a/modules/web/src/main/native/Source/ThirdParty/icu/java/data/icudata_wrapper.sh b/modules/web/src/main/native/Source/ThirdParty/icu/java/data/icudata_wrapper.sh index 7073e3e38..13bd524f0 100644 --- a/modules/web/src/main/native/Source/ThirdParty/icu/java/data/icudata_wrapper.sh +++ b/modules/web/src/main/native/Source/ThirdParty/icu/java/data/icudata_wrapper.sh @@ -5,24 +5,28 @@ # $3 : icu Data library location # $4 : CFLAGS used by cmake # $5 : CPPFLAGS used by cmake +# $6 : Mac OSX min version JAVA_DATA_LIBRARY=$3 case "$(uname -s)" in Darwin) - JAVA_LIBDIR=$1/lib + JAVA_LIBDIR=$1 PLATFORM=MacOSX + export CFLAGS=$4 + export CPPFLAGS="$5 -mmacosx-version-min=$6" + export LDFLAGS=-mmacosx-version-min=$6 ;; Linux) - JAVA_LIBDIR=$1/lib + JAVA_LIBDIR=$1 PLATFORM=Linux/gcc export CFLAGS=$4 export CPPFLAGS=$5 ;; CYGWIN*) - JAVA_LIBDIR=$1/lib + JAVA_LIBDIR=$1 PLATFORM=Cygwin/MSVC export CFLAGS=$4 export CPPFLAGS=$5 @@ -46,9 +50,10 @@ ICU_STATIC_ARGS="--enable-static --enable-shared=no --enable-extras=no --enable- function build_data { echo "Building icudata for $PLATFORM" - unzip -o ../../source/data/in/icudt51l.zip -d ../../source/data/in + mkdir -p $JAVA_LIBDIR/icu/data + unzip -o ../../source/data/in/icudt51l.zip -d $JAVA_LIBDIR/icu/data/ # create icu autoconf build folder - cd $JAVA_LIBDIR/../ + cd $JAVA_LIBDIR mkdir -p icu/lib && cd icu # run configure bash ${ICU_RUNCONFIGURE_PATH} $PLATFORM --libdir=$PWD/../lib ${ICU_STATIC_ARGS} diff --git a/modules/web/src/main/native/Source/ThirdParty/icu/source/data/Makefile.in b/modules/web/src/main/native/Source/ThirdParty/icu/source/data/Makefile.in index 71ba935ab..fac023e49 100644 --- a/modules/web/src/main/native/Source/ThirdParty/icu/source/data/Makefile.in +++ b/modules/web/src/main/native/Source/ThirdParty/icu/source/data/Makefile.in @@ -154,7 +154,7 @@ check-local: # Find out if we have a source archive. # If we have that, then use that instead of building everything from scratch. -ICUDATA_SOURCE_ARCHIVE = $(wildcard $(srcdir)/in/$(ICUDATA_PLATFORM_NAME).dat) +ICUDATA_SOURCE_ARCHIVE = $(wildcard ./$(ICUDATA_PLATFORM_NAME).dat) ifeq ($(ICUDATA_SOURCE_ARCHIVE),) ICUDATA_ARCHIVE = $(firstword $(wildcard $(srcdir)/in/$(ICUDATA_BASENAME_VERSION)*.dat)) # We don't have the data in the current endianess or charset. diff --git a/modules/web/src/main/native/Source/WebCore/bindings/java/JavaEventListener.cpp b/modules/web/src/main/native/Source/WebCore/bindings/java/JavaEventListener.cpp index f61f944cf..ec840291e 100644 --- a/modules/web/src/main/native/Source/WebCore/bindings/java/JavaEventListener.cpp +++ b/modules/web/src/main/native/Source/WebCore/bindings/java/JavaEventListener.cpp @@ -92,6 +92,9 @@ JNIEXPORT void JNICALL Java_com_sun_webkit_dom_EventListenerImpl_twkDisposeJSPee JNIEXPORT void JNICALL Java_com_sun_webkit_dom_EventListenerImpl_twkDispatchEvent (JNIEnv*, jclass, jlong peer, jlong eventPeer) { + if (!peer || !eventPeer || !JavaEventListener::scriptExecutionContext()) + return; + static_cast<EventListener *>(jlong_to_ptr(peer))->handleEvent( JavaEventListener::scriptExecutionContext(), static_cast<Event*>(jlong_to_ptr(eventPeer))); diff --git a/modules/web/src/main/native/Source/WebCore/bridge/jni/jsc/BridgeUtils.cpp b/modules/web/src/main/native/Source/WebCore/bridge/jni/jsc/BridgeUtils.cpp index 79f7e9370..6e7e7038a 100644 --- a/modules/web/src/main/native/Source/WebCore/bridge/jni/jsc/BridgeUtils.cpp +++ b/modules/web/src/main/native/Source/WebCore/bridge/jni/jsc/BridgeUtils.cpp @@ -120,6 +120,7 @@ JSValueRef Java_Object_to_JSValue( if (val == NULL) return JSValueMakeNull(ctx); JSC::ExecState* exec = toJS(ctx); + JSC::JSLockHolder lock(exec); jclass clJSObject = getJSObjectClass(env); if (env->IsInstanceOf(val, clJSObject)) { @@ -127,7 +128,6 @@ JSValueRef Java_Object_to_JSValue( static jfieldID fldPeerType = env->GetFieldID(clJSObject, "peer_type", "I"); jlong peer = env->GetLongField(val, fldPeer); jint peer_type = env->GetIntField(val, fldPeerType); - JSC::JSObject *jobject = 0; switch (peer_type) { case com_sun_webkit_dom_JSObject_JS_CONTEXT_OBJECT: return static_cast<JSObjectRef>(jlong_to_ptr(peer)); @@ -193,7 +193,7 @@ jstring JSValue_to_Java_String(JSValueRef value, JNIEnv* env, JSContextRef ctx) jobject JSValue_to_Java_Object( JSValueRef value, - JNIEnv* env, + JNIEnv*, JSContextRef ctx, JSC::Bindings::RootObject* rootObject) { @@ -275,6 +275,7 @@ PassRefPtr<JSC::Bindings::RootObject> checkJSPeer( if (rootObject) { context = WebCore::getGlobalContext(&frame->script()); JSC::ExecState* exec = toJS(context); + JSC::JSLockHolder lock(exec); object = const_cast<JSObjectRef>(toRef(exec, (peer_type == com_sun_webkit_dom_JSObject_JS_DOM_WINDOW_OBJECT) @@ -294,7 +295,7 @@ PassRefPtr<JSC::Bindings::RootObject> checkJSPeer( extern "C" { JNIEXPORT jobject JNICALL Java_com_sun_webkit_dom_JSObject_evalImpl -(JNIEnv *env, jclass clas, jlong peer, jint peer_type, jstring str) +(JNIEnv *env, jclass, jlong peer, jint peer_type, jstring str) { if (str == NULL) { throwNullPointerException(env); @@ -308,7 +309,7 @@ JNIEXPORT jobject JNICALL Java_com_sun_webkit_dom_JSObject_evalImpl } JNIEXPORT jobject JNICALL Java_com_sun_webkit_dom_JSObject_getMemberImpl -(JNIEnv *env, jclass clas, jlong peer, jint peer_type, jstring str) +(JNIEnv *env, jclass, jlong peer, jint peer_type, jstring str) { if (str == NULL) { throwNullPointerException(env); @@ -325,7 +326,7 @@ JNIEXPORT jobject JNICALL Java_com_sun_webkit_dom_JSObject_getMemberImpl } JNIEXPORT void JNICALL Java_com_sun_webkit_dom_JSObject_setMemberImpl -(JNIEnv *env, jclass clas, jlong peer, jint peer_type, jstring str, jobject value, jobject accessControlContext) +(JNIEnv *env, jclass, jlong peer, jint peer_type, jstring str, jobject value, jobject accessControlContext) { if (str == NULL) { throwNullPointerException(env); @@ -346,7 +347,7 @@ JNIEXPORT void JNICALL Java_com_sun_webkit_dom_JSObject_setMemberImpl } JNIEXPORT void JNICALL Java_com_sun_webkit_dom_JSObject_removeMemberImpl -(JNIEnv *env, jclass clas, jlong peer, jint peer_type, jstring str) +(JNIEnv *env, jclass, jlong peer, jint peer_type, jstring str) { if (str == NULL) { throwNullPointerException(env); @@ -362,7 +363,7 @@ JNIEXPORT void JNICALL Java_com_sun_webkit_dom_JSObject_removeMemberImpl } JNIEXPORT jobject JNICALL Java_com_sun_webkit_dom_JSObject_getSlotImpl - (JNIEnv *env, jclass clas, jlong peer, jint peer_type, jint index) + (JNIEnv *env, jclass, jlong peer, jint peer_type, jint index) { JSObjectRef object; JSContextRef ctx; @@ -373,25 +374,25 @@ JNIEXPORT jobject JNICALL Java_com_sun_webkit_dom_JSObject_getSlotImpl } JNIEXPORT void JNICALL Java_com_sun_webkit_dom_JSObject_setSlotImpl -(JNIEnv *env, jclass clas, jlong peer, jint peer_type, jint index, jobject value, jobject accessControlContext) +(JNIEnv *env, jclass, jlong peer, jint peer_type, jint index, jobject value, jobject accessControlContext) { JSObjectRef object; JSContextRef ctx; RefPtr<JSC::Bindings::RootObject> rootObject(checkJSPeer(peer, peer_type, object, ctx)); JSValueRef jsvalue = WebCore::Java_Object_to_JSValue(env, ctx, rootObject.get(), value, accessControlContext); - JSPropertyAttributes attributes = 0; JSObjectSetPropertyAtIndex(ctx, object, (unsigned) index, jsvalue, NULL); } JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_JSObject_toStringImpl -(JNIEnv *env, jclass clas, jlong peer, jint peer_type) +(JNIEnv *env, jclass, jlong peer, jint peer_type) { JSObjectRef object; JSContextRef ctx; checkJSPeer(peer, peer_type, object, ctx); JSC::ExecState* exec = toJS(ctx); + JSC::JSLockHolder lock(exec); return toJS(object)->toString(exec)->value(exec) .toJavaString(env).releaseLocal(); @@ -439,7 +440,7 @@ JNIEXPORT jobject JNICALL Java_com_sun_webkit_dom_JSObject_callImpl } JNIEXPORT void JNICALL Java_com_sun_webkit_dom_JSObject_unprotectImpl -(JNIEnv *env, jclass clas, jlong peer, jint peer_type) +(JNIEnv*, jclass, jlong peer, jint peer_type) { JSObjectRef object; JSContextRef ctx; diff --git a/modules/web/src/main/native/Source/WebCore/bridge/jni/jsc/JavaClassJSC.cpp b/modules/web/src/main/native/Source/WebCore/bridge/jni/jsc/JavaClassJSC.cpp index e36a3c84b..46b6c5357 100644 --- a/modules/web/src/main/native/Source/WebCore/bridge/jni/jsc/JavaClassJSC.cpp +++ b/modules/web/src/main/native/Source/WebCore/bridge/jni/jsc/JavaClassJSC.cpp @@ -208,7 +208,6 @@ Method* JavaClass::methodNamed(PropertyName propertyName, Instance*) const && pname[pnameLength-1] == ']') { // Primitive array type names. if (methodParamLength == 2) { - UChar sig1 = methodParam[1]; const char *prim; switch (methodParam[1]) { case 'I': prim = "int[]"; break; diff --git a/modules/web/src/main/native/Source/WebCore/page/java/DragControllerJava.cpp b/modules/web/src/main/native/Source/WebCore/page/java/DragControllerJava.cpp index db6c0d3f5..9bcb6d363 100644 --- a/modules/web/src/main/native/Source/WebCore/page/java/DragControllerJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/page/java/DragControllerJava.cpp @@ -32,7 +32,7 @@ namespace WebCore { } //uta: need to be fixed with usage of DragData pointer - bool DragController::isCopyKeyDown(const DragData& dragData) + bool DragController::isCopyKeyDown(const DragData&) { //State has not direct connection with keyboard state. //Now it is imported from Java (user drag action). diff --git a/modules/web/src/main/native/Source/WebCore/platform/URL.h b/modules/web/src/main/native/Source/WebCore/platform/URL.h index 6cd0d9fc1..d50ecbf40 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/URL.h +++ b/modules/web/src/main/native/Source/WebCore/platform/URL.h @@ -199,7 +199,7 @@ public: #if PLATFORM(JAVA) bool isJarFile() const { return m_protocolIsInJar; } - URL(JNIEnv* env, jstring url) : URL(ParsedURLString, String(env, url)) {} + URL(JNIEnv* env, jstring url) : URL(URL(), String(env, url)) {} #endif #ifndef NDEBUG diff --git a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/BufferImageJava.h b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/BufferImageJava.h index 917022070..80653b73e 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/BufferImageJava.h +++ b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/BufferImageJava.h @@ -26,7 +26,7 @@ public: return adoptRef(new BufferImage(rqoImage, rq, w, h)); } - void destroyDecodedData(bool destroyAll = true) override { } + void destroyDecodedData(bool = true) override { } //utatodo: callback to Java bool currentFrameKnownToBeOpaque() const override { return false; /*!m_data->m_bitmap->hasAlpha() ;*/} diff --git a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/ChromiumBridge.cpp b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/ChromiumBridge.cpp index 728a3f2d3..171ec56c6 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/ChromiumBridge.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/ChromiumBridge.cpp @@ -443,7 +443,7 @@ String ChromiumBridge::getFontFamilyForCharacters(const UChar* characters, size_ return family; #endif //USE(ICU_UNICODE) #endif //SKIA -void ChromiumBridge::plugins(bool refresh, Vector<PluginInfo>*) +void ChromiumBridge::plugins(bool, Vector<PluginInfo>*) { } diff --git a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/FontCacheJava.cpp b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/FontCacheJava.cpp index aca720ddc..1a7eb54f5 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/FontCacheJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/FontCacheJava.cpp @@ -55,7 +55,7 @@ Ref<Font> FontCache::lastResortFallbackFontForEveryCharacter(const FontDescripti return lastResortFallbackFont(fontDescription); } -const AtomicString& FontCache::platformAlternateFamilyName(const AtomicString& familyName) +const AtomicString& FontCache::platformAlternateFamilyName(const AtomicString&) { notImplemented(); return nullAtom; @@ -63,4 +63,3 @@ const AtomicString& FontCache::platformAlternateFamilyName(const AtomicString& f } - diff --git a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/FontJava.cpp b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/FontJava.cpp index ccd550543..a1f5c5aa3 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/FontJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/FontJava.cpp @@ -123,5 +123,4 @@ FloatRect Font::platformBoundsForGlyph(Glyph) const return FloatRect(); //That is OK! platformWidthForGlyph impl is enough. } - } diff --git a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/ImageDecoderJava.cpp b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/ImageDecoderJava.cpp index 0d6569477..2dd503647 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/ImageDecoderJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/ImageDecoderJava.cpp @@ -163,7 +163,7 @@ size_t ImageDecoder::frameCount() const : count; } -NativeImagePtr ImageDecoder::createFrameImageAtIndex(size_t idx, SubsamplingLevel samplingLevel, const std::optional<IntSize>&) +NativeImagePtr ImageDecoder::createFrameImageAtIndex(size_t idx, SubsamplingLevel, const std::optional<IntSize>&) { JNIEnv* env = WebCore_GetJavaEnv(); ASSERT(m_nativeDecoder); @@ -232,7 +232,7 @@ bool ImageDecoder::frameAllowSubsamplingAtIndex(size_t) const return true; } -bool ImageDecoder::frameHasAlphaAtIndex(size_t idx) const +bool ImageDecoder::frameHasAlphaAtIndex(size_t) const { // FIXME-java: Read it from ImageMetadata return true; diff --git a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/ImageJava.cpp b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/ImageJava.cpp index f089c34bd..0f25cdaa0 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/ImageJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/ImageJava.cpp @@ -62,8 +62,6 @@ void Image::drawPattern(GraphicsContext& gc, const FloatRect& destRect, const Fl void Image::drawImage(GraphicsContext& gc, const FloatRect &dstRect, const FloatRect &srcRect, CompositeOperator, BlendMode) { - JNIEnv* env = WebCore_GetJavaEnv(); - if (gc.paintingDisabled()) { return; } diff --git a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/NativeImageJava.cpp b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/NativeImageJava.cpp index d3e3daebf..3294ef1c1 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/NativeImageJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/NativeImageJava.cpp @@ -67,7 +67,7 @@ IntSize nativeImageSize(const NativeImagePtr& image) return frameSize; } -bool nativeImageHasAlpha(const NativeImagePtr& image) +bool nativeImageHasAlpha(const NativeImagePtr&) { // FIXME-java: Get alpha details from ImageMetadata class return true; diff --git a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/RenderingQueue.cpp b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/RenderingQueue.cpp index ff3b82932..adf7efd7d 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/graphics/java/RenderingQueue.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/graphics/java/RenderingQueue.cpp @@ -106,7 +106,7 @@ using namespace WebCore; extern "C" { JNIEXPORT void JNICALL Java_com_sun_webkit_graphics_WCRenderQueue_twkRelease - (JNIEnv* env, jobject clazz, jobjectArray bufs) + (JNIEnv* env, jobject, jobjectArray bufs) { /* * This method should be called on the Event thread to synchronize with JavaScript diff --git a/modules/web/src/main/native/Source/WebCore/platform/java/ContextMenuClientJava.cpp b/modules/web/src/main/native/Source/WebCore/platform/java/ContextMenuClientJava.cpp index 378197032..adb4e146e 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/java/ContextMenuClientJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/java/ContextMenuClientJava.cpp @@ -21,7 +21,7 @@ void ContextMenuClientJava::contextMenuDestroyed() delete this; } -void ContextMenuClientJava::downloadURL(const URL& url) +void ContextMenuClientJava::downloadURL(const URL&) { notImplemented(); } diff --git a/modules/web/src/main/native/Source/WebCore/platform/java/DragClientJava.cpp b/modules/web/src/main/native/Source/WebCore/platform/java/DragClientJava.cpp index 57d380694..d4ba3ac21 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/java/DragClientJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/java/DragClientJava.cpp @@ -133,7 +133,7 @@ void DragClientJava::startDrag( const FloatPoint&, DataTransfer& DataTransfer, Frame&, - DragSourceAction) + DragSourceAction dragSourceAction) { JNIEnv* env = WebCore_GetJavaEnv(); static jmethodID mid = env->GetMethodID( @@ -144,6 +144,7 @@ void DragClientJava::startDrag( "II" "[Ljava/lang/String;" "[Ljava/lang/Object;" + "Z" ")V"); ASSERT(mid); @@ -189,13 +190,16 @@ void DragClientJava::startDrag( jobject jimage = dragImage.get() && dragImage.get()->javaImage() ? jobject(*(dragImage.get()->javaImage())) : nullptr; + bool isImageSource = dragSourceAction & DragSourceActionImage; + env->CallVoidMethod(m_webPage, mid, jimage, eventPos.x() - dragImageOrigin.x(), eventPos.y() - dragImageOrigin.y(), eventPos.x(), eventPos.y(), jobjectArray(jmimeTypes), - jobjectArray(jvalues) ); + jobjectArray(jvalues), + bool_to_jbool(isImageSource)); CheckAndClearException(env); } diff --git a/modules/web/src/main/native/Source/WebCore/platform/java/DragDataJava.cpp b/modules/web/src/main/native/Source/WebCore/platform/java/DragDataJava.cpp index 8a2fd3e35..8deeef385 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/java/DragDataJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/java/DragDataJava.cpp @@ -17,14 +17,14 @@ namespace WebCore { -bool DragData::containsURL(FilenameConversionPolicy filenamePolicy /*= ConvertFilenames*/) const +bool DragData::containsURL(FilenameConversionPolicy /*= ConvertFilenames*/) const { /* utaTODO: extent the functionality */ return m_platformDragData->containsURL(); } -String DragData::asURL(FilenameConversionPolicy filenamePolicy, String* title) const +String DragData::asURL(FilenameConversionPolicy, String* title) const { /* utaTODO: extent the functionality String url; diff --git a/modules/web/src/main/native/Source/WebCore/platform/java/FileSystemJava.cpp b/modules/web/src/main/native/Source/WebCore/platform/java/FileSystemJava.cpp index 12bbcf581..1d1585605 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/java/FileSystemJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/java/FileSystemJava.cpp @@ -83,7 +83,7 @@ bool getFileModificationTime(const String& path, time_t& result) } } -bool getFileCreationTime(const String&, time_t& result) +bool getFileCreationTime(const String&, time_t&) { notImplemented(); // todo tav return false; @@ -169,7 +169,7 @@ bool getFileMetadata(const String& path, FileMetadata& metadata) return false; } -Vector<String> listDirectory(const String& path, const String& filter) +Vector<String> listDirectory(const String&, const String&) { Vector<String> entities; notImplemented(); @@ -189,7 +189,7 @@ String openTemporaryFile(const String&, PlatformFileHandle& handle) return String(); } -PlatformFileHandle openFile(const String& path, FileOpenMode mode) +PlatformFileHandle openFile(const String&, FileOpenMode) { notImplemented(); return invalidPlatformFileHandle; @@ -200,13 +200,13 @@ void closeFile(PlatformFileHandle&) notImplemented(); } -int readFromFile(PlatformFileHandle handle, char* data, int length) +int readFromFile(PlatformFileHandle, char*, int) { notImplemented(); return -1; } -int writeToFile(PlatformFileHandle, const char* data, int length) +int writeToFile(PlatformFileHandle, const char*, int) { notImplemented(); return -1; @@ -237,13 +237,13 @@ String pathGetFileName(const String& path) return String(env, result); } -long long seekFile(PlatformFileHandle handle, long long offset, FileSeekOrigin origin) +long long seekFile(PlatformFileHandle, long long, FileSeekOrigin) { notImplemented(); return (long long)(-1); } -std::optional<int32_t> getFileDeviceId(const CString& fsFile) +std::optional<int32_t> getFileDeviceId(const CString&) { notImplemented(); return {}; diff --git a/modules/web/src/main/native/Source/WebCore/platform/java/FrameLoaderClientJava.cpp b/modules/web/src/main/native/Source/WebCore/platform/java/FrameLoaderClientJava.cpp index e2c872101..acd614b6a 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/java/FrameLoaderClientJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/java/FrameLoaderClientJava.cpp @@ -181,6 +181,15 @@ FrameLoaderClientJava::FrameLoaderClientJava(const JLObject &webPage) { } +void FrameLoaderClientJava::dispatchDidNavigateWithinPage() +{ + postLoadEvent(frame(), + com_sun_webkit_LoadListenerClient_PAGE_REPLACED, + frame()->document()->url(), + frame()->loader().documentLoader()->responseMIMEType(), + 1.0 /* progress */); +} + void FrameLoaderClientJava::frameLoaderDestroyed() { WC_GETJAVAENV_CHKRET(env); @@ -329,7 +338,7 @@ void FrameLoaderClientJava::committedLoad(DocumentLoader* loader, const char* da loader->commitData(data, length); } -void FrameLoaderClientJava::dispatchDecidePolicyForResponse(const ResourceResponse& response, const ResourceRequest& request, FramePolicyFunction policyFunction) +void FrameLoaderClientJava::dispatchDecidePolicyForResponse(const ResourceResponse& response, const ResourceRequest&, FramePolicyFunction policyFunction) { PolicyAction action; @@ -829,8 +838,17 @@ void FrameLoaderClientJava::setCopiesOnScroll() { notImplemented(); } void FrameLoaderClientJava::detachedFromParent2() { notImplemented(); } void FrameLoaderClientJava::detachedFromParent3() { notImplemented(); } void FrameLoaderClientJava::dispatchDidDispatchOnloadEvents() {notImplemented(); } -void FrameLoaderClientJava::dispatchDidPushStateWithinPage() { notImplemented(); } -void FrameLoaderClientJava::dispatchDidReplaceStateWithinPage() { notImplemented(); } + +void FrameLoaderClientJava::dispatchDidPushStateWithinPage() +{ + dispatchDidNavigateWithinPage(); +} + +void FrameLoaderClientJava::dispatchDidReplaceStateWithinPage() +{ + dispatchDidNavigateWithinPage(); +} + void FrameLoaderClientJava::dispatchDidPopStateWithinPage() { notImplemented(); } void FrameLoaderClientJava::dispatchDidReceiveServerRedirectForProvisionalLoad() { notImplemented(); } void FrameLoaderClientJava::dispatchDidCancelClientRedirect() { notImplemented(); } diff --git a/modules/web/src/main/native/Source/WebCore/platform/java/FrameLoaderClientJava.h b/modules/web/src/main/native/Source/WebCore/platform/java/FrameLoaderClientJava.h index 3ab313e2e..9e8b74502 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/java/FrameLoaderClientJava.h +++ b/modules/web/src/main/native/Source/WebCore/platform/java/FrameLoaderClientJava.h @@ -193,6 +193,7 @@ private: void postLoadEvent(Frame* f, int state, String url, String contentType, double progress, int errorCode = 0); void postResourceLoadEvent(Frame* f, int state, int id, String contentType, double progress, int errorCode = 0); + void dispatchDidNavigateWithinPage(); // Plugin widget for handling data redirection // PluginWidgetJava* m_pluginWidget; }; diff --git a/modules/web/src/main/native/Source/WebCore/platform/java/LocalizedStringsJava.cpp b/modules/web/src/main/native/Source/WebCore/platform/java/LocalizedStringsJava.cpp index c46a0a239..5fa30d3c1 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/java/LocalizedStringsJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/java/LocalizedStringsJava.cpp @@ -202,7 +202,7 @@ String contextMenuItemTagSpellingMenu() return String(); // UNSUPPORTED: getLocalizedProperty("contextMenuItemTagSpellingMenu"); } -String contextMenuItemTagShowSpellingPanel(bool show) +String contextMenuItemTagShowSpellingPanel(bool) { return String(); /* UNSUPPORTED: show ? getLocalizedProperty("contextMenuItemTagShowSpellingPanelShow") @@ -330,7 +330,7 @@ String insecurePluginVersionText() } -String imageTitle(const String& filename, const IntSize& size) +String imageTitle(const String&, const IntSize&) { return String(); } diff --git a/modules/web/src/main/native/Source/WebCore/platform/java/MIMETypeRegistryJava.cpp b/modules/web/src/main/native/Source/WebCore/platform/java/MIMETypeRegistryJava.cpp index 9ecacd933..722d05f45 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/java/MIMETypeRegistryJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/java/MIMETypeRegistryJava.cpp @@ -18,6 +18,7 @@ struct ExtensionMap { static const ExtensionMap extensionMap [] = { { "bmp", "image/bmp" }, { "css", "text/css" }, + { "cur", "image/x-icon" }, { "gif", "image/gif" }, { "html", "text/html" }, { "htm", "text/html" }, @@ -25,39 +26,33 @@ static const ExtensionMap extensionMap [] = { { "jpeg", "image/jpeg" }, { "jpg", "image/jpeg" }, { "js", "application/x-javascript" }, + { "mp3", "audio/mpeg"}, { "pdf", "application/pdf" }, { "png", "image/png" }, { "rss", "application/rss+xml" }, { "svg", "image/svg+xml" }, + { "svgz", "image/svg+xml" }, { "swf", "application/x-shockwave-flash" }, { "text", "text/plain" }, + { "tif", "image/tiff" }, + { "tiff", "image/tiff" }, { "txt", "text/plain" }, { "xbm", "image/x-xbitmap" }, { "xml", "text/xml" }, { "xsl", "text/xsl" }, + { "xht", "application/xhtml+xml" }, { "xhtml", "application/xhtml+xml" }, { "wml", "text/vnd.wap.wml" }, { "wmlc", "application/vnd.wap.wmlc" }, }; -String MIMETypeRegistry::getMIMETypeForExtension(const String &ext) +String MIMETypeRegistry::getMIMETypeForExtension(const String& extension) { - JNIEnv* env = WebCore_GetJavaEnv(); - ASSERT(env); - - static JGClass cls(env->FindClass("com/sun/webkit/Utilities")); - ASSERT(cls); - - static jmethodID mid = env->GetStaticMethodID(cls, - "fwkGetMIMETypeForExtension", - "(Ljava/lang/String;)Ljava/lang/String;"); - ASSERT(mid); - - JLString type(static_cast<jstring>(env->CallStaticObjectMethod(cls, mid, - (jstring)ext.toJavaString(env)))); - CheckAndClearException(env); - - return String(env, type); + for (auto& entry : extensionMap) { + if (equalIgnoringASCIICase(extension, entry.extension)) + return entry.mimeType; + } + return String(); } bool MIMETypeRegistry::isApplicationPluginMIMEType(const String&) diff --git a/modules/web/src/main/native/Source/WebCore/platform/java/PlatformScreenJava.cpp b/modules/web/src/main/native/Source/WebCore/platform/java/PlatformScreenJava.cpp index 8ff97b6f8..3d5ac6dc1 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/java/PlatformScreenJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/java/PlatformScreenJava.cpp @@ -60,13 +60,13 @@ static void initRefs(JNIEnv* env) namespace WebCore { -int screenHorizontalDPI(Widget* widget) +int screenHorizontalDPI(Widget*) { notImplemented(); return 0; } -int screenVerticalDPI(Widget* widget) +int screenVerticalDPI(Widget*) { notImplemented(); return 0; @@ -99,7 +99,7 @@ int screenDepthPerComponent(Widget* w) return screenDepth(w) / 3; } -bool screenIsMonochrome(Widget* w) +bool screenIsMonochrome(Widget*) { notImplemented(); return false; diff --git a/modules/web/src/main/native/Source/WebCore/platform/java/PluginDataJava.cpp b/modules/web/src/main/native/Source/WebCore/platform/java/PluginDataJava.cpp index d5ae6ef99..681496291 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/java/PluginDataJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/java/PluginDataJava.cpp @@ -9,7 +9,7 @@ namespace WebCore { -void init_plugins(bool refresh, Vector<PluginInfo> *plugins) { +void init_plugins(bool, Vector<PluginInfo>*) { /* JNIEnv* env = WebCore_GetJavaEnv(); diff --git a/modules/web/src/main/native/Source/WebCore/platform/java/ProgressTrackerClientJava.cpp b/modules/web/src/main/native/Source/WebCore/platform/java/ProgressTrackerClientJava.cpp index 323e670a7..870cc6a84 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/java/ProgressTrackerClientJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/java/ProgressTrackerClientJava.cpp @@ -58,7 +58,7 @@ ProgressTrackerClientJava::ProgressTrackerClientJava(const JLObject &webPage) { } -void ProgressTrackerClientJava::progressStarted(Frame& originatingProgressFrame) +void ProgressTrackerClientJava::progressStarted(Frame&) { } @@ -90,7 +90,7 @@ void ProgressTrackerClientJava::progressEstimateChanged(Frame& originatingProgre } } -void ProgressTrackerClientJava::progressFinished(Frame& originatingProgressFrame) +void ProgressTrackerClientJava::progressFinished(Frame&) { // shouldn't post PROGRESS_CHANGED after PAGE_FINISHED } diff --git a/modules/web/src/main/native/Source/WebCore/platform/java/ScrollbarThemeJava.cpp b/modules/web/src/main/native/Source/WebCore/platform/java/ScrollbarThemeJava.cpp index a0674315e..328ebe969 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/java/ScrollbarThemeJava.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/java/ScrollbarThemeJava.cpp @@ -98,7 +98,7 @@ IntRect getPartRect(Scrollbar& scrollbar, ScrollbarPart part) { } -bool ScrollbarThemeJava::paint(Scrollbar& scrollbar, GraphicsContext& gc, const IntRect& damageRect) +bool ScrollbarThemeJava::paint(Scrollbar& scrollbar, GraphicsContext& gc, const IntRect&) { // platformContext() returns 0 when printing if (gc.paintingDisabled() || !gc.platformContext()) { @@ -166,7 +166,7 @@ IntRect ScrollbarThemeJava::trackRect(Scrollbar& scrollbar, bool) { return getPartRect(scrollbar, TrackBGPart); } -int ScrollbarThemeJava::scrollbarThickness(ScrollbarControlSize controlSize) +int ScrollbarThemeJava::scrollbarThickness(ScrollbarControlSize) { JNIEnv* env = WebCore_GetJavaEnv(); diff --git a/modules/web/src/main/native/Source/WebCore/platform/java/WebPage.cpp b/modules/web/src/main/native/Source/WebCore/platform/java/WebPage.cpp index 73fa89dbf..8c3105430 100644 --- a/modules/web/src/main/native/Source/WebCore/platform/java/WebPage.cpp +++ b/modules/web/src/main/native/Source/WebCore/platform/java/WebPage.cpp @@ -944,6 +944,7 @@ JNIEXPORT void JNICALL Java_com_sun_webkit_WebPage_twkInit settings.setUserAgent(defaultUserAgent()); settings.setMaximumHTMLParserDOMTreeDepth(180); settings.setXSSAuditorEnabled(true); + settings.setInteractiveFormValidationEnabled(true); /* Using java logical fonts as defaults */ settings.setSerifFontFamily("Serif"); diff --git a/modules/web/src/main/native/Source/WebKit/java/BackForwardList.cpp b/modules/web/src/main/native/Source/WebKit/java/BackForwardList.cpp index 2d5dfe54e..98e1028b6 100644 --- a/modules/web/src/main/native/Source/WebKit/java/BackForwardList.cpp +++ b/modules/web/src/main/native/Source/WebKit/java/BackForwardList.cpp @@ -170,7 +170,7 @@ void notifyHistoryItemDestroyed(const JLObject &host) } // entry.getURL() -JNIEXPORT jstring JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetURL(JNIEnv* env, jclass z, jlong jitem) +JNIEXPORT jstring JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetURL(JNIEnv* env, jclass, jlong jitem) { HistoryItem* item = getItem(jitem); String urlString = item->urlString(); @@ -178,7 +178,7 @@ JNIEXPORT jstring JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetURL(JNIE } // entry.getTitle() -JNIEXPORT jstring JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetTitle(JNIEnv* env, jclass z, jlong jitem) +JNIEXPORT jstring JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetTitle(JNIEnv* env, jclass, jlong jitem) { HistoryItem* item = getItem(jitem); String title = item->title(); @@ -186,10 +186,10 @@ JNIEXPORT jstring JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetTitle(JN } // entry.getIcon() -JNIEXPORT jobject JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetIcon(JNIEnv* env, jclass z, jlong jitem) +JNIEXPORT jobject JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetIcon(JNIEnv*, jclass, jlong) { - HistoryItem* item = getItem(jitem); /* + HistoryItem* item = getItem(jitem); if (item != nullptr) { // TODO: crashes with DRT return *WebCore::iconDatabase().synchronousIconForPageURL(item->url(), WebCore::IntSize(16, 16))->nativeImageForCurrentFrame(); @@ -203,7 +203,7 @@ JNIEXPORT jobject JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetIcon(JNI } // entry.getLastVisited() -JNIEXPORT jlong JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetLastVisitedDate(JNIEnv* env, jclass z, jlong jitem) +JNIEXPORT jlong JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetLastVisitedDate(JNIEnv*, jclass, jlong) { // HistoryItem* item = getItem(jitem); // double lastVisitedDate = item->lastVisitedTime(); @@ -212,14 +212,14 @@ JNIEXPORT jlong JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetLastVisite } // entry.isTargetItem() -JNIEXPORT jboolean JNICALL Java_com_sun_webkit_BackForwardList_bflItemIsTargetItem(JNIEnv* env, jclass z, jlong jitem) +JNIEXPORT jboolean JNICALL Java_com_sun_webkit_BackForwardList_bflItemIsTargetItem(JNIEnv*, jclass, jlong jitem) { HistoryItem* item = getItem(jitem); return (jboolean)item->isTargetItem(); } // entry.getTarget() -JNIEXPORT jstring JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetTarget(JNIEnv* env, jclass z, jlong jitem) +JNIEXPORT jstring JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetTarget(JNIEnv* env, jclass, jlong jitem) { HistoryItem* item = getItem(jitem); String target = item->target(); @@ -231,7 +231,7 @@ JNIEXPORT jstring JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetTarget(J } // entry.getChildren() -JNIEXPORT jobjectArray JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetChildren(JNIEnv* env, jclass z, jlong jitem, jlong jpage) +JNIEXPORT jobjectArray JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetChildren(JNIEnv* env, jclass, jlong jitem, jlong jpage) { HistoryItem* item = getItem(jitem); if (!item->hasChildren()) { @@ -246,48 +246,48 @@ JNIEXPORT jobjectArray JNICALL Java_com_sun_webkit_BackForwardList_bflItemGetChi } // BackForwardList.size() -JNIEXPORT jint JNICALL Java_com_sun_webkit_BackForwardList_bflSize(JNIEnv* env, jclass z, jlong jpage) +JNIEXPORT jint JNICALL Java_com_sun_webkit_BackForwardList_bflSize(JNIEnv*, jclass, jlong jpage) { return getSize(getBfl(jpage)); } // BackForwardList.getMaximumSize() -JNIEXPORT jint JNICALL Java_com_sun_webkit_BackForwardList_bflGetMaximumSize(JNIEnv* env, jclass z, jlong jpage) +JNIEXPORT jint JNICALL Java_com_sun_webkit_BackForwardList_bflGetMaximumSize(JNIEnv*, jclass, jlong jpage) { BackForwardList* bfl = static_cast<BackForwardList *>(getBfl(jpage)); return bfl->capacity(); } // BackForwardList.setMaximumSize() -JNIEXPORT void JNICALL Java_com_sun_webkit_BackForwardList_bflSetMaximumSize(JNIEnv* env, jclass z, jlong jpage, jint size) +JNIEXPORT void JNICALL Java_com_sun_webkit_BackForwardList_bflSetMaximumSize(JNIEnv*, jclass, jlong jpage, jint size) { BackForwardList* bfl = static_cast<BackForwardList *>(getBfl(jpage)); bfl->setCapacity(size); } // BackForwardList.getCurrentIndex() -JNIEXPORT jint JNICALL Java_com_sun_webkit_BackForwardList_bflGetCurrentIndex(JNIEnv* env, jclass z, jlong jpage) +JNIEXPORT jint JNICALL Java_com_sun_webkit_BackForwardList_bflGetCurrentIndex(JNIEnv*, jclass, jlong jpage) { BackForwardList* bfl = getBfl(jpage); return bfl->currentItem() ? bfl->backListCount() : -1; } // BackForwardList.setEnabled() -JNIEXPORT void JNICALL Java_com_sun_webkit_BackForwardList_bflSetEnabled(JNIEnv* env, jclass z, jlong jpage, jboolean flag) +JNIEXPORT void JNICALL Java_com_sun_webkit_BackForwardList_bflSetEnabled(JNIEnv*, jclass, jlong jpage, jboolean flag) { BackForwardList* bfl = static_cast<BackForwardList *>(getBfl(jpage)); bfl->setEnabled(flag); } // BackForwardList.isEnabled() -JNIEXPORT jboolean JNICALL Java_com_sun_webkit_BackForwardList_bflIsEnabled(JNIEnv* env, jclass z, jlong jpage) +JNIEXPORT jboolean JNICALL Java_com_sun_webkit_BackForwardList_bflIsEnabled(JNIEnv*, jclass, jlong jpage) { BackForwardList* bfl = static_cast<BackForwardList *>(getBfl(jpage)); return bfl->enabled(); } // BackForwardList.get() -JNIEXPORT jobject JNICALL Java_com_sun_webkit_BackForwardList_bflGet(JNIEnv* env, jclass z, jlong jpage, jint index) +JNIEXPORT jobject JNICALL Java_com_sun_webkit_BackForwardList_bflGet(JNIEnv*, jclass, jlong jpage, jint index) { BackForwardList* bfl = getBfl(jpage); HistoryItem* item = itemAtIndex(bfl, index); @@ -301,7 +301,7 @@ JNIEXPORT jobject JNICALL Java_com_sun_webkit_BackForwardList_bflGet(JNIEnv* env } // BackForwardList.setCurrentIndex() -JNIEXPORT jint JNICALL Java_com_sun_webkit_BackForwardList_bflSetCurrentIndex(JNIEnv* env, jclass z, jlong jpage, jint index) +JNIEXPORT jint JNICALL Java_com_sun_webkit_BackForwardList_bflSetCurrentIndex(JNIEnv*, jclass, jlong jpage, jint index) { Page* page = getPage(jpage); BackForwardList* bfl = static_cast<BackForwardList*>(page->backForward().client()); @@ -313,7 +313,7 @@ JNIEXPORT jint JNICALL Java_com_sun_webkit_BackForwardList_bflSetCurrentIndex(JN } // BackForwardList.get[Last]IndexOf() -JNIEXPORT jint JNICALL Java_com_sun_webkit_BackForwardList_bflIndexOf(JNIEnv* env, jclass z, jlong jpage, jlong jitem, jboolean reverse) +JNIEXPORT jint JNICALL Java_com_sun_webkit_BackForwardList_bflIndexOf(JNIEnv*, jclass, jlong jpage, jlong jitem, jboolean reverse) { if (!jitem) return -1; @@ -329,7 +329,7 @@ JNIEXPORT jint JNICALL Java_com_sun_webkit_BackForwardList_bflIndexOf(JNIEnv* en return -1; } -JNIEXPORT void JNICALL Java_com_sun_webkit_BackForwardList_bflSetHostObject(JNIEnv* env, jclass z, jlong jpage, jobject host) +JNIEXPORT void JNICALL Java_com_sun_webkit_BackForwardList_bflSetHostObject(JNIEnv*, jclass, jlong jpage, jobject host) { BackForwardList* bfl = getBfl(jpage); bfl->setHostObject(JLObject(host, true)); diff --git a/modules/web/src/main/resources/com/sun/webkit/LocalizedStrings.properties b/modules/web/src/main/resources/com/sun/webkit/LocalizedStrings.properties index f312398d8..fda9cf86e 100644 --- a/modules/web/src/main/resources/com/sun/webkit/LocalizedStrings.properties +++ b/modules/web/src/main/resources/com/sun/webkit/LocalizedStrings.properties @@ -127,3 +127,4 @@ validationMessageStepMismatchText = step mismatch validationMessageTooLongText = too long validationMessageTypeMismatchText = type mismatch validationMessageValueMissingText = value missing +validationMessageBadInputForNumberText = Please enter a number diff --git a/modules/web/src/test/java/com/sun/webkit/network/CookieTest.java b/modules/web/src/test/java/com/sun/webkit/network/CookieTest.java index 2e1415f4b..1f935bd7f 100644 --- a/modules/web/src/test/java/com/sun/webkit/network/CookieTest.java +++ b/modules/web/src/test/java/com/sun/webkit/network/CookieTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, 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 @@ -193,10 +193,11 @@ public class CookieTest { actual = Cookie.parse(testString, expected.creationTime); assertAsExpected(testString, expected, actual); - long maxAge = (Long.MAX_VALUE - currentTimeMillis()) / 1000; - testString = "foo=bar; Max-Age=" + maxAge; expected = new CookieModel("foo", "bar"); - expected.expiryTime = expected.creationTime.baseTime() + maxAge * 1000; + long currentTimeInMillis = expected.creationTime.baseTime(); + long maxAge = (Long.MAX_VALUE - currentTimeInMillis) / 1000; + testString = "foo=bar; Max-Age=" + maxAge; + expected.expiryTime = currentTimeInMillis + maxAge * 1000; expected.persistent = true; actual = Cookie.parse(testString, expected.creationTime); assertAsExpected(testString, expected, actual); diff --git a/modules/web/src/test/java/javafx/scene/web/HistoryStateTest.java b/modules/web/src/test/java/javafx/scene/web/HistoryStateTest.java new file mode 100644 index 000000000..53f823467 --- /dev/null +++ b/modules/web/src/test/java/javafx/scene/web/HistoryStateTest.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2017, 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 javafx.scene.web; + +import org.junit.Test; +import org.junit.Before; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +public class HistoryStateTest extends TestBase { + private static final CountDownLatch historyStateLatch = new CountDownLatch(3); + final AtomicInteger historyListenerIndex = new AtomicInteger(-1); + + private static final String resourcePath= "test/html/"; + private static final String initialLoadUrl = "archive-root0.html"; + private static final String firstLoadUrl = "archive-root1.html"; + private static final String secondLoadUrl = "archive-root2.html"; + private static final String replaceLoadUrl = "archive-root3.html"; + + private static final String historyPushScript1 = "history.pushState({push1key : 1}, '', '?" + + firstLoadUrl + "');"; + private static final String historyPushScript2 = "history.pushState({push2key : 2}, '', '?" + + secondLoadUrl + "');"; + private static final String historyReplaceScript = "history.replaceState({replaceObject : 3}, '', '?" + + replaceLoadUrl + "');"; + private static final String historyStateScript = "history.state"; + private static final String historyLengthScript = "history.length"; + private static final String historyGoBackScript = "history.go(-1)"; + private static final String historyGoForwardScript = "history.go(1)"; + private static final String historyBackcript = "history.back()"; + + private static final int TIMEOUT = 30; // seconds + + @Before + public void before() { + load(HistoryStateTest.class.getClassLoader().getResource( + resourcePath + initialLoadUrl).toExternalForm()); + } + + @Test + public void pushAndReplaceTest() throws Exception { + // Initial history.state should be null + assertNull(historyStateScript + " : Failed", + executeScript(historyStateScript)); + // Initial history.length will be 1 + assertEquals(historyLengthScript + " : Failed", + 1, executeScript(historyLengthScript)); + + // history.pushState({push1Key : 1}, '', '?firstLoadUrl"'); + executeScript(historyPushScript1); + // Check if the history.state object for not null + assertNotNull(historyStateScript + " : Failed", + executeScript(historyStateScript)); + // {push1Key : 1} : {key = push1Key :value = (Integer) 1} + assertEquals("history.state.push1key Failed", + 1, executeScript("history.state.push1key")); + + // history.length expected to be 2 + // Initial load + history.pushState(...) + assertEquals(historyLengthScript + " : Failed", + 2, executeScript(historyLengthScript)); + + // Check for WebEngine location is updated with new URL + assertTrue(historyPushScript1 + " : Failed", + getEngine().getLocation().endsWith(firstLoadUrl)); + + + executeScript(historyPushScript2); + // {push2Key : 2} : {key = push1Key :value = (Integer) 2} + assertEquals("history.state.push1key Failed", + 2, executeScript("history.state.push2key")); + + // history.length expected to be 2 + // Initial load + history.pushState(...) + assertEquals(historyLengthScript + " : Failed", + 3, executeScript(historyLengthScript)); + + // Check for WebEngine location is updated with new URL + assertTrue(historyPushScript2 + " : Failed", + getEngine().getLocation().endsWith(secondLoadUrl)); + + executeScript(historyReplaceScript); + // history.length remains same + assertEquals(historyLengthScript + " : Failed", + 3, executeScript(historyLengthScript)); + + assertEquals("history.state.replaceObject Failed", + 3, executeScript("history.state.replaceObject")); + + // Check for WebEngine location is updated with new URL + assertTrue(historyPushScript2 + " : Failed", + getEngine().getLocation().endsWith(replaceLoadUrl)); + + submit(() -> { + getEngine().locationProperty().addListener((observable, previousUrl, newUrl) -> { + switch(historyListenerIndex.incrementAndGet()) { + case 0: + // call back to history.go(-1) --> newUrl = initialLoadURL + assertTrue(newUrl.endsWith(firstLoadUrl)); + // history.go(1), navigate forward + getEngine().executeScript(historyGoForwardScript); + break; + case 1: + // call back to history.go(1) --> newURL = firstLoad + assertTrue(newUrl.endsWith(replaceLoadUrl)); + // navigate back using history.back() + getEngine().executeScript(historyBackcript); + break; + case 2: + // call back to history.back() --> newURL = initialLoadUrl + assertTrue(newUrl.endsWith(firstLoadUrl)); + break; + default: + fail(); + } + historyStateLatch.countDown(); + }); + // history.go(-1), location will update in listener asynchronously + // expected to go back to firstLoadUrl based on previous states + // a. history.pushState(,,firstLoadUrl) + // b. history.pushState(,,secondUrl) + // c. history.replaceState(,,replaceLoadUrl) + getEngine().executeScript(historyGoBackScript); + }); + try { + historyStateLatch.await(TIMEOUT, TimeUnit.SECONDS); + } catch (InterruptedException ex) { + throw new AssertionError(ex); + } finally { + assertEquals("history navigation using javascript failed", 2, historyListenerIndex.get()); + } + } +} + |