Skip to content

Commit

Permalink
Bug 827801 - Test that OS.Constants is not available to content. r=khuey
Browse files Browse the repository at this point in the history
  • Loading branch information
David Rajchenbach-Teller committed Jan 9, 2013
1 parent d98f0be commit 002e900
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dom/system/tests/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ MOCHITEST_CHROME_FILES = \
test_constants.xul \
worker_constants.js \
$(NULL)

MOCHITEST_FILES = \
test-notaccessiblefromcontent.html \
worker_notaccessiblefromcontent.js \
$(NULL)
include $(topsrcdir)/config/rules.mk
31 changes: 31 additions & 0 deletions dom/system/tests/test-notaccessiblefromcontent.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Testing that OS.Constants is not available from web content</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">

// 1. Test that OS is not available from the main thread
SimpleTest.is(typeof OS, "undefined", "OS is not available from the main thread");

// 2. Test that OS is not available from a web worker
SimpleTest.waitForExplicitFinish();
worker = new Worker("worker_notaccessiblefromcontent.js");
worker.onmessage = function onmessage(event) {
SimpleTest.info("Received " + JSON.stringify(event.data));
SimpleTest.ok(event.data.result, "OS is not available from a web worker");
SimpleTest.finish();
}
worker.onerror = function onerror(event) {
SimpleTest.ok(false, "Error: " + event);
SimpleTest.finish();
};
worker.postMessage(0);

</script>
</head>

<body>
</body>
</html>
6 changes: 6 additions & 0 deletions dom/system/tests/worker_notaccessiblefromcontent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */

self.onmessage = function onmessage() {
self.postMessage({result: typeof OS == "undefined"});
};

0 comments on commit 002e900

Please sign in to comment.