Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / browser / dom_storage / dom_storage_browsertest.cc
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.
4
5 #include "content/browser/web_contents/web_contents_impl.h"
6 #include "content/common/dom_storage/dom_storage_types.h"
7 #include "content/public/common/content_paths.h"
8 #include "content/public/test/browser_test_utils.h"
9 #include "content/public/test/content_browser_test.h"
10 #include "content/public/test/content_browser_test_utils.h"
11 #include "content/shell/browser/shell.h"
12 #include "net/base/net_util.h"
13
14 namespace content {
15
16 // This browser test is aimed towards exercising the DOMStorage system
17 // from end-to-end.
18 class DOMStorageBrowserTest : public ContentBrowserTest {
19  public:
20   DOMStorageBrowserTest() {}
21
22   void SimpleTest(const GURL& test_url, bool incognito) {
23     // The test page will perform tests then navigate to either
24     // a #pass or #fail ref.
25     Shell* the_browser = incognito ? CreateOffTheRecordBrowser() : shell();
26     NavigateToURLBlockUntilNavigationsComplete(the_browser, test_url, 2);
27     std::string result =
28         the_browser->web_contents()->GetLastCommittedURL().ref();
29     if (result != "pass") {
30       std::string js_result;
31       ASSERT_TRUE(ExecuteScriptAndExtractString(
32           the_browser->web_contents(),
33           "window.domAutomationController.send(getLog())",
34           &js_result));
35       FAIL() << "Failed: " << js_result;
36     }
37   }
38 };
39
40 static const bool kIncognito = true;
41 static const bool kNotIncognito = false;
42
43 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, SanityCheck) {
44   SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kNotIncognito);
45 }
46
47 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, SanityCheckIncognito) {
48   SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kIncognito);
49 }
50
51 }  // namespace content