diff options
author | tzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-22 11:04:04 +0000 |
---|---|---|
committer | tzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-22 11:04:04 +0000 |
commit | b2a03ff223d4dd29a483fdd3cacad80bb34ecd2b (patch) | |
tree | f4dbad49f68cd1c6c6aeb76213651ff4d0427b1d /chrome | |
parent | da6541c3f277d75b1b1b120c118bc190913ff433 (diff) | |
download | chromium_src-b2a03ff223d4dd29a483fdd3cacad80bb34ecd2b.zip chromium_src-b2a03ff223d4dd29a483fdd3cacad80bb34ecd2b.tar.gz chromium_src-b2a03ff223d4dd29a483fdd3cacad80bb34ecd2b.tar.bz2 |
Make quota requests from background pages not crash
BUG=149804
Review URL: https://chromiumcodereview.appspot.com/10948002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158184 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
4 files changed, 31 insertions, 1 deletions
diff --git a/chrome/browser/chrome_quota_permission_context.cc b/chrome/browser/chrome_quota_permission_context.cc index 8c7c6d5..bb583c6 100644 --- a/chrome/browser/chrome_quota_permission_context.cc +++ b/chrome/browser/chrome_quota_permission_context.cc @@ -138,7 +138,8 @@ void ChromeQuotaPermissionContext::RequestQuotaPermission( } TabContents* tab_contents = TabContents::FromWebContents(web_contents); - InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); + InfoBarTabHelper* infobar_helper = + tab_contents ? tab_contents->infobar_tab_helper() : NULL; if (!infobar_helper) { // The tab has no infobar helper. LOG(WARNING) << "Attempt to request quota from a background page: " diff --git a/chrome/browser/extensions/extension_fileapi_apitest.cc b/chrome/browser/extensions/extension_fileapi_apitest.cc index 6151e04..81e10e7 100644 --- a/chrome/browser/extensions/extension_fileapi_apitest.cc +++ b/chrome/browser/extensions/extension_fileapi_apitest.cc @@ -11,3 +11,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_FileAPI) { IN_PROC_BROWSER_TEST_F(ExtensionApiTest, XHROnPersistentFileSystem) { ASSERT_TRUE(RunPlatformAppTest("xhr_persistent_fs")) << message_; } + +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, RequestQuotaInBackgroundPage) { + ASSERT_TRUE(RunExtensionTest("request_quota_background")) << message_; +} diff --git a/chrome/test/data/extensions/api_test/request_quota_background/background.js b/chrome/test/data/extensions/api_test/request_quota_background/background.js new file mode 100644 index 0000000..2f14925 --- /dev/null +++ b/chrome/test/data/extensions/api_test/request_quota_background/background.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 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. + +webkitStorageInfo.requestQuota(PERSISTENT, 1, pass, fail); + +function pass() { + console.log("PASS"); + if (window.chrome && chrome.test && chrome.test.succeed) + chrome.test.succeed(); +} + +function fail() { + console.log("FAIL"); + if (window.chrome && chrome.test && chrome.test.fail) + chrome.test.fail(); +} diff --git a/chrome/test/data/extensions/api_test/request_quota_background/manifest.json b/chrome/test/data/extensions/api_test/request_quota_background/manifest.json new file mode 100644 index 0000000..3016a43 --- /dev/null +++ b/chrome/test/data/extensions/api_test/request_quota_background/manifest.json @@ -0,0 +1,8 @@ +{ + "name": "Test requestQuota in background page", + "version": "1.0", + "manifest_version": 2, + "background": { + "scripts": ["background.js"] + } +} |