OLD | NEW |
(Empty) | |
| 1 <!-- This tests the agreed upon outcome for https://www.w3.org/Bugs/Public/show_
bug.cgi?id=24652 |
| 2 that has not been reflected in the IDL standard yet due to lack of editing
resources. |
| 3 |
| 4 TODO: https://github.com/w3c/webcrypto/issues/85 --> |
| 5 <!DOCTYPE html> |
| 6 <meta charset=utf-8> |
| 7 <title>Current Realm</title> |
| 8 <script src="/resources/testharness.js"></script> |
| 9 <script src="/resources/testharnessreport.js"></script> |
| 10 <div id="log"></div> |
| 11 <iframe srcdoc="<body test>"></iframe> |
| 12 <script> |
| 13 setup({explicit_done:true}) |
| 14 |
| 15 function isObjectFromGlobal(object, global) { |
| 16 return object instanceof global.Object; |
| 17 } |
| 18 function assert_global(obj) { |
| 19 assert_false(isObjectFromGlobal(obj, self), obj + " should not be from top-le
vel Realm") |
| 20 assert_true(isObjectFromGlobal(obj, self[0]), obj + " should be from <iframe>
Realm") |
| 21 } |
| 22 |
| 23 onload = function() { |
| 24 [["querySelectorAll", "test"], |
| 25 ["createElement", "x"], |
| 26 ["createElementNS", null, "x"], |
| 27 ["createDocumentFragment"], |
| 28 ["createTextNode", "test"], |
| 29 ["createComment", "test"], |
| 30 ["createProcessingInstruction", "x", "x"], |
| 31 ["createAttribute", "x"], |
| 32 ["createAttributeNS", "x", "x"], |
| 33 ["createEvent", "Event"], |
| 34 ["createRange"], |
| 35 ["createNodeIterator", document.head], |
| 36 ["createTreeWalker", document.head]].forEach(function(val) { |
| 37 test(function() { |
| 38 var obj = self[0].document[val[0]](val[1], val[2]) |
| 39 assert_global(obj) |
| 40 |
| 41 obj = Document.prototype[val[0]].call(self[0].document, val[1], val[2]) |
| 42 assert_global(obj) |
| 43 }, val[0]) |
| 44 }) |
| 45 |
| 46 // Note: these are not [NewObject] and can be cached. But across globals? |
| 47 ;[["getElementsByTagName", "x"], |
| 48 ["getElementsByTagNameNS", null, "x"], |
| 49 ["getElementsByClassName", "x"]].forEach(function(val) { |
| 50 test(function() { |
| 51 var obj = self[0].document[val[0]](val[1], val[2]) |
| 52 assert_global(obj) |
| 53 |
| 54 var obj2 = Document.prototype[val[0]].call(self[0].document, val[1], val[
2]) |
| 55 assert_global(obj) |
| 56 |
| 57 assert_equals(obj, obj2) // XXX this might be controversial |
| 58 }, val[0]) |
| 59 }) |
| 60 |
| 61 ;[["createDocumentType", "x", "", ""], |
| 62 ["createDocument", null, "", null], |
| 63 ["createHTMLDocument", "x"]].forEach(function(val) { |
| 64 test(function() { |
| 65 var obj = self[0].document.implementation[val[0]](val[1], val[2], val[3]) |
| 66 assert_global(obj) |
| 67 |
| 68 obj = DOMImplementation.prototype[val[0]].call(self[0].document.implement
ation, val[1], val[2], val[3]) |
| 69 assert_global(obj) |
| 70 }, val[0]) |
| 71 }) |
| 72 |
| 73 ;[["item", 0], |
| 74 ["getNamedItem", "test"], |
| 75 ["getNamedItemNS", null, "test"]].forEach(function(val) { |
| 76 test(function() { |
| 77 var obj = self[0].document.body.attributes[val[0]](val[1], val[2]) |
| 78 assert_global(obj) |
| 79 |
| 80 var obj2 = NamedNodeMap.prototype[val[0]].call(self[0].document.body.attr
ibutes, val[1], val[2]) |
| 81 assert_global(obj) |
| 82 |
| 83 assert_equals(obj, obj2) |
| 84 }, "NamedNodeMap " + val[0]) |
| 85 }) |
| 86 |
| 87 test(function() { |
| 88 var c = self[0].document.createTextNode(""), |
| 89 obj = c.splitText(0) |
| 90 assert_global(obj) |
| 91 |
| 92 obj = Text.prototype.splitText.call(c, "") |
| 93 assert_global(obj) |
| 94 }, "splitText") |
| 95 |
| 96 ;["extractContents", |
| 97 "cloneContents", |
| 98 "cloneRange"].forEach(function(val) { |
| 99 test(function() { |
| 100 var c = self[0].document.createRange(), |
| 101 obj = c[val]() |
| 102 assert_global(obj) |
| 103 |
| 104 obj = Range.prototype[val].call(c) |
| 105 assert_global(obj) |
| 106 }, val) |
| 107 }) |
| 108 |
| 109 ;["2d", "webgl"].forEach(function(val) { |
| 110 test(function() { |
| 111 var c = self[0].document.createElement("canvas"), |
| 112 obj = c.getContext(val) |
| 113 assert_global(obj) |
| 114 |
| 115 obj = HTMLCanvasElement.prototype.getContext.call(c, val) |
| 116 assert_global(obj) |
| 117 }, "getContext " + val) |
| 118 }) |
| 119 |
| 120 ;[["createImageData", 5, 5], |
| 121 ["getImageData", 5, 5, 5, 5]].forEach(function(val) { |
| 122 test(function() { |
| 123 var c = self[0].document.createElement("canvas").getContext("2d"), |
| 124 obj = c[val[0]](val[1], val[2], val[3], val[4]); |
| 125 assert_global(obj) |
| 126 assert_global(obj.data) |
| 127 |
| 128 obj = CanvasRenderingContext2D.prototype[val[0]].call(c, val[1], val[2],
val[3], val[4]); |
| 129 assert_global(obj) |
| 130 assert_global(obj.data) |
| 131 }, val[0]) |
| 132 }) |
| 133 |
| 134 test(function() { |
| 135 var c = new self[0].FontFace("test", "about:blank"), |
| 136 obj = c.load() |
| 137 assert_global(obj) |
| 138 |
| 139 obj = FontFace.prototype.load.call(c) |
| 140 assert_global(obj) |
| 141 }, "FontFace's load()") |
| 142 |
| 143 done() |
| 144 } |
| 145 </script> |
OLD | NEW |