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

Unified Diff: tools/telemetry/telemetry/page/wait_action.py

Issue 12294002: Revert 182991 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/page/wait_action.py
===================================================================
--- tools/telemetry/telemetry/page/wait_action.py (revision 182999)
+++ tools/telemetry/telemetry/page/wait_action.py (working copy)
@@ -1,59 +0,0 @@
-# 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.
-import time
-
-from telemetry.core import util
-from telemetry.page import page_action
-
-class WaitAction(page_action.PageAction):
- DEFAULT_TIMEOUT = 60
-
- def __init__(self, attributes=None):
- super(WaitAction, self).__init__(attributes)
-
- def RunsPreviousAction(self):
- assert hasattr(self, 'condition')
- return self.condition == 'navigate' or self.condition == 'href_change'
-
- def RunAction(self, page, tab, previous_action):
- assert hasattr(self, 'condition')
-
- if self.condition == 'duration':
- assert hasattr(self, 'seconds')
- time.sleep(self.seconds)
-
- elif self.condition == 'navigate':
- if not previous_action:
- raise page_action.PageActionFailed('You need to perform an action '
- 'before waiting for navigate.')
- previous_action.WillRunAction()
- action_to_perform = lambda: previous_action.RunAction(page, tab, None)
- tab.PerformActionAndWaitForNavigate(action_to_perform)
-
- elif self.condition == 'href_change':
- if not previous_action:
- raise page_action.PageActionFailed('You need to perform an action '
- 'before waiting for a href change.')
- previous_action.WillRunAction()
- old_url = tab.EvaluateJavaScript('document.location.href')
- previous_action.RunAction(page, tab, None)
- util.WaitFor(lambda: tab.EvaluateJavaScript(
- 'document.location.href') != old_url, self.DEFAULT_TIMEOUT)
-
- elif self.condition == 'element':
- assert hasattr(self, 'text') or hasattr(self, 'selector')
- if self.text:
- callback_code = 'function(element) { return element != null; }'
- util.WaitFor(
- lambda: util.FindElementAndPerformAction(
- tab, self.text, callback_code), self.DEFAULT_TIMEOUT)
- elif self.selector:
- util.WaitFor(lambda: tab.EvaluateJavaScript(
- 'document.querySelector("%s") != null' % self.selector),
- self.DEFAULT_TIMEOUT)
-
- elif self.condition == 'javascript':
- assert hasattr(self, 'javascript')
- util.WaitFor(lambda: tab.EvaluateJavaScript(self.javascript),
- self.DEFAULT_TIMEOUT)
« no previous file with comments | « tools/telemetry/telemetry/page/scrolling_action_unittest.py ('k') | tools/telemetry/telemetry/page/wait_action_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698