1 /*
   2  * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
   3  */
   4 #include "config.h"
   5 #include "JavaEnv.h"
   6 #include <JavaScriptCore/JSRetainPtr.h>
   7 #include <JavaScriptCore/JSStringRef.h>
   8 #include <wtf/java/JavaRef.h>
   9 
  10 #include "WorkQueueItem.h"
  11 
  12 extern jstring JSStringRef_to_jstring(JSStringRef ref, JNIEnv* env);
  13 extern JSStringRef jstring_to_JSStringRef(jstring str, JNIEnv* env);
  14 
  15 bool LoadItem::invoke() const
  16 {
  17     JNIEnv* env = DumpRenderTree_GetJavaEnv();
  18     JLString jUrl(JSStringRef_to_jstring(m_url.get(), env));
  19     env->CallStaticObjectMethod(getDumpRenderTreeClass(), getLoadURLMID(), (jstring)jUrl);
  20     CheckAndClearException(env);
  21 
  22     return true;
  23 }
  24 
  25 bool ReloadItem::invoke() const
  26 {
  27     // FIXME: implement
  28     return true;
  29 }
  30 
  31 bool ScriptItem::invoke() const
  32 {
  33     // FIXME: implement
  34     return true;
  35 }
  36 
  37 bool BackForwardItem::invoke() const
  38 {
  39     JNIEnv* env = DumpRenderTree_GetJavaEnv();
  40     env->CallStaticObjectMethod(getDumpRenderTreeClass(), getGoBackForward(), m_howFar);
  41     CheckAndClearException(env);
  42 
  43     return true;
  44 }