@@ -533,6 +533,11 @@ class NWWebViewTestBase : public extensions::PlatformAppBrowserTest {
533
533
command_line->AppendSwitchASCII (switches::kJavaScriptFlags , " --expose-gc" );
534
534
535
535
extensions::PlatformAppBrowserTest::SetUpCommandLine (command_line);
536
+ PathService::Get (base::DIR_SOURCE_ROOT, &test_data_dir_);
537
+ test_data_dir_ = test_data_dir_.Append (FILE_PATH_LITERAL (" content" ));
538
+ test_data_dir_ = test_data_dir_.Append (FILE_PATH_LITERAL (" nw" ));
539
+ test_data_dir_ = test_data_dir_.Append (FILE_PATH_LITERAL (" test" ));
540
+ test_data_dir_ = test_data_dir_.Append (FILE_PATH_LITERAL (" data" ));
536
541
}
537
542
538
543
// Handles |request| by serving a redirect response if the |User-Agent| is
@@ -857,11 +862,6 @@ class NWJSWebViewTest : public NWWebViewTestBase, public testing::WithParamInter
857
862
858
863
void SetUpCommandLine (base::CommandLine* command_line) override {
859
864
NWWebViewTestBase::SetUpCommandLine (command_line);
860
- PathService::Get (base::DIR_SOURCE_ROOT, &test_data_dir_);
861
- test_data_dir_ = test_data_dir_.Append (FILE_PATH_LITERAL (" content" ));
862
- test_data_dir_ = test_data_dir_.Append (FILE_PATH_LITERAL (" nw" ));
863
- test_data_dir_ = test_data_dir_.Append (FILE_PATH_LITERAL (" test" ));
864
- test_data_dir_ = test_data_dir_.Append (FILE_PATH_LITERAL (" data" ));
865
865
866
866
trusted_ = GetParam ();
867
867
}
@@ -871,6 +871,8 @@ class NWJSWebViewTest : public NWWebViewTestBase, public testing::WithParamInter
871
871
872
872
INSTANTIATE_TEST_CASE_P (NWJSWebViewTests, NWJSWebViewTest, testing::Bool());
873
873
874
+ class NWJSWebViewTestF : public NWWebViewTestBase {};
875
+
874
876
class NWAppTest : public extensions ::PlatformAppBrowserTest {
875
877
public:
876
878
NWAppTest () {}
@@ -1006,17 +1008,45 @@ void CountFrames(int* frame_count,
1006
1008
++(*frame_count);
1007
1009
}
1008
1010
1009
- std::string g_tree_dump;
1010
- void CheckPdfPluginForRenderFrame (content::RenderFrameHost* frame) {
1011
+ void DumpAxTree (std::string* dump_output, content::RenderFrameHost* frame) {
1011
1012
content::RenderFrameHostImpl* f = static_cast <content::RenderFrameHostImpl*>(frame);
1012
1013
content::BrowserAccessibilityManager* manager = f->GetOrCreateBrowserAccessibilityManager ();
1013
1014
ui::AXTreeUpdate ax_tree = manager->SnapshotAXTreeForTesting ();
1014
1015
std::string ax_tree_dump = DumpPdfAccessibilityTree (ax_tree);
1015
- g_tree_dump += ax_tree_dump;
1016
+ *dump_output += ax_tree_dump;
1016
1017
}
1017
1018
1018
1019
} // namespace
1019
1020
1021
+ IN_PROC_BROWSER_TEST_F (NWJSWebViewTestF, SilentPrintChangeFooter) {
1022
+ content::BrowserAccessibilityState::GetInstance ()->EnableAccessibility ();
1023
+ LoadAndLaunchPlatformApp (" silent_print" , " Launched" );
1024
+ content::WebContents* web_contents = GetFirstAppWindowWebContents ();
1025
+ ASSERT_TRUE (web_contents);
1026
+ ExtensionTestMessageListener listener (" Loaded" , false );
1027
+ ASSERT_TRUE (content::ExecuteScript (web_contents, " document.getElementById('testbtn').click()" ));
1028
+ EXPECT_TRUE (listener.WaitUntilSatisfied ()) << " '" << listener.message ()
1029
+ << " ' message was not receieved" ;
1030
+
1031
+ std::vector<content::WebContents*> guest_web_contents_list;
1032
+ unsigned long n_guests = 2 ;
1033
+ LOG (WARNING) << " WaitForNumGuestsCreated" ;
1034
+ GetGuestViewManager ()->WaitForNumGuestsCreated (n_guests);
1035
+ GetGuestViewManager ()->GetGuestWebContentsList (&guest_web_contents_list);
1036
+ ASSERT_EQ (n_guests, guest_web_contents_list.size ());
1037
+
1038
+ content::WebContents* web_view_contents = guest_web_contents_list[0 ];
1039
+ bool load_success = pdf_extension_test_util::EnsurePDFHasLoaded (
1040
+ web_view_contents);
1041
+ EXPECT_TRUE (load_success);
1042
+ WaitForAccessibilityTreeToContainNodeWithName (web_view_contents, " hello world\r\n " );
1043
+ std::string tree_dump;
1044
+ // Make sure all the frames in the dialog has access to the PDF plugin.
1045
+ guest_web_contents_list[1 ]->ForEachFrame (base::Bind (&DumpAxTree, base::Unretained (&tree_dump)));
1046
+ LOG (INFO) << " ax tree: " << tree_dump;
1047
+ EXPECT_TRUE (tree_dump.find (" nwtestfooter" ) != std::string::npos);
1048
+ }
1049
+
1020
1050
IN_PROC_BROWSER_TEST_F (NWJSAppTest, PrintChangeFooter) {
1021
1051
content::BrowserAccessibilityState::GetInstance ()->EnableAccessibility ();
1022
1052
LoadAndLaunchPlatformApp (" print_test" , " Launched" );
@@ -1040,9 +1070,10 @@ IN_PROC_BROWSER_TEST_F(NWJSAppTest, PrintChangeFooter) {
1040
1070
} while (frame_count < kExpectedFrameCount );
1041
1071
ASSERT_EQ (kExpectedFrameCount , frame_count);
1042
1072
WaitForAccessibilityTreeToContainNodeWithName (preview_dialog, " hello world\r\n " );
1073
+ std::string tree_dump;
1043
1074
// Make sure all the frames in the dialog has access to the PDF plugin.
1044
- preview_dialog->ForEachFrame (base::Bind (&CheckPdfPluginForRenderFrame ));
1045
- EXPECT_TRUE (g_tree_dump .find (" nwtestfooter" ) != std::string::npos);
1075
+ preview_dialog->ForEachFrame (base::Bind (&DumpAxTree, base::Unretained (&tree_dump) ));
1076
+ EXPECT_TRUE (tree_dump .find (" nwtestfooter" ) != std::string::npos);
1046
1077
}
1047
1078
1048
1079
IN_PROC_BROWSER_TEST_P (NWJSWebViewTest, LocalPDF) {
0 commit comments