js/xpconnect/tests/unit/test_bug868675.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 const Cu = Components.utils;
     2 function run_test() {
     4   // Make sure we don't throw for primitive values.
     5   var result = "threw";
     6   try { result = XPCNativeWrapper.unwrap(2); } catch (e) {}
     7   do_check_eq(result, 2);
     8   result = "threw";
     9   try { result = XPCNativeWrapper(2); } catch (e) {}
    10   do_check_eq(result, 2);
    12   // Make sure that we can waive on a non-Xrayable object, and that we preserve
    13   // transitive waiving behavior.
    14   var sb = new Cu.Sandbox('http://www.example.com', { wantGlobalProperties: ["XMLHttpRequest"] });
    15   Cu.evalInSandbox('this.xhr = new XMLHttpRequest();', sb);
    16   Cu.evalInSandbox('this.jsobj = {mynative: xhr};', sb);
    17   do_check_true(!Cu.isXrayWrapper(XPCNativeWrapper.unwrap(sb.xhr)));
    18   do_check_true(Cu.isXrayWrapper(sb.jsobj.mynative));
    19   do_check_true(!Cu.isXrayWrapper(XPCNativeWrapper.unwrap(sb.jsobj).mynative));
    21   // Test the new Cu API.
    22   var waived = Cu.waiveXrays(sb.xhr);
    23   do_check_true(!Cu.isXrayWrapper(waived));
    24   do_check_true(Cu.isXrayWrapper(Cu.unwaiveXrays(waived)));
    25 }

mercurial