How to use testReferrerAfterRedirection method in wpt

Best JavaScript code snippet using wpt

redirect-referrer.js

Source:redirect-referrer.js Github

copy

Full Screen

...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);...

Full Screen

Full Screen

redirect-referrer.any.js

Source:redirect-referrer.any.js Github

copy

Full Screen

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);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var testReferrerAfterRedirection = require('wpt').testReferrerAfterRedirection;2 if(err){3 console.log(err);4 }5 else{6 console.log(data);7 }8});9var testReferrerAfterRedirection = require('wpt').testReferrerAfterRedirection;10 if(err){11 console.log(err);12 }13 else{14 console.log(data);15 }16});17var testReferrerAfterRedirection = require('wpt').testReferrerAfterRedirection;18 if(err){19 console.log(err);20 }21 else{22 console.log(data);23 }24});25var testReferrerAfterRedirection = require('wpt').testReferrerAfterRedirection;26 if(err){27 console.log(err);28 }29 else{30 console.log(data);31 }32});33var testReferrerAfterRedirection = require('wpt').testReferrerAfterRedirection;34 if(err){35 console.log(err);36 }37 else{38 console.log(data);39 }40});41var testReferrerAfterRedirection = require('wpt').testReferrerAfterRedirection;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptReferrerTest = require('wptReferrerTest');2var test = new wptReferrerTest();3test.testReferrerAfterRedirection();4var wptReferrerTest = function(){5 this.testReferrerAfterRedirection = function(){6 }7}8module.exports = wptReferrerTest;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wptRef = new wpt('your api key');3 console.log(data);4});5var wpt = require('wpt');6var wptRef = new wpt('your api key');7wptRef.getTestResults('test id', function(err, data){8 console.log(data);9});10var wpt = require('wpt');11var wptRef = new wpt('your api key');12wptRef.getTestStatus('test id', function(err, data){13 console.log(data);14});15var wpt = require('wpt');16var wptRef = new wpt('your api key');17wptRef.getLocations(function(err, data){18 console.log(data);19});20var wpt = require('wpt');21var wptRef = new wpt('your api key');22wptRef.getLocations(function(err, data){23 console.log(data);24});25var wpt = require('wpt');26var wptRef = new wpt('your api key');27wptRef.getTesters(function(err, data){28 console.log(data);29});30var wpt = require('wpt');31var wptRef = new wpt('your api key');32wptRef.getTesters(function(err, data){33 console.log(data);34});35var wpt = require('wpt');36var wptRef = new wpt('your api key');37wptRef.getWaterfall('test id', function(err, data){38 console.log(data);39});

Full Screen

Using AI Code Generation

copy

Full Screen

1wpt.testReferrerAfterRedirection(function(data) {2 console.log(data);3});4wpt.testReferrerAfterRedirection(function(data) {5 console.log(data);6});7wpt.testReferrerAfterRedirection(function(data) {8 console.log(data);9});10wpt.testReferrerAfterRedirection(function(data) {11 console.log(data);12});13wpt.testReferrerAfterRedirection(function(data) {14 console.log(data);15});16wpt.testReferrerAfterRedirection(function(data) {17 console.log(data);18});19wpt.testReferrerAfterRedirection(function(data) {20 console.log(data);21});22wpt.testReferrerAfterRedirection(function(data) {23 console.log(data);24});25wpt.testReferrerAfterRedirection(function(data) {26 console.log(data);27});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var test = new wpt('www.webpagetest.org', options);5test.runTest(testUrl, function(err, data) {6 if (err) {7 console.log('Error: ' + err);8 } else {9 console.log('Test status: ' + data.statusText);10 if (data.statusCode === 200) {11 console.log('Test ID: ' + data.data.testId);12 test.getTestResults(data.data.testId, function(err, data) {13 if (err) {14 console.log('Error: ' + err);15 } else {16 console.log('Test results: ' + JSON.stringify(data));17 }18 });19 }20 }21});

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful