Commit 52308ad8 authored by Philip Jägenstedt's avatar Philip Jägenstedt Committed by Commit Bot

Deprecate document.origin

Intent to Deprecate and Remove:
https://groups.google.com/a/chromium.org/d/msg/blink-dev/0D_37iuh1zc/ndyyNaxgCQAJ

Bug: 692084
Change-Id: Iae09a7d82e09c9bc3f0394dfa476370fd1efe516
Reviewed-on: https://chromium-review.googlesource.com/1013699Reviewed-by: default avatarMike West <mkwst@chromium.org>
Commit-Queue: Philip Jägenstedt <foolip@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553537}
parent 90cd442f
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
<script src="../../resources/testharnessreport.js"></script> <script src="../../resources/testharnessreport.js"></script>
<script> <script>
test (function() { test (function() {
assert_equals((new DOMParser).parseFromString("", "text/html").origin, document.origin); assert_equals((new DOMParser).parseFromString("", "text/html").origin, self.origin);
}, "This test checks that documents created from DOMParser inherit origin"); }, "This test checks that documents created from DOMParser inherit origin");
</script> </script>
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
var i = document.createElement('iframe'); var i = document.createElement('iframe');
i.src = "support/frame-ancestors-and-x-frame-options.sub.html?policy='self'&xfo=DENY"; i.src = "support/frame-ancestors-and-x-frame-options.sub.html?policy='self'&xfo=DENY";
i.onload = t.step_func_done(function () { i.onload = t.step_func_done(function () {
assert_equals(i.contentDocument.origin, document.origin, "The same-origin page loaded."); assert_equals(i.contentWindow.origin, window.origin, "The same-origin page loaded.");
}); });
document.body.appendChild(i); document.body.appendChild(i);
}, "A 'frame-ancestors' CSP directive overrides an 'x-frame-options' header which would block the page."); }, "A 'frame-ancestors' CSP directive overrides an 'x-frame-options' header which would block the page.");
......
...@@ -248,7 +248,3 @@ function queryScript(url, callback) { ...@@ -248,7 +248,3 @@ function queryScript(url, callback) {
function SanityChecker() {} function SanityChecker() {}
SanityChecker.prototype.checkScenario = function() {}; SanityChecker.prototype.checkScenario = function() {};
SanityChecker.prototype.checkSubresourceResult = function() {}; SanityChecker.prototype.checkSubresourceResult = function() {};
// TODO(kristijanburnik): document.origin is supported since Chrome 41,
// other browsers still don't support it. Remove once they do.
document.origin = document.origin || (location.protocol + "//" + location.host);
...@@ -29,7 +29,7 @@ function ReferrerPolicyTestCase(scenario, testDescription, sanityChecker) { ...@@ -29,7 +29,7 @@ function ReferrerPolicyTestCase(scenario, testDescription, sanityChecker) {
return undefined; return undefined;
}, },
"origin": function() { "origin": function() {
return document.origin + "/"; return self.origin + "/";
}, },
"stripped-referrer": function() { "stripped-referrer": function() {
return stripUrlForUseAsReferrer(location.toString()); return stripUrlForUseAsReferrer(location.toString());
......
CONSOLE WARNING: line 17: 'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead. CONSOLE WARNING: line 17: 'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.
CONSOLE WARNING: line 28: document.origin is deprecated and will be removed in M70, around October 2018. Please use self.origin (window.origin) instead. See https://www.chromestatus.com/features/5701042356355072 for more details.
Test for bug 8131: Some properties and methods of window and document objects cannot be converted to a string. Test for bug 8131: Some properties and methods of window and document objects cannot be converted to a string.
Should say SUCCESS: Should say SUCCESS:
......
...@@ -24,7 +24,7 @@ backgroundFetchTest((t, bgFetch) => { ...@@ -24,7 +24,7 @@ backgroundFetchTest((t, bgFetch) => {
}, 'POST and text/plain are whitelisted, so should register ok'); }, 'POST and text/plain are whitelisted, so should register ok');
backgroundFetchTest((t, bgFetch) => { backgroundFetchTest((t, bgFetch) => {
return bgFetch.fetch(uniqueTag(), new Request(document.origin, { return bgFetch.fetch(uniqueTag(), new Request(self.origin, {
method: 'PUT', method: 'PUT',
headers: {'Content-Type': 'text/json'} headers: {'Content-Type': 'text/json'}
})); }));
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
// Verify that the current origin is different than what // Verify that the current origin is different than what
// we use for the content. // we use for the content.
logMessage('setting src'); logMessage('setting src');
assert_equals(document.origin, 'http://127.0.0.1:8000'); assert_equals(self.origin, 'http://127.0.0.1:8000');
video.src = 'http://127.0.0.1:8080/media/encrypted-media/test-encrypted.webm'; video.src = 'http://127.0.0.1:8080/media/encrypted-media/test-encrypted.webm';
video.play(); video.play();
}); });
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
]; ];
url_list.forEach(url => test(t => { url_list.forEach(url => test(t => {
var a = document.createElement('a'); var a = document.createElement('a');
a.ping = document.origin + url; a.ping = self.origin + url;
a.href = '#' + url; a.href = '#' + url;
document.body.appendChild(a); document.body.appendChild(a);
a.click(); a.click();
......
...@@ -16,7 +16,7 @@ async_test(t => { ...@@ -16,7 +16,7 @@ async_test(t => {
f.sandbox = "allow-scripts"; f.sandbox = "allow-scripts";
f.srcdoc = ` f.srcdoc = `
<script> <script>
var url = URL.createObjectURL(new Blob(["parent.postMessage('PASS: origin=' + document.origin, '*');"])); var url = URL.createObjectURL(new Blob(["parent.postMessage('PASS: origin=' + self.origin, '*');"]));
var s = document.createElement("script"); var s = document.createElement("script");
s.src = url; s.src = url;
document.head.appendChild(s); document.head.appendChild(s);
......
<script> <script>
opener.postMessage({ 'origin': document.origin }, '*'); opener.postMessage({ 'origin': self.origin }, '*');
</script> </script>
<script> <script>
window.parent.postMessage({ 'origin': document.origin }, '*'); window.parent.postMessage({ 'origin': self.origin }, '*');
</script> </script>
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// origin. // origin.
window.addEventListener('message', function (e) { window.addEventListener('message', function (e) {
event.source.postMessage({ event.source.postMessage({
'origin': document.origin, 'origin': self.origin,
'id': e.data.id 'id': e.data.id
}, e.origin); }, e.origin);
}); });
......
...@@ -20,7 +20,7 @@ header("Content-Security-Policy: sandbox allow-scripts allow-popups allow-popups ...@@ -20,7 +20,7 @@ header("Content-Security-Policy: sandbox allow-scripts allow-popups allow-popups
var win = null; var win = null;
window.addEventListener("message", test.step_func(function (e) { window.addEventListener("message", test.step_func(function (e) {
assert_equals(document.origin, 'null'); assert_equals(self.origin, 'null');
if (current == 0) { if (current == 0) {
assert_equals(e.data.origin, 'http://127.0.0.1:8000'); assert_equals(e.data.origin, 'http://127.0.0.1:8000');
current++; current++;
......
...@@ -18,8 +18,8 @@ header("Content-Security-Policy: sandbox allow-scripts allow-popups allow-popups ...@@ -18,8 +18,8 @@ header("Content-Security-Policy: sandbox allow-scripts allow-popups allow-popups
var test = async_test("Testing sandbox not inherited via target='_blank' when 'allow-popups-to-escape-sandbox' present"); var test = async_test("Testing sandbox not inherited via target='_blank' when 'allow-popups-to-escape-sandbox' present");
window.addEventListener("message", test.step_func(function (e) { window.addEventListener("message", test.step_func(function (e) {
assert_equals(document.origin, 'null'); assert_equals(self.origin, 'null');
assert_equals(e.data.origin, 'http://127.0.0.1:8000'); assert_equals(e.data.origin, 'http://127.0.0.1:8000');
test.done(); test.done();
})); }));
......
...@@ -18,7 +18,7 @@ header("Content-Security-Policy: sandbox allow-scripts allow-popups"); ...@@ -18,7 +18,7 @@ header("Content-Security-Policy: sandbox allow-scripts allow-popups");
var test = async_test("Testing sandbox inherited via target='_blank'"); var test = async_test("Testing sandbox inherited via target='_blank'");
window.addEventListener("message", test.step_func(function (e) { window.addEventListener("message", test.step_func(function (e) {
assert_equals(document.origin, 'null'); assert_equals(self.origin, 'null');
assert_equals(e.data.origin, 'null'); assert_equals(e.data.origin, 'null');
test.done(); test.done();
})); }));
......
...@@ -43,7 +43,7 @@ typedef (HTMLScriptElement or SVGScriptElement) HTMLOrSVGScriptElement; ...@@ -43,7 +43,7 @@ typedef (HTMLScriptElement or SVGScriptElement) HTMLOrSVGScriptElement;
[ImplementedAs=urlForBinding] readonly attribute USVString URL; [ImplementedAs=urlForBinding] readonly attribute USVString URL;
// FIXME: documentURI should not be nullable. // FIXME: documentURI should not be nullable.
[ImplementedAs=urlForBinding] readonly attribute USVString? documentURI; [ImplementedAs=urlForBinding] readonly attribute USVString? documentURI;
[MeasureAs=DocumentOrigin] readonly attribute USVString origin; [DeprecateAs=DocumentOrigin] readonly attribute USVString origin;
readonly attribute DOMString compatMode; readonly attribute DOMString compatMode;
readonly attribute DOMString characterSet; readonly attribute DOMString characterSet;
......
...@@ -575,6 +575,12 @@ DeprecationInfo GetDeprecationInfo(WebFeature feature) { ...@@ -575,6 +575,12 @@ DeprecationInfo GetDeprecationInfo(WebFeature feature) {
"TouchEvent constructor", kM68, "TouchEvent constructor", kM68,
"5668612064935936")}; "5668612064935936")};
case WebFeature::kDocumentOrigin:
return {"DocumentOrigin", kM70,
ReplacedWillBeRemoved("document.origin",
"self.origin (window.origin)", kM70,
"5701042356355072")};
// Features that aren't deprecated don't have a deprecation message. // Features that aren't deprecated don't have a deprecation message.
default: default:
return {"NotDeprecated", kUnknown, ""}; return {"NotDeprecated", kUnknown, ""};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment