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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/security/promise-realm.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/promise-realm.html b/third_party/WebKit/LayoutTests/http/tests/security/promise-realm.html
new file mode 100644
index 0000000000000000000000000000000000000000..d4ae08c4a12828d15c01e0800a8e27ee95f6dd5d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/promise-realm.html
@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+<iframe id="same-origin-window"></iframe>
+<iframe id="cross-origin-window" src="//www1.web-paltform.test/resources/dummy.html"></iframe>
+<script defer>
+window.onload = () => {
+
+test(() => {
+ let same = window['same-origin-window'].contentWindow;
+ let cross = window['cross-origin-window'].contentWindow;
+
+ let p = fetch.call(same, 'resources/blank.html');
+ assert_equals(
+ p.constructor.constructor,
+ same.Function,
+ "A regular promise is created in the relevant realm of the context object.");
+
+ // Following test cases produce reject promises. Must be created in the
+ // current realm.
+ p = fetch.call();
+ assert_equals(
+ p.constructor.constructor,
+ Function,
+ "type mismatch error, case 1");
+ p.then(() => {
+ assert_unreached("type mismatch error, case 1: must be a reject promise");
+ });
+
+ p = same.fetch.call();
+ assert_equals(
+ p.constructor.constructor,
+ same.Function,
+ "type mismatch error, case 2");
+ p.then(() => {
+ assert_unreached("type mismatch error, case 2: must be a reject promise");
+ });
+
+ p = fetch.call(same);
+ assert_equals(
+ p.constructor.constructor,
+ Function,
+ "type mismatch error, case 3");
+ p.then(() => {
+ assert_unreached("type mismatch error, case 3: must be a reject promise");
+ });
+
+ p = fetch.call(cross, 'resources/dummy.html');
+ assert_equals(
+ p.constructor.constructor,
+ Function,
+ "cross origin access");
+ p.then(() => {
+ assert_unreached("cross origin access: must be a reject promise");
+ });
+}, "Reject promises must be created in the current realm");
+
+done();
+
+};
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698