diff options
author | dan sinclair <dsinclair@chromium.org> | 2017-10-24 21:46:57 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-10-25 18:14:23 +0000 |
commit | 5daf07afe5b76e702d053aaca648b977ec3bb663 (patch) | |
tree | 7f7d36eabd41737fce559d25adf7a17046c9f007 /fxjs/fxjs_v8_embeddertest.cpp | |
parent | 80435cb746fa7bd22cf062ab39829ec86000fd21 (diff) | |
download | pdfium-5daf07afe5b76e702d053aaca648b977ec3bb663.tar.xz |
Make NewNull return an actual Null
This CL updates the CFXJS_Engine::NewNull method to return a real v8::Null
instead of an empty v8::Local. This also adds a NewUndefined and returns
undefined in most of the places null was returned previously.
Change-Id: If1a96bf253057892a3b709cbc72f8825c52503c3
Reviewed-on: https://pdfium-review.googlesource.com/16730
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs/fxjs_v8_embeddertest.cpp')
-rw-r--r-- | fxjs/fxjs_v8_embeddertest.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/fxjs/fxjs_v8_embeddertest.cpp b/fxjs/fxjs_v8_embeddertest.cpp index 53fe8f268b..d975264d1d 100644 --- a/fxjs/fxjs_v8_embeddertest.cpp +++ b/fxjs/fxjs_v8_embeddertest.cpp @@ -98,11 +98,25 @@ TEST_F(FXJSV8EmbedderTest, NewNull) { EXPECT_FALSE(engine()->ToBoolean(nullz)); EXPECT_EQ(0, engine()->ToInt32(nullz)); EXPECT_EQ(0.0, engine()->ToDouble(nullz)); - EXPECT_EQ(L"", engine()->ToWideString(nullz)); + EXPECT_EQ(L"null", engine()->ToWideString(nullz)); EXPECT_TRUE(engine()->ToObject(nullz).IsEmpty()); EXPECT_TRUE(engine()->ToArray(nullz).IsEmpty()); } +TEST_F(FXJSV8EmbedderTest, NewUndefined) { + v8::Isolate::Scope isolate_scope(isolate()); + v8::HandleScope handle_scope(isolate()); + v8::Context::Scope context_scope(GetV8Context()); + + auto undef = engine()->NewUndefined(); + EXPECT_FALSE(engine()->ToBoolean(undef)); + EXPECT_EQ(0, engine()->ToInt32(undef)); + EXPECT_TRUE(std::isnan(engine()->ToDouble(undef))); + EXPECT_EQ(L"undefined", engine()->ToWideString(undef)); + EXPECT_TRUE(engine()->ToObject(undef).IsEmpty()); + EXPECT_TRUE(engine()->ToArray(undef).IsEmpty()); +} + TEST_F(FXJSV8EmbedderTest, NewBoolean) { v8::Isolate::Scope isolate_scope(isolate()); v8::HandleScope handle_scope(isolate()); |