From 7fa691bb0c1900bd6d929e1d0e12aaf0c5384e08 Mon Sep 17 00:00:00 2001 From: David Rajchenbach-Teller Date: Thu, 28 Jun 2012 21:56:53 -0400 Subject: [PATCH] Bug 763848 - Companion test suite. r=khuey --- dom/system/Makefile.in | 4 ++ dom/system/tests/Makefile.in | 16 ++++++++ dom/system/tests/test_constants.xul | 56 +++++++++++++++++++++++++++ dom/system/tests/worker_constants.js | 58 ++++++++++++++++++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 dom/system/tests/Makefile.in create mode 100644 dom/system/tests/test_constants.xul create mode 100644 dom/system/tests/worker_constants.js diff --git a/dom/system/Makefile.in b/dom/system/Makefile.in index 230804466fef..d8251abbe7e6 100644 --- a/dom/system/Makefile.in +++ b/dom/system/Makefile.in @@ -68,6 +68,10 @@ EXPORTS_mozilla = \ # We fire the nsDOMDeviceAcceleration LOCAL_INCLUDES += -I$(topsrcdir)/content/events/src +ifdef ENABLE_TESTS +DIRS += tests +endif + include $(topsrcdir)/config/config.mk # we don't want the shared lib, but we want to force the creation of a static lib. diff --git a/dom/system/tests/Makefile.in b/dom/system/tests/Makefile.in new file mode 100644 index 000000000000..801c22674f29 --- /dev/null +++ b/dom/system/tests/Makefile.in @@ -0,0 +1,16 @@ +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ +relativesrcdir = dom/system/tests + +MODULE = test_domsystem +_CHROME_TEST_FILES = \ + test_constants.xul \ + worker_constants.js \ + $(NULL) + +include $(topsrcdir)/config/rules.mk + +libs:: $(_CHROME_TEST_FILES) + $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir) diff --git a/dom/system/tests/test_constants.xul b/dom/system/tests/test_constants.xul new file mode 100644 index 000000000000..4a99d87dcfe3 --- /dev/null +++ b/dom/system/tests/test_constants.xul @@ -0,0 +1,56 @@ + + + + + + + +

+ +

+  
+  
diff --git a/dom/system/tests/worker_constants.js b/dom/system/tests/worker_constants.js new file mode 100644 index 000000000000..260b6cbd89ab --- /dev/null +++ b/dom/system/tests/worker_constants.js @@ -0,0 +1,58 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +function log(text) { + dump("WORKER "+text+"\n"); +} + +function send(message) { + self.postMessage(message); +} + +self.onmessage = function(msg) { + self.onmessage = function(msg) { + log("ignored message "+JSON.stringify(msg.data)); + }; + try { + test_xul(); + } catch (x) { + log("Catching error: " + x); + log("Stack: " + x.stack); + log("Source: " + x.toSource()); + ok(false, x.toString() + "\n" + x.stack); + } + finish(); +}; + +function finish() { + send({kind: "finish"}); +} + +function ok(condition, description) { + send({kind: "ok", condition: condition, description:description}); +} +function is(a, b, description) { + send({kind: "is", a: a, b:b, description:description}); +} +function isnot(a, b, description) { + send({kind: "isnot", a: a, b:b, description:description}); +} + +// Test that OS.Constants.Sys.libxulpath lets us open libxul +function test_xul() { + let success; + let lib; + isnot(null, OS.Constants.Sys.libxulpath, "libxulpath is defined"); + try { + lib = ctypes.open(OS.Constants.Sys.libxulpath); + lib.declare("DumpJSStack", ctypes.default_abi, ctypes.void_t); + success = true; + } catch (x) { + success = false; + log("Could not open libxul " + x); + } + if (lib) { + lib.close(); + } + ok(success, "test_xul: opened libxul successfully"); +}