mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Linux: Add default implementation for JavaScript alert/confirm/prompt/filechooser dialogs.
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1029 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -660,3 +660,7 @@ void RunPluginInfoTest(CefRefPtr<CefBrowser> browser) {
|
||||
void RunGeolocationTest(CefRefPtr<CefBrowser> browser) {
|
||||
browser->GetMainFrame()->LoadURL("http://html5demos.com/geo");
|
||||
}
|
||||
|
||||
void RunDialogsTest(CefRefPtr<CefBrowser> browser) {
|
||||
browser->GetMainFrame()->LoadURL("http://tests/dialogs");
|
||||
}
|
||||
|
@@ -52,6 +52,7 @@ void RunDragDropTest(CefRefPtr<CefBrowser> browser);
|
||||
void RunModalDialogTest(CefRefPtr<CefBrowser> browser);
|
||||
void RunPluginInfoTest(CefRefPtr<CefBrowser> browser);
|
||||
void RunGeolocationTest(CefRefPtr<CefBrowser> browser);
|
||||
void RunDialogsTest(CefRefPtr<CefBrowser> browser);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
void RunTransparentPopupTest(CefRefPtr<CefBrowser> browser);
|
||||
|
@@ -79,6 +79,14 @@ gboolean PerformanceActivated(GtkWidget* widget) {
|
||||
return FALSE; // Don't stop this message.
|
||||
}
|
||||
|
||||
// Callback for Debug > Dialogs... menu item.
|
||||
gboolean DialogsActivated(GtkWidget* widget) {
|
||||
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
||||
RunDialogsTest(g_handler->GetBrowser());
|
||||
|
||||
return FALSE; // Don't stop this message.
|
||||
}
|
||||
|
||||
// Callback for Debug > Request... menu item.
|
||||
gboolean RequestActivated(GtkWidget* widget) {
|
||||
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
||||
@@ -291,6 +299,8 @@ GtkWidget* CreateMenuBar() {
|
||||
G_CALLBACK(JSExecuteActivated));
|
||||
AddMenuEntry(debug_menu, "Performance Tests",
|
||||
G_CALLBACK(PerformanceActivated));
|
||||
AddMenuEntry(debug_menu, "Dialogs",
|
||||
G_CALLBACK(DialogsActivated));
|
||||
AddMenuEntry(debug_menu, "Request",
|
||||
G_CALLBACK(RequestActivated));
|
||||
AddMenuEntry(debug_menu, "Local Storage",
|
||||
|
@@ -66,6 +66,11 @@ bool ClientHandler::OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
resourceStream = GetBinaryResourceReader("performance.html");
|
||||
response->SetMimeType("text/html");
|
||||
response->SetStatus(200);
|
||||
} else if (url == "http://tests/dialogs") {
|
||||
// Show the dialogs HTML contents
|
||||
resourceStream = GetBinaryResourceReader("dialogs.html");
|
||||
response->SetMimeType("text/html");
|
||||
response->SetStatus(200);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
43
cef1/tests/cefclient/res/dialogs.html
Normal file
43
cef1/tests/cefclient/res/dialogs.html
Normal file
@@ -0,0 +1,43 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Dialog Test</title>
|
||||
<script>
|
||||
function show_alert() {
|
||||
alert("I am an alert box!");
|
||||
}
|
||||
|
||||
function show_confirm() {
|
||||
var r = confirm("Press a button");
|
||||
var msg = r ? "You pressed OK!" : "You pressed Cancel!";
|
||||
document.getElementById('cm').innerText = msg;
|
||||
}
|
||||
|
||||
function show_prompt() {
|
||||
var name = prompt("Please enter your name" ,"Harry Potter");
|
||||
if (name != null && name != "")
|
||||
document.getElementById('pm').innerText = "Hello " + name + "!";
|
||||
}
|
||||
|
||||
function update_time() {
|
||||
document.getElementById('time').innerText = new Date().toLocaleString();
|
||||
}
|
||||
|
||||
function setup() {
|
||||
update_time();
|
||||
setInterval(update_time, 1000);
|
||||
}
|
||||
|
||||
window.addEventListener('load', setup, false);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<form>
|
||||
Click a button to show the associated dialog type.
|
||||
<br/><input type="button" onclick="show_alert();" value="Show Alert">
|
||||
<br/><input type="button" onclick="show_confirm();" value="Show Confirm"> <span id="cm"></span>
|
||||
<br/><input type="button" onclick="show_prompt();" value="Show Prompt"> <span id="pm"></span>
|
||||
<br/>input type="file": <input type="file" name="pic" accept="text/*,.js,.css,image/*">
|
||||
<p id="time"></p>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user