# Pastebin GI83y0lT # HG changeset patch # User Gregory Mierzwinski # Date 1556231949 14400 # Thu Apr 25 18:39:09 2019 -0400 # Node ID c5916eb3302b1cefdc0ddef41c4267cf0823839c # Parent 0ec836eceb969c548067cee6de2ea213513a43d5 Raptor power usage tests. diff --git a/testing/raptor/raptor/raptor.ini b/testing/raptor/raptor/raptor.ini --- a/testing/raptor/raptor/raptor.ini +++ b/testing/raptor/raptor/raptor.ini @@ -58,3 +58,6 @@ [include:tests/raptor-wasm-misc-ion.ini] [include:tests/raptor-wasm-misc-cranelift.ini] [include:tests/raptor-webaudio.ini] + +# raptor resource tests +[include:tests/raptor-res-power-dark.ini] diff --git a/testing/raptor/raptor/tests/raptor-res-power-dark.ini b/testing/raptor/raptor/tests/raptor-res-power-dark.ini new file mode 100644 --- /dev/null +++ b/testing/raptor/raptor/tests/raptor-res-power-dark.ini @@ -0,0 +1,18 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# power-usage/resource-measurement for Firefox on Android + +[DEFAULT] +type = resource +test_url = about:blank +measure = fakeMeasure +unit = fakeUnit +page_cycles = 1 +page_timeout = 30000 +lower_is_better = true +alert_threshold = 2.0 + +[raptor-res-power-dark-geckoview] +apps = geckoview diff --git a/testing/raptor/raptor/tests/raptor-res-power-idle.ini b/testing/raptor/raptor/tests/raptor-res-power-idle.ini new file mode 100644 --- /dev/null +++ b/testing/raptor/raptor/tests/raptor-res-power-idle.ini @@ -0,0 +1,18 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# power-usage/resource-measurement for Firefox on Android + +[DEFAULT] +type = resource +test_url = about:blank +measure = fakeMeasure +unit = fakeUnit +page_cycles = 1 +page_timeout = 30000 +lower_is_better = true +alert_threshold = 2.0 + +[raptor-res-power-dark-geckoview] +apps = geckoview diff --git a/testing/raptor/raptor/tests/resource-tests/browser-baseline.html b/testing/raptor/raptor/tests/resource-tests/browser-baseline.html new file mode 100644 --- /dev/null +++ b/testing/raptor/raptor/tests/resource-tests/browser-baseline.html @@ -0,0 +1,1 @@ + \ No newline at end of file diff --git a/testing/raptor/webext/raptor/manifest.json b/testing/raptor/webext/raptor/manifest.json --- a/testing/raptor/webext/raptor/manifest.json +++ b/testing/raptor/webext/raptor/manifest.json @@ -63,6 +63,11 @@ "*://*/assorted-dom/assorted/results.html*"], "js": ["benchmark-relay.js"], "run_at": "document_end" + }, + { + "matches": ["*about:blank"], + "js": ["resource.js"], + "run_at": "document_end" } ], "browser_action": { diff --git a/testing/raptor/webext/raptor/resource.js b/testing/raptor/webext/raptor/resource.js new file mode 100644 --- /dev/null +++ b/testing/raptor/webext/raptor/resource.js @@ -0,0 +1,25 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +var testType = "resource"; + +// receives result from resource tests onto our background runner + +function resourceMain() { + console.log("res: Waiting for 30 seconds..."); + setTimeout(sendMessage(testType, "res_load_success"), 30000); +} + +function sendMessage(_type, _value) { + // send result back to background runner script + console.log(`sending message back to runner: ${_type} ${_value}`); + chrome.runtime.sendMessage({"type": _type, "value": _value}, function(response) { + if (response !== undefined) { + console.log(response.text); + } + }); +} + +console.log("raptor resource content loaded"); +window.addEventListener("load", resourceMain); diff --git a/testing/raptor/webext/raptor/runner.js b/testing/raptor/webext/raptor/runner.js --- a/testing/raptor/webext/raptor/runner.js +++ b/testing/raptor/webext/raptor/runner.js @@ -18,6 +18,7 @@ // Supported test types const TEST_BENCHMARK = "benchmark"; const TEST_PAGE_LOAD = "pageload"; +const TEST_RESOURCE = "resource"; // when the browser starts this webext runner will start automatically; we // want to give the browser some time (ms) to settle before starting tests @@ -56,6 +57,7 @@ var isFCPPending = false; var isDCFPending = false; var isTTFIPending = false; var isLoadTimePending = false; +var isResLoadPending = false; var isBenchmarkPending = false; var pageTimeout = 10000; // default pageload timeout var geckoProfiling = false; @@ -283,6 +285,12 @@ function waitForResult() { setTimeout(checkForResult, 5); } break; + case TEST_RESOURCE: + if (!isResLoadPending) { + cancelTimeoutAlarm("raptor-page-timeout"); + postToControlServer("status", "resource load message received"); + } + break; } } checkForResult(); @@ -395,8 +403,13 @@ async function nextCycle() { if (getLoadTime) isLoadTimePending = true; break; + + case TEST_RESOURCE: + isResLoadPending = true; + break; } + if (reuseTab && testTabID != 0) { // close previous test tab ext.tabs.remove(testTabID); @@ -487,6 +500,7 @@ function resultListener(request, sender, case TEST_BENCHMARK: // benchmark results received (all results for that complete benchmark run) console.log("received results from benchmark"); + postToControlServer("status", request.value) results.measurements[request.type].push(request.value); isBenchmarkPending = false; break; @@ -521,6 +535,14 @@ function resultListener(request, sender, isLoadTimePending = false; } break; + + case TEST_RESOURCE: + console.log("received message from resource content"); + if (request.type == "res_load_success") { + console.log("resource load sucess"); + results.measurements["resource"].push(0) + isResLoadPending = false; + } } } else { console.log(`unknown message received from content: ${request}`);