Bug 987111 - Add test coverage to make sure we don't add new Xrayable functionality without auditing it. r=gabor
☠☠ backed out by fe14647a422d ☠ ☠
authorBobby Holley <bobbyholley@gmail.com>
Wed, 04 Jun 2014 15:12:26 -0700
changeset 205919 33860f30fc4f41fd66cf8a6ce65f78eede465b1a
parent 205918 518a915fb81b2ce455a28a627bd530d642ba0a94
child 205920 944d128f135aeebe1d91d940f5ad1d81917db58f
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs987111
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 987111 - Add test coverage to make sure we don't add new Xrayable functionality without auditing it. r=gabor
js/xpconnect/tests/chrome/test_xrayToJS.xul
--- a/js/xpconnect/tests/chrome/test_xrayToJS.xul
+++ b/js/xpconnect/tests/chrome/test_xrayToJS.xul
@@ -105,24 +105,48 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     // We could also test DataView and Iterator here for completeness, but it's
     // more trouble than it's worth.
 
 
     SimpleTest.finish();
   }
 
+  // Maintain a static list of the properties that are available on each standard
+  // prototype, so that we make sure to audit any new ones to make sure they're
+  // Xray-safe.
+  //
+  // DO NOT CHANGE WTIHOUT REVIEW FROM AN XPCONNECT PEER.
+  var gPrototypeProperties = {};
+  gPrototypeProperties['Date'] =
+    ["getTime", "getTimezoneOffset", "getYear", "getFullYear", "getUTCFullYear",
+    "getMonth", "getUTCMonth", "getDate", "getUTCDate", "getDay", "getUTCDay",
+    "getHours", "getUTCHours", "getMinutes", "getUTCMinutes", "getSeconds",
+    "getUTCSeconds", "getMilliseconds", "getUTCMilliseconds", "setTime",
+    "setYear", "setFullYear", "setUTCFullYear", "setMonth", "setUTCMonth",
+    "setDate", "setUTCDate", "setHours", "setUTCHours", "setMinutes",
+    "setUTCMinutes", "setSeconds", "setUTCSeconds", "setMilliseconds",
+    "setUTCMilliseconds", "toUTCString", "toLocaleFormat", "toLocaleString",
+    "toLocaleDateString", "toLocaleTimeString", "toDateString", "toTimeString",
+    "toISOString", "toJSON", "toSource", "toString", "valueOf", "constructor",
+    "toGMTString"];
+
   function filterOut(array, props) {
     return array.filter(p => props.indexOf(p) == -1);
   }
 
   function testXray(classname, xray, xray2, propsToSkip) {
     propsToSkip = propsToSkip || [];
     let xrayProto = Object.getPrototypeOf(xray);
     let localProto = window[classname].prototype;
+    is(Object.getOwnPropertyNames(localProto).sort().toSource(),
+       gPrototypeProperties[classname].sort().toSource(),
+       "A new property on the " + classname +
+       " prototype has been added! You need a security audit from an XPConnect peer");
+
     let protoProps = filterOut(Object.getOwnPropertyNames(localProto), propsToSkip).sort();
     let protoMethods = protoProps.filter(name => typeof localProto[name] == 'function' &&
                                          name != 'constructor');
     ok(protoMethods.length > 0, "Need something to test");
     is(xrayProto, iwin[classname].prototype, "Xray proto is correct");
     is(xrayProto, xray.__proto__, "Proto accessors agree");
     is(Object.getPrototypeOf(xrayProto), iwin.Object.prototype, "proto proto is correct");
     for (let name of protoMethods) {