Commit 7086001a authored by ctguil@chromium.org's avatar ctguil@chromium.org

Add DCHECK to BrowserAccessibilityManager::Remove to detect undefined behavoir...

Add DCHECK to BrowserAccessibilityManager::Remove to detect undefined behavoir that may lead to a crash.
- Remove logic BrowserAccessibilityManagerTest.TestCreateEmptyDocument that attempts to change an accessibility object's role.

BUG=92716
Test=none
Review URL: http://codereview.chromium.org/7648055

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97076 0039d316-1c4b-4281-b951-d872f2087c98
parent 60b189a1
......@@ -604,7 +604,7 @@ TEST(BrowserAccessibilityManagerTest, TestCreateEmptyDocument) {
tree2_1.role = WebAccessibility::ROLE_WEB_AREA;
WebAccessibility tree2_2;
tree2_2.id = 1001;
tree2_2.id = 1002;
tree2_2.role = WebAccessibility::ROLE_BUTTON;
tree2_1.children.push_back(tree2_2);
......@@ -614,17 +614,14 @@ TEST(BrowserAccessibilityManagerTest, TestCreateEmptyDocument) {
// Fire another load complete.
manager->OnAccessibilityNotifications(params);
BrowserAccessibility* acc2_2 = manager->GetFromRendererID(1001);
BrowserAccessibility* acc2_2 = manager->GetFromRendererID(1002);
// Verify the root has not changed.
EXPECT_EQ(root, manager->GetRoot());
// And the proper child remains.
// And the new child exists.
EXPECT_EQ(WebAccessibility::ROLE_BUTTON, acc2_2->role());
EXPECT_EQ(1001, acc2_2->renderer_id());
// Verify we don't reuse objects that have changed roles.
EXPECT_NE(acc1_2, acc2_2);
EXPECT_EQ(1002, acc2_2->renderer_id());
// Ensure we properly cleaned up.
manager.reset();
......
......@@ -116,6 +116,9 @@ BrowserAccessibility* BrowserAccessibilityManager::GetFromRendererID(
void BrowserAccessibilityManager::Remove(int32 child_id, int32 renderer_id) {
child_id_map_.erase(child_id);
// TODO(ctguil): Investigate if hit. We should never have a newer entry.
DCHECK(renderer_id_to_child_id_map_[renderer_id] == child_id);
// Make sure we don't overwrite a newer entry (see UpdateNode for a possible
// corner case).
if (renderer_id_to_child_id_map_[renderer_id] == child_id)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment