Avoid nullptr crash in CJS_App::get_active_docs().
Also add more asserts and fix a nit in cjs_app.cpp.
BUG=pdfium:1252
Change-Id: I10e3dd296e7b0ee609c1c1079337bf6aab7a7edf
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/51292
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cfxjse_app_embeddertest.cpp b/fxjs/xfa/cfxjse_app_embeddertest.cpp
new file mode 100644
index 0000000..628f56e
--- /dev/null
+++ b/fxjs/xfa/cfxjse_app_embeddertest.cpp
@@ -0,0 +1,15 @@
+// Copyright 2019 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/xfa_js_embedder_test.h"
+
+class CFXJSE_AppEmbedderTest : public XFAJSEmbedderTest {};
+
+// Should not crash.
+TEST_F(CFXJSE_AppEmbedderTest, BUG_1252) {
+ ASSERT_TRUE(OpenDocument("simple_xfa.pdf"));
+
+ EXPECT_FALSE(Execute("app.activeDocs()"));
+}