Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/scripting-1/the-script-element/script-referrerpolicy-idl.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title><script> referrerPolicy IDL</title>
<link rel="author" href="mailto:masonf@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
test(() => {
const script = document.createElement('script');
document.body.appendChild(script);
assert_equals(script.referrerPolicy,"",'Missing content attribute should reflect as empty');
script.setAttribute('referrerpolicy','no-referrer');
assert_equals(script.referrerPolicy,"no-referrer",'Valid value should reflect');
script.setAttribute('referrerpolicy','');
assert_equals(script.referrerPolicy,"",'Empty string should reflect as empty');
script.setAttribute('referrerpolicy','invalid-value-here');
assert_equals(script.referrerPolicy,"",'Invalid values should reflect as empty');
script.referrerPolicy = 'no-referrer';
assert_equals(script.referrerPolicy,"no-referrer",'Valid value via IDL');
script.referrerPolicy = null;
assert_equals(script.referrerPolicy,"",'Null should reflect as empty');
},'Missing/invalid/null referrerPolicy should reflect as the empty string')
</script>