Best JavaScript code snippet using wpt
document-base-url-initiated-grand-parent.https.window.js
Source:document-base-url-initiated-grand-parent.https.window.js
1// META: script=/common/get-host-info.sub.js2// META: script=/common/utils.js3// META: script=/common/dispatcher/dispatcher.js4const testBaseUriAboutBlankFromGrandParent = (description, child_origin) => {5 promise_test(async test => {6 // Create a child in an iframe.7 const child_token = token();8 const child_url = child_origin +9 '/common/dispatcher/executor.html' +10 `?uuid=${child_token}`;11 const iframe = document.createElement("iframe");12 iframe.src = child_url;13 document.body.appendChild(iframe);14 // The child creates a grand child in an iframe.15 const reply_token = token();16 send(child_token, `17 const iframe = document.createElement("iframe");18 location.hash = "interesting-fragment";19 iframe.src = "/common/blank.html";20 iframe.onload = () => {21 send("${reply_token}", "grand child loaded");22 };23 document.body.appendChild(iframe);24 `);25 assert_equals(await receive(reply_token), "grand child loaded");26 const child = iframe.contentWindow;27 const grandchild = child[0];28 // Navigate the grand-child toward about:blank.29 // Navigation are always asynchronous. It doesn't exist a ways to know the30 // about:blank document committed. A timer is used instead:31 grandchild.location = "about:blank";32 await new Promise(r => test.step_timeout(r, /*ms=*/500));33 // The grandchild baseURI must correspond to its grand parent.34 //35 // Note: `child_token` is removed, to get a stable failure, in case the36 // about:blank's document.baseURI reports the parent's URL instead of its37 // grand-parent.38 assert_equals(39 grandchild.document.baseURI.replace(child_token, "child_token"),40 self.document.baseURI);41 }, description);42}43onload = () => {44 testBaseUriAboutBlankFromGrandParent(45 "Check the baseURL of an about:blank document same-origin with its parent",46 get_host_info().HTTPS_ORIGIN,47 );48 testBaseUriAboutBlankFromGrandParent(49 "Check the baseURL of an about:blank document cross-origin with its parent",50 get_host_info().HTTPS_REMOTE_ORIGIN,51 );52 testBaseUriAboutBlankFromGrandParent(53 "Check the baseURL of an about:blank document cross-site with its parent",54 get_host_info().HTTPS_NOTSAMESITE_ORIGIN,55 );...
deploy.js
Source:deploy.js
1// We require the Hardhat Runtime Environment explicitly here. This is optional2// but useful for running the script in a standalone fashion through `node <script>`.3//4// When running the script with `npx hardhat run <script>` you'll find the Hardhat5// Runtime Environment's members available in the global scope.6const hre = require("hardhat");7async function main() {8 // Hardhat always runs the compile task when running scripts with its command9 // line interface.10 //11 // If this script is run directly using `node` you may want to call compile12 // manually to make sure everything is compiled13 // await hre.run('compile');14 // We get the contract to deploy15 // // Deploy USDT contract16 // const MainToken = await hre.ethers.getContractFactory("USDT");17 // const main_token = await MainToken.deploy("EXL-USD", "USDT", 18, 5000);18 // await main_token.deployed();19 // console.log("USDT contract address: " + main_token.address);20 // // Deploy MainBridge contract21 // const MainBrige = await hre.ethers.getContractFactory("MainBridge");22 // const main_bridge = await MainBrige.deploy(main_token.address);23 // await main_bridge.deployed();24 // console.log("MainBridge contract address: " + main_bridge.address);25 // Deploy USDT contract26 const ChildToken = await hre.ethers.getContractFactory("USDT");27 const child_token = await ChildToken.deploy("EXL-USD", "R.USDT", 18, 4000);28 await child_token.deployed();29 console.log("R.USDT contract address: " + child_token.address);30 // Deploy MainBridge contract31 const ChildBridge = await hre.ethers.getContractFactory("ChildBridge");32 const child_bridge = await Greeter1.deploy(child_token.address);33 await child_bridge.deployed();34 console.log("ChildBridge contract address: " + child_bridge.address);35}36// We recommend this pattern to be able to use async/await everywhere37// and properly handle errors.38main()39 .then(() => process.exit(0))40 .catch((error) => {41 console.error(error);42 process.exit(1);...
Using AI Code Generation
1var WebPageTest = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.5b5e5f5e5e5e5e5e5e5e5e5e5e5e5e5');3wpt.getLocations(function(err, data) {4 console.log(data);5});6}, function(err, data) {7 console.log(data);8});9}, function(err, data) {10 console.log(data);11});12wpt.childToken(function(err, data) {13 console.log(data);14});
Using AI Code Generation
1var wptools = require('wptools');2wptools.child_token('en','Adele',function(err,resp,html){3 if (!err){4 console.log(html);5 }6});7* `lang` - Wikipedia language code (e.g. `en`, `fr`, `de`, `es`, `it`, `ru`, `ja`, `pt`, `nl`, `pl`, `zh`, `sv`, `vi`, `war`, `uk`, `no`, `fa`, `ceb`, `ca`, `ar`, `cs`, `ko`, `fi`, `hu`, `id`, `ms`, `ro`, `sk`, `sr`, `tr`, `eu`, `eo`, `da`, `he`, `lt`, `bg`, `hr`, `sl`, `et`, `gl`, `nn`, `uz`, `el`, `th`, `la`, `hy`, `ka`, `new`, `be`, `hi`, `mk`, `te`, `ta`, `ml`, `bn`, `sq`, `is`, `jv`, `sw`, `az`, `tt`, `cy`, `lv`, `bs`, `tg`, `mr`, `my`, `pms`, `lb`, `br`, `ht`, `ga`, `oc`, `af`, `an`, `ast`, `bar`, `co`, `cv`, `ga`, `ia`, `nds`, `scn`, `sco`, `simple`, `vec`, `wuu`, `yi`, `zh-min-nan`, `bat-smg`, `be-x-old`, `zh-yue`)8* `title` - Wikipedia page title (e.g. `Adele`, `New York City`, `United States`)9 * `redirect` - follow redirects (default: true)10 * `follow` - follow redirects and get the final page (default: false)11 * `language` - language to use for templates (default: `lang`)12 * `mainpage` - title of the main page (default: `title`)13 * `mobile` - use the mobile version of Wikipedia (default: true)
Using AI Code Generation
1var wpt = require('webpagetest');2var util = require('util');3var wpt = new WebPageTest('www.webpagetest.org','A.3f0b2d0e6c1b1e8d6b8e0b9f9c4b0d72');4var child_token = null;5wpt.childToken(function(err,data){6 if (err) console.log(err);7 else {8 console.log(util.inspect(data));9 child_token = data;10 console.log(child_token);11 }12});13var wpt = require('webpagetest');14var util = require('util');15var wpt = new WebPageTest('www.webpagetest.org','A.3f0b2d0e6c1b1e8d6b8e0b9f9c4b0d72');16var child_token = null;17wpt.childToken(function(err,data){18 if (err) console.log(err);19 else {20 console.log(util.inspect(data));21 child_token = data;22 console.log(child_token);23 }24});25var wpt = require('webpagetest');26var util = require('util');27var wpt = new WebPageTest('www.webpagetest.org','A.3f0b2d0e6c1b1e8d6b8e0b9f9c4b0d72');28var child_token = null;29wpt.childToken(function(err,data){30 if (err) console.log(err);31 else {32 console.log(util.inspect(data));33 child_token = data;34 console.log(child_token);35 }36});37var wpt = require('webpagetest');38var util = require('util');
Using AI Code Generation
1var wpt = require('webpagetest');2var options = {3};4var wpt = new WebPageTest('www.webpagetest.org', 'A.8f7a1c1b75a9f9c9b2c3f3d3f1e1e1e1');5 if (err) return console.error(err);6 console.log('Test status:', data.statusText);7 console.log('Test ID:', data.data.testId);8 console.log('Test URL:', data.data.summary);9 console.log('Test results:', data.data.userUrl);10});11var wpt = require('webpagetest');12var options = {13};14var wpt = new WebPageTest('www.webpagetest.org', 'A.8f7a1c1b75a9f9c9b2c3f3d3f1e1e1e1');15 if (err) return console.error(err);16 console.log('Test status:', data.statusText);17 console.log('Test ID:', data.data.testId);18 console.log('Test URL:', data.data.summary);19 console.log('Test results:', data.data.userUrl);20});
Using AI Code Generation
1var request = require('request');2var fs = require('fs');3var child_token = require('./child_token.js');4var run_test = require('./run_test.js');5child_token.get_child_token(function(child_token){6 run_test.run_test(child_token, function(test_id){7 console.log(test_id);8 });9});
Using AI Code Generation
1var wpt = require('./wpt.js');2var wpt = new WebPageTest('www.webpagetest.org', 'A.3f0f1e8e9d9e2b2f2b2d8b8f0d8f0e8e');3wpt.child_token('www.webpagetest.org', 'A.3f0f1e8e9d9e2b2f2b2d8b8f0d8f0e8e', function(data) {4 console.log(data);5});6var wpt = require('./wpt.js');7var wpt = new WebPageTest('www.webpagetest.org', 'A.3f0f1e8e9d9e2b2f2b2d8b8f0d8f0e8e');8wpt.getLocations(function(data) {9 console.log(data);10});11var wpt = require('./wpt.js');12var wpt = new WebPageTest('www.webpagetest.org', 'A.3f0f1e8e9d9e2b2f2b2d8b8f0d8f0e8e');13wpt.getTesters(function(data) {14 console.log(data);15});16var wpt = require('./wpt.js');17var wpt = new WebPageTest('www.webpagetest.org');18wpt.getTestStatus('151114_1S_1c9a9a5a5a5a5a5a5a5a5a5a5a5a5a5a', function(data) {19 console.log(data);20});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!