| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 | |
| 3 <!-- Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | |
| 4 for details. All rights reserved. Use of this source code is governed by a | |
| 5 BSD-style license that can be found in the LICENSE file. --> | |
| 6 | |
| 7 <html> | |
| 8 <head> | |
| 9 <meta charset="utf-8"> | |
| 10 <title>dart:js test</title> | |
| 11 </head> | |
| 12 <body> | |
| 13 See console for test results... | |
| 14 <script> | |
| 15 var x = 42; | |
| 16 | |
| 17 var _x = 123; | |
| 18 | |
| 19 var myArray = ["value1"]; | |
| 20 | |
| 21 var foreignDoc = (function(){ | |
| 22 var doc = document.implementation.createDocument("", "root", null); | |
| 23 var element = doc.createElement('element'); | |
| 24 element.setAttribute('id', 'abc'); | |
| 25 doc.documentElement.appendChild(element); | |
| 26 return doc; | |
| 27 })(); | |
| 28 | |
| 29 function razzle() { | |
| 30 return x; | |
| 31 } | |
| 32 | |
| 33 function returnThis() { | |
| 34 return this; | |
| 35 } | |
| 36 | |
| 37 function getTypeOf(o) { | |
| 38 return typeof(o); | |
| 39 } | |
| 40 | |
| 41 function varArgs() { | |
| 42 var args = arguments; | |
| 43 var sum = 0; | |
| 44 for (var i = 0; i < args.length; ++i) { | |
| 45 sum += args[i]; | |
| 46 } | |
| 47 return sum; | |
| 48 } | |
| 49 | |
| 50 function Foo(a) { | |
| 51 this.a = a; | |
| 52 } | |
| 53 | |
| 54 Foo.b = 38; | |
| 55 | |
| 56 Foo.prototype.bar = function() { | |
| 57 return this.a; | |
| 58 }; | |
| 59 Foo.prototype.toString = function() { | |
| 60 return "I'm a Foo a=" + this.a; | |
| 61 }; | |
| 62 | |
| 63 var container = new Object(); | |
| 64 container.Foo = Foo; | |
| 65 | |
| 66 function isArray(a) { | |
| 67 return a instanceof Array; | |
| 68 } | |
| 69 | |
| 70 function checkMap(m, key, value) { | |
| 71 if (m.hasOwnProperty(key)) | |
| 72 return m[key] == value; | |
| 73 else | |
| 74 return false; | |
| 75 } | |
| 76 | |
| 77 function invokeCallback() { | |
| 78 return callback(); | |
| 79 } | |
| 80 | |
| 81 function invokeCallbackWith11params() { | |
| 82 return callbackWith11params(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); | |
| 83 } | |
| 84 | |
| 85 function returnElement(element) { | |
| 86 return element; | |
| 87 } | |
| 88 | |
| 89 function getElementAttribute(element, attr) { | |
| 90 return element.getAttribute(attr); | |
| 91 } | |
| 92 | |
| 93 function addClassAttributes(list) { | |
| 94 var result = ""; | |
| 95 for (var i=0; i < list.length; i++) { | |
| 96 result += list[i].getAttribute("class"); | |
| 97 } | |
| 98 return result; | |
| 99 } | |
| 100 | |
| 101 function getNewDate() { | |
| 102 return new Date(1995, 11, 17); | |
| 103 } | |
| 104 | |
| 105 function getNewDivElement() { | |
| 106 return document.createElement("div"); | |
| 107 } | |
| 108 | |
| 109 function getNewEvent() { | |
| 110 return new CustomEvent('test'); | |
| 111 } | |
| 112 | |
| 113 function getNewBlob() { | |
| 114 var fileParts = ['<a id="a"><b id="b">hey!</b></a>']; | |
| 115 return new Blob(fileParts, {type : 'text/html'}); | |
| 116 } | |
| 117 | |
| 118 function getNewIDBKeyRange() { | |
| 119 return IDBKeyRange.only(1); | |
| 120 } | |
| 121 | |
| 122 function getNewImageData() { | |
| 123 var canvas = document.createElement('canvas'); | |
| 124 var context = canvas.getContext('2d'); | |
| 125 return context.createImageData(1, 1); | |
| 126 } | |
| 127 | |
| 128 function getNewInt32Array() { | |
| 129 return new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]); | |
| 130 } | |
| 131 | |
| 132 function getNewArrayBuffer() { | |
| 133 return new ArrayBuffer(8); | |
| 134 } | |
| 135 | |
| 136 function isPropertyInstanceOf(property, type) { | |
| 137 return window[property] instanceof type; | |
| 138 } | |
| 139 | |
| 140 function testJsMap(callback) { | |
| 141 var result = callback(); | |
| 142 return result['value']; | |
| 143 } | |
| 144 | |
| 145 function addTestProperty(o) { | |
| 146 o.testProperty = "test"; | |
| 147 } | |
| 148 | |
| 149 function fireClickEvent(w) { | |
| 150 var event = w.document.createEvent('Events'); | |
| 151 event.initEvent('click', true, false); | |
| 152 w.document.dispatchEvent(event); | |
| 153 } | |
| 154 | |
| 155 function Bar() { | |
| 156 return "ret_value"; | |
| 157 } | |
| 158 Bar.foo = "property_value"; | |
| 159 | |
| 160 function Baz(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11) { | |
| 161 this.f1 = p1; | |
| 162 this.f2 = p2; | |
| 163 this.f3 = p3; | |
| 164 this.f4 = p4; | |
| 165 this.f5 = p5; | |
| 166 this.f6 = p6; | |
| 167 this.f7 = p7; | |
| 168 this.f8 = p8; | |
| 169 this.f9 = p9; | |
| 170 this.f10 = p10; | |
| 171 this.f11 = p11; | |
| 172 } | |
| 173 | |
| 174 function Liar(){} | |
| 175 | |
| 176 Liar.prototype.toString = function() { | |
| 177 return 1; | |
| 178 }; | |
| 179 | |
| 180 function identical(o1, o2) { | |
| 181 return o1 === o2; | |
| 182 } | |
| 183 | |
| 184 var someProto = { role: "proto" }; | |
| 185 var someObject = Object.create(someProto); | |
| 186 someObject.role = "object"; | |
| 187 | |
| 188 </script> | |
| 189 <script type="application/dart" src="js_test.dart"></script> | |
| 190 </body> | |
| 191 </html> | |
| OLD | NEW |