forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Telemetry: Add a functional test for InspectorBackendList.GetTabById().
This CL also exposes the property tabs on the class TabTestCase. BUG=442546 Review URL: https://codereview.chromium.org/940153002 Cr-Commit-Position: refs/heads/master@{#317662}
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
tools/telemetry/telemetry/core/backends/chrome/tab_list_backend_unittest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright 2015 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. | ||
from telemetry.core import exceptions | ||
from telemetry.unittest_util import tab_test_case | ||
|
||
|
||
class TabListBackendTest(tab_test_case.TabTestCase): | ||
def testTabIdMatchesContextId(self): | ||
# Ensure that there are two tabs. | ||
while len(self.tabs) < 2: | ||
self.tabs.New() | ||
|
||
# Check that the tab.id matches context_id. | ||
tabs = [] | ||
for context_id in self.tabs: | ||
tab = self.tabs.GetTabById(context_id) | ||
self.assertEquals(tab.id, context_id) | ||
tabs.append(self.tabs.GetTabById(context_id)) | ||
|
||
def testTabIdStableAfterTabCrash(self): | ||
# Ensure that there are two tabs. | ||
while len(self.tabs) < 2: | ||
self.tabs.New() | ||
|
||
tabs = [] | ||
for context_id in self.tabs: | ||
tabs.append(self.tabs.GetTabById(context_id)) | ||
|
||
# Crash the first tab. | ||
self.assertRaises(exceptions.DevtoolsTargetCrashException, | ||
lambda: tabs[0].Navigate('chrome://crash')) | ||
|
||
# Fetching the second tab by id should still work. Fetching the first tab | ||
# should raise an exception. | ||
self.assertEquals(tabs[1], self.tabs.GetTabById(tabs[1].id)) | ||
self.assertRaises(KeyError, lambda: self.tabs.GetTabById(tabs[0].id)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters