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

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt/WebIDL/current-realm.html

Issue 2446483002: Import wpt@c5a14f553cba5f197743b9af605a84eddd8692a2 (Closed)
Patch Set: 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/imported/wpt/WebIDL/current-realm.html
diff --git a/third_party/WebKit/LayoutTests/imported/wpt/WebIDL/current-realm.html b/third_party/WebKit/LayoutTests/imported/wpt/WebIDL/current-realm.html
new file mode 100644
index 0000000000000000000000000000000000000000..fd24709b3be55a1cddced3827a7bef00be301ca9
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/wpt/WebIDL/current-realm.html
@@ -0,0 +1,145 @@
+<!-- This tests the agreed upon outcome for https://www.w3.org/Bugs/Public/show_bug.cgi?id=24652
+ that has not been reflected in the IDL standard yet due to lack of editing resources.
+
+ TODO: https://github.com/w3c/webcrypto/issues/85 -->
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Current Realm</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe srcdoc="<body test>"></iframe>
+<script>
+ setup({explicit_done:true})
+
+ function isObjectFromGlobal(object, global) {
+ return object instanceof global.Object;
+ }
+ function assert_global(obj) {
+ assert_false(isObjectFromGlobal(obj, self), obj + " should not be from top-level Realm")
+ assert_true(isObjectFromGlobal(obj, self[0]), obj + " should be from <iframe> Realm")
+ }
+
+ onload = function() {
+ [["querySelectorAll", "test"],
+ ["createElement", "x"],
+ ["createElementNS", null, "x"],
+ ["createDocumentFragment"],
+ ["createTextNode", "test"],
+ ["createComment", "test"],
+ ["createProcessingInstruction", "x", "x"],
+ ["createAttribute", "x"],
+ ["createAttributeNS", "x", "x"],
+ ["createEvent", "Event"],
+ ["createRange"],
+ ["createNodeIterator", document.head],
+ ["createTreeWalker", document.head]].forEach(function(val) {
+ test(function() {
+ var obj = self[0].document[val[0]](val[1], val[2])
+ assert_global(obj)
+
+ obj = Document.prototype[val[0]].call(self[0].document, val[1], val[2])
+ assert_global(obj)
+ }, val[0])
+ })
+
+ // Note: these are not [NewObject] and can be cached. But across globals?
+ ;[["getElementsByTagName", "x"],
+ ["getElementsByTagNameNS", null, "x"],
+ ["getElementsByClassName", "x"]].forEach(function(val) {
+ test(function() {
+ var obj = self[0].document[val[0]](val[1], val[2])
+ assert_global(obj)
+
+ var obj2 = Document.prototype[val[0]].call(self[0].document, val[1], val[2])
+ assert_global(obj)
+
+ assert_equals(obj, obj2) // XXX this might be controversial
+ }, val[0])
+ })
+
+ ;[["createDocumentType", "x", "", ""],
+ ["createDocument", null, "", null],
+ ["createHTMLDocument", "x"]].forEach(function(val) {
+ test(function() {
+ var obj = self[0].document.implementation[val[0]](val[1], val[2], val[3])
+ assert_global(obj)
+
+ obj = DOMImplementation.prototype[val[0]].call(self[0].document.implementation, val[1], val[2], val[3])
+ assert_global(obj)
+ }, val[0])
+ })
+
+ ;[["item", 0],
+ ["getNamedItem", "test"],
+ ["getNamedItemNS", null, "test"]].forEach(function(val) {
+ test(function() {
+ var obj = self[0].document.body.attributes[val[0]](val[1], val[2])
+ assert_global(obj)
+
+ var obj2 = NamedNodeMap.prototype[val[0]].call(self[0].document.body.attributes, val[1], val[2])
+ assert_global(obj)
+
+ assert_equals(obj, obj2)
+ }, "NamedNodeMap " + val[0])
+ })
+
+ test(function() {
+ var c = self[0].document.createTextNode(""),
+ obj = c.splitText(0)
+ assert_global(obj)
+
+ obj = Text.prototype.splitText.call(c, "")
+ assert_global(obj)
+ }, "splitText")
+
+ ;["extractContents",
+ "cloneContents",
+ "cloneRange"].forEach(function(val) {
+ test(function() {
+ var c = self[0].document.createRange(),
+ obj = c[val]()
+ assert_global(obj)
+
+ obj = Range.prototype[val].call(c)
+ assert_global(obj)
+ }, val)
+ })
+
+ ;["2d", "webgl"].forEach(function(val) {
+ test(function() {
+ var c = self[0].document.createElement("canvas"),
+ obj = c.getContext(val)
+ assert_global(obj)
+
+ obj = HTMLCanvasElement.prototype.getContext.call(c, val)
+ assert_global(obj)
+ }, "getContext " + val)
+ })
+
+ ;[["createImageData", 5, 5],
+ ["getImageData", 5, 5, 5, 5]].forEach(function(val) {
+ test(function() {
+ var c = self[0].document.createElement("canvas").getContext("2d"),
+ obj = c[val[0]](val[1], val[2], val[3], val[4]);
+ assert_global(obj)
+ assert_global(obj.data)
+
+ obj = CanvasRenderingContext2D.prototype[val[0]].call(c, val[1], val[2], val[3], val[4]);
+ assert_global(obj)
+ assert_global(obj.data)
+ }, val[0])
+ })
+
+ test(function() {
+ var c = new self[0].FontFace("test", "about:blank"),
+ obj = c.load()
+ assert_global(obj)
+
+ obj = FontFace.prototype.load.call(c)
+ assert_global(obj)
+ }, "FontFace's load()")
+
+ done()
+ }
+</script>

Powered by Google App Engine
This is Rietveld 408576698