diff options
author | tonyg@chromium.org <tonyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-27 17:56:47 +0000 |
---|---|---|
committer | tonyg@chromium.org <tonyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-27 17:56:47 +0000 |
commit | dbc4934d5d6a37009eb8acd1c61222ca1fa0c506 (patch) | |
tree | 0a588b7b45b61051b8cbd8f32ec0a2acba798a94 | |
parent | df50a8694d0bd908e6c68a0a6d3fe0fe8f979305 (diff) | |
download | chromium_src-dbc4934d5d6a37009eb8acd1c61222ca1fa0c506.zip chromium_src-dbc4934d5d6a37009eb8acd1c61222ca1fa0c506.tar.gz chromium_src-dbc4934d5d6a37009eb8acd1c61222ca1fa0c506.tar.bz2 |
Revert 219675 "Removing Page.WaitToLoad and update all pagesets ..."
Broke the image_decoding_measurement
BUG=279481
> Removing Page.WaitToLoad and update all pagesets to use explicit wait actions
>
> BUG=273845
>
> Review URL: https://chromiumcodereview.appspot.com/22883011
TBR=edmundyan@chromium.org
Review URL: https://codereview.chromium.org/23498009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219813 0039d316-1c4b-4281-b951-d872f2087c98
22 files changed, 391 insertions, 303 deletions
diff --git a/content/test/gpu/gpu_tests/webgl_conformance.py b/content/test/gpu/gpu_tests/webgl_conformance.py index 6a58b79..5e27d21b 100644 --- a/content/test/gpu/gpu_tests/webgl_conformance.py +++ b/content/test/gpu/gpu_tests/webgl_conformance.py @@ -88,9 +88,10 @@ class WebglConformance(test_module.Test): {'action': 'navigate'}, { 'action': 'wait', + 'condition': 'javascript', 'javascript': 'webglTestHarness._finished', 'timeout': 120 - } + }, ] }) diff --git a/content/test/gpu/gpu_tests/webgl_robustness.py b/content/test/gpu/gpu_tests/webgl_robustness.py index aefb8b9..507d770 100644 --- a/content/test/gpu/gpu_tests/webgl_robustness.py +++ b/content/test/gpu/gpu_tests/webgl_robustness.py @@ -57,10 +57,7 @@ class WebglRobustness(test.Test): { 'url': 'file:///extra/lots-of-polys-example.html', 'script_to_evaluate_on_commit': robustness_harness_script, - 'navigate_steps': [ - { 'action': 'navigate' }, - { 'action': 'wait', 'javascript': 'webglTestHarness._finished' } - ] + 'wait_for_javascript_expression': 'webglTestHarness._finished' } ] } diff --git a/content/test/gpu/page_sets/pixel_tests.json b/content/test/gpu/page_sets/pixel_tests.json index bd83281..7581ff8 100644 --- a/content/test/gpu/page_sets/pixel_tests.json +++ b/content/test/gpu/page_sets/pixel_tests.json @@ -4,10 +4,7 @@ "pages": [ { "url": "file:///../../data/gpu/pixel_webgl.html", - "navigate_steps": [ - { "action": "navigate"}, - { "action": "wait", "seconds": 4 } - ] + "wait_seconds": 4 } ] } diff --git a/tools/perf/page_sets/2012Q3.json b/tools/perf/page_sets/2012Q3.json index 777d5db..151a1d6 100644 --- a/tools/perf/page_sets/2012Q3.json +++ b/tools/perf/page_sets/2012Q3.json @@ -3,11 +3,7 @@ "archive_data_file": "../data/2012Q3.json", "credentials_path": "../data/credentials.json", "smoothness": { "action": "scroll" }, - "reload_and_gc": [ - {"action": "reload" }, - {"action": "wait", "seconds": 1 }, - {"action": "js_collect_garbage" } - ], + "reload_and_gc": [{"action": "reload", "wait_seconds": 1}, {"action": "js_collect_garbage"}], "stress_memory": { "action": "reload_and_gc", "repeat": 3 }, "pages": [ { "url": "http://www.facebook.com/barackobama" }, diff --git a/tools/perf/page_sets/calendar_forward_backward.json b/tools/perf/page_sets/calendar_forward_backward.json index 5b72a25..7e5257f 100644 --- a/tools/perf/page_sets/calendar_forward_backward.json +++ b/tools/perf/page_sets/calendar_forward_backward.json @@ -8,29 +8,58 @@ "url": "https://www.google.com/calendar/", "why": "Click forward(4x) and backwards(4x) repeatedly", "credentials": "google", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navForward\"]" }, - { "action": "javascript", "expression": "(function() { var elem = document.createElement('meta');elem.name='viewport';elem.content='initial-scale=1';document.body.appendChild(elem); })();" } - ], + "wait_for_element_with_selector": "div[class~=\"navForward\"]", + "post_navigate_javascript_to_execute": "(function() { var elem = document.createElement('meta');elem.name='viewport';elem.content='initial-scale=1';document.body.appendChild(elem); })();", + "wait_seconds": 2, "endure": [ - { "action": "click_element", "selector": "div[class~=\"navForward\"]" }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navForward\"]" }, - { "action": "click_element", "selector": "div[class~=\"navForward\"]" }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navForward\"]" }, - { "action": "click_element", "selector": "div[class~=\"navForward\"]" }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navForward\"]" }, - { "action": "click_element", "selector": "div[class~=\"navForward\"]" }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navBack\"]" }, - { "action": "click_element", "selector": "div[class~=\"navBack\"]" }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navBack\"]" }, - { "action": "click_element", "selector": "div[class~=\"navBack\"]" }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navBack\"]" }, - { "action": "click_element", "selector": "div[class~=\"navBack\"]" }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navBack\"]" }, - { "action": "click_element", "selector": "div[class~=\"navBack\"]" }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navForward\"]" } + { + "action": "click_element", + "selector": "div[class~=\"navForward\"]", + "wait_seconds": 2, + "wait_for_element_with_selector": "div[class~=\"navForward\"]" + }, + { + "action": "click_element", + "selector": "div[class~=\"navForward\"]", + "wait_seconds": 2, + "wait_for_element_with_selector": "div[class~=\"navForward\"]" + }, + { + "action": "click_element", + "selector": "div[class~=\"navForward\"]", + "wait_seconds": 2, + "wait_for_element_with_selector": "div[class~=\"navForward\"]" + }, + { + "action": "click_element", + "selector": "div[class~=\"navForward\"]", + "wait_seconds": 2, + "wait_for_element_with_selector": "div[class~=\"navBack\"]" + }, + { + "action": "click_element", + "selector": "div[class~=\"navBack\"]", + "wait_seconds": 2, + "wait_for_element_with_selector": "div[class~=\"navBack\"]" + }, + { + "action": "click_element", + "selector": "div[class~=\"navBack\"]", + "wait_seconds": 2, + "wait_for_element_with_selector": "div[class~=\"navBack\"]" + }, + { + "action": "click_element", + "selector": "div[class~=\"navBack\"]", + "wait_seconds": 2, + "wait_for_element_with_selector": "div[class~=\"navBack\"]" + }, + { + "action": "click_element", + "selector": "div[class~=\"navBack\"]", + "wait_seconds": 2, + "wait_for_element_with_selector": "div[class~=\"navForward\"]" + } ] } ] diff --git a/tools/perf/page_sets/image_decoding_measurement.json b/tools/perf/page_sets/image_decoding_measurement.json index cfe6ff7..fcf1ce2 100644 --- a/tools/perf/page_sets/image_decoding_measurement.json +++ b/tools/perf/page_sets/image_decoding_measurement.json @@ -1,10 +1,7 @@ { "description": "A directed benchmark of image decoding performance", - "navigate_steps": [ - { "action": "navigate" }, - { "action": "javascript", "expression": "runBenchmark();" }, - { "action": "wait", "javascript": "isDone" } - ], + "post_navigate_javascript_to_execute": "runBenchmark();", + "wait_for_javascript_expression": "isDone", "image_decoding_measurement_limit_results_to_min_iterations": true, "pages": [ { "url": "file:///../../../chrome/test/data/image_decoding/image_decoding.html?gif" }, diff --git a/tools/perf/page_sets/key_desktop_sites.json b/tools/perf/page_sets/key_desktop_sites.json index 69613a2..85b05e8 100644 --- a/tools/perf/page_sets/key_desktop_sites.json +++ b/tools/perf/page_sets/key_desktop_sites.json @@ -620,10 +620,10 @@ "url": "https://mail.google.com/mail/", "credentials": "google", "scrollable_element_function": "function(callback) { gmonkey.load('2.0', function(api) { callback(api.getScrollableElement()); }); }", - "smoothness": [ - { "action": "scroll" }, - { "action": "wait", "javascript": "window.gmonkey !== undefined && document.getElementById('gb') !== null" } - ] + "smoothness": { + "action": "scroll", + "wait_for_javascript_expression": "window.gmonkey !== undefined && document.getElementById('gb') !== null" + } }, { "url": "https://www.google.com/calendar/", @@ -634,19 +634,19 @@ "url": "https://drive.google.com", "credentials": "google", "scrollable_element_function": "function(callback) { callback(document.getElementsByClassName('doclistview-list')[0]); }", - "smoothness": [ - { "action": "scroll" }, - { "action": "wait", "javascript": "document.getElementsByClassName('doclistview-list').length" } - ] + "smoothness": { + "action": "scroll", + "wait_for_javascript_expression": "document.getElementsByClassName('doclistview-list').length" + } }, { "url": "https://docs.google.com/a/google.com/document/d/1XMAtPiVFZfItsMUOYl39v5YA8bcSPe4LDrVO25OdsCU/edit", "credentials": "google", "scrollable_element_function": "function(callback) { callback(document.getElementsByClassName('kix-appview-editor')[0]); }", - "smoothness": [ - { "action": "scroll" }, - { "action": "wait", "javascript": "document.getElementsByClassName('kix-appview-editor').length" } - ] + "smoothness": { + "action": "scroll", + "wait_for_javascript_expression": "document.getElementsByClassName('kix-appview-editor').length" + } }, { "url": "https://maps.google.com" }, { "url": "http://reader.google.com" }, diff --git a/tools/perf/page_sets/key_mobile_sites.json b/tools/perf/page_sets/key_mobile_sites.json index afc436c..3c2cc6b 100644 --- a/tools/perf/page_sets/key_mobile_sites.json +++ b/tools/perf/page_sets/key_mobile_sites.json @@ -16,10 +16,7 @@ { "url": "http://iphone.capitolvolkswagen.com/index.htm#new-inventory_p_2Fsb-new_p_2Ehtm_p_3Freset_p_3DInventoryListing", "why": "Typical mobile business site", - "navigate_steps": [ - { "action": "navigate" }, - { "action": "wait", "condition": "element", "text": "Next 35" } - ] + "wait_for_element_with_text": "Next 35" }, { "url": "http://gsp.ro", @@ -36,18 +33,12 @@ { "url": "http://www.theverge.com/2012/10/28/3568746/amazon-7-inch-fire-hd-ipad-mini-ad-ballsy", "why": "Top tech blog", - "navigate_steps": [ - { "action": "navigate" }, - { "action": "wait", "javascript": "window.Chorus !== undefined && window.Chorus.Comments !== undefined && window.Chorus.Comments.Json !== undefined && (window.Chorus.Comments.loaded || window.Chorus.Comments.Json.load_comments())" } - ] + "wait_for_javascript_expression": "window.Chorus !== undefined && window.Chorus.Comments !== undefined && window.Chorus.Comments.Json !== undefined && (window.Chorus.Comments.loaded || window.Chorus.Comments.Json.load_comments())" }, { "url": "http://www.cnn.com/2012/10/03/politics/michelle-obama-debate/index.html", "why": "Top news site", - "navigate_steps": [ - { "action": "navigate" }, - { "action": "wait", "seconds": 8 } - ] + "wait_seconds": 8 }, { "url": "http://digg.com", @@ -68,18 +59,12 @@ { "url": "https://facebook.com/barackobama", "why": "#1 (Alexa global)", - "navigate_steps": [ - { "action": "navigate" }, - { "action": "wait", "javascript": "document.getElementById('timelineBody') !== null" } - ] + "wait_for_javascript_expression": "document.getElementById('timelineBody') !== null" }, { "url": "http://m.youtube.com/watch?v=9hBpF_Zj4OA", "why": "#3 (Alexa global)", - "navigate_steps": [ - { "action": "navigate"}, - { "action": "wait", "javascript": "document.getElementById('paginatortarget') !== null"} - ] + "wait_for_javascript_expression": "document.getElementById('paginatortarget') !== null" }, { "name": "Blogger", @@ -95,11 +80,8 @@ "name": "LinkedIn", "url": "https://www.linkedin.com/in/linustorvalds", "why": "#12 (Alexa global),Public profile", - "navigate_steps": [ - { "action": "navigate" }, - { "action": "javascript", "expression": "getAppJs.noApp();" }, - { "action": "wait", "javascript": "document.getElementById('profile-view-scroller') !== null" } - ] + "post_navigate_javascript_to_execute": "getAppJs.noApp();", + "wait_for_javascript_expression": "document.getElementById('profile-view-scroller') !== null" }, { "name": "Wikipedia (1 tab)", @@ -159,10 +141,7 @@ "url": "https://mail.google.com/mail/", "why": "productivity, top google properties", "credentials": "google", - "navigate_steps": [ - { "action": "navigate" }, - { "action": "wait", "condition": "element", "text": "Inbox" } - ], + "wait_for_element_with_text": "Inbox", "smoothness": { "action": "scroll", "scrollable_element_function": "function(callback) { callback(document.getElementById('views').childNodes[1].firstChild); }" @@ -215,11 +194,8 @@ { "url": "http://groupcloned.com", "why": "crbug.com/172906", - "navigate_steps": [ - { "action": "navigate" }, - { "action": "wait", "seconds": 5 }, - { "action": "wait", "javascript": "document.getElementById('element-19') !== null && document.getElementById('element-19').contentDocument.getElementById('element-22') !== null && document.getElementById('element-19').contentDocument.getElementsByClassName('container list-item gc-list-item stretched').length !== 0" } - ], + "wait_for_javascript_expression": "document.getElementById('element-19') !== null && document.getElementById('element-19').contentDocument.getElementById('element-22') !== null && document.getElementById('element-19').contentDocument.getElementsByClassName('container list-item gc-list-item stretched').length !== 0", + "wait_seconds": 5, "smoothness": { "action": "scroll", "scroll_requires_touch": true, diff --git a/tools/perf/page_sets/mobile_memory.json b/tools/perf/page_sets/mobile_memory.json index b9e65a7..57884749 100644 --- a/tools/perf/page_sets/mobile_memory.json +++ b/tools/perf/page_sets/mobile_memory.json @@ -3,11 +3,7 @@ "archive_data_file": "../data/mobile_memory.json", "credentials_path": "../data/credentials.json", "user_agent_type": "mobile", - "reload_and_gc": [ - {"action": "reload" }, - {"action": "wait", "seconds": 15 }, - {"action": "js_collect_garbage" } - ], + "reload_and_gc": [{"action": "reload", "wait_seconds": 15}, {"action": "js_collect_garbage"}], "stress_memory": { "action": "reload_and_gc", "repeat": 3 }, "pages": [ { diff --git a/tools/perf/page_sets/pica.json b/tools/perf/page_sets/pica.json index 11527f6..2315276 100644 --- a/tools/perf/page_sets/pica.json +++ b/tools/perf/page_sets/pica.json @@ -5,10 +5,7 @@ { "url": "http://www.polymer-project.org/polymer-all/projects/pica/index.html", "script_to_evaluate_on_commit": "document.addEventListener('WebComponentsReady', function(){var unused = document.body.offsetHeight; window.__pica_load_time = performance.now(); setTimeout(function(){window.__web_components_ready=true}, 1000)})", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "javascript": "window.__web_components_ready" } - ], + "wait_for_javascript_expression": "window.__web_components_ready", "smoothness": { "action": "tap_element", "find_element_expression": "document.querySelector('pi-app').$.Topics.$.topics.$.container.querySelector('.item > .card')", diff --git a/tools/perf/page_sets/top_10.json b/tools/perf/page_sets/top_10.json index 31f5db5..b14ae24 100644 --- a/tools/perf/page_sets/top_10.json +++ b/tools/perf/page_sets/top_10.json @@ -8,38 +8,26 @@ { "url": "https://www.google.com/#hl=en&q=barack+obama", "why": "top google property; a google tab is often open", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "condition": "element", "text": "Next" } - ] + "wait_for_element_with_text": "Next" }, { "url": "https://mail.google.com/mail/", "why": "productivity, top google properties", "credentials": "google", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "javascript": "window.gmonkey !== undefined && document.getElementById('gb') !== null" } - ] + "wait_for_javascript_expression": "window.gmonkey !== undefined && document.getElementById('gb') !== null" }, { "url": "https://www.google.com/calendar/", "why": "productivity, top google properties", "credentials": "google", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "javascript", "expression": "(function() { var elem = document.createElement('meta');elem.name='viewport';elem.content='initial-scale=1';document.body.appendChild(elem); })();" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navForward\"]" } - ] + "wait_for_element_with_selector": "div[class~=\"navForward\"]", + "post_navigate_javascript_to_execute": "(function() { var elem = document.createElement('meta');elem.name='viewport';elem.content='initial-scale=1';document.body.appendChild(elem); })();", + "wait_seconds": 2 }, { "url": "http://www.youtube.com", "why": "#3 (Alexa global)", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "seconds": 2 } - ], + "wait_seconds": 2, "credentials": "google" }, { @@ -47,10 +35,7 @@ "url": "http://www.facebook.com/barackobama", "why": "top social,Public profile", "credentials": "facebook", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "condition": "element", "text": "About" } - ] + "wait_for_element_with_text": "About" }, { "name": "Wikipedia (1 tab)", diff --git a/tools/perf/page_sets/top_25.json b/tools/perf/page_sets/top_25.json index 619ff77..3f47fa6 100644 --- a/tools/perf/page_sets/top_25.json +++ b/tools/perf/page_sets/top_25.json @@ -8,109 +8,148 @@ { "url": "https://www.google.com/#hl=en&q=barack+obama", "why": "top google property; a google tab is often open", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "condition": "element", "text": "Next" } - ], + "wait_for_element_with_text": "Next", "stress_memory": [ { "action": "scroll" }, - { "action": "click_element", "text": "Next" }, - { "action": "wait", "condition": "href_change" }, - { "action": "wait", "condition": "element", "text": "Next" }, + { + "action": "click_element", + "text": "Next", + "wait_for_href_change": true, + "wait_for_element_with_text": "Next" + }, { "action": "scroll" }, - { "action": "click_element", "text": "Next" }, - { "action": "wait", "condition": "href_change" }, - { "action": "wait", "condition": "element", "text": "Next" }, + { + "action": "click_element", + "text": "Next", + "wait_for_href_change": true, + "wait_for_element_with_text": "Next" + }, { "action": "scroll" }, - { "action": "click_element", "text": "Next" }, - { "action": "wait", "condition": "href_change" }, - { "action": "wait", "condition": "element", "text": "Previous" }, + { + "action": "click_element", + "text": "Next", + "wait_for_href_change": true, + "wait_for_element_with_text": "Previous" + }, { "action": "scroll" }, - { "action": "click_element", "text": "Previous" }, - { "action": "wait", "condition": "href_change" }, - { "action": "wait", "condition": "element", "text": "Previous" }, + { + "action": "click_element", + "text": "Previous", + "wait_for_href_change": true, + "wait_for_element_with_text": "Previous" + }, { "action": "scroll" }, - { "action": "click_element", "text": "Previous" }, - { "action": "wait", "condition": "href_change" }, - { "action": "wait", "condition": "element", "text": "Previous" }, + { + "action": "click_element", + "text": "Previous", + "wait_for_href_change": true, + "wait_for_element_with_text": "Previous" + }, { "action": "scroll" }, - { "action": "click_element", "text": "Previous" }, - { "action": "wait", "condition": "href_change" }, - { "action": "wait", "condition": "element", "text": "Images" }, + { + "action": "click_element", + "text": "Previous", + "wait_for_href_change": true, + "wait_for_element_with_text": "Images" + }, { "action": "scroll" }, - { "action": "click_element", "text": "Images" }, - { "action": "wait", "condition": "href_change" }, - { "action": "wait", "condition": "element", "text": "Images" } + { + "action": "click_element", + "text": "Images", + "wait_for_href_change": true, + "wait_for_element_with_text": "Images" + } ] }, { "url": "https://mail.google.com/mail/", "why": "productivity, top google properties", "credentials": "google", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "javascript": "window.gmonkey !== undefined && document.getElementById('gb') !== null" } - ], + "wait_for_javascript_expression": "window.gmonkey !== undefined && document.getElementById('gb') !== null", "smoothness": { "action": "scroll", "scrollable_element_function": "function(callback) { gmonkey.load('2.0', function(api) { callback(api.getScrollableElement()); }); }" }, "stress_memory": [ - { "action": "click_element", "selector": "a[href=\"https://mail.google.com/mail/u/0/?shva=1#starred\"]" }, - { "action": "wait", "condition": "href_change" }, - { "action": "click_element", "selector": "a[href=\"https://mail.google.com/mail/u/0/?shva=1#inbox\"]" }, - { "action": "wait", "condition": "href_change" } + { + "action": "click_element", + "selector": "a[href=\"https://mail.google.com/mail/u/0/?shva=1#starred\"]", + "wait_for_href_change": true + }, + { + "action": "click_element", + "selector": "a[href=\"https://mail.google.com/mail/u/0/?shva=1#inbox\"]", + "wait_for_href_change": true + } ] }, { "url": "https://www.google.com/calendar/", "why": "productivity, top google properties", "credentials": "google", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navForward\"]" }, - { "action": "javascript", "expression": "(function() { var elem = document.createElement('meta');elem.name='viewport';elem.content='initial-scale=1';document.body.appendChild(elem); })();" } - ], + "wait_for_element_with_selector": "div[class~=\"navForward\"]", + "post_navigate_javascript_to_execute": "(function() { var elem = document.createElement('meta');elem.name='viewport';elem.content='initial-scale=1';document.body.appendChild(elem); })();", + "wait_seconds": 2, "smoothness": { "action": "scroll", "scrollable_element_function": "function(callback) { callback(document.getElementById('scrolltimedeventswk')); }" }, "stress_memory": [ - { "action": "click_element", "selector": "div[class~=\"navForward\"]" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navForward\"]" }, - { "action": "click_element", "selector": "div[class~=\"navForward\"]" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navForward\"]" }, - { "action": "click_element", "selector": "div[class~=\"navForward\"]" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navForward\"]" }, - { "action": "click_element", "selector": "div[class~=\"navForward\"]" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navBack\"]" }, - { "action": "click_element", "selector": "div[class~=\"navBack\"]" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navBack\"]" }, - { "action": "click_element", "selector": "div[class~=\"navBack\"]" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navBack\"]" }, - { "action": "click_element", "selector": "div[class~=\"navBack\"]" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navBack\"]" }, - { "action": "click_element", "selector": "div[class~=\"navBack\"]" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "condition": "element", "selector": "div[class~=\"navBack\"]" } + { + "action": "click_element", + "selector": "div[class~=\"navForward\"]", + "wait_for_seconds": 2, + "wait_for_element_with_selector": "div[class~=\"navForward\"]" + }, + { + "action": "click_element", + "selector": "div[class~=\"navForward\"]", + "wait_for_seconds": 2, + "wait_for_element_with_selector": "div[class~=\"navForward\"]" + }, + { + "action": "click_element", + "selector": "div[class~=\"navForward\"]", + "wait_for_seconds": 2, + "wait_for_element_with_selector": "div[class~=\"navForward\"]" + }, + { + "action": "click_element", + "selector": "div[class~=\"navForward\"]", + "wait_for_seconds": 2, + "wait_for_element_with_selector": "div[class~=\"navBack\"]" + }, + { + "action": "click_element", + "selector": "div[class~=\"navBack\"]", + "wait_for_seconds": 2, + "wait_for_element_with_selector": "div[class~=\"navBack\"]" + }, + { + "action": "click_element", + "selector": "div[class~=\"navBack\"]", + "wait_for_seconds": 2, + "wait_for_element_with_selector": "div[class~=\"navBack\"]" + }, + { + "action": "click_element", + "selector": "div[class~=\"navBack\"]", + "wait_for_seconds": 2, + "wait_for_element_with_selector": "div[class~=\"navBack\"]" + }, + { + "action": "click_element", + "selector": "div[class~=\"navBack\"]", + "wait_for_seconds": 2, + "wait_for_element_with_selector": "div[class~=\"navBack\"]" + } ] }, { "url": "https://drive.google.com", "why": "productivity, top google properties", "credentials": "google", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "javascript": "document.getElementsByClassName('doclistview-list').length" } - ], + "wait_for_javascript_expression": "document.getElementsByClassName('doclistview-list').length", "smoothness": { "action": "scroll", "scrollable_element_function": "function(callback) { callback(document.getElementsByClassName('doclistview-list')[0]); }" @@ -121,11 +160,8 @@ "url": "https://docs.google.com/document/d/1X-IKNjtEnx-WW5JIKRLsyhz5sbsat3mfTpAPUSX3_s4/view", "why": "productivity, top google properties; Sample doc in the link", "credentials": "google", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "javascript": "document.getElementsByClassName('kix-appview-editor').length" } - ], + "wait_for_javascript_expression": "document.getElementsByClassName('kix-appview-editor').length", + "wait_seconds": 2, "smoothness": { "action": "scroll", "scrollable_element_function": "function(callback) { callback(document.getElementsByClassName('kix-appview-editor')[0]); }" @@ -135,88 +171,112 @@ "url": "https://plus.google.com/110031535020051778989/posts", "why": "social; top google property; Public profile; infinite scrolls", "credentials": "google", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "condition": "element", "text": "Home" } - ], + "wait_for_element_with_text": "Home", "smoothness": { "action": "scroll", "scroll_is_infinite": true }, "stress_memory": [ - { "action": "click_element", "text": "Home" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "condition": "element", "text": "Profile" }, - { "action": "click_element", "text": "Profile" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "condition": "element", "text": "Explore" }, - { "action": "click_element", "text": "Explore" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "condition": "element", "text": "Events" }, - { "action": "click_element", "text": "Events" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "condition": "element", "text": "Communities" }, - { "action": "click_element", "text": "Communities" }, - { "action": "wait", "seconds": 2 }, - { "action": "wait", "condition": "element", "text": "Home" } + { + "action": "click_element", + "text": "Home", + "wait_seconds": 2, + "wait_for_element_with_text": "Profile" + }, + { + "action": "click_element", + "text": "Profile", + "wait_seconds": 2, + "wait_for_element_with_text": "Explore" + }, + { + "action": "click_element", + "text": "Explore", + "wait_seconds": 2, + "wait_for_element_with_text": "Events" + }, + { + "action": "click_element", + "text": "Events", + "wait_seconds": 2, + "wait_for_element_with_text": "Communities" + }, + { + "action": "click_element", + "text": "Communities", + "wait_seconds": 2, + "wait_for_element_with_text": "Home" + } ] }, { "url": "http://www.youtube.com", "why": "#3 (Alexa global)", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "seconds": 2 } - ], + "wait_seconds": 2, "credentials": "google" }, { "name": "Blogger", "url": "http://googlewebmastercentral.blogspot.com/", "why": "#11 (Alexa global), google property; some blogger layouts have infinite scroll but more interesting", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "condition": "element", "text": "accessibility" } - ], + "wait_for_element_with_text": "accessibility", "stress_memory": [ - { "action": "click_element", "text": "accessibility" }, - { "action": "wait", "condition": "navigate" }, - { "action": "wait", "condition": "element", "text": "advanced" }, + { + "action": "click_element", + "text": "accessibility", + "wait_for_navigate": true, + "wait_for_element_with_text": "advanced" + }, { "action": "scroll" }, - { "action": "click_element", "text": "advanced" }, - { "action": "wait", "condition": "navigate" }, - { "action": "wait", "condition": "element", "text": "beginner" }, + { + "action": "click_element", + "text": "advanced", + "wait_for_navigate": true, + "wait_for_element_with_text": "beginner" + }, { "action": "scroll" }, - { "action": "click_element", "text": "beginner" }, - { "action": "wait", "condition": "navigate" }, - { "action": "wait", "condition": "element", "text": "Home" }, + { + "action": "click_element", + "text": "beginner", + "wait_for_navigate": true, + "wait_for_element_with_text": "Home" + }, { "action": "scroll" }, - { "action": "click_element", "text": "Home" }, - { "action": "wait", "condition": "navigate" }, - { "action": "wait", "condition": "element", "text": "Home" } + { + "action": "click_element", + "text": "Home", + "wait_for_navigate": true, + "wait_for_element_with_text": "Home" + } ] }, { "name": "Wordpress", "url": "http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/", "why": "#18 (Alexa global), Picked an interesting post", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "condition": "element", "selector": "a[href=\"http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sight/\"]" } - ], + "wait_for_element_with_selector": "a[href=\"http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sight/\"]", "stress_memory": [ { "action": "scroll" }, - { "action": "click_element", "selector": "a[href=\"http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sight/\"]" }, - { "action": "wait", "condition": "navigate" }, - { "action": "wait", "condition": "element", "text": "Features" }, + { + "action": "click_element", + "selector": "a[href=\"http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sight/\"]", + "wait_for_navigate": true, + "wait_for_element_with_text": "Features" + }, { "action": "scroll" }, - { "action": "click_element", "text": "Features" }, - { "action": "wait", "condition": "navigate" }, - { "action": "wait", "condition": "element", "text": "News" }, + { + "action": "click_element", + "text": "Features", + "wait_for_navigate": true, + "wait_for_element_with_text": "News" + }, { "action": "scroll" }, - { "action": "click_element", "text": "News" }, - { "action": "wait", "condition": "navigate" }, - { "action": "wait", "condition": "element", "text": "News" }, + { + "action": "click_element", + "text": "News", + "wait_for_navigate": true, + "wait_for_element_with_text": "News" + }, { "action": "scroll" } ] }, @@ -225,33 +285,48 @@ "url": "http://www.facebook.com/barackobama", "why": "top social,Public profile", "credentials": "facebook", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "condition": "element", "text": "About" } - ], + "wait_for_element_with_text": "About", "smoothness": { "action": "scroll", "scroll_is_infinite": true }, "stress_memory": [ - { "action": "click_element", "text": "About" }, - { "action": "wait", "condition": "navigate" }, - { "action": "wait", "condition": "element", "text": "The Audacity of Hope" }, - { "action": "click_element", "text": "The Audacity of Hope" }, - { "action": "wait", "condition": "navigate" }, - { "action": "wait", "condition": "element", "text": "Back to Barack Obama's Timeline" }, - { "action": "click_element", "text": "Back to Barack Obama's Timeline" }, - { "action": "wait", "condition": "navigate" }, - { "action": "wait", "condition": "element", "text": "About" }, - { "action": "click_element", "text": "About" }, - { "action": "wait", "condition": "navigate" }, - { "action": "wait", "condition": "element", "text": "Elected to U.S. Senate" }, - { "action": "click_element", "text": "Elected to U.S. Senate" }, - { "action": "wait", "condition": "navigate" }, - { "action": "wait", "condition": "element", "text": "Home" }, - { "action": "click_element", "text": "Home" }, - { "action": "wait", "condition": "navigate" }, - { "action": "wait", "condition": "element", "text": "Home" } + { + "action": "click_element", + "text": "About", + "wait_for_navigate": true, + "wait_for_element_with_text": "The Audacity of Hope" + }, + { + "action": "click_element", + "text": "The Audacity of Hope", + "wait_for_navigate": true, + "wait_for_element_with_text": "Back to Barack Obama's Timeline" + }, + { + "action": "click_element", + "text": "Back to Barack Obama's Timeline", + "wait_for_navigate": true, + "wait_for_element_with_text": "About" + }, + { + "action": "click_element", + "text": "About", + "wait_for_navigate": true, + "wait_for_element_with_text": "Elected to U.S. Senate" + }, + { + "action": "click_element", + "text": "Elected to U.S. Senate", + "wait_for_navigate": true, + "wait_for_element_with_text": "Home" + }, + { + "action": "click_element", + "text": "Home", + "wait_for_navigate": true, + "wait_for_element_with_text": "Home" + } ] }, { @@ -268,10 +343,7 @@ "name": "Twitter", "url": "https://twitter.com/katyperry", "why": "#8 (Alexa global),Picked an interesting page", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "seconds": 2 } - ], + "wait_seconds": 2, "smoothness": { "action": "scroll", "scroll_is_infinite": true @@ -319,10 +391,7 @@ { "url": "http://games.yahoo.com", "why": "#1 games according to Alexa (with actual games in it)", - "navigate_steps" : [ - { "action": "navigate" }, - { "action": "wait", "seconds": 2 } - ] + "wait_seconds": 2 }, { "url": "http://booking.com", diff --git a/tools/perf/page_sets/tough_animation_cases.json b/tools/perf/page_sets/tough_animation_cases.json index cba0f31..1e26bcf 100644 --- a/tools/perf/page_sets/tough_animation_cases.json +++ b/tools/perf/page_sets/tough_animation_cases.json @@ -1,6 +1,6 @@ { "description": "A collection of animation performance tests", - "smoothness": { "action": "wait", "seconds": 5 }, + "smoothness": { "action": "wait", "condition": "duration", "seconds": 5 }, "pages": [ { "url": "file:///tough_animation_cases/keyframed_animations.html", diff --git a/tools/perf/page_sets/tough_canvas_cases.json b/tools/perf/page_sets/tough_canvas_cases.json index a2ca25bd..dde8ef8 100644 --- a/tools/perf/page_sets/tough_canvas_cases.json +++ b/tools/perf/page_sets/tough_canvas_cases.json @@ -2,7 +2,7 @@ "description": "Self-driven Canvas2D animation examples", "archive_data_file": "../data/tough_canvas_cases.json", "make_javascript_deterministic": false, - "smoothness": { "action": "wait", "seconds": 5 }, + "smoothness": { "action": "wait", "condition": "duration", "seconds": 5 }, "pages": [ { "url":"http://mudcu.be/labs/JS1k/BreathingGalaxies.html" }, { "url":"http://runway.countlessprojects.com/prototype/performance_test.html" }, diff --git a/tools/telemetry/telemetry/page/actions/click_element.py b/tools/telemetry/telemetry/page/actions/click_element.py index 7ff2dc4..7891153 100644 --- a/tools/telemetry/telemetry/page/actions/click_element.py +++ b/tools/telemetry/telemetry/page/actions/click_element.py @@ -6,6 +6,7 @@ import re from telemetry.core import util from telemetry.core import exceptions +from telemetry.page import page as page_module from telemetry.page.actions import page_action class ClickElementAction(page_action.PageAction): @@ -44,5 +45,15 @@ class ClickElementAction(page_action.PageAction): raise page_action.PageActionFailed( 'No condition given to click_element') - DoClick() + if hasattr(self, 'wait_for_navigate'): + tab.PerformActionAndWaitForNavigate(DoClick) + elif hasattr(self, 'wait_for_href_change'): + old_url = tab.EvaluateJavaScript('document.location.href') + DoClick() + util.WaitFor(lambda: tab.EvaluateJavaScript( + 'document.location.href') != old_url, 60) + else: + DoClick() + + page_module.Page.WaitForPageToLoad(self, tab, 60) tab.WaitForDocumentReadyStateToBeInteractiveOrBetter() diff --git a/tools/telemetry/telemetry/page/actions/click_element_unittest.py b/tools/telemetry/telemetry/page/actions/click_element_unittest.py index 2665c7d..c50d8c9 100644 --- a/tools/telemetry/telemetry/page/actions/click_element_unittest.py +++ b/tools/telemetry/telemetry/page/actions/click_element_unittest.py @@ -4,7 +4,6 @@ from telemetry.core import util from telemetry.page.actions import click_element -from telemetry.page.actions import wait from telemetry.unittest import tab_test_case class ClickElementActionTest(tab_test_case.TabTestCase): @@ -17,11 +16,9 @@ class ClickElementActionTest(tab_test_case.TabTestCase): self._tab.EvaluateJavaScript('document.location.pathname;'), '/page_with_link.html') - data = {'selector': 'a[id="clickme"]'} + data = {'selector': 'a[id="clickme"]', 'wait_for_href_change': True} i = click_element.ClickElementAction(data) - data = {'condition': 'href_change'} - j = wait.WaitAction(data) - j.RunAction(None, self._tab, i) + i.RunAction(None, self._tab, None) self.assertEquals( self._tab.EvaluateJavaScript('document.location.pathname;'), @@ -36,11 +33,9 @@ class ClickElementActionTest(tab_test_case.TabTestCase): self._tab.EvaluateJavaScript('document.location.pathname;'), '/page_with_link.html') - data = {'text': 'Click me'} + data = {'text': 'Click me', 'wait_for_href_change': True} i = click_element.ClickElementAction(data) - data = {'condition': 'href_change'} - j = wait.WaitAction(data) - j.RunAction(None, self._tab, i) + i.RunAction(None, self._tab, None) self.assertEquals( self._tab.EvaluateJavaScript('document.location.pathname;'), diff --git a/tools/telemetry/telemetry/page/actions/reload.py b/tools/telemetry/telemetry/page/actions/reload.py index c98853c..caa362e 100644 --- a/tools/telemetry/telemetry/page/actions/reload.py +++ b/tools/telemetry/telemetry/page/actions/reload.py @@ -1,7 +1,7 @@ # Copyright (c) 2013 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.page import page as page_module from telemetry.page.actions import page_action class ReloadAction(page_action.PageAction): @@ -10,4 +10,5 @@ class ReloadAction(page_action.PageAction): def RunAction(self, page, tab, previous_action): tab.ExecuteJavaScript('window.location.reload()') + page_module.Page.WaitForPageToLoad(self, tab, 60) tab.WaitForDocumentReadyStateToBeInteractiveOrBetter() diff --git a/tools/telemetry/telemetry/page/actions/tap_element.py b/tools/telemetry/telemetry/page/actions/tap_element.py index f8c669e..f3a4734 100644 --- a/tools/telemetry/telemetry/page/actions/tap_element.py +++ b/tools/telemetry/telemetry/page/actions/tap_element.py @@ -4,6 +4,7 @@ from telemetry.core import exceptions from telemetry.core import util +from telemetry.page import page as page_module from telemetry.page.actions import page_action class TapElementAction(page_action.PageAction): @@ -40,3 +41,5 @@ class TapElementAction(page_action.PageAction): 'window.__tap_event_finished'), 60) else: DoTap() + + page_module.Page.WaitForPageToLoad(self, tab, 60) diff --git a/tools/telemetry/telemetry/page/actions/wait.py b/tools/telemetry/telemetry/page/actions/wait.py index 861c916..d610cd4 100644 --- a/tools/telemetry/telemetry/page/actions/wait.py +++ b/tools/telemetry/telemetry/page/actions/wait.py @@ -14,14 +14,17 @@ class WaitAction(page_action.PageAction): super(WaitAction, self).__init__(attributes) def RunsPreviousAction(self): - return (getattr(self, 'condition', None) == 'navigate' or - getattr(self, 'condition', None) == 'href_change') + assert hasattr(self, 'condition') + return self.condition == 'navigate' or self.condition == 'href_change' def RunAction(self, page, tab, previous_action): - if hasattr(self, 'seconds'): + assert hasattr(self, 'condition') + + if self.condition == 'duration': + assert hasattr(self, 'seconds') time.sleep(self.seconds) - elif getattr(self, 'condition', None) == 'navigate': + elif self.condition == 'navigate': if not previous_action: raise page_action.PageActionFailed('You need to perform an action ' 'before waiting for navigate.') @@ -29,7 +32,7 @@ class WaitAction(page_action.PageAction): action_to_perform = lambda: previous_action.RunAction(page, tab, None) tab.PerformActionAndWaitForNavigate(action_to_perform, self.timeout) - elif getattr(self, 'condition', None) == 'href_change': + 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.') @@ -39,7 +42,7 @@ class WaitAction(page_action.PageAction): util.WaitFor(lambda: tab.EvaluateJavaScript( 'document.location.href') != old_url, self.timeout) - elif getattr(self, 'condition', None) == 'element': + elif self.condition == 'element': if hasattr(self, 'text'): callback_code = 'function(element) { return element != null; }' util.WaitFor( @@ -61,8 +64,7 @@ class WaitAction(page_action.PageAction): else: raise page_action.PageActionFailed( 'No element condition given to wait') - elif hasattr(self, 'javascript'): + elif self.condition == 'javascript': + assert hasattr(self, 'javascript') util.WaitFor(lambda: tab.EvaluateJavaScript(self.javascript), self.timeout) - else: - raise page_action.PageActionFailed('No wait condition found') diff --git a/tools/telemetry/telemetry/page/page.py b/tools/telemetry/telemetry/page/page.py index e572bc2..5d06076 100644 --- a/tools/telemetry/telemetry/page/page.py +++ b/tools/telemetry/telemetry/page/page.py @@ -3,8 +3,10 @@ # found in the LICENSE file. import os import re +import time import urlparse +from telemetry.core import util def _UrlPathJoin(*args): """Joins each path in |args| for insertion into a URL path. @@ -53,7 +55,6 @@ class Page(object): self.credentials = None self.disabled = False self.script_to_evaluate_on_commit = None - self.navigate_steps = {'action': 'navigate'} if attributes: for k, v in attributes.iteritems(): @@ -110,3 +111,30 @@ class Page(object): def __str__(self): return self.url + + def WaitToLoad(self, tab, timeout, poll_interval=0.1): + Page.WaitForPageToLoad(self, tab, timeout, poll_interval) + + # TODO(dtu): Remove this method when no page sets use a click interaction + # with a wait condition. crbug.com/168431 + @staticmethod + def WaitForPageToLoad(obj, tab, timeout, poll_interval=0.1): + """Waits for various wait conditions present in obj.""" + if hasattr(obj, 'wait_seconds'): + time.sleep(obj.wait_seconds) + if hasattr(obj, 'wait_for_element_with_text'): + callback_code = 'function(element) { return element != null; }' + util.WaitFor( + lambda: util.FindElementAndPerformAction( + tab, obj.wait_for_element_with_text, callback_code), + timeout, poll_interval) + if hasattr(obj, 'wait_for_element_with_selector'): + util.WaitFor(lambda: tab.EvaluateJavaScript( + 'document.querySelector(\'' + obj.wait_for_element_with_selector + + '\') != null'), timeout, poll_interval) + if hasattr(obj, 'post_navigate_javascript_to_execute'): + tab.EvaluateJavaScript(obj.post_navigate_javascript_to_execute) + if hasattr(obj, 'wait_for_javascript_expression'): + util.WaitFor( + lambda: tab.EvaluateJavaScript(obj.wait_for_javascript_expression), + timeout, poll_interval) diff --git a/tools/telemetry/telemetry/page/page_runner.py b/tools/telemetry/telemetry/page/page_runner.py index 0277187..e622072 100644 --- a/tools/telemetry/telemetry/page/page_runner.py +++ b/tools/telemetry/telemetry/page/page_runner.py @@ -138,6 +138,7 @@ class PageState(object): else: i = navigate.NavigateAction() i.RunAction(page, tab, None) + page.WaitToLoad(tab, 60) def CleanUpPage(self, page, tab): if page.credentials and self._did_login: diff --git a/tools/telemetry/telemetry/page/page_test.py b/tools/telemetry/telemetry/page/page_test.py index 405a621..e9d7147 100644 --- a/tools/telemetry/telemetry/page/page_test.py +++ b/tools/telemetry/telemetry/page/page_test.py @@ -205,15 +205,22 @@ class PageTest(object): def RunNavigateSteps(self, page, tab): """Navigates the tab to the page URL attribute. - Runs the 'navigate_steps' page attribute as a compound action. + If 'navigate_steps' is defined for the page, this will attempt to + run it as a compound action. """ - navigate_actions = GetCompoundActionFromPage(page, 'navigate_steps') - if not any(isinstance(action, navigate.NavigateAction) - for action in navigate_actions): - raise page_action.PageActionFailed( - 'No NavigateAction in navigate_steps') - - self._RunCompoundAction(page, tab, navigate_actions, False) + if hasattr(page, 'navigate_steps'): + navigate_actions = GetCompoundActionFromPage(page, 'navigate_steps') + if not any(isinstance(action, navigate.NavigateAction) + for action in navigate_actions): + raise page_action.PageActionFailed( + 'No NavigateAction in navigate_steps') + self._RunCompoundAction(page, tab, navigate_actions, False) + else: + # TODO(edmundyan): Make a default navigate_steps action on the page object + # once we can deprecate page.WaitToLoad() + i = navigate.NavigateAction() + i.RunAction(page, tab, None) + page.WaitToLoad(tab, 60) @property def action_name_to_run(self): |