How to use referrerPolicyTestString method in wpt

Best JavaScript code snippet using wpt

assorted.window.js

Source:assorted.window.js Github

copy

Full Screen

...105 const json = await (await fetch(redirectPath + "?dump&stash=" + stash)).json();106 assert_equals(json[0], expectedOrigin);107 };108}109function referrerPolicyTestString(referrerPolicy, method, destination) {110 return "Origin header and " + method + " " + destination + " with Referrer-Policy " +111 referrerPolicy;112}113[114 {115 "policy": "no-referrer",116 "expectedOriginForSameOrigin": "null",117 "expectedOriginForCrossOrigin": "null"118 },119 {120 "policy": "same-origin",121 "expectedOriginForSameOrigin": origins.HTTP_ORIGIN,122 "expectedOriginForCrossOrigin": "null"123 },124 {125 "policy": "origin-when-cross-origin",126 "expectedOriginForSameOrigin": origins.HTTP_ORIGIN,127 "expectedOriginForCrossOrigin": origins.HTTP_ORIGIN128 },129 {130 "policy": "no-referrer-when-downgrade",131 "expectedOriginForSameOrigin": origins.HTTP_ORIGIN,132 "expectedOriginForCrossOrigin": origins.HTTP_ORIGIN133 },134 {135 "policy": "unsafe-url",136 "expectedOriginForSameOrigin": origins.HTTP_ORIGIN,137 "expectedOriginForCrossOrigin": origins.HTTP_ORIGIN138 },139].forEach(testObj => {140 [141 {142 "name": "same-origin",143 "expectedOrigin": testObj.expectedOriginForSameOrigin144 },145 {146 "name": "cross-origin",147 "expectedOrigin": testObj.expectedOriginForCrossOrigin148 }149 ].forEach(destination => {150 // Test form POST navigation151 promise_test(navigationReferrerPolicy(testObj.policy,152 destination.name,153 destination.expectedOrigin),154 referrerPolicyTestString(testObj.policy, "POST",155 destination.name + " navigation"));156 // Test fetch157 promise_test(fetchReferrerPolicy(testObj.policy,158 destination.name,159 "no-cors",160 destination.expectedOrigin,161 "POST"),162 referrerPolicyTestString(testObj.policy, "POST",163 destination.name + " fetch no-cors mode"));164 // Test cors mode POST165 promise_test(fetchReferrerPolicy(testObj.policy,166 destination.name,167 "cors",168 (destination.name == "same-origin") ? destination.expectedOrigin : origins.HTTP_ORIGIN,169 "POST"),170 referrerPolicyTestString(testObj.policy, "POST",171 destination.name + " fetch cors mode"));172 // Test cors mode GET173 promise_test(fetchReferrerPolicy(testObj.policy,174 destination.name,175 "cors",176 (destination.name == "same-origin") ? "no Origin header" : origins.HTTP_ORIGIN,177 "GET"),178 referrerPolicyTestString(testObj.policy, "GET",179 destination.name + " fetch cors mode"));180 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1def main(request, response):2 response.headers.set(b"Access-Control-Allow-Origin", b"*")3 response.headers.set(b"Access-Control-Allow-Credentials", b"true")4 response.headers.set(b"Access-Control-Allow-Methods", b"GET, POST, PUT")5 response.headers.set(b"Access-Control-Allow-Headers", b"X-Test")6 response.headers.set(b"Access-Control-Expose-Headers", b"X-Test")7 response.headers.set(b"Access-Control-Max-Age", b"86400")8 response.headers.set(b"Content-Type", b"text/html")9 response.headers.set(b"X-Frame-Options", b"deny")10 response.headers.set(b"Referrer-Policy", request.GET.first(b"policy"))11 response.headers.set(b"X-Content-Type-Options", b"nosniff")12 response.headers.set(b"X-XSS-Protection", b"1; mode=block")13 response.headers.set(b"Content-Security-Policy", b"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'")

Full Screen

Using AI Code Generation

copy

Full Screen

1referrerPolicyTestString(“no-referrer”, “no-referrer”);2referrerPolicyTestString(“no-referrer”, “origin”);3referrerPolicyTestString(“no-referrer”, “unsafe-url”);4referrerPolicyTestString(“origin”, “no-referrer”);5referrerPolicyTestString(“origin”, “origin”);6referrerPolicyTestString(“origin”, “unsafe-url”);7referrerPolicyTestString(“origin-when-cross-origin”, “no-referrer”);8referrerPolicyTestString(“origin-when-cross-origin”, “origin”);9referrerPolicyTestString(“origin-when-cross-origin”, “unsafe-url”);10referrerPolicyTestString(“same-origin”, “no-referrer”);11referrerPolicyTestString(“same-origin”, “origin”);12referrerPolicyTestString(“same-origin”, “unsafe-url”);13referrerPolicyTestString(“strict-origin”, “no-referrer”);

Full Screen

Using AI Code Generation

copy

Full Screen

1function run_test() {2 var referrerPolicy = "no-referrer-when-downgrade";3 var request = new XMLHttpRequest();4 request.open("GET", url, false, null, null);5 request.setRequestHeader("referer", referrer);6 request.setRequestHeader("referrer-policy", referrerPolicy);7 request.send();8 var referrerString = request.getResponseHeader("referrer");9 Assert.equal(referrerString, referrer, "expected referrer string to be " + referrer);10}11 > + return policy;12> +}13> +nsDocShell::ShouldSendReferrer(nsIChannel* aChannel, nsIHttpChannel* aHttpChannel) 14 > + return true;15> + }16> + nsCOMPtr<nsIURI> referrerURI;17> + aHttpChannel->GetReferrer(getter_AddRefs(referrerURI));

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