Best JavaScript code snippet using wpt
redirect-referrer.js
Source:redirect-referrer.js
1if (this.document === undefined) {2 importScripts("/common/utils.js");3 importScripts("/resources/testharness.js");4 importScripts("../resources/utils.js");5 importScripts("/common/get-host-info.sub.js");6}7function testReferrerAfterRedirection(desc, redirectUrl, redirectLocation, referrerPolicy, redirectReferrerPolicy, expectedReferrer) {8 var url = redirectUrl;9 var urlParameters = "?location=" + encodeURIComponent(redirectLocation);10 if (redirectReferrerPolicy)11 urlParameters += "&redirect_referrerpolicy=" + redirectReferrerPolicy;12 var requestInit = {"redirect": "follow", "referrerPolicy": referrerPolicy};13 promise_test(function(test) {14 return fetch(url + urlParameters, requestInit).then(function(response) {15 assert_equals(response.status, 200, "Inspect header response's status is 200");16 assert_equals(response.headers.get("x-request-referer"), expectedReferrer ? expectedReferrer : null, "Check referrer header");17 });18 }, desc);19}20var referrerOrigin = get_host_info().HTTP_ORIGIN + "/";21var referrerUrl = location.href;22var redirectUrl = RESOURCES_DIR + "redirect.py";23var locationUrl = get_host_info().HTTP_ORIGIN + dirname(location.pathname) + RESOURCES_DIR + "inspect-headers.py?headers=referer";24var crossLocationUrl = get_host_info().HTTP_REMOTE_ORIGIN + dirname(location.pathname) + RESOURCES_DIR + "inspect-headers.py?cors&headers=referer";25testReferrerAfterRedirection("Same origin redirection, empty init, unsafe-url redirect header ", redirectUrl, locationUrl, "", "unsafe-url", referrerUrl);26testReferrerAfterRedirection("Same origin redirection, empty init, no-referrer-when-downgrade redirect header ", redirectUrl, locationUrl, "", "no-referrer-when-downgrade", referrerUrl);27testReferrerAfterRedirection("Same origin redirection, empty init, same-origin redirect header ", redirectUrl, locationUrl, "", "same-origin", referrerUrl);28testReferrerAfterRedirection("Same origin redirection, empty init, origin redirect header ", redirectUrl, locationUrl, "", "origin", referrerOrigin);29testReferrerAfterRedirection("Same origin redirection, empty init, origin-when-cross-origin redirect header ", redirectUrl, locationUrl, "", "origin-when-cross-origin", referrerUrl);30testReferrerAfterRedirection("Same origin redirection, empty init, no-referrer redirect header ", redirectUrl, locationUrl, "", "no-referrer", null);31testReferrerAfterRedirection("Same origin redirection, empty init, strict-origin redirect header ", redirectUrl, locationUrl, "", "strict-origin", referrerOrigin);32testReferrerAfterRedirection("Same origin redirection, empty init, strict-origin-when-cross-origin redirect header ", redirectUrl, locationUrl, "", "strict-origin-when-cross-origin", referrerUrl);33testReferrerAfterRedirection("Same origin redirection, empty redirect header, unsafe-url init ", redirectUrl, locationUrl, "unsafe-url", "", referrerUrl);34testReferrerAfterRedirection("Same origin redirection, empty redirect header, no-referrer-when-downgrade init ", redirectUrl, locationUrl, "no-referrer-when-downgrade", "", referrerUrl);35testReferrerAfterRedirection("Same origin redirection, empty redirect header, same-origin init ", redirectUrl, locationUrl, "same-origin", "", referrerUrl);36testReferrerAfterRedirection("Same origin redirection, empty redirect header, origin init ", redirectUrl, locationUrl, "origin", "", referrerOrigin);37testReferrerAfterRedirection("Same origin redirection, empty redirect header, origin-when-cross-origin init ", redirectUrl, locationUrl, "origin-when-cross-origin", "", referrerUrl);38testReferrerAfterRedirection("Same origin redirection, empty redirect header, no-referrer init ", redirectUrl, locationUrl, "no-referrer", "", null);39testReferrerAfterRedirection("Same origin redirection, empty redirect header, strict-origin init ", redirectUrl, locationUrl, "strict-origin", "", referrerOrigin);40testReferrerAfterRedirection("Same origin redirection, empty redirect header, strict-origin-when-cross-origin init ", redirectUrl, locationUrl, "strict-origin-when-cross-origin", "", referrerUrl);41testReferrerAfterRedirection("Cross origin redirection, empty init, unsafe-url redirect header ", redirectUrl, crossLocationUrl, "", "unsafe-url", referrerUrl);42testReferrerAfterRedirection("Cross origin redirection, empty init, no-referrer-when-downgrade redirect header ", redirectUrl, crossLocationUrl, "", "no-referrer-when-downgrade", referrerUrl);43testReferrerAfterRedirection("Cross origin redirection, empty init, same-origin redirect header ", redirectUrl, crossLocationUrl, "", "same-origin", null);44testReferrerAfterRedirection("Cross origin redirection, empty init, origin redirect header ", redirectUrl, crossLocationUrl, "", "origin", referrerOrigin);45testReferrerAfterRedirection("Cross origin redirection, empty init, origin-when-cross-origin redirect header ", redirectUrl, crossLocationUrl, "", "origin-when-cross-origin", referrerOrigin);46testReferrerAfterRedirection("Cross origin redirection, empty init, no-referrer redirect header ", redirectUrl, crossLocationUrl, "", "no-referrer", null);47testReferrerAfterRedirection("Cross origin redirection, empty init, strict-origin redirect header ", redirectUrl, crossLocationUrl, "", "strict-origin", referrerOrigin);48testReferrerAfterRedirection("Cross origin redirection, empty init, strict-origin-when-cross-origin redirect header ", redirectUrl, crossLocationUrl, "", "strict-origin-when-cross-origin", referrerOrigin);49testReferrerAfterRedirection("Cross origin redirection, empty redirect header, unsafe-url init ", redirectUrl, crossLocationUrl, "unsafe-url", "", referrerUrl);50testReferrerAfterRedirection("Cross origin redirection, empty redirect header, no-referrer-when-downgrade init ", redirectUrl, crossLocationUrl, "no-referrer-when-downgrade", "", referrerUrl);51testReferrerAfterRedirection("Cross origin redirection, empty redirect header, same-origin init ", redirectUrl, crossLocationUrl, "same-origin", "", null);52testReferrerAfterRedirection("Cross origin redirection, empty redirect header, origin init ", redirectUrl, crossLocationUrl, "origin", "", referrerOrigin);53testReferrerAfterRedirection("Cross origin redirection, empty redirect header, origin-when-cross-origin init ", redirectUrl, crossLocationUrl, "origin-when-cross-origin", "", referrerOrigin);54testReferrerAfterRedirection("Cross origin redirection, empty redirect header, no-referrer init ", redirectUrl, crossLocationUrl, "no-referrer", "", null);55testReferrerAfterRedirection("Cross origin redirection, empty redirect header, strict-origin init ", redirectUrl, crossLocationUrl, "strict-origin", "", referrerOrigin);56testReferrerAfterRedirection("Cross origin redirection, empty redirect header, strict-origin-when-cross-origin init ", redirectUrl, crossLocationUrl, "strict-origin-when-cross-origin", "", referrerOrigin);...
redirect-referrer.any.js
Source:redirect-referrer.any.js
1// META: timeout=long2// META: script=/common/utils.js3// META: script=../resources/utils.js4// META: script=/common/get-host-info.sub.js5function testReferrerAfterRedirection(desc, redirectUrl, redirectLocation, referrerPolicy, redirectReferrerPolicy, expectedReferrer) {6 var url = redirectUrl;7 var urlParameters = "?location=" + encodeURIComponent(redirectLocation);8 if (redirectReferrerPolicy)9 urlParameters += "&redirect_referrerpolicy=" + redirectReferrerPolicy;10 var requestInit = {"redirect": "follow", "referrerPolicy": referrerPolicy};11 promise_test(function(test) {12 return fetch(url + urlParameters, requestInit).then(function(response) {13 assert_equals(response.status, 200, "Inspect header response's status is 200");14 assert_equals(response.headers.get("x-request-referer"), expectedReferrer ? expectedReferrer : null, "Check referrer header");15 });16 }, desc);17}18var referrerOrigin = get_host_info().HTTP_ORIGIN + "/";19var referrerUrl = location.href;20var redirectUrl = RESOURCES_DIR + "redirect.py";21var locationUrl = get_host_info().HTTP_ORIGIN + dirname(location.pathname) + RESOURCES_DIR + "inspect-headers.py?headers=referer";22var crossLocationUrl = get_host_info().HTTP_REMOTE_ORIGIN + dirname(location.pathname) + RESOURCES_DIR + "inspect-headers.py?cors&headers=referer";23testReferrerAfterRedirection("Same origin redirection, empty init, unsafe-url redirect header ", redirectUrl, locationUrl, "", "unsafe-url", referrerUrl);24testReferrerAfterRedirection("Same origin redirection, empty init, no-referrer-when-downgrade redirect header ", redirectUrl, locationUrl, "", "no-referrer-when-downgrade", referrerUrl);25testReferrerAfterRedirection("Same origin redirection, empty init, same-origin redirect header ", redirectUrl, locationUrl, "", "same-origin", referrerUrl);26testReferrerAfterRedirection("Same origin redirection, empty init, origin redirect header ", redirectUrl, locationUrl, "", "origin", referrerOrigin);27testReferrerAfterRedirection("Same origin redirection, empty init, origin-when-cross-origin redirect header ", redirectUrl, locationUrl, "", "origin-when-cross-origin", referrerUrl);28testReferrerAfterRedirection("Same origin redirection, empty init, no-referrer redirect header ", redirectUrl, locationUrl, "", "no-referrer", null);29testReferrerAfterRedirection("Same origin redirection, empty init, strict-origin redirect header ", redirectUrl, locationUrl, "", "strict-origin", referrerOrigin);30testReferrerAfterRedirection("Same origin redirection, empty init, strict-origin-when-cross-origin redirect header ", redirectUrl, locationUrl, "", "strict-origin-when-cross-origin", referrerUrl);31testReferrerAfterRedirection("Same origin redirection, empty redirect header, unsafe-url init ", redirectUrl, locationUrl, "unsafe-url", "", referrerUrl);32testReferrerAfterRedirection("Same origin redirection, empty redirect header, no-referrer-when-downgrade init ", redirectUrl, locationUrl, "no-referrer-when-downgrade", "", referrerUrl);33testReferrerAfterRedirection("Same origin redirection, empty redirect header, same-origin init ", redirectUrl, locationUrl, "same-origin", "", referrerUrl);34testReferrerAfterRedirection("Same origin redirection, empty redirect header, origin init ", redirectUrl, locationUrl, "origin", "", referrerOrigin);35testReferrerAfterRedirection("Same origin redirection, empty redirect header, origin-when-cross-origin init ", redirectUrl, locationUrl, "origin-when-cross-origin", "", referrerUrl);36testReferrerAfterRedirection("Same origin redirection, empty redirect header, no-referrer init ", redirectUrl, locationUrl, "no-referrer", "", null);37testReferrerAfterRedirection("Same origin redirection, empty redirect header, strict-origin init ", redirectUrl, locationUrl, "strict-origin", "", referrerOrigin);38testReferrerAfterRedirection("Same origin redirection, empty redirect header, strict-origin-when-cross-origin init ", redirectUrl, locationUrl, "strict-origin-when-cross-origin", "", referrerUrl);39testReferrerAfterRedirection("Cross origin redirection, empty init, unsafe-url redirect header ", redirectUrl, crossLocationUrl, "", "unsafe-url", referrerUrl);40testReferrerAfterRedirection("Cross origin redirection, empty init, no-referrer-when-downgrade redirect header ", redirectUrl, crossLocationUrl, "", "no-referrer-when-downgrade", referrerUrl);41testReferrerAfterRedirection("Cross origin redirection, empty init, same-origin redirect header ", redirectUrl, crossLocationUrl, "", "same-origin", null);42testReferrerAfterRedirection("Cross origin redirection, empty init, origin redirect header ", redirectUrl, crossLocationUrl, "", "origin", referrerOrigin);43testReferrerAfterRedirection("Cross origin redirection, empty init, origin-when-cross-origin redirect header ", redirectUrl, crossLocationUrl, "", "origin-when-cross-origin", referrerOrigin);44testReferrerAfterRedirection("Cross origin redirection, empty init, no-referrer redirect header ", redirectUrl, crossLocationUrl, "", "no-referrer", null);45testReferrerAfterRedirection("Cross origin redirection, empty init, strict-origin redirect header ", redirectUrl, crossLocationUrl, "", "strict-origin", referrerOrigin);46testReferrerAfterRedirection("Cross origin redirection, empty init, strict-origin-when-cross-origin redirect header ", redirectUrl, crossLocationUrl, "", "strict-origin-when-cross-origin", referrerOrigin);47testReferrerAfterRedirection("Cross origin redirection, empty redirect header, unsafe-url init ", redirectUrl, crossLocationUrl, "unsafe-url", "", referrerUrl);48testReferrerAfterRedirection("Cross origin redirection, empty redirect header, no-referrer-when-downgrade init ", redirectUrl, crossLocationUrl, "no-referrer-when-downgrade", "", referrerUrl);49testReferrerAfterRedirection("Cross origin redirection, empty redirect header, same-origin init ", redirectUrl, crossLocationUrl, "same-origin", "", null);50testReferrerAfterRedirection("Cross origin redirection, empty redirect header, origin init ", redirectUrl, crossLocationUrl, "origin", "", referrerOrigin);51testReferrerAfterRedirection("Cross origin redirection, empty redirect header, origin-when-cross-origin init ", redirectUrl, crossLocationUrl, "origin-when-cross-origin", "", referrerOrigin);52testReferrerAfterRedirection("Cross origin redirection, empty redirect header, no-referrer init ", redirectUrl, crossLocationUrl, "no-referrer", "", null);53testReferrerAfterRedirection("Cross origin redirection, empty redirect header, strict-origin init ", redirectUrl, crossLocationUrl, "strict-origin", "", referrerOrigin);54testReferrerAfterRedirection("Cross origin redirection, empty redirect header, strict-origin-when-cross-origin init ", redirectUrl, crossLocationUrl, "strict-origin-when-cross-origin", "", referrerOrigin);...
dashboard.component.ts
Source:dashboard.component.ts
1import { Component, OnInit } from '@angular/core';2import { TokenStorageService } from '../services/token-storage.service';3@Component({4 selector: 'app-dashboard',5 templateUrl: './dashboard.component.html',6 styleUrls: ['./dashboard.component.css'],7})8export class DashboardComponent implements OnInit {9 // displayDashboard :any ;10 displayDashboard = [11 {12 title: 'Appointments',13 icon: 'local_hospital',14 redirectUrl: '/appointments',15 },16 {17 title: 'Records',18 icon: 'description',19 redirectUrl: '/records',20 },21 {22 title: 'User Profile',23 icon: 'person',24 redirectUrl: '/patients',25 },26 {27 title: 'Reports',28 icon: 'description',29 redirectUrl: '/reports',30 },31 {32 title: 'Payments',33 icon: 'payment',34 redirectUrl: '/payment',35 },36 {37 title: 'Insurance',38 icon: 'favorite',39 redirectUrl: '/insurance',40 },41 {42 title: 'Diagnosis',43 icon: 'storage',44 redirectUrl: '/diagnosis',45 },46 {47 title: 'Prescription',48 icon: 'description',49 redirectUrl: '/prescription',50 },51 {52 title: 'Chatbot',53 icon: 'chat',54 redirectUrl: '/chat',55 }56 ];57 hospitalStaffDashboard = [58 {59 title: 'Appointments',60 icon: 'local_hospital',61 redirectUrl: '/appointments',62 },63 {64 title: 'Records',65 icon: 'description',66 redirectUrl: '/records',67 },68 {69 title: 'User Profile',70 icon: 'person',71 redirectUrl: '/patients',72 },73 {74 title: 'Reports',75 icon: 'description',76 redirectUrl: '/reports',77 },78 {79 title: 'Payments',80 icon: 'payment',81 redirectUrl: '/payment',82 },83 {84 title: 'Diagnosis',85 icon: 'storage',86 redirectUrl: '/diagnosis',87 },88 {89 title: 'Prescription',90 icon: 'description',91 redirectUrl: '/prescription',92 }93 ];94 doctorDashBoard = [95 {96 title: 'Appointments',97 icon: 'local_hospital',98 redirectUrl: '/appointments',99 },100 // {101 // title: 'Records',102 // icon: 'description',103 // redirectUrl: '/records',104 // },105 {106 title: 'User Profile',107 icon: 'person',108 redirectUrl: '/patients',109 },110 {111 title: 'Reports',112 icon: 'description',113 redirectUrl: '/reports',114 },115 // {116 // title: 'Diagnosis',117 // icon: 'storage',118 // redirectUrl: '/diagnosis',119 // },120 // {121 // title: 'Prescription',122 // icon: 'description',123 // redirectUrl: '/prescription',124 // }125 ];126 labStaffDashBoard = [127 {128 title: 'Lab Requests',129 icon: '',130 redirectUrl: '/lab-request',131 },132 {133 title: 'Reports',134 icon: 'description',135 redirectUrl: '/reports',136 },137 {138 title: 'Diagnosis',139 icon: 'storage',140 redirectUrl: '/diagnosis',141 }142 ];143 insuranceStaffDashBoard = [144 {145 title: 'InsuranceStaff',146 icon: 'person_outline',147 redirectUrl: '/insurancestaff'148 }149 ];150 adminStaffDashboard = [151 152 {153 title: 'Registration',154 icon: 'person',155 redirectUrl: '/admin-registration'156 },157 {158 title: 'Profiles',159 icon: 'person',160 redirectUrl: '/all-users',161 },162 {163 title: 'Pending Transactions',164 icon: 'payment',165 redirectUrl: '/payment',166 },167 {168 title: 'Appointments',169 icon: 'local_hospital',170 redirectUrl: '/appointments',171 },172 {173 title: 'Records',174 icon: 'description',175 redirectUrl: '/records',176 },177 {178 title: 'User Profile',179 icon: 'person',180 redirectUrl: '/patients',181 },182 {183 title: 'Reports',184 icon: 'description',185 redirectUrl: '/reports',186 },187 {188 title: 'Diagnosis',189 icon: 'storage',190 redirectUrl: '/diagnosis',191 },192 {193 title: 'Prescription',194 icon: 'description',195 redirectUrl: '/prescription',196 }197 ]198 constructor(private tokenStorageService: TokenStorageService) {}199 ngOnInit(): void {200 if(this.tokenStorageService.getUser().roles && this.tokenStorageService.getUser().roles.includes('ROLE_DOCTOR')){201 this.displayDashboard = this.doctorDashBoard;202 }203 if(this.tokenStorageService.getUser().roles && this.tokenStorageService.getUser().roles.includes('ROLE_HOSPITALSTAFF')){204 this.displayDashboard = this.hospitalStaffDashboard;205 }206 if(this.tokenStorageService.getUser().roles && this.tokenStorageService.getUser().roles.includes('ROLE_LABSTAFF')){207 this.displayDashboard = this.labStaffDashBoard;208 }209 if(this.tokenStorageService.getUser().roles && this.tokenStorageService.getUser().roles.includes('ROLE_INSURANCESTAFF')){210 this.displayDashboard = this.insuranceStaffDashBoard;211 }212 if(this.tokenStorageService.getUser().roles && this.tokenStorageService.getUser().roles.includes('ROLE_ADMIN')){213 this.displayDashboard = this.adminStaffDashboard;214 }215 }216 navigate(){217 // this.router.navigate(['/app-appointment'])218 }...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 wpt.getTestResults(data.data.testId, function(err, data) {5 if (err) return console.error(err);6 console.log(data.data.summary);7 });8});9{ loadTime: 0,10 rumSpeedIndex: 0 }11var wpt = require('webpagetest');12var wpt = new WebPageTest('www.webpagetest.org');13 if (err) return console.error(err);14 wpt.getTestResults(data.data.testId, function(err, data) {15 if (err) return console.error(err);16 console.log(data.data.summary);17 });18});19{ loadTime: 0,
Using AI Code Generation
1var wpt = require('webpagetest');2var client = wpt('www.webpagetest.org');3client.runTest(url, { location: 'Dulles:Chrome', firstViewOnly: true }, function (err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 client.redirectUrl(data.data.runs[1].firstView.results, function (err, data) {9 if (err) {10 console.log(err);11 } else {12 console.log(data);13 }14 });15 }16});17### getLocations(callback)18var wpt = require('webpagetest');19var client = wpt('www.webpagetest.org');20client.getLocations(function (err, data) {21 if (err) {22 console.log(err);23 } else {24 console.log(data);25 }26});27### getLocation(location, callback)28var wpt = require('webpagetest');29var client = wpt('www.webpagetest.org');30client.getLocation('Dulles:Chrome', function (err, data) {31 if (err) {32 console.log(err);33 } else {34 console.log(data);35 }36});37### getTesters(callback)38var wpt = require('webpagetest');39var client = wpt('www.webpagetest.org');40client.getTesters(function (err, data) {41 if (err) {42 console.log(err);43 } else {44 console.log(data);45 }46});47### getTestStatus(testId, callback)48var wpt = require('webpagetest');49var client = wpt('www.webpagetest.org');
Using AI Code Generation
1var wptoolkit = require("wptoolkit");2 if (err) {3 return console.error(err);4 }5 console.log(url);6});7var wptoolkit = require("wptoolkit");8 if (err) {9 return console.error(err);10 }11 console.log(url);12});13var wptoolkit = require("wptoolkit");14 if (err) {15 return console.error(err);16 }17 console.log(url);18});19var wptoolkit = require("wptoolkit");20 if (err) {21 return console.error(err);22 }23 console.log(url);24});25var wptoolkit = require("wptoolkit");26 if (err) {27 return console.error(err);28 }29 console.log(url);30});31var wptoolkit = require("wptoolkit");32 if (err) {33 return console.error(err);34 }35 console.log(url);36});
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!!