diff options
author | joth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-06 11:39:31 +0000 |
---|---|---|
committer | joth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-06 11:39:31 +0000 |
commit | c8f59aa0cd3b5c4d3ed1100d0053aad069aa43c6 (patch) | |
tree | c95f2ef7e997bf3d7d3b68e65302ccee3615cf76 /webkit | |
parent | 09ba959014a49bfe1952862c1831329a630c87e9 (diff) | |
download | chromium_src-c8f59aa0cd3b5c4d3ed1100d0053aad069aa43c6.zip chromium_src-c8f59aa0cd3b5c4d3ed1100d0053aad069aa43c6.tar.gz chromium_src-c8f59aa0cd3b5c4d3ed1100d0053aad069aa43c6.tar.bz2 |
Make delayed-permission-denied-for-multiple-requests pass
Enqueue permission requests until the first setPermission call is received.
BUG=webkit 43480
TEST=fast/dom/Geolocation/delayed-permission-denied-for-multiple-requests.html
Review URL: http://codereview.chromium.org/3294007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58631 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/tools/layout_tests/test_expectations.txt | 6 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_geolocation_service.cc | 37 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_geolocation_service.h | 8 |
3 files changed, 40 insertions, 11 deletions
diff --git a/webkit/tools/layout_tests/test_expectations.txt b/webkit/tools/layout_tests/test_expectations.txt index b797e76..fbac9da 100644 --- a/webkit/tools/layout_tests/test_expectations.txt +++ b/webkit/tools/layout_tests/test_expectations.txt @@ -5,6 +5,12 @@ // Only add expectations here to temporarily suppress messages on the bots // until the changes can be landed upstream. +// Temporary override until http://codereview.chromium.org/3294007 is upstreamed +BUGWK43480 : fast/dom/Geolocation/delayed-permission-allowed.html = TEXT PASS +BUGWK43480 : fast/dom/Geolocation/delayed-permission-denied.html = TEXT PASS +BUGWK43480 : fast/dom/Geolocation/delayed-permission-allowed-for-multiple-requests.html = TEXT PASS +BUGWK43480 : fast/dom/Geolocation/delayed-permission-denied-for-multiple-requests.html = TEXT PASS + BUG52841 MAC : fast/dom/Geolocation/callback-exception.html = TEXT PASS BUG52841 MAC : fast/dom/Geolocation/no-page-cache.html = TEXT PASS BUG52841 MAC : fast/dom/HTMLAnchorElement/set-href-attribute-hash.html = TEXT PASS diff --git a/webkit/tools/test_shell/test_geolocation_service.cc b/webkit/tools/test_shell/test_geolocation_service.cc index 50fe369..6653ecf 100644 --- a/webkit/tools/test_shell/test_geolocation_service.cc +++ b/webkit/tools/test_shell/test_geolocation_service.cc @@ -7,22 +7,24 @@ #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationServiceBridge.h" TestGeolocationService::TestGeolocationService() - : allowed_(false) { + : allowed_(false), + permission_set_(false) { } TestGeolocationService::~TestGeolocationService() { - } void TestGeolocationService::SetGeolocationPermission(bool allowed) { allowed_ = allowed; + permission_set_ = true; + TryToSendPermissions(); } void TestGeolocationService::requestPermissionForFrame( int bridgeId, const WebKit::WebURL& url) { - pending_permissions_.push_back(std::make_pair(bridgeId, allowed_)); - permission_timer_.Start(base::TimeDelta::FromMilliseconds(0), - this, &TestGeolocationService::SendPermission); + DCHECK(bridges_map_.Lookup(bridgeId)) << "Unknown bridge " << bridgeId; + pending_permissions_.push_back(bridgeId); + TryToSendPermissions(); } int TestGeolocationService::attachBridge( @@ -32,15 +34,30 @@ int TestGeolocationService::attachBridge( void TestGeolocationService::detachBridge(int bridgeId) { bridges_map_.Remove(bridgeId); + std::vector<int>::iterator i = pending_permissions_.begin(); + while (i != pending_permissions_.end()) { + if (*i == bridgeId) + pending_permissions_.erase(i); + else + ++i; + } +} + +void TestGeolocationService::TryToSendPermissions() { + if (permission_set_ && !permission_timer_.IsRunning()) + permission_timer_.Start(base::TimeDelta::FromMilliseconds(0), + this, &TestGeolocationService::SendPermission); } void TestGeolocationService::SendPermission() { - for (std::vector<std::pair<int, bool> >::const_iterator i = - pending_permissions_.begin(); i != pending_permissions_.end(); ++i) { + DCHECK(permission_set_); + std::vector<int> pending_permissions; + pending_permissions.swap(pending_permissions_); + for (std::vector<int>::const_iterator i = pending_permissions.begin(); + i != pending_permissions.end(); ++i) { WebKit::WebGeolocationServiceBridge* bridge = - bridges_map_.Lookup(i->first); + bridges_map_.Lookup(*i); DCHECK(bridge); - bridge->setIsAllowed(i->second); + bridge->setIsAllowed(allowed_); } - pending_permissions_.clear(); } diff --git a/webkit/tools/test_shell/test_geolocation_service.h b/webkit/tools/test_shell/test_geolocation_service.h index 0a0a145..cd6ce00 100644 --- a/webkit/tools/test_shell/test_geolocation_service.h +++ b/webkit/tools/test_shell/test_geolocation_service.h @@ -45,15 +45,21 @@ class TestGeolocationService : public WebKit::WebGeolocationService { virtual void detachBridge(int bridgeId); private: + void TryToSendPermissions(); void SendPermission(); + // Holds the value of |allowed| in most recent SetGeolocationPermission call. bool allowed_; + // Remains false until the first SetGeolocationPermission call. + bool permission_set_; IDMap<WebKit::WebGeolocationServiceBridge> bridges_map_; base::OneShotTimer<TestGeolocationService> permission_timer_; - std::vector<std::pair<int, bool> > pending_permissions_; + // In-order vector of pending bridge IDs. Is not pumped by + // TryToSendPermissions until the first call to SetGeolocationPermission. + std::vector<int> pending_permissions_; DISALLOW_COPY_AND_ASSIGN(TestGeolocationService); }; |