32 ASSERT_TRUE(OpenDocument(
"js.pdf"));
33 EXPECT_EQ(5, FPDFDoc_GetJavaScriptActionCount(document()));
35 ScopedFPDFJavaScriptAction js;
36 js.reset(FPDFDoc_GetJavaScriptAction(document(), -1));
38 js.reset(FPDFDoc_GetJavaScriptAction(document(), 5));
51 js.reset(FPDFDoc_GetJavaScriptAction(document(), 0));
53 js.reset(FPDFDoc_GetJavaScriptAction(document(), 1));
55 js.reset(FPDFDoc_GetJavaScriptAction(document(), 2));
57 js.reset(FPDFDoc_GetJavaScriptAction(document(), 3));
59 js.reset(FPDFDoc_GetJavaScriptAction(document(), 4));
64 ASSERT_TRUE(OpenDocument(
"bug_679649.pdf"));
65 ScopedFPDFJavaScriptAction js(FPDFDoc_GetJavaScriptAction(document(), 0));
75 constexpr size_t kExpectedLength = 22;
76 ASSERT_EQ(kExpectedLength,
77 FPDFJavaScriptAction_GetName(js.get(),
nullptr, 0));
81 std::vector<FPDF_WCHAR> buf = GetFPDFWideStringBuffer(kExpectedLength);
83 memcpy(buf.data(),
"abcdefgh", 8);
84 EXPECT_EQ(kExpectedLength, FPDFJavaScriptAction_GetName(js.get(), buf.data(),
85 kExpectedLength - 1));
86 EXPECT_EQ(0, memcmp(buf.data(),
"abcdefgh", 8));
88 EXPECT_EQ(kExpectedLength, FPDFJavaScriptAction_GetName(js.get(), buf.data(),
90 EXPECT_EQ(L"startDelay", GetPlatformWString(buf.data()));
94 ASSERT_TRUE(OpenDocument(
"bug_679649.pdf"));
95 ScopedFPDFJavaScriptAction js(FPDFDoc_GetJavaScriptAction(document(), 0));
105 constexpr size_t kExpectedLength = 218;
106 ASSERT_EQ(kExpectedLength,
107 FPDFJavaScriptAction_GetScript(js.get(),
nullptr, 0));
111 std::vector<FPDF_WCHAR> buf = GetFPDFWideStringBuffer(kExpectedLength);
113 memcpy(buf.data(),
"abcdefgh", 8);
114 EXPECT_EQ(kExpectedLength, FPDFJavaScriptAction_GetScript(
115 js.get(), buf.data(), kExpectedLength - 1));
116 EXPECT_EQ(0, memcmp(buf.data(),
"abcdefgh", 8));
118 static const wchar_t kExpectedScript[] =
119 L"function ping() {\n app.alert(\"ping\");\n}\n"
120 L"var timer = app.setTimeOut(\"ping()\", 100);\napp.clearTimeOut(timer);";
121 EXPECT_EQ(kExpectedLength, FPDFJavaScriptAction_GetScript(
122 js.get(), buf.data(), kExpectedLength));
123 EXPECT_EQ(kExpectedScript, GetPlatformWString(buf.data()));