2019-01-17 21:18:31 +03:00
|
|
|
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
2018-11-05 17:41:45 +03:00
|
|
|
|
|
|
|
Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
|
|
|
|
registerCleanupFunction(() => {
|
|
|
|
Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
|
|
|
|
});
|
|
|
|
|
2014-07-24 02:20:05 +04:00
|
|
|
function run_test() {
|
|
|
|
|
|
|
|
var toEval = [
|
|
|
|
"var customIterator = {",
|
2017-08-14 14:45:14 +03:00
|
|
|
" _array: [6, 7, 8, 9]",
|
|
|
|
"};",
|
|
|
|
"customIterator[Symbol.iterator] = function* () {",
|
2014-07-24 02:20:05 +04:00
|
|
|
" for (var i = 0; i < this._array.length; ++i)",
|
|
|
|
" yield this._array[i];",
|
2017-08-14 14:45:14 +03:00
|
|
|
"};"
|
2014-07-24 02:20:05 +04:00
|
|
|
].join('\n');
|
|
|
|
|
|
|
|
function checkIterator(iterator) {
|
|
|
|
var control = [6, 7, 8, 9];
|
|
|
|
var i = 0;
|
2017-08-14 14:45:14 +03:00
|
|
|
for (var item of iterator) {
|
2017-12-21 13:08:17 +03:00
|
|
|
Assert.equal(item, control[i]);
|
2014-07-24 02:20:05 +04:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// First, try in our own scope.
|
|
|
|
eval(toEval);
|
|
|
|
checkIterator(customIterator);
|
|
|
|
|
|
|
|
// Next, try a vanilla CCW.
|
|
|
|
var sbChrome = Cu.Sandbox(this);
|
|
|
|
Cu.evalInSandbox(toEval, sbChrome, '1.7');
|
|
|
|
checkIterator(sbChrome.customIterator);
|
|
|
|
|
|
|
|
// Finally, try an Xray waiver.
|
|
|
|
var sbContent = Cu.Sandbox('http://www.example.com');
|
|
|
|
Cu.evalInSandbox(toEval, sbContent, '1.7');
|
|
|
|
checkIterator(Cu.waiveXrays(sbContent.customIterator));
|
|
|
|
}
|