1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/chrome_switches.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/ui/ui_layout_test.h"
static const char* kRootFiles[] = {
"clear.html",
// "complex-keys.html", // Output too big for a cookie. crbug.com/33472
// "complex-values.html", // crbug.com/33472
"quota.html",
"remove-item.html",
"window-attributes-exist.html",
NULL
};
static const char* kEventsFiles[] = {
// "basic-body-attribute.html", // crbug.com/33472
// "basic.html", // crbug.com/33472
// "basic-setattribute.html", // crbug.com/33472
"case-sensitive.html",
"documentURI.html",
NULL
};
static const char* kStorageFiles[] = {
"delete-removal.html",
"enumerate-storage.html",
"enumerate-with-length-and-key.html",
"index-get-and-set.html",
"simple-usage.html",
"string-conversion.html",
// "window-open.html", // TODO(jorlow): Fix
NULL
};
class DOMStorageTest : public UILayoutTest {
protected:
DOMStorageTest()
: UILayoutTest(),
test_dir_(FilePath().AppendASCII("LayoutTests").
AppendASCII("storage").AppendASCII("domstorage")) {
}
virtual ~DOMStorageTest() { }
virtual void SetUp() {
launch_arguments_.AppendSwitch(switches::kDisablePopupBlocking);
UILayoutTest::SetUp();
}
// We require fast/js/resources for most of the DOM Storage layout tests.
// Add those to the list to be copied.
void AddJSTestResources() {
// Add other paths our tests require.
FilePath js_dir = FilePath().AppendASCII("LayoutTests").
AppendASCII("fast").AppendASCII("js");
AddResourceForLayoutTest(js_dir, FilePath().AppendASCII("resources"));
}
// This is somewhat of a hack because we're running a real browser that
// actually persists the LocalStorage state vs. DRT and TestShell which don't.
// The correct fix is to fix the LayoutTests, but similar patches have been
// rejected in the past.
void ClearDOMStorage() {
scoped_refptr<TabProxy> tab(GetActiveTab());
ASSERT_TRUE(tab.get());
GURL url = GetTestUrl(L"layout_tests", L"clear_dom_storage.html");
ASSERT_TRUE(tab->SetCookie(url, ""));
ASSERT_TRUE(tab->NavigateToURL(url));
WaitUntilCookieNonEmpty(tab.get(), url, "cleared", action_max_timeout_ms());
}
// Runs each test in an array of strings until it hits a NULL.
void RunTests(const char** files) {
while (*files) {
ClearDOMStorage();
RunLayoutTest(*files, kNoHttpPort);
++files;
}
}
FilePath test_dir_;
};
TEST_F(DOMStorageTest, RootLayoutTests) {
InitializeForLayoutTest(test_dir_, FilePath(), kNoHttpPort);
AddJSTestResources();
AddResourceForLayoutTest(test_dir_, FilePath().AppendASCII("script-tests"));
RunTests(kRootFiles);
}
TEST_F(DOMStorageTest, EventLayoutTests) {
InitializeForLayoutTest(test_dir_, FilePath().AppendASCII("events"),
kNoHttpPort);
AddJSTestResources();
AddResourceForLayoutTest(test_dir_, FilePath().AppendASCII("events").
AppendASCII("resources"));
AddResourceForLayoutTest(test_dir_, FilePath().AppendASCII("events").
AppendASCII("script-tests"));
RunTests(kEventsFiles);
}
TEST_F(DOMStorageTest, LocalStorageLayoutTests) {
InitializeForLayoutTest(test_dir_, FilePath().AppendASCII("localstorage"),
kNoHttpPort);
AddJSTestResources();
AddResourceForLayoutTest(test_dir_, FilePath().AppendASCII("localstorage").
AppendASCII("resources"));
RunTests(kStorageFiles);
}
TEST_F(DOMStorageTest, SessionStorageLayoutTests) {
InitializeForLayoutTest(test_dir_, FilePath().AppendASCII("sessionstorage"),
kNoHttpPort);
AddJSTestResources();
AddResourceForLayoutTest(test_dir_, FilePath().AppendASCII("sessionstorage").
AppendASCII("resources"));
RunTests(kStorageFiles);
}
|