Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: chrome/browser/extensions/web_view_browsertest.cc

Issue 11234032: Webview tag creation should be using storage partitions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes for all comments so far. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/utf_string_conversions.h"
5 #include "chrome/browser/automation/automation_util.h" 6 #include "chrome/browser/automation/automation_util.h"
6 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 7 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
7 #include "chrome/browser/ui/browser_tabstrip.h" 8 #include "chrome/browser/ui/browser_tabstrip.h"
8 #include "chrome/test/base/ui_test_utils.h" 9 #include "chrome/test/base/ui_test_utils.h"
9 #include "chrome/test/base/test_launcher_utils.h" 10 #include "chrome/test/base/test_launcher_utils.h"
10 #include "content/public/browser/notification_service.h" 11 #include "content/public/browser/notification_service.h"
11 #include "content/public/browser/render_process_host.h" 12 #include "content/public/browser/render_process_host.h"
12 #include "content/public/test/browser_test_utils.h" 13 #include "content/public/test/browser_test_utils.h"
13 #include "ui/compositor/compositor_setup.h" 14 #include "ui/compositor/compositor_setup.h"
14 #include "ui/gl/gl_switches.h" 15 #include "ui/gl/gl_switches.h"
15 16
16 class WebViewTest : public extensions::PlatformAppBrowserTest { 17 class WebViewTest : public extensions::PlatformAppBrowserTest {
17 protected: 18 protected:
18 virtual void SetUpCommandLine(CommandLine* command_line) { 19 virtual void SetUpCommandLine(CommandLine* command_line) {
19 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); 20 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line);
20 #if !defined(OS_MACOSX) 21 #if !defined(OS_MACOSX)
21 CHECK(test_launcher_utils::OverrideGLImplementation( 22 CHECK(test_launcher_utils::OverrideGLImplementation(
22 command_line, gfx::kGLImplementationOSMesaName)) << 23 command_line, gfx::kGLImplementationOSMesaName)) <<
23 "kUseGL must not be set by test framework code!"; 24 "kUseGL must not be set by test framework code!";
24 #endif 25 #endif
25 ui::DisableTestCompositor(); 26 ui::DisableTestCompositor();
26 } 27 }
28
29 // This method is responsible for initializing a packaged app, which contains
30 // multiple webview tags. The tags have different partition identifiers and
31 // their WebContent objects are returned as output. The method also verifies
32 // the expected process allocation and storage partition assignment.
33 // The |navigate_to_url| paramter is used to navigate the main browser window.
Charlie Reis 2012/11/07 18:38:36 nit: parameter
nasko 2012/11/07 18:48:05 Done.
34 void NavigateAndOpenAppForIsolation(
35 GURL navigate_to_url,
36 content::WebContents** default_tag_contents1,
37 content::WebContents** default_tag_contents2,
38 content::WebContents** named_partition_contents1,
39 content::WebContents** named_partition_contents2) {
40 GURL::Replacements replace_host;
41 std::string host_str("localhost"); // Must stay in scope with replace_host.
42 replace_host.SetHostStr(host_str);
43
44 navigate_to_url = navigate_to_url.ReplaceComponents(replace_host);
45
46 GURL tag_url1 = test_server()->GetURL(
47 "files/extensions/platform_apps/web_view_isolation/cookie.html");
48 tag_url1 = tag_url1.ReplaceComponents(replace_host);
49 GURL tag_url2 = test_server()->GetURL(
50 "files/extensions/platform_apps/web_view_isolation/cookie2.html");
51 tag_url2 = tag_url2.ReplaceComponents(replace_host);
52 GURL tag_url3 = test_server()->GetURL(
53 "files/extensions/platform_apps/web_view_isolation/storage1.html");
54 tag_url3 = tag_url3.ReplaceComponents(replace_host);
55 GURL tag_url4 = test_server()->GetURL(
56 "files/extensions/platform_apps/web_view_isolation/storage2.html");
57 tag_url4 = tag_url4.ReplaceComponents(replace_host);
58
59 ui_test_utils::NavigateToURLWithDisposition(
60 browser(), navigate_to_url, CURRENT_TAB,
61 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
62
63 ui_test_utils::UrlLoadObserver observer1(
64 tag_url1, content::NotificationService::AllSources());
65 ui_test_utils::UrlLoadObserver observer2(
66 tag_url2, content::NotificationService::AllSources());
67 ui_test_utils::UrlLoadObserver observer3(
68 tag_url3, content::NotificationService::AllSources());
69 ui_test_utils::UrlLoadObserver observer4(
70 tag_url4, content::NotificationService::AllSources());
71 LoadAndLaunchPlatformApp("web_view_isolation");
72 observer1.Wait();
73 observer2.Wait();
74 observer3.Wait();
75 observer4.Wait();
76
77 content::Source<content::NavigationController> source1 = observer1.source();
78 EXPECT_TRUE(source1->GetWebContents()->GetRenderProcessHost()->IsGuest());
79 content::Source<content::NavigationController> source2 = observer2.source();
80 EXPECT_TRUE(source2->GetWebContents()->GetRenderProcessHost()->IsGuest());
81 content::Source<content::NavigationController> source3 = observer3.source();
82 EXPECT_TRUE(source3->GetWebContents()->GetRenderProcessHost()->IsGuest());
83 content::Source<content::NavigationController> source4 = observer4.source();
84 EXPECT_TRUE(source4->GetWebContents()->GetRenderProcessHost()->IsGuest());
85
86 // Tags with the same storage partition are not yet combined in the same
87 // process. Check this until http://crbug.com/138296 is fixed.
88 EXPECT_NE(source1->GetWebContents()->GetRenderProcessHost()->GetID(),
89 source2->GetWebContents()->GetRenderProcessHost()->GetID());
90
91 // Check that the storage partitions of the first two tags match and are
92 // different than the other two.
93 EXPECT_EQ(
94 source1->GetWebContents()->GetRenderProcessHost()->
95 GetStoragePartition(),
96 source2->GetWebContents()->GetRenderProcessHost()->
97 GetStoragePartition());
98 EXPECT_EQ(
99 source3->GetWebContents()->GetRenderProcessHost()->
100 GetStoragePartition(),
101 source4->GetWebContents()->GetRenderProcessHost()->
102 GetStoragePartition());
103 EXPECT_NE(
104 source1->GetWebContents()->GetRenderProcessHost()->
105 GetStoragePartition(),
106 source3->GetWebContents()->GetRenderProcessHost()->
107 GetStoragePartition());
108
109 *default_tag_contents1 = source1->GetWebContents();
110 *default_tag_contents2 = source2->GetWebContents();
111 *named_partition_contents1 = source3->GetWebContents();
112 *named_partition_contents2 = source4->GetWebContents();
113 }
114
115 void ExecuteScriptWaitForTitle(content::WebContents* web_contents,
116 const char* script,
117 const char* title) {
118 std::wstring js_script = ASCIIToWide(script);
119 string16 expected_title(ASCIIToUTF16(title));
120 string16 error_title(ASCIIToUTF16("error"));
121
122 content::TitleWatcher title_watcher(web_contents, expected_title);
123 title_watcher.AlsoWaitForTitle(error_title);
124 EXPECT_TRUE(content::ExecuteJavaScript(web_contents->GetRenderViewHost(),
125 std::wstring(), js_script));
126 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
127 }
27 }; 128 };
28 129
29 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim) { 130 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim) {
30 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view")) << message_; 131 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view")) << message_;
31 } 132 }
32 133
33 IN_PROC_BROWSER_TEST_F(WebViewTest, ShimSrcAttribute) { 134 IN_PROC_BROWSER_TEST_F(WebViewTest, ShimSrcAttribute) {
34 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view_src_attribute")) 135 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view_src_attribute"))
35 << message_; 136 << message_;
36 } 137 }
37 138
38 IN_PROC_BROWSER_TEST_F(WebViewTest, Isolation) { 139 // This tests cookie isolation for packaged apps with webview tags. It navigates
140 // the main browser window to a page that sets a cookie and loads an app with
141 // multiple webview tags. Each tag sets a cookie and the test checks the proper
142 // storage isolation is enforced.
143 IN_PROC_BROWSER_TEST_F(WebViewTest, CookieIsolation) {
39 ASSERT_TRUE(StartTestServer()); 144 ASSERT_TRUE(StartTestServer());
40 const std::wstring kExpire = 145 const std::wstring kExpire =
41 L"var expire = new Date(Date.now() + 24 * 60 * 60 * 1000);"; 146 L"var expire = new Date(Date.now() + 24 * 60 * 60 * 1000);";
42 std::wstring cookie_script1(kExpire); 147 std::wstring cookie_script1(kExpire);
43 cookie_script1.append( 148 cookie_script1.append(
44 L"document.cookie = 'guest1=true; path=/; expires=' + expire + ';';"); 149 L"document.cookie = 'guest1=true; path=/; expires=' + expire + ';';");
45 std::wstring cookie_script2(kExpire); 150 std::wstring cookie_script2(kExpire);
46 cookie_script2.append( 151 cookie_script2.append(
47 L"document.cookie = 'guest2=true; path=/; expires=' + expire + ';';"); 152 L"document.cookie = 'guest2=true; path=/; expires=' + expire + ';';");
48 153
49 GURL::Replacements replace_host; 154 GURL::Replacements replace_host;
50 std::string host_str("localhost"); // Must stay in scope with replace_host. 155 std::string host_str("localhost"); // Must stay in scope with replace_host.
51 replace_host.SetHostStr(host_str); 156 replace_host.SetHostStr(host_str);
52 157
53 GURL set_cookie_url = test_server()->GetURL( 158 GURL set_cookie_url = test_server()->GetURL(
54 "files/extensions/platform_apps/isolation/set_cookie.html"); 159 "files/extensions/platform_apps/isolation/set_cookie.html");
55 set_cookie_url = set_cookie_url.ReplaceComponents(replace_host); 160 set_cookie_url = set_cookie_url.ReplaceComponents(replace_host);
56 GURL tag_url1 = test_server()->GetURL(
57 "files/extensions/platform_apps/web_view_isolation/cookie.html");
58 tag_url1 = tag_url1.ReplaceComponents(replace_host);
59 GURL tag_url2 = test_server()->GetURL(
60 "files/extensions/platform_apps/web_view_isolation/cookie2.html");
61 tag_url2 = tag_url2.ReplaceComponents(replace_host);
62 161
63 // Load a (non-app) page under the "localhost" origin that sets a cookie. 162 // The first two partitions will be used to set cookies and ensure they are
64 ui_test_utils::NavigateToURLWithDisposition( 163 // shared. The named partition is used to ensure that cookies are isolated
65 browser(), set_cookie_url, 164 // between partitions within the same app.
66 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 165 content::WebContents* cookie_contents1;
67 // Make sure the cookie is set. 166 content::WebContents* cookie_contents2;
167 content::WebContents* named_partition_contents1;
168 content::WebContents* named_partition_contents2;
169
170 NavigateAndOpenAppForIsolation(set_cookie_url, &cookie_contents1,
171 &cookie_contents2, &named_partition_contents1,
172 &named_partition_contents2);
173
174 EXPECT_TRUE(content::ExecuteJavaScript(
175 cookie_contents1->GetRenderViewHost(), std::wstring(), cookie_script1));
176 EXPECT_TRUE(content::ExecuteJavaScript(
177 cookie_contents2->GetRenderViewHost(), std::wstring(), cookie_script2));
178
68 int cookie_size; 179 int cookie_size;
69 std::string cookie_value; 180 std::string cookie_value;
70 automation_util::GetCookies(set_cookie_url,
71 chrome::GetWebContentsAt(browser(), 0),
72 &cookie_size, &cookie_value);
73 EXPECT_EQ("testCookie=1", cookie_value);
74 181
75 ui_test_utils::UrlLoadObserver observer1( 182 // Test the regular browser context to ensure we have only one cookie.
76 tag_url1, content::NotificationService::AllSources());
77 ui_test_utils::UrlLoadObserver observer2(
78 tag_url2, content::NotificationService::AllSources());
79 LoadAndLaunchPlatformApp("web_view_isolation");
80 observer1.Wait();
81 observer2.Wait();
82
83 content::Source<content::NavigationController> source1 = observer1.source();
84 EXPECT_TRUE(source1->GetWebContents()->GetRenderProcessHost()->IsGuest());
85 content::Source<content::NavigationController> source2 = observer2.source();
86 EXPECT_TRUE(source2->GetWebContents()->GetRenderProcessHost()->IsGuest());
87 EXPECT_NE(source1->GetWebContents()->GetRenderProcessHost()->GetID(),
88 source2->GetWebContents()->GetRenderProcessHost()->GetID());
89
90 EXPECT_TRUE(content::ExecuteJavaScript(
91 source1->GetWebContents()->GetRenderViewHost(), std::wstring(),
92 cookie_script1));
93 EXPECT_TRUE(content::ExecuteJavaScript(
94 source2->GetWebContents()->GetRenderViewHost(), std::wstring(),
95 cookie_script2));
96
97 // Test the regular browser context to ensure we still have only one cookie.
98 automation_util::GetCookies(GURL("http://localhost"), 183 automation_util::GetCookies(GURL("http://localhost"),
99 chrome::GetWebContentsAt(browser(), 0), 184 chrome::GetWebContentsAt(browser(), 0),
100 &cookie_size, &cookie_value); 185 &cookie_size, &cookie_value);
101 EXPECT_EQ("testCookie=1", cookie_value); 186 EXPECT_EQ("testCookie=1", cookie_value);
102 187
103 // The default behavior is to combine webview tags with no explicit partition 188 // The default behavior is to combine webview tags with no explicit partition
104 // declaration into the same in-memory partition. Test the webview tags to 189 // declaration into the same in-memory partition. Test the webview tags to
105 // ensure we have properly set the cookies and we have both cookies in both 190 // ensure we have properly set the cookies and we have both cookies in both
106 // tags. 191 // tags.
107 automation_util::GetCookies(GURL("http://localhost"), 192 automation_util::GetCookies(GURL("http://localhost"),
108 source1->GetWebContents(), 193 cookie_contents1,
109 &cookie_size, &cookie_value); 194 &cookie_size, &cookie_value);
110 EXPECT_EQ("guest1=true; guest2=true", cookie_value); 195 EXPECT_EQ("guest1=true; guest2=true", cookie_value);
111 196
112 automation_util::GetCookies(GURL("http://localhost"), 197 automation_util::GetCookies(GURL("http://localhost"),
113 source2->GetWebContents(), 198 cookie_contents2,
114 &cookie_size, &cookie_value); 199 &cookie_size, &cookie_value);
115 EXPECT_EQ("guest1=true; guest2=true", cookie_value); 200 EXPECT_EQ("guest1=true; guest2=true", cookie_value);
201
202 // The third tag should not have any cookies as it is in a separate partition.
203 automation_util::GetCookies(GURL("http://localhost"),
204 named_partition_contents1,
205 &cookie_size, &cookie_value);
206 EXPECT_EQ("", cookie_value);
207
116 CloseShellWindowsAndWaitForAppToExit(); 208 CloseShellWindowsAndWaitForAppToExit();
117 } 209 }
210
211 // This tests DOM storage isolation for packaged apps with webview tags. It
212 // loads an app with multiple webview tags and each tag sets DOM storage
213 // entries, which the test checks to ensure proper storage isolation is
214 // enforced.
215 IN_PROC_BROWSER_TEST_F(WebViewTest, DOMStorageIsolation) {
216 ASSERT_TRUE(StartTestServer());
217 GURL regular_url = test_server()->GetURL("files/title1.html");
218
219 std::string output;
220 std::wstring get_local_storage(L"window.domAutomationController.send("
221 L"window.localStorage.getItem('foo') || 'badval')");
222 std::wstring get_session_storage(L"window.domAutomationController.send("
223 L"window.sessionStorage.getItem('bar') || 'badval')");
224
225 content::WebContents* default_tag_contents1;
226 content::WebContents* default_tag_contents2;
227 content::WebContents* storage_contents1;
228 content::WebContents* storage_contents2;
229
230 NavigateAndOpenAppForIsolation(regular_url, &default_tag_contents1,
231 &default_tag_contents2, &storage_contents1,
232 &storage_contents2);
233
234 // Initialize the storage for the first of the two tags that share a storage
235 // partition.
236 EXPECT_TRUE(content::ExecuteJavaScript(
237 storage_contents1->GetRenderViewHost(), std::wstring(),
238 L"initDomStorage('page1')"));
239
240 // Let's test that the expected values are present in the first tag, as they
241 // will be overwritten once we call the initDomStorage on the second tag.
242 EXPECT_TRUE(ExecuteJavaScriptAndExtractString(
243 storage_contents1->GetRenderViewHost(), std::wstring(),
244 get_local_storage.c_str(), &output));
245 EXPECT_STREQ("local-page1", output.c_str());
246 EXPECT_TRUE(ExecuteJavaScriptAndExtractString(
247 storage_contents1->GetRenderViewHost(), std::wstring(),
248 get_session_storage.c_str(), &output));
249 EXPECT_STREQ("session-page1", output.c_str());
250
251 // Now, init the storage in the second tag in the same storage partition,
252 // which will overwrite the shared localStorage.
253 EXPECT_TRUE(content::ExecuteJavaScript(
254 storage_contents2->GetRenderViewHost(), std::wstring(),
255 L"initDomStorage('page2')"));
256
257 // The localStorage value now should reflect the one written through the
258 // second tag.
259 EXPECT_TRUE(ExecuteJavaScriptAndExtractString(
260 storage_contents1->GetRenderViewHost(), std::wstring(),
261 get_local_storage.c_str(), &output));
262 EXPECT_STREQ("local-page2", output.c_str());
263 EXPECT_TRUE(ExecuteJavaScriptAndExtractString(
264 storage_contents2->GetRenderViewHost(), std::wstring(),
265 get_local_storage.c_str(), &output));
266 EXPECT_STREQ("local-page2", output.c_str());
267
268 // Session storage is not shared though, as each webview tag has separate
269 // instance, even if they are in the same storage partition.
270 EXPECT_TRUE(ExecuteJavaScriptAndExtractString(
271 storage_contents1->GetRenderViewHost(), std::wstring(),
272 get_session_storage.c_str(), &output));
273 EXPECT_STREQ("session-page1", output.c_str());
274 EXPECT_TRUE(ExecuteJavaScriptAndExtractString(
275 storage_contents2->GetRenderViewHost(), std::wstring(),
276 get_session_storage.c_str(), &output));
277 EXPECT_STREQ("session-page2", output.c_str());
278
279 // Also, let's check that the main browser and another tag that doesn't share
280 // the same partition don't have those values stored.
281 EXPECT_TRUE(ExecuteJavaScriptAndExtractString(
282 chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(),
283 std::wstring(), get_local_storage.c_str(), &output));
284 EXPECT_STREQ("badval", output.c_str());
285 EXPECT_TRUE(ExecuteJavaScriptAndExtractString(
286 chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(),
287 std::wstring(), get_session_storage.c_str(), &output));
288 EXPECT_STREQ("badval", output.c_str());
289 EXPECT_TRUE(ExecuteJavaScriptAndExtractString(
290 default_tag_contents1->GetRenderViewHost(), std::wstring(),
291 get_local_storage.c_str(), &output));
292 EXPECT_STREQ("badval", output.c_str());
293 EXPECT_TRUE(ExecuteJavaScriptAndExtractString(
294 default_tag_contents1->GetRenderViewHost(), std::wstring(),
295 get_session_storage.c_str(), &output));
296 EXPECT_STREQ("badval", output.c_str());
297
298 CloseShellWindowsAndWaitForAppToExit();
299 }
300
301 // This tests IndexedDB isolation for packaged apps with webview tags. It loads
302 // an app with multiple webview tags and each tag creates an IndexedDB record,
303 // which the test checks to ensure proper storage isolation is enforced.
304 IN_PROC_BROWSER_TEST_F(WebViewTest, IndexedDBIsolation) {
305 ASSERT_TRUE(StartTestServer());
306 GURL regular_url = test_server()->GetURL("files/title1.html");
307
308 content::WebContents* default_tag_contents1;
309 content::WebContents* default_tag_contents2;
310 content::WebContents* storage_contents1;
311 content::WebContents* storage_contents2;
312
313 NavigateAndOpenAppForIsolation(regular_url, &default_tag_contents1,
314 &default_tag_contents2, &storage_contents1,
315 &storage_contents2);
316
317 // Initialize the storage for the first of the two tags that share a storage
318 // partition.
319 ExecuteScriptWaitForTitle(storage_contents1, "initIDB()", "idb created");
320 ExecuteScriptWaitForTitle(storage_contents1, "addItemIDB(7, 'page1')",
321 "addItemIDB complete");
322 ExecuteScriptWaitForTitle(storage_contents1, "readItemIDB(7)",
323 "readItemIDB complete");
324
325 std::string output;
326 std::wstring get_value(
327 L"window.domAutomationController.send(getValueIDB() || 'badval')");
328
329 EXPECT_TRUE(ExecuteJavaScriptAndExtractString(
330 storage_contents1->GetRenderViewHost(), std::wstring(),
331 get_value.c_str(), &output));
332 EXPECT_STREQ("page1", output.c_str());
333
334 // Initialize the db in the second tag.
335 ExecuteScriptWaitForTitle(storage_contents2, "initIDB()", "idb open");
336
337 // Since we share a partition, reading the value should return the existing
338 // one.
339 ExecuteScriptWaitForTitle(storage_contents2, "readItemIDB(7)",
340 "readItemIDB complete");
341 EXPECT_TRUE(ExecuteJavaScriptAndExtractString(
342 storage_contents2->GetRenderViewHost(), std::wstring(),
343 get_value.c_str(), &output));
344 EXPECT_STREQ("page1", output.c_str());
345
346 // Now write through the second tag and read it back.
347 ExecuteScriptWaitForTitle(storage_contents2, "addItemIDB(7, 'page2')",
348 "addItemIDB complete");
349 ExecuteScriptWaitForTitle(storage_contents2, "readItemIDB(7)",
350 "readItemIDB complete");
351 EXPECT_TRUE(ExecuteJavaScriptAndExtractString(
352 storage_contents2->GetRenderViewHost(), std::wstring(),
353 get_value.c_str(), &output));
354 EXPECT_STREQ("page2", output.c_str());
355
356 // Reset the document title, otherwise the next call will not see a change and
357 // will hang waiting for it.
358 EXPECT_TRUE(content::ExecuteJavaScript(
359 storage_contents1->GetRenderViewHost(), std::wstring(),
360 L"document.title = 'foo'"));
361
362 // Read through the first tag to ensure we have the second value.
363 ExecuteScriptWaitForTitle(storage_contents1, "readItemIDB(7)",
364 "readItemIDB complete");
365 EXPECT_TRUE(ExecuteJavaScriptAndExtractString(
366 storage_contents1->GetRenderViewHost(), std::wstring(),
367 get_value.c_str(), &output));
368 EXPECT_STREQ("page2", output.c_str());
369
370 // Now, let's confirm there is no database in the main browser and another
371 // tag that doesn't share the same partition. Due to the IndexedDB API design,
372 // open will succeed, but the version will be 1, since it creates the database
373 // if it is not found. The two tags use database version 3, so we avoid
374 // ambiguity.
375 const char* script =
376 "indexedDB.open('isolation').onsuccess = function(e) {"
377 " if (e.target.result.version == 1)"
378 " document.title = 'db not found';"
379 " else "
380 " document.title = 'error';"
381 "}";
382 ExecuteScriptWaitForTitle(chrome::GetWebContentsAt(browser(), 0),
383 script, "db not found");
384 ExecuteScriptWaitForTitle(default_tag_contents1, script, "db not found");
385
386 CloseShellWindowsAndWaitForAppToExit();
387 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698