toolkit/components/thumbnails/test/thumbnails_crash_content_helper.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/thumbnails/test/thumbnails_crash_content_helper.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,31 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +* http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +let Cu = Components.utils;
     1.8 +
     1.9 +// Ideally we would use CrashTestUtils.jsm, but that's only available for
    1.10 +// xpcshell tests - so we just copy a ctypes crasher from it.
    1.11 +Cu.import("resource://gre/modules/ctypes.jsm");
    1.12 +let crash = function() { // this will crash when called.
    1.13 +  let zero = new ctypes.intptr_t(8);
    1.14 +  let badptr = ctypes.cast(zero, ctypes.PointerType(ctypes.int32_t));
    1.15 +  badptr.contents
    1.16 +};
    1.17 +
    1.18 +
    1.19 +TestHelper = {
    1.20 +  init: function() {
    1.21 +    addMessageListener("thumbnails-test:crash", this);
    1.22 +  },
    1.23 +
    1.24 +  receiveMessage: function(msg) {
    1.25 +    switch (msg.name) {
    1.26 +      case "thumbnails-test:crash":
    1.27 +        privateNoteIntentionalCrash();
    1.28 +        crash();
    1.29 +      break;
    1.30 +    }
    1.31 +  },
    1.32 +}
    1.33 +
    1.34 +TestHelper.init();

mercurial