1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 async function pageload_test(context, commands) {
8 let testUrl = context.options.browsertime.url;
9 let secondaryUrl = context.options.browsertime.secondary_url;
10 let testName = context.options.browsertime.testName;
12 // Wait for browser to settle
13 await commands.wait.byTime(1000);
15 await commands.measure.start(testUrl);
16 commands.screenshot.take("test_url_" + testName);
18 if (secondaryUrl !== null) {
19 // Wait for browser to settle
20 await commands.wait.byTime(1000);
22 await commands.measure.start(secondaryUrl);
23 commands.screenshot.take("secondary_url_" + testName);
26 // Wait for browser to settle
27 await commands.wait.byTime(1000);
30 async function get_command_function(cmd, commands) {
32 Converts a string such as `measure.start` into the actual
33 function that is found in the `commands` module.
35 XXX: Find a way to share this function between
36 perftest_record.js and browsertime_interactive.js
39 throw new Error("A blank command was given.");
40 } else if (cmd.endsWith(".")) {
42 "An extra `.` was found at the end of this command: " + cmd
46 // `func` will hold the actual method that needs to be called,
47 // and the `parent_mod` is the context required to run the `func`
48 // method. Without that context, `this` becomes undefined in the browsertime
51 let parent_mod = null;
52 for (let func_part of cmd.split(".")) {
53 if (func_part == "") {
55 "An empty function part was found in the command: " + cmd
60 parent_mod = commands;
61 func = commands[func_part];
62 } else if (func !== undefined) {
64 func = func[func_part];
70 if (func == undefined) {
72 "The given command could not be found as a function: " + cmd
76 return [func, parent_mod];
79 async function interactive_test(input_cmds, context, commands) {
80 let cmds = input_cmds.split(";;;");
82 await commands.navigate("about:blank");
84 for (let cmdstr of cmds) {
85 let [cmd, ...args] = cmdstr.split(":::");
86 let [func, parent_mod] = await get_command_function(cmd, commands);
89 await func.call(parent_mod, ...args);
92 `Exception found while running \`commands.${cmd}(${args})\`: ` + e
98 async function test(context, commands) {
99 let input_cmds = context.options.browsertime.commands;
101 await interactive_test(input_cmds, context, commands);
103 await pageload_test(context, commands);
110 owner: "Bebe fstrugariu@mozilla.com",
111 name: "Mozproxy recording generator",
113 description: ` This test generates fresh MozProxy recordings. It iterates through a list of
114 websites provided in *_sites.json and for each one opens a browser and
115 records all the associated HTTP traffic`,
117 "mach perftest --proxy --hooks testing/raptor/recorder/hooks.py testing/raptor/recorder/perftest_record.js",