AdblockPlus::JsValuePtr AdblockPlus::ConsoleJsObject::Setup(
    AdblockPlus::JsEnginePtr jsEngine, AdblockPlus::JsValuePtr obj)
{
  obj->SetProperty("log", jsEngine->NewCallback(::LogCallback));
  obj->SetProperty("debug", jsEngine->NewCallback(::DebugCallback));
  obj->SetProperty("info", jsEngine->NewCallback(::InfoCallback));
  obj->SetProperty("warn", jsEngine->NewCallback(::WarnCallback));
  obj->SetProperty("error", jsEngine->NewCallback(::ErrorCallback));
  obj->SetProperty("trace", jsEngine->NewCallback(::TraceCallback));
  return obj;
}
Esempio n. 2
0
TEST_F(JsValueTest, NullValue)
{
  AdblockPlus::JsValuePtr value = jsEngine->Evaluate("null");
  ASSERT_FALSE(value->IsUndefined());
  ASSERT_TRUE(value->IsNull());
  ASSERT_FALSE(value->IsString());
  ASSERT_FALSE(value->IsBool());
  ASSERT_FALSE(value->IsNumber());
  ASSERT_FALSE(value->IsObject());
  ASSERT_FALSE(value->IsArray());
  ASSERT_FALSE(value->IsFunction());
  ASSERT_EQ("null", value->AsString());
  ASSERT_FALSE(value->AsBool());
  ASSERT_ANY_THROW(value->AsList());
  ASSERT_ANY_THROW(value->GetProperty("foo"));
  ASSERT_ANY_THROW(value->SetProperty("foo", false));
  ASSERT_ANY_THROW(value->GetClass());
  ASSERT_ANY_THROW(value->GetOwnPropertyNames());
  ASSERT_ANY_THROW(value->Call());
}
AdblockPlus::JsValuePtr AdblockPlus::WebRequestJsObject::Setup(
    AdblockPlus::JsEnginePtr jsEngine, AdblockPlus::JsValuePtr obj)
{
  obj->SetProperty("GET", jsEngine->NewCallback(::GETCallback));
  return obj;
}