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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/security/promise-realm.html

Issue 2418413004: binding: Creates a reject promise always in the current realm. (Closed)
Patch Set: Added a layout test. Created 4 years, 2 months 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 <html>
3 <head>
4 <script src="/resources/testharness.js"></script>
5 <script src="/resources/testharnessreport.js"></script>
6 </head>
7 <body>
8 <iframe id="same-origin-window"></iframe>
9 <iframe id="cross-origin-window" src="//www1.web-paltform.test/resources/dummy.h tml"></iframe>
10 <script defer>
11 window.onload = () => {
12
13 test(() => {
14 let same = window['same-origin-window'].contentWindow;
15 let cross = window['cross-origin-window'].contentWindow;
16
17 let p = fetch.call(same, 'resources/blank.html');
18 assert_equals(
19 p.constructor.constructor,
20 same.Function,
21 "A regular promise is created in the relevant realm of the context object. ");
22
23 // Following test cases produce reject promises. Must be created in the
24 // current realm.
25 p = fetch.call();
26 assert_equals(
27 p.constructor.constructor,
28 Function,
29 "type mismatch error, case 1");
30 p.then(() => {
31 assert_unreached("type mismatch error, case 1: must be a reject promise");
32 });
33
34 p = same.fetch.call();
35 assert_equals(
36 p.constructor.constructor,
37 same.Function,
38 "type mismatch error, case 2");
39 p.then(() => {
40 assert_unreached("type mismatch error, case 2: must be a reject promise");
41 });
42
43 p = fetch.call(same);
44 assert_equals(
45 p.constructor.constructor,
46 Function,
47 "type mismatch error, case 3");
48 p.then(() => {
49 assert_unreached("type mismatch error, case 3: must be a reject promise");
50 });
51
52 p = fetch.call(cross, 'resources/dummy.html');
53 assert_equals(
54 p.constructor.constructor,
55 Function,
56 "cross origin access");
57 p.then(() => {
58 assert_unreached("cross origin access: must be a reject promise");
59 });
60 }, "Reject promises must be created in the current realm");
61
62 done();
63
64 };
65 </script>
66 </body>
67 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698