diff --git a/dom/system/Makefile.in b/dom/system/Makefile.in index 230804466fe..d8251abbe7e 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 00000000000..801c22674f2 --- /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 00000000000..4a99d87dcfe --- /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 00000000000..260b6cbd89a --- /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"); +}