perftest_http3_google_search.js (2278B)
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/. 4 /* eslint-env node */ 5 6 /* 7 Ensure the `--firefox.preference=network.http.http3.enable:true` is 8 set for this test. 9 */ 10 11 async function test(context, commands) { 12 let rootUrl = "https://www.google.com/"; 13 let waitTime = 1000; 14 const driver = context.selenium.driver; 15 const webdriver = context.selenium.webdriver; 16 17 if ( 18 (typeof context.options.browsertime !== "undefined") & 19 (typeof context.options.browsertime.waitTime !== "undefined") 20 ) { 21 waitTime = context.options.browsertime.waitTime; 22 } 23 24 // Make firefox learn of HTTP/3 server 25 await commands.navigate(rootUrl); 26 27 let cycles = 1; 28 for (let cycle = 0; cycle < cycles; cycle++) { 29 await commands.navigate(rootUrl); 30 await commands.wait.byTime(1000); 31 32 // Set up the search 33 context.log.info("Setting up search"); 34 const searchfield = driver.findElement(webdriver.By.name("q")); 35 searchfield.sendKeys("Python\n"); 36 await commands.wait.byTime(5000); 37 38 // Measure the search time 39 context.log.info("Start search"); 40 await commands.measure.start("pageload"); 41 await commands.click.byJs(`document.querySelector("input[name='btnK']")`); 42 await commands.wait.byTime(5000); 43 await commands.measure.stop(); 44 context.log.info("Done"); 45 46 commands.measure.result[0].browserScripts.pageinfo.url = 47 "Google Search (Python)"; 48 49 // Wait for X seconds 50 context.log.info(`Waiting for ${waitTime} milliseconds`); 51 await commands.wait.byTime(waitTime); 52 53 // Go to the next search page and measure 54 context.log.info("Going to second page of search results"); 55 await commands.measure.start("pageload"); 56 await commands.click.byIdAndWait("pnnext"); 57 58 // XXX: Increase wait time when we add latencies 59 await commands.wait.byTime(3000); 60 await commands.measure.stop(); 61 62 commands.measure.result[1].browserScripts.pageinfo.url = 63 "Google Search (Python) - Next Page"; 64 } 65 } 66 67 module.exports = { 68 test, 69 owner: "Network Team", 70 component: "netwerk", 71 name: "g-search", 72 description: "User-journey live site test for google search", 73 };