Skip to content

Commit

Permalink
move webview-cdt to browser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerwang committed Apr 17, 2024
1 parent 350be49 commit 0fedba8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 49 deletions.
35 changes: 35 additions & 0 deletions src/nwjs_browsertest.cc
Expand Up @@ -988,6 +988,41 @@ IN_PROC_BROWSER_TEST_P(NWJSWebViewTest, LocalPDF) {
}
}

IN_PROC_BROWSER_TEST_F(NWJSWebViewTestF, WebViewCDT) {
std::string contents;
base::FilePath test_dir = test_data_dir_.Append(FILE_PATH_LITERAL("platform_apps")).Append(FILE_PATH_LITERAL("webview_cdt"));
LoadAndLaunchPlatformApp("webview_cdt", "Launched");

// Flush any pending events to make sure we start with a clean slate.
content::RunAllPendingInMessageLoop();
content::WebContents* web_contents = GetFirstAppWindowWebContents();
if (base::FeatureList::IsEnabled(::features::kNWNewWin)) {
web_contents = BrowserList::GetInstance()->GetLastActive()->tab_strip_model()->GetActiveWebContents();
}
ASSERT_TRUE(web_contents);
std::vector<content::WebContents*> guest_web_contents_list;
unsigned long n_guests = 2;
{
base::RunLoop run_loop;
base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
FROM_HERE, run_loop.QuitClosure(), base::Seconds(5));
run_loop.Run();
}

ASSERT_TRUE(content::ExecJs(web_contents, "document.getElementById('testbtn').click()"));
{
base::RunLoop run_loop;
base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
FROM_HERE, run_loop.QuitClosure(), base::Seconds(5));
run_loop.Run();
}

std::vector<content::RenderFrameHost*> guest_rfh_list;
GetGuestViewManager()->GetGuestRenderFrameHostList(&guest_rfh_list);
ASSERT_EQ(n_guests, guest_rfh_list.size());
EXPECT_TRUE(guest_rfh_list[1]->GetLastCommittedURL().spec().rfind("devtools://") == 0);
}

using content::DesktopMediaID;

namespace {
Expand Down
Expand Up @@ -25,14 +25,13 @@
</head>

<body>
<webview partition="persist:trusted" id="demo" src="http://xw.qq.com"></webview>
<webview partition="persist:trusted" id="demo" src="https://nwjs.io"></webview>
<webview partition="persist:trusted" id="demodev" src="about:blank"></webview>
<button id='testbtn' onclick="test(true)">show</button>
<script>
document.getElementById('demo').addEventListener('contentload', function() {
console.log("left webview load done");
test(true);
});
if (chrome.test) {
chrome.test.sendMessage("Launched");
}
</script>
</body>

Expand Down
File renamed without changes.
44 changes: 0 additions & 44 deletions test/sanity/webview-cdt/test.py

This file was deleted.

0 comments on commit 0fedba8

Please sign in to comment.