mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- Persist localStorage data across sessions when a cache path is specified (issue #139).
- Add a localStorage test to cefclient. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@140 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -338,3 +338,8 @@ void RunPopupTest(CefRefPtr<CefBrowser> browser)
|
||||
browser->GetMainFrame()->ExecuteJavaScript(
|
||||
L"window.open('http://www.google.com');", L"about:blank", 0);
|
||||
}
|
||||
|
||||
void RunLocalStorageTest(CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
browser->GetMainFrame()->LoadURL(L"http://tests/localstorage");
|
||||
}
|
||||
|
@@ -361,5 +361,6 @@ void RunGetTextTest(CefRefPtr<CefFrame> frame);
|
||||
void RunRequestTest(CefRefPtr<CefBrowser> browser);
|
||||
void RunJavaScriptExecuteTest(CefRefPtr<CefBrowser> browser);
|
||||
void RunPopupTest(CefRefPtr<CefBrowser> browser);
|
||||
void RunLocalStorageTest(CefRefPtr<CefBrowser> browser);
|
||||
|
||||
#endif // _CEFCLIENT_H
|
||||
|
@@ -31,6 +31,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
IDS_LOGO BINARY "res\logo.png"
|
||||
IDS_UIPLUGIN BINARY "res\uiplugin.html"
|
||||
IDS_LOGOBALL BINARY "res\logoball.png"
|
||||
IDS_LOCALSTORAGE BINARY "res\localstorage.html"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -73,7 +74,8 @@ BEGIN
|
||||
MENUITEM "Request", ID_TESTS_REQUEST
|
||||
MENUITEM "Scheme Handler", ID_TESTS_SCHEME_HANDLER
|
||||
MENUITEM "UI App Example", ID_TESTS_UIAPP
|
||||
END
|
||||
MENUITEM "Local Storage", ID_TESTS_LOCALSTORAGE
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
|
@@ -533,6 +533,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
if(browser.get())
|
||||
RunUIPluginTest(browser);
|
||||
return 0;
|
||||
case ID_TESTS_LOCALSTORAGE: // Test localStorage
|
||||
if(browser.get())
|
||||
RunLocalStorageTest(browser);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -656,14 +660,20 @@ CefHandler::RetVal ClientHandler::HandleBeforeResourceLoad(
|
||||
resourceStream = CefStreamReader::CreateForData(
|
||||
(void*)dump.c_str(), dump.size() * sizeof(wchar_t));
|
||||
mimeType = L"text/plain";
|
||||
}
|
||||
else if(url == L"http://tests/uiapp") {
|
||||
} else if(url == L"http://tests/uiapp") {
|
||||
// Show the uiapp contents
|
||||
if(LoadBinaryResource(IDS_UIPLUGIN, dwSize, pBytes)) {
|
||||
resourceStream = CefStreamReader::CreateForHandler(
|
||||
new CefByteReadHandler(pBytes, dwSize, NULL));
|
||||
mimeType = L"text/html";
|
||||
}
|
||||
} else if(url == L"http://tests/localstorage") {
|
||||
// Show the localstorage contents
|
||||
if(LoadBinaryResource(IDS_LOCALSTORAGE, dwSize, pBytes)) {
|
||||
resourceStream = CefStreamReader::CreateForHandler(
|
||||
new CefByteReadHandler(pBytes, dwSize, NULL));
|
||||
mimeType = L"text/html";
|
||||
}
|
||||
} else if(wcsstr(url.c_str(), L"/ps_logo2.png") != NULL) {
|
||||
// Any time we find "ps_logo2.png" in the URL substitute in our own image
|
||||
if(LoadBinaryResource(IDS_LOGO, dwSize, pBytes)) {
|
||||
|
24
tests/cefclient/res/localstorage.html
Normal file
24
tests/cefclient/res/localstorage.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<html>
|
||||
<body>
|
||||
<script language="JavaScript">
|
||||
var val = window.localStorage.getItem('val');
|
||||
function addLine() {
|
||||
if(val == null)
|
||||
val = '<br/>One Line.';
|
||||
else
|
||||
val += '<br/>Another Line.';
|
||||
window.localStorage.setItem('val', val);
|
||||
document.getElementById('out').innerHTML = val;
|
||||
}
|
||||
</script>
|
||||
Click the "Add Line" button to add a line or the "Clear" button to clear.<br/>
|
||||
This data will persist across sessions if a cache path was specified.<br/>
|
||||
<input type="button" value="Add Line" onClick="addLine();"/>
|
||||
<input type="button" value="Clear" onClick="window.localStorage.removeItem('val'); window.location.reload();"/>
|
||||
<div id="out"></div>
|
||||
<script language="JavaScript">
|
||||
if(val != null)
|
||||
document.getElementById('out').innerHTML = val;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -36,10 +36,12 @@
|
||||
#define ID_TESTS_REQUEST 32776
|
||||
#define ID_TESTS_SCHEME_HANDLER 32777
|
||||
#define ID_TESTS_UIAPP 32778
|
||||
#define ID_TESTS_LOCALSTORAGE 32779
|
||||
#define IDC_STATIC -1
|
||||
#define IDS_LOGO 1000
|
||||
#define IDS_UIPLUGIN 1001
|
||||
#define IDS_LOGOBALL 1002
|
||||
#define IDS_LOCALSTORAGE 1003
|
||||
|
||||
// Avoid files associated with MacOS
|
||||
#define _X86_
|
||||
|
Reference in New Issue
Block a user