4 https://bugzilla.mozilla.org/show_bug.cgi?id=484107
7 <title>Test for Bug
484107</title>
8 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
12 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=484107">Mozilla Bug
484107</a>
14 <div id=
"content" style=
"display: none">
18 <script type=
"application/javascript">
20 /** Test for Bug
484107 **/
22 var text =
"first group",
23 xpcWin = new XPCSafeJSObjectWrapper(window);
24 function get$
1() { return RegExp.$
1 };
27 var match = /(.*)/.exec(text);
28 if (!reset.skipStupidTests) {
29 reset.skipStupidTests = true;
30 ok(match,
"No match?");
31 is(match[
1], text,
"Bad match?");
32 is(text, RegExp.$
1,
"RegExp.$1 missing?");
33 is(text, get$
1(),
"RegExp.$1 inaccessible?");
37 function test_XPC_SJOW_Call() {
38 isnot(text, xpcWin.get$
1(),
"Able to see RegExp.$1 from wrapped method.");
39 is(
"", xpcWin.get$
1(),
"Saw something other than an empty string for " +
40 "RegExp.$1 from wrapped method.");
41 is(text, window.get$
1(),
"Unable to see RegExp.$1 from non-wrapped method.");
44 function test_XPC_SJOW_Call_foreign_obj() {
49 isnot(text, obj.xpcGet(),
"obj.xpcGet() returned matched text.");
50 is(
"", obj.xpcGet(),
"obj.xpcGet() returned something other than the empty string.");
51 is(text, obj.rawGet(),
"obj.rawGet() did not return matched text.");
54 function test_XPC_SJOW_toString() {
55 var str = new XPCSafeJSObjectWrapper({
56 toString: function() { return RegExp.$
1 }
58 isnot(text, str,
"toString() returned the matched text.");
59 is(
"", str,
"toString() returned something other than the empty string.");
62 function test_XPC_SJOW_GetOrSetProperty() {
63 window.__defineGetter__(
"firstMatch", function() { return RegExp.$
1 });
64 isnot(text, xpcWin.firstMatch,
"Getter xpcWin.firstMatch returned matched text.");
65 is(
"", xpcWin.firstMatch,
66 "Getter xpcWin.firstMatch returned something other than the empty string.");
67 is(text, window.firstMatch,
"Getter window.firstMatch did not return matched text.");
70 function test_XPC_SJOW_Create() {
72 this.match = RegExp.$
1;
73 return this; // XXX Why is this necessary?
75 ctor.prototype.getMatch = function() { return this.match };
76 var xpcCtor = new XPCSafeJSObjectWrapper(ctor),
77 match = (new xpcCtor).getMatch();
78 isnot(text, match,
"(new xpcCtor).getMatch() was the matched text.");
79 is(
"", match,
"(new xpcCtor).getMatch() was not the empty string.");
84 test_XPC_SJOW_Call_foreign_obj,
85 test_XPC_SJOW_toString,
86 test_XPC_SJOW_GetOrSetProperty,
90 for (var i =
0; i < tests.length; i++) {
93 is(text, RegExp.$
1,
"RegExp.$1 was clobbered.");