diff options
-rw-r--r-- | src/test/html/test_sandboxed.html | 12 | ||||
-rw-r--r-- | src/test/html/test_sandboxed_iframe.html | 75 |
2 files changed, 62 insertions, 25 deletions
diff --git a/src/test/html/test_sandboxed.html b/src/test/html/test_sandboxed.html index f0c485b5794..5db41761275 100644 --- a/src/test/html/test_sandboxed.html +++ b/src/test/html/test_sandboxed.html @@ -1,14 +1,10 @@ <html> <body> <iframe sandbox="allow-scripts" src="test_sandboxed_iframe.html" - style="display:block; border: 1px; width: 400px; height: 400px" - frameborder="yes" - scrolling="yes"></iframe> -hiiiiiiiii + style="display:block; border: 1px; width: 400px; height: 400px"> + </iframe> <iframe sandbox="allow-scripts" src="test_sandboxed_iframe.html" - style="display:block; border: 1px; width: 400px; height: 400px" - frameborder="yes" - scrolling="yes"></iframe> -byeeeeeeeeeeee + style="display:block; border: 1px; width: 400px; height: 400px"> + </iframe> </body> </html> diff --git a/src/test/html/test_sandboxed_iframe.html b/src/test/html/test_sandboxed_iframe.html index 210a6134a1b..d4dbb045ea7 100644 --- a/src/test/html/test_sandboxed_iframe.html +++ b/src/test/html/test_sandboxed_iframe.html @@ -1,24 +1,65 @@ <html> <body> <script> - var a = 1; - var b = 1; - var c = 2; - var step = 1; - window.alert(Date.now()); - var next = new Date(); - window.alert(next); - while (true) { - if ((new Date()) >= next) { - window.alert("step " + step + ": " + c); - a = b; - b = c; - c = a + b; - step++; - next = new Date(Date.now() + 500); - } +function Matrix(ary) { + this.mtx = ary + this.height = ary.length; + this.width = ary[0].length; +} + +Matrix.prototype.toString = function() { + var s = [] + for (var i = 0; i < this.mtx.length; i++) + s.push( this.mtx[i].join(",") ); + return s.join("\n"); +} + +Matrix.prototype.mult = function(other) { + if (this.width != other.height) { + throw "error: incompatible sizes"; } + + var result = []; + for (var i = 0; i < this.height; i++) { + result[i] = []; + for (var j = 0; j < other.width; j++) { + var sum = 0; + for (var k = 0; k < this.width; k++) { + sum += this.mtx[i][k] * other.mtx[k][j]; + } + result[i][j] = sum; + } + } + return new Matrix(result); +} + +function run() { + var now = new Date(); + var div = document.getElementsByTagName('div')[0]; + var elems = []; + for (var i = 0; i < 900; i++) { + elems.push(i); + } + var outer = []; + for (var i = 0; i < 900; i++) { + outer.push(elems); + } + var a = new Matrix(outer); + var b = new Matrix(outer); + var result = a.mult(b); + var time = (new Date()) - now; + var text = document.createTextNode(time.toString() + 'ms'); + var para = document.createElement('p'); + para.appendChild(text); + div.appendChild(para); +} + +setTimeout(function forever() { + run(); + setTimeout(forever, 3000); +}, 0); </script> -hi there +<p>Time required to multiply two 900x900 matrices:</p> +<div></div> </body> </html> |