Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Bug 1211470 - r=zer0
Browse files Browse the repository at this point in the history
  • Loading branch information
gijsk committed Oct 14, 2015
1 parent 27e10bf commit bfab090
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/test-panel.js
Expand Up @@ -1368,6 +1368,43 @@ exports["test Panel links"] = function*(assert) {
loader.unload();
}

exports["test Panel script allow property"] = function*(assert) {
const loader = Loader(module);
const { Panel } = loader.require('sdk/panel');
const { getActiveView } = loader.require('sdk/view/core');

const contentURL = 'data:text/html;charset=utf-8,' +
encodeURIComponent(`<body onclick='postMessage("got script click", "*")'>
<script>
document.body.appendChild(document.createElement('unwanted'))
</script>
</body>`);
let panel = Panel({
contentURL,
allow: {script: false},
});

panel.show();

yield wait(panel, 'show');

let { contentWindow } = getActiveView(panel).querySelector('iframe');

assert.equal(contentWindow.document.body.lastElementChild.localName, "script",
"Script should not have executed");

panel.allow.script = true;

let p = wait(contentWindow, "message");
let event = new contentWindow.MouseEvent('click', {});
contentWindow.document.body.dispatchEvent(event);

let msg = yield p;
assert.equal(msg.data, "got script click", "Should have seen script click");

loader.unload();
};

after(exports, function*(name, assert) {
yield cleanUI();
assert.pass("ui was cleaned.");
Expand Down

0 comments on commit bfab090

Please sign in to comment.