зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1605854 - Fix remaining tests using uneval/toSource r=mccr8,bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D58685 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
d1b15f3063
Коммит
c73016a38b
|
@ -91,7 +91,7 @@
|
|||
for (var p in b) bProps.push(p);
|
||||
|
||||
is (aProps.length, bProps.length, 'Props match');
|
||||
is (aProps.sort().toSource(), bProps.sort().toSource(), 'Props match - using toSource()');
|
||||
is (aProps.sort().toString(), bProps.sort().toString(), 'Props names match');
|
||||
|
||||
for (var p in a) {
|
||||
compare(a[p], b[p]);
|
||||
|
@ -106,7 +106,7 @@
|
|||
}
|
||||
|
||||
if (type != 'null') {
|
||||
is (a.toSource(), b.toSource(), 'Matching using toSource()');
|
||||
is (a, b, 'Same value');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,10 +31,10 @@ function getCOW(x) {
|
|||
x = Cu.waiveXrays(x);
|
||||
var rval = {};
|
||||
if (typeof x == "function")
|
||||
rval = eval(uneval(x));
|
||||
rval = eval(`(${x.toString()})`);
|
||||
for (var i in x) {
|
||||
if (x.__lookupGetter__(i))
|
||||
rval.__defineGetter__(i, eval(uneval(x.__lookupGetter__(i))))
|
||||
rval.__defineGetter__(i, eval(`(${x.__lookupGetter__(i).toString()})`))
|
||||
else
|
||||
rval[i] = getCOW(x[i]);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ function COWTests() {
|
|||
return names;
|
||||
}
|
||||
|
||||
// This function is actually decompiled and run inside a
|
||||
// This function is actually stringified and run inside a
|
||||
// sandbox with content privileges.
|
||||
|
||||
// TODO: This could use some refactoring; creating helper
|
||||
|
@ -204,8 +204,8 @@ function COWTests() {
|
|||
}
|
||||
}
|
||||
|
||||
// Decompile the COW test suite, re-evaluate it in the sandbox and execute it.
|
||||
Cu.evalInSandbox('(' + uneval(COWTests) + ')()', sandbox);
|
||||
// Stringify the COW test suite and directly evaluate it in the sandbox.
|
||||
Cu.evalInSandbox('(' + COWTests.toString() + ')()', sandbox);
|
||||
|
||||
// Test that COWed objects passing from content to chrome get unwrapped.
|
||||
function returnCOW() {
|
||||
|
@ -214,7 +214,7 @@ function returnCOW() {
|
|||
}
|
||||
|
||||
var unwrapped = Cu.evalInSandbox(
|
||||
'(' + uneval(returnCOW) + ')()',
|
||||
'(' + returnCOW.toString() + ')()',
|
||||
sandbox
|
||||
);
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990353
|
|||
function frameLoaded() {
|
||||
switch (++gLoadCount) {
|
||||
case 1:
|
||||
ok(/native code/.test(window[0].canary.toSource()), "System function should be sourceless: " + window[0].canary.toSource());
|
||||
ok(/native code/.test(window[0].onload.toSource()), "System event handler should be sourceless: " + window[0].onload.toSource());
|
||||
ok(/native code/.test(window[0].canary.toString()), "System function should be sourceless: " + window[0].canary.toString());
|
||||
ok(/native code/.test(window[0].onload.toString()), "System event handler should be sourceless: " + window[0].onload.toString());
|
||||
var sb = new Cu.Sandbox('http://www.example.com', { discardSource: true });
|
||||
Cu.evalInSandbox('function canary() { var someBitOfSource = 42; }', sb);
|
||||
ok(/native code/.test(sb.canary.toSource()), "Function from sandbox with explicit discarding should be sourceless");
|
||||
ok(/native code/.test(sb.canary.toString()), "Function from sandbox with explicit discarding should be sourceless");
|
||||
try {
|
||||
window[0].throwSomething();
|
||||
ok(false, "should have thrown");
|
||||
|
@ -43,8 +43,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990353
|
|||
window[0].location = "http://example.org/tests/js/xpconnect/tests/chrome/file_discardSystemSource.html";
|
||||
break;
|
||||
case 2:
|
||||
ok(/someBitOfSource/.test(Cu.waiveXrays(window[0]).canary.toSource()), "Content function should have source");
|
||||
ok(/someBitOfSource/.test(Cu.waiveXrays(window[0]).onload.toSource()), "Content event handler should have source");
|
||||
ok(/someBitOfSource/.test(Cu.waiveXrays(window[0]).canary.toString()), "Content function should have source");
|
||||
ok(/someBitOfSource/.test(Cu.waiveXrays(window[0]).onload.toString()), "Content event handler should have source");
|
||||
testWorker();
|
||||
break;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990353
|
|||
function go() {
|
||||
// We should have our own source, because the pref wasn't enabled when we
|
||||
// were loaded.
|
||||
ok(/someBitOfSource/.test(canary.toSource()), "Should have own source");
|
||||
ok(/someBitOfSource/.test(canary.toString()), "Should have own source");
|
||||
|
||||
window[0].frameElement.onload = frameLoaded;
|
||||
window[0].location = "file_discardSystemSource.html";
|
||||
|
|
|
@ -2,4 +2,4 @@ function canary() {
|
|||
var someBitOfSource = 42;
|
||||
}
|
||||
|
||||
postMessage(canary.toSource());
|
||||
postMessage(canary.toString());
|
||||
|
|
|
@ -46,7 +46,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=390488
|
|||
|
||||
function matches(s, p, name) {
|
||||
ok(s.match(p) != null,
|
||||
name + " - got " + uneval(s) + ", expected a string matching " + uneval(p));
|
||||
name + " - got " + s + ", expected a string matching " + p);
|
||||
}
|
||||
|
||||
function checkForStacks() {
|
||||
|
|
|
@ -19,17 +19,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=628410
|
|||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 628410 **/
|
||||
{
|
||||
// window.toSource() will throw if SpecialPowers is defined on the window and
|
||||
// permissive COWs are not enabled for the global that owns its frame message
|
||||
// manager.
|
||||
let sp = window.SpecialPowers;
|
||||
window.SpecialPowers = null;
|
||||
|
||||
window.toSource();
|
||||
window.SpecialPowers = sp;
|
||||
}
|
||||
|
||||
window.toString();
|
||||
InstallTrigger + "";
|
||||
console + "";
|
||||
|
|
|
@ -27,7 +27,7 @@ function runSandboxTest(testFunc, argString) {
|
|||
var finishFuncName = 'finish_' + testFunc.name;
|
||||
SpecialPowers.Cu.exportFunction(_ => resolvePromise(), sb,
|
||||
{ defineAs: finishFuncName });
|
||||
SpecialPowers.Cu.evalInSandbox('(' + testFunc.toSource() + ')' +
|
||||
SpecialPowers.Cu.evalInSandbox('(' + testFunc.toString() + ')' +
|
||||
'(' + argString + ')' +
|
||||
'.then(' + finishFuncName + ');', sb);
|
||||
return testPromise;
|
||||
|
|
|
@ -24,7 +24,7 @@ function loadPrivilegedScriptTest() {
|
|||
var contentProcessType = SpecialPowers.isMainProcess();
|
||||
var port;
|
||||
try {
|
||||
port = SpecialPowers.loadPrivilegedScript(loadPrivilegedScriptTest.toSource());
|
||||
port = SpecialPowers.loadPrivilegedScript(loadPrivilegedScriptTest.toString());
|
||||
} catch (e) {
|
||||
ok(false, "loadPrivilegedScript shoulde not throw");
|
||||
}
|
||||
|
|
|
@ -1348,7 +1348,7 @@ SimpleTest.monitorConsole = function (continuation, msgs, forbidUnexpectedMsgs)
|
|||
}
|
||||
|
||||
var counter = 0;
|
||||
var assertionLabel = msgs.toSource();
|
||||
var assertionLabel = JSON.stringify(msgs);
|
||||
function listener(msg) {
|
||||
if (msg.message === "SENTINEL" && !msg.isScriptError) {
|
||||
is(counter, msgs.length,
|
||||
|
|
|
@ -29,7 +29,7 @@ function testData(data) {
|
|||
};
|
||||
|
||||
function compare(prop, expected) {
|
||||
if (uneval(data[prop]) == uneval(expected))
|
||||
if (JSON.stringify(data[prop]) == JSON.stringify(expected))
|
||||
return;
|
||||
if (response.result)
|
||||
response.status = "";
|
||||
|
|
|
@ -344,7 +344,7 @@ var classifierTester = {
|
|||
async function fn(frame, iframeId, depth) {
|
||||
return SpecialPowers.spawn(
|
||||
frame,
|
||||
[iframeId, depth, fn.toSource()],
|
||||
[iframeId, depth, fn.toString()],
|
||||
async (iframeId, depth, fnSource) => {
|
||||
// eslint-disable-next-line no-eval
|
||||
let fnGetIframePluginInfo = eval(`(() => (${fnSource}))()`);
|
||||
|
|
|
@ -190,7 +190,7 @@ async function runTest(test, expectedFlag, expectedTrackingResource, prefs) {
|
|||
],
|
||||
];
|
||||
|
||||
info("Testing: " + config.toSource() + "\n");
|
||||
info("Testing: " + JSON.stringify(config) + "\n");
|
||||
|
||||
await SpecialPowers.pushPrefEnv({ set: config.concat(prefs) });
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ async function runTest(test) {
|
|||
[ "privacy.trackingprotection.socialtracking.enabled", false ],
|
||||
]});
|
||||
|
||||
info("Testing: " + test.config.toSource() + "\n");
|
||||
info("Testing: " + JSON.stringify(test.config) + "\n");
|
||||
|
||||
// Let's load an image with a random query string, just to avoid network cache.
|
||||
let result = await new Promise(resolve => {
|
||||
|
|
|
@ -42,7 +42,7 @@ async function runTest(test) {
|
|||
[ "privacy.trackingprotection.socialtracking.enabled", false ],
|
||||
]});
|
||||
|
||||
info("Testing: " + test.config.toSource() + "\n");
|
||||
info("Testing: " + JSON.stringify(test.config) + "\n");
|
||||
|
||||
// Let's load an image with a random query string, just to avoid network cache.
|
||||
let result = await new Promise(resolve => {
|
||||
|
|
|
@ -42,7 +42,7 @@ async function runTest(test) {
|
|||
[ "privacy.trackingprotection.socialtracking.enabled", true ],
|
||||
]});
|
||||
|
||||
info("Testing: " + test.config.toSource() + "\n");
|
||||
info("Testing: " + JSON.stringify(test.config) + "\n");
|
||||
|
||||
// Let's load an image with a random query string, just to avoid network cache.
|
||||
let result = await new Promise(resolve => {
|
||||
|
|
|
@ -75,7 +75,7 @@ const sandboxScript = function(shadowRoot) {
|
|||
win.wrappedJSObject.spanElementFromUAWidget = span;
|
||||
win.wrappedJSObject.divElementFromUAWidget = shadowRoot.lastChild;
|
||||
};
|
||||
SpecialPowers.Cu.evalInSandbox("this.script = " + sandboxScript.toSource(), sandbox);
|
||||
SpecialPowers.Cu.evalInSandbox("this.script = " + sandboxScript.toString(), sandbox);
|
||||
sandbox.script(div.shadowRoot);
|
||||
|
||||
ok(window.spanElementFromUAWidget instanceof HTMLSpanElement, "<span> exposed");
|
||||
|
|
Загрузка…
Ссылка в новой задаче