1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/path_service.h"
6 #include "content/browser/web_contents/web_contents_impl.h"
7 #include "content/common/dom_storage/dom_storage_types.h"
8 #include "content/public/common/content_paths.h"
9 #include "content/public/test/browser_test_utils.h"
10 #include "content/public/test/content_browser_test.h"
11 #include "content/public/test/content_browser_test_utils.h"
12 #include "content/shell/browser/shell.h"
13 #include "net/base/net_util.h"
17 // This browser test is aimed towards exercising the DOMStorage system
19 class DOMStorageBrowserTest
: public ContentBrowserTest
{
21 DOMStorageBrowserTest() {}
23 void SimpleTest(const GURL
& test_url
, bool incognito
) {
24 // The test page will perform tests then navigate to either
25 // a #pass or #fail ref.
26 Shell
* the_browser
= incognito
? CreateOffTheRecordBrowser() : shell();
27 NavigateToURLBlockUntilNavigationsComplete(the_browser
, test_url
, 2);
29 the_browser
->web_contents()->GetLastCommittedURL().ref();
30 if (result
!= "pass") {
31 std::string js_result
;
32 ASSERT_TRUE(ExecuteScriptAndExtractString(
33 the_browser
->web_contents(),
34 "window.domAutomationController.send(getLog())",
36 FAIL() << "Failed: " << js_result
;
41 static const bool kIncognito
= true;
42 static const bool kNotIncognito
= false;
44 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest
, SanityCheck
) {
45 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kNotIncognito
);
48 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest
, SanityCheckIncognito
) {
49 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kIncognito
);
52 } // namespace content