js/xpconnect/tests/unit/test_bug868675.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial