| 1 |
dojo.provide("dojox.secure.tests.sandbox"); |
| 2 |
|
| 3 |
doh.register("dojox.secure.tests.sandbox.good", |
| 4 |
[ |
| 5 |
function setup(){ |
| 6 |
var div = document.createElement("div"); |
| 7 |
document.body.appendChild(div); |
| 8 |
div.innerHTML = "Sandboxed div:"; |
| 9 |
div.style.position = "absolute"; |
| 10 |
div.style.top = "100px"; |
| 11 |
div.style.left = "100px"; |
| 12 |
div.style.backgroundColor = "red"; |
| 13 |
div.style.color = "white"; |
| 14 |
container = document.createElement("div"); |
| 15 |
container.style.backgroundColor = "cyan"; |
| 16 |
container.style.color = "black"; |
| 17 |
div.appendChild(container); |
| 18 |
}, |
| 19 |
function innerHTML(t){ |
| 20 |
dojox.secure.evaluate("element.innerHTML = 'Hi there';",container); |
| 21 |
t.assertEqual("Hi there",container.innerHTML); |
| 22 |
}, |
| 23 |
function docWrite(t){ |
| 24 |
dojox.secure.evaluate("document.write(\"<div style='color:red'>written</div>\");",container); |
| 25 |
t.t(container.innerHTML.match(/written/)); |
| 26 |
} |
| 27 |
]); |
| 28 |
|
| 29 |
function violater(func) { |
| 30 |
return {name: func.name, |
| 31 |
runTest: function(t) { |
| 32 |
var insecure; |
| 33 |
try { |
| 34 |
func(t); |
| 35 |
insecure = true; |
| 36 |
}catch(e){ |
| 37 |
console.log("successfully threw error",e); |
| 38 |
} |
| 39 |
t.f(insecure); |
| 40 |
}}; |
| 41 |
} |
| 42 |
doh.register("dojox.secure.tests.sandbox.bad", |
| 43 |
[ |
| 44 |
function parentNode(t){ |
| 45 |
t.f(dojox.secure.evaluate("document.body",container)); |
| 46 |
}, |
| 47 |
function innerHTMLScript(t){ |
| 48 |
try { |
| 49 |
dojox.secure.evaluate("bad = true",container); |
| 50 |
}catch(e){} |
| 51 |
t.t(typeof bad == 'undefined'); |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
]); |
| 119 |
|