Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Side by Side Diff: LayoutTests/http/tests/security/document-origin.html

Issue 758913002: Implement the 'document.origin' accessor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Test. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>document.origin</title>
3 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script>
5
6 <iframe id="srcdoc" srcdoc="<p>yay</p>"></iframe>
jochen (gone - plz use gerrit) 2014/11/25 15:53:49 where do you check the origin in the srcdoc?
Mike West 2014/11/25 15:56:34 I thought I did, but I apparently didn't. Fixing!
7
8 <script>
9 test(function() {
10 assert_equals(document.origin, 'http://127.0.0.1:8000');
11 }, 'Top-level document.');
12
13 test(function() {
14 var doc = document.implementation.createHTMLDocument();
15 assert_equals(doc.origin, 'http://127.0.0.1:8000');
16 }, 'createHTMLDocument()');
17
18
19 (function() {
20 var t = async_test("about:blank IFrame.");
21 t.step(function () {
22 var iframe = document.createElement('iframe');
23 iframe.addEventListener('load', function () {
24 assert_equals(iframe.contentDocument.origin, 'http://127.0.0.1:8000' );
25 t.done();
26 });
27 document.body.appendChild(iframe);
28 });
29 })();
30
31 (function() {
32 var t = async_test("Same-origin IFrame.");
33 t.step(function () {
34 var iframe = document.createElement('iframe');
35 iframe.src = "/security/resources/postmessage-document-origin.html";
36 iframe.addEventListener('load', function () {
37 iframe.contentWindow.postMessage({ 'id': 'same-origin-iframe' }, '*' );
38 });
39 window.addEventListener('message', function (e) {
40 if (e.data.id != 'same-origin-iframe')
41 return;
42
43 assert_equals(e.data.origin, 'http://127.0.0.1:8000');
44 assert_equals(e.data.origin, e.origin);
45 t.done();
46 });
47 document.body.appendChild(iframe);
48 });
49 })();
50
51 (function() {
52 var t = async_test("Cross-origin IFrame.");
53 t.step(function () {
54 var iframe = document.createElement('iframe');
55 iframe.src = "http://localhost:8080/security/resources/postmessage-docum ent-origin.html";
56 iframe.addEventListener('load', function () {
57 iframe.contentWindow.postMessage({ 'id': 'cross-origin-iframe' }, '* ');
58 });
59 window.addEventListener('message', function (e) {
60 if (e.data.id != 'cross-origin-iframe')
61 return;
62
63 assert_equals(e.data.origin, 'http://localhost:8080');
64 assert_equals(e.data.origin, e.origin);
65 t.done();
66 });
67 document.body.appendChild(iframe);
68 });
69 })();
70
71 (function() {
72 var t = async_test("Sandboxed same-origin IFrame.");
73 t.step(function () {
74 var iframe = document.createElement('iframe');
75 iframe.setAttribute('sandbox', 'allow-scripts');
76 iframe.src = "/security/resources/postmessage-document-origin.html";
77 iframe.addEventListener('load', function () {
78 iframe.contentWindow.postMessage({ 'id': 'sandboxed-same-origin-ifra me' }, '*');
79 });
80 window.addEventListener('message', function (e) {
81 if (e.data.id != 'sandboxed-same-origin-iframe')
82 return;
83
84 assert_equals(e.data.origin, 'null');
Mike West 2014/11/25 15:56:34 This test and the one below test that sandboxed if
85 assert_equals(e.data.origin, e.origin);
86 t.done();
87 });
88 document.body.appendChild(iframe);
89 });
90 })();
91
92 (function() {
93 var t = async_test("Sandboxed cross-origin IFrame.");
94 t.step(function () {
95 var iframe = document.createElement('iframe');
96 iframe.setAttribute('sandbox', 'allow-scripts');
97 iframe.src = "http://localhost:8080/security/resources/postmessage-docum ent-origin.html";
98 iframe.addEventListener('load', function () {
99 iframe.contentWindow.postMessage({ 'id': 'sandboxed-cross-origin-ifr ame' }, '*');
100 });
101 window.addEventListener('message', function (e) {
102 if (e.data.id != 'sandboxed-cross-origin-iframe')
103 return;
104
105 assert_equals(e.data.origin, 'null');
106 assert_equals(e.data.origin, e.origin);
107 t.done();
108 });
109 document.body.appendChild(iframe);
110 });
111 })();
112 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/security/document-origin-domain.html » ('j') | Source/core/dom/Document.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698