зеркало из https://github.com/mozilla/gecko-dev.git
Merge mozilla-central to autoland. a=merge CLOSED TREE
This commit is contained in:
Коммит
a27f06758a
|
@ -7,12 +7,14 @@ const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/
|
|||
const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/benignPage.html";
|
||||
const TP_PREF = "privacy.trackingprotection.enabled";
|
||||
const ANIMATIONS_PREF = "toolkit.cosmeticAnimations.enabled";
|
||||
const DTSCBN_PREF = "dom.testing.sync-content-blocking-notifications";
|
||||
|
||||
// Test that the shield icon animation can be controlled by the cosmetic
|
||||
// animations pref and that one of the icons is visible in each case.
|
||||
add_task(async function testShieldAnimation() {
|
||||
await UrlClassifierTestUtils.addTestTrackers();
|
||||
Services.prefs.setBoolPref(TP_PREF, true);
|
||||
Services.prefs.setBoolPref(DTSCBN_PREF, true);
|
||||
|
||||
let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
|
||||
|
@ -20,7 +22,8 @@ add_task(async function testShieldAnimation() {
|
|||
let noAnimationIcon = document.getElementById("tracking-protection-icon");
|
||||
|
||||
Services.prefs.setBoolPref(ANIMATIONS_PREF, true);
|
||||
await promiseTabLoadEvent(tab, TRACKING_PAGE);
|
||||
await Promise.all([promiseTabLoadEvent(tab, TRACKING_PAGE),
|
||||
waitForContentBlockingEvent(2, tab.linkedBrowser.ownerGlobal)]);
|
||||
ok(BrowserTestUtils.is_hidden(noAnimationIcon), "the default icon is hidden when animations are enabled");
|
||||
ok(BrowserTestUtils.is_visible(animationIcon), "the animated icon is shown when animations are enabled");
|
||||
|
||||
|
@ -29,12 +32,14 @@ add_task(async function testShieldAnimation() {
|
|||
ok(BrowserTestUtils.is_hidden(noAnimationIcon), "the default icon is hidden");
|
||||
|
||||
Services.prefs.setBoolPref(ANIMATIONS_PREF, false);
|
||||
await promiseTabLoadEvent(tab, TRACKING_PAGE);
|
||||
await Promise.all([promiseTabLoadEvent(tab, TRACKING_PAGE),
|
||||
waitForContentBlockingEvent(2, tab.linkedBrowser.ownerGlobal)]);
|
||||
ok(BrowserTestUtils.is_visible(noAnimationIcon), "the default icon is shown when animations are disabled");
|
||||
ok(BrowserTestUtils.is_hidden(animationIcon), "the animated icon is hidden when animations are disabled");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
Services.prefs.clearUserPref(ANIMATIONS_PREF);
|
||||
Services.prefs.clearUserPref(TP_PREF);
|
||||
Services.prefs.clearUserPref(DTSCBN_PREF);
|
||||
UrlClassifierTestUtils.cleanupTestTrackers();
|
||||
});
|
||||
|
|
|
@ -11,6 +11,7 @@ const NCB_PREF = "network.cookie.cookieBehavior";
|
|||
const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/benignPage.html";
|
||||
const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
|
||||
const COOKIE_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/cookiePage.html";
|
||||
const DTSCBN_PREF = "dom.testing.sync-content-blocking-notifications";
|
||||
|
||||
requestLongerTimeout(2);
|
||||
|
||||
|
@ -19,10 +20,13 @@ registerCleanupFunction(function() {
|
|||
Services.prefs.clearUserPref(TP_PREF);
|
||||
Services.prefs.clearUserPref(TP_PB_PREF);
|
||||
Services.prefs.clearUserPref(NCB_PREF);
|
||||
Services.prefs.clearUserPref(DTSCBN_PREF);
|
||||
Services.prefs.clearUserPref(ContentBlocking.prefIntroCount);
|
||||
});
|
||||
|
||||
async function testTrackingProtectionAnimation(tabbrowser) {
|
||||
Services.prefs.setBoolPref(DTSCBN_PREF, true);
|
||||
|
||||
info("Load a test page not containing tracking elements");
|
||||
let benignTab = await BrowserTestUtils.openNewForegroundTab(tabbrowser, BENIGN_PAGE);
|
||||
let ContentBlocking = tabbrowser.ownerGlobal.ContentBlocking;
|
||||
|
|
|
@ -6,12 +6,14 @@
|
|||
|
||||
const TP_PB_PREF = "privacy.trackingprotection.enabled";
|
||||
const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
|
||||
const DTSCBN_PREF = "dom.testing.sync-content-blocking-notifications";
|
||||
var TrackingProtection = null;
|
||||
var ContentBlocking = null;
|
||||
var browser = null;
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref(TP_PB_PREF);
|
||||
Services.prefs.clearUserPref(DTSCBN_PREF);
|
||||
ContentBlocking = TrackingProtection = browser = null;
|
||||
UrlClassifierTestUtils.cleanupTestTrackers();
|
||||
});
|
||||
|
@ -79,6 +81,7 @@ function testTrackingPageUnblocked() {
|
|||
|
||||
add_task(async function testExceptionAddition() {
|
||||
await UrlClassifierTestUtils.addTestTrackers();
|
||||
Services.prefs.setBoolPref(DTSCBN_PREF, true);
|
||||
let privateWin = await BrowserTestUtils.openNewBrowserWindow({private: true});
|
||||
browser = privateWin.gBrowser;
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab({ gBrowser: browser, waitForLoad: true, waitForStateStop: true });
|
||||
|
@ -92,7 +95,8 @@ add_task(async function testExceptionAddition() {
|
|||
ok(TrackingProtection.enabled, "TP is enabled after setting the pref");
|
||||
|
||||
info("Load a test page containing tracking elements");
|
||||
await promiseTabLoadEvent(tab, TRACKING_PAGE);
|
||||
await Promise.all([promiseTabLoadEvent(tab, TRACKING_PAGE),
|
||||
waitForContentBlockingEvent(2, tab.ownerGlobal)]);
|
||||
|
||||
testTrackingPage(tab.ownerGlobal);
|
||||
|
||||
|
@ -128,7 +132,8 @@ add_task(async function testExceptionPersistence() {
|
|||
ok(TrackingProtection.enabled, "TP is still enabled");
|
||||
|
||||
info("Load a test page containing tracking elements");
|
||||
await promiseTabLoadEvent(tab, TRACKING_PAGE);
|
||||
await Promise.all([promiseTabLoadEvent(tab, TRACKING_PAGE),
|
||||
waitForContentBlockingEvent(2, tab.ownerGlobal)]);
|
||||
|
||||
testTrackingPage(tab.ownerGlobal);
|
||||
|
||||
|
@ -137,7 +142,8 @@ add_task(async function testExceptionPersistence() {
|
|||
clickButton("#tracking-action-unblock");
|
||||
is(identityPopupState(), "closed", "Identity popup is closed");
|
||||
|
||||
await tabReloadPromise;
|
||||
await Promise.all([tabReloadPromise,
|
||||
waitForContentBlockingEvent(2, tab.ownerGlobal)]);
|
||||
testTrackingPageUnblocked();
|
||||
|
||||
privateWin.close();
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
const TP_PREF = "privacy.trackingprotection.enabled";
|
||||
const TP_PB_PREF = "privacy.trackingprotection.pbmode.enabled";
|
||||
const TPC_PREF = "network.cookie.cookieBehavior";
|
||||
const DTSCBN_PREF = "dom.testing.sync-content-blocking-notifications";
|
||||
const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/benignPage.html";
|
||||
const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
|
||||
const COOKIE_PAGE = "http://not-tracking.example.com/browser/browser/base/content/test/trackingUI/cookiePage.html";
|
||||
|
@ -33,6 +34,7 @@ registerCleanupFunction(function() {
|
|||
Services.prefs.clearUserPref(TP_PREF);
|
||||
Services.prefs.clearUserPref(TP_PB_PREF);
|
||||
Services.prefs.clearUserPref(TPC_PREF);
|
||||
Services.prefs.clearUserPref(DTSCBN_PREF);
|
||||
});
|
||||
|
||||
// This is a special version of "hidden" that doesn't check for item
|
||||
|
@ -106,8 +108,8 @@ function testTrackingPage(window) {
|
|||
ok(ContentBlocking.content.hasAttribute("detected"), "trackers are detected");
|
||||
ok(!ContentBlocking.content.hasAttribute("hasException"), "content shows no exception");
|
||||
|
||||
let isPrivateBrowsing = PrivateBrowsingUtils.isWindowPrivate(window);
|
||||
let blockedByTP = areTrackersBlocked(isPrivateBrowsing);
|
||||
let isWindowPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
|
||||
let blockedByTP = areTrackersBlocked(isWindowPrivate);
|
||||
is(BrowserTestUtils.is_visible(ContentBlocking.iconBox), blockedByTP,
|
||||
"icon box is" + (blockedByTP ? "" : " not") + " visible");
|
||||
is(ContentBlocking.iconBox.hasAttribute("active"), blockedByTP,
|
||||
|
@ -119,7 +121,6 @@ function testTrackingPage(window) {
|
|||
|
||||
ok(hidden("#tracking-action-block"), "blockButton is hidden");
|
||||
|
||||
let isWindowPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
|
||||
if (isWindowPrivate) {
|
||||
ok(hidden("#tracking-action-unblock"), "unblockButton is hidden");
|
||||
is(!hidden("#tracking-action-unblock-private"), blockedByTP,
|
||||
|
@ -218,6 +219,8 @@ async function testContentBlocking(tab) {
|
|||
add_task(async function testNormalBrowsing() {
|
||||
await UrlClassifierTestUtils.addTestTrackers();
|
||||
|
||||
Services.prefs.setBoolPref(DTSCBN_PREF, true);
|
||||
|
||||
tabbrowser = gBrowser;
|
||||
let tab = tabbrowser.selectedTab = BrowserTestUtils.addTab(tabbrowser);
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/te
|
|||
const TP_PREF = "privacy.trackingprotection.enabled";
|
||||
const COOKIE_PREF = "network.cookie.cookieBehavior";
|
||||
const ANIMATIONS_PREF = "toolkit.cosmeticAnimations.enabled";
|
||||
const DTSCBN_PREF = "dom.testing.sync-content-blocking-notifications";
|
||||
|
||||
// Check that the shield icon is always hidden when all content blocking
|
||||
// categories are turned off, even when content blocking is on.
|
||||
|
@ -15,6 +16,7 @@ add_task(async function testContentBlockingAllDisabled() {
|
|||
await SpecialPowers.pushPrefEnv({set: [
|
||||
[TP_PREF, false],
|
||||
[COOKIE_PREF, Ci.nsICookieService.BEHAVIOR_ACCEPT],
|
||||
[DTSCBN_PREF, true],
|
||||
]});
|
||||
await UrlClassifierTestUtils.addTestTrackers();
|
||||
|
||||
|
@ -30,7 +32,8 @@ add_task(async function testContentBlockingAllDisabled() {
|
|||
let animationIcon = document.getElementById("tracking-protection-icon-animatable-image");
|
||||
let noAnimationIcon = document.getElementById("tracking-protection-icon");
|
||||
|
||||
await promiseTabLoadEvent(tab, TRACKING_PAGE);
|
||||
await Promise.all([promiseTabLoadEvent(tab, TRACKING_PAGE),
|
||||
waitForContentBlockingEvent(2, tab.ownerGlobal)]);
|
||||
ok(BrowserTestUtils.is_hidden(noAnimationIcon), "the default icon is hidden");
|
||||
ok(BrowserTestUtils.is_hidden(animationIcon), "the animated icon is hidden");
|
||||
|
||||
|
@ -47,6 +50,7 @@ add_task(async function testContentBlockingAllDisabled() {
|
|||
await SpecialPowers.pushPrefEnv({set: [
|
||||
[TP_PREF, true],
|
||||
]});
|
||||
await promiseTabLoadEvent(tab, TRACKING_PAGE);
|
||||
await Promise.all([promiseTabLoadEvent(tab, TRACKING_PAGE),
|
||||
waitForContentBlockingEvent(2, tab.ownerGlobal)]);
|
||||
ok(BrowserTestUtils.is_visible(noAnimationIcon), "the default icon is shown");
|
||||
});
|
||||
|
|
|
@ -26,8 +26,10 @@ export function createFrame(frame: FramePacket): ?Frame {
|
|||
} else {
|
||||
title = `(${frame.type})`;
|
||||
}
|
||||
|
||||
// NOTE: Firefox 66 switched from where.source to where.actor
|
||||
const location = {
|
||||
sourceId: frame.where.source.actor,
|
||||
sourceId: frame.where.source ? frame.where.source.actor : frame.where.actor,
|
||||
line: frame.where.line,
|
||||
column: frame.where.column
|
||||
};
|
||||
|
|
|
@ -99,7 +99,7 @@ const FrameActor = ActorClassWithSpec(frameSpec, {
|
|||
if (this.frame.script) {
|
||||
const generatedLocation = this.threadActor.sources.getFrameLocation(this.frame);
|
||||
form.where = {
|
||||
source: generatedLocation.generatedSourceActor.form(),
|
||||
actor: generatedLocation.generatedSourceActor.actorID,
|
||||
line: generatedLocation.generatedLine,
|
||||
column: generatedLocation.generatedColumn,
|
||||
};
|
||||
|
|
|
@ -483,7 +483,7 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
|
|||
}
|
||||
|
||||
packet.frame.where = {
|
||||
source: generatedSourceActor.form(),
|
||||
actor: generatedSourceActor.actorID,
|
||||
line: generatedLine,
|
||||
column: generatedColumn,
|
||||
};
|
||||
|
@ -1191,19 +1191,17 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
|
|||
|
||||
const frameSourceActor = this.sources.createSourceActor(frame.script.source);
|
||||
if (frameSourceActor) {
|
||||
const sourceForm = frameSourceActor.form();
|
||||
form.where = {
|
||||
source: sourceForm,
|
||||
actor: frameSourceActor.actorID,
|
||||
line: form.where.line,
|
||||
column: form.where.column,
|
||||
};
|
||||
form.source = sourceForm;
|
||||
frameItem = form;
|
||||
}
|
||||
frames.push(frameItem);
|
||||
}
|
||||
|
||||
// Filter null values because sourcemapping may have failed.
|
||||
// Filter null values because createSourceActor can be falsey
|
||||
return { frames: frames.filter(x => !!x) };
|
||||
},
|
||||
|
||||
|
|
|
@ -804,19 +804,26 @@ function getSourceContent(sourceClient) {
|
|||
* @param string url
|
||||
* @returns Promise<SourceClient>
|
||||
*/
|
||||
function getSource(threadClient, url) {
|
||||
const deferred = defer();
|
||||
threadClient.getSources((res) => {
|
||||
const source = res.sources.filter(function(s) {
|
||||
return s.url === url;
|
||||
});
|
||||
if (source.length) {
|
||||
deferred.resolve(threadClient.source(source[0]));
|
||||
} else {
|
||||
deferred.reject(new Error("source not found"));
|
||||
}
|
||||
});
|
||||
return deferred.promise;
|
||||
async function getSource(threadClient, url) {
|
||||
const {sources} = await threadClient.getSources();
|
||||
const source = sources.find((s) => s.url === url);
|
||||
|
||||
if (source) {
|
||||
return threadClient.source(source);
|
||||
}
|
||||
|
||||
throw new Error("source not found");
|
||||
}
|
||||
|
||||
async function getSourceById(threadClient, id) {
|
||||
const { sources } = await threadClient.getSources();
|
||||
const form = sources.find(source => source.actor == id);
|
||||
return threadClient.source(form);
|
||||
}
|
||||
|
||||
async function getSourceFormById(threadClient, id) {
|
||||
const { sources } = await threadClient.getSources();
|
||||
return sources.find(source => source.actor == id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,29 +30,31 @@ const SOURCE_URL = "http://example.com/source.js";
|
|||
|
||||
const testBlackBox = async function() {
|
||||
const packet = await executeOnNextTickAndWaitForPause(evalCode, gClient);
|
||||
const source = gThreadClient.source(packet.frame.where.source);
|
||||
const bpSource = await getSourceById(
|
||||
gThreadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
|
||||
await setBreakpoint(source, {
|
||||
line: 2,
|
||||
});
|
||||
await setBreakpoint(bpSource, { line: 2 });
|
||||
await resume(gThreadClient);
|
||||
|
||||
const { sources } = await getSources(gThreadClient);
|
||||
const sourceClient = gThreadClient.source(
|
||||
sources.filter(s => s.url == BLACK_BOXED_URL)[0]
|
||||
);
|
||||
const sourceClient = await getSource(gThreadClient, BLACK_BOXED_URL);
|
||||
|
||||
Assert.ok(!sourceClient.isBlackBoxed,
|
||||
"By default the source is not black boxed.");
|
||||
|
||||
// Test that we can step into `doStuff` when we are not black boxed.
|
||||
await runTest(
|
||||
function onSteppedLocation(location) {
|
||||
Assert.equal(location.source.url, BLACK_BOXED_URL);
|
||||
async function onSteppedLocation(location) {
|
||||
const source = await getSourceFormById(gThreadClient, location.actor);
|
||||
Assert.equal(source.url, BLACK_BOXED_URL);
|
||||
Assert.equal(location.line, 2);
|
||||
},
|
||||
function onDebuggerStatementFrames(frames) {
|
||||
Assert.ok(!frames.some(f => f.where.source.isBlackBoxed));
|
||||
async function onDebuggerStatementFrames(frames) {
|
||||
for (const frame of frames) {
|
||||
const source = await getSourceFormById(gThreadClient, frame.where.actor);
|
||||
Assert.ok(!source.isBlackBoxed);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -62,16 +64,18 @@ const testBlackBox = async function() {
|
|||
// Test that we step through `doStuff` when we are black boxed and its frame
|
||||
// doesn't show up.
|
||||
await runTest(
|
||||
function onSteppedLocation(location) {
|
||||
Assert.equal(location.source.url, SOURCE_URL);
|
||||
async function onSteppedLocation(location) {
|
||||
const source = await getSourceFormById(gThreadClient, location.actor);
|
||||
Assert.equal(source.url, SOURCE_URL);
|
||||
Assert.equal(location.line, 4);
|
||||
},
|
||||
function onDebuggerStatementFrames(frames) {
|
||||
for (const f of frames) {
|
||||
if (f.where.source.url == BLACK_BOXED_URL) {
|
||||
Assert.ok(f.where.source.isBlackBoxed);
|
||||
async function onDebuggerStatementFrames(frames) {
|
||||
for (const frame of frames) {
|
||||
const source = await getSourceFormById(gThreadClient, frame.where.actor);
|
||||
if (source.url == BLACK_BOXED_URL) {
|
||||
Assert.ok(source.isBlackBoxed);
|
||||
} else {
|
||||
Assert.ok(!f.where.source.isBlackBoxed);
|
||||
Assert.ok(!source.isBlackBoxed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,12 +86,16 @@ const testBlackBox = async function() {
|
|||
|
||||
// Test that we can step into `doStuff` again.
|
||||
await runTest(
|
||||
function onSteppedLocation(location) {
|
||||
Assert.equal(location.source.url, BLACK_BOXED_URL);
|
||||
async function onSteppedLocation(location) {
|
||||
const source = await getSourceFormById(gThreadClient, location.actor);
|
||||
Assert.equal(source.url, BLACK_BOXED_URL);
|
||||
Assert.equal(location.line, 2);
|
||||
},
|
||||
function onDebuggerStatementFrames(frames) {
|
||||
Assert.ok(!frames.some(f => f.where.source.isBlackBoxed));
|
||||
async function onDebuggerStatementFrames(frames) {
|
||||
for (const frame of frames) {
|
||||
const source = await getSourceFormById(gThreadClient, frame.where.actor);
|
||||
Assert.ok(!source.isBlackBoxed);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -132,13 +140,13 @@ const runTest = async function(onSteppedLocation, onDebuggerStatementFrames) {
|
|||
await stepIn(gClient, gThreadClient);
|
||||
|
||||
const location = await getCurrentLocation();
|
||||
onSteppedLocation(location);
|
||||
await onSteppedLocation(location);
|
||||
|
||||
packet = await resumeAndWaitForPause(gClient, gThreadClient);
|
||||
Assert.equal(packet.why.type, "debuggerStatement");
|
||||
|
||||
const { frames } = await getFrames(gThreadClient, 0, 100);
|
||||
onDebuggerStatementFrames(frames);
|
||||
await onDebuggerStatementFrames(frames);
|
||||
|
||||
return resume(gThreadClient);
|
||||
};
|
||||
|
|
|
@ -31,14 +31,12 @@ const BLACK_BOXED_URL = "http://example.com/blackboxme.js";
|
|||
const SOURCE_URL = "http://example.com/source.js";
|
||||
|
||||
function test_black_box() {
|
||||
gClient.addOneTimeListener("paused", function(event, packet) {
|
||||
const source = gThreadClient.source(packet.frame.where.source);
|
||||
source.setBreakpoint({
|
||||
line: 4,
|
||||
}).then(function([response, bpClient]) {
|
||||
gBpClient = bpClient;
|
||||
gThreadClient.resume(test_black_box_dbg_statement);
|
||||
});
|
||||
gClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const source = await getSourceById(gThreadClient, packet.frame.where.actor);
|
||||
const [, bpClient] = await source.setBreakpoint({ line: 4 });
|
||||
gBpClient = bpClient;
|
||||
await gThreadClient.resume();
|
||||
test_black_box_dbg_statement();
|
||||
});
|
||||
|
||||
/* eslint-disable no-multi-spaces, no-undef */
|
||||
|
@ -73,19 +71,17 @@ function test_black_box() {
|
|||
function test_black_box_dbg_statement() {
|
||||
gThreadClient.getSources(async function({error, sources}) {
|
||||
Assert.ok(!error, "Should not get an error: " + error);
|
||||
const sourceClient = gThreadClient.source(
|
||||
sources.filter(s => s.url == BLACK_BOXED_URL)[0]
|
||||
);
|
||||
const sourceClient = await getSource(gThreadClient, BLACK_BOXED_URL);
|
||||
|
||||
await blackBox(sourceClient);
|
||||
|
||||
gClient.addOneTimeListener("paused", function(event, packet) {
|
||||
gThreadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
Assert.equal(packet.why.type, "breakpoint",
|
||||
"We should pass over the debugger statement.");
|
||||
gBpClient.remove(function({error}) {
|
||||
Assert.ok(!error, "Should not get an error: " + error);
|
||||
gThreadClient.resume(test_unblack_box_dbg_statement.bind(null, sourceClient));
|
||||
});
|
||||
|
||||
await gBpClient.remove();
|
||||
await gThreadClient.resume();
|
||||
await test_unblack_box_dbg_statement(sourceClient);
|
||||
});
|
||||
gDebuggee.runTest();
|
||||
});
|
||||
|
|
|
@ -71,15 +71,14 @@ function test_black_box() {
|
|||
function test_black_box_exception() {
|
||||
gThreadClient.getSources(async function({error, sources}) {
|
||||
Assert.ok(!error, "Should not get an error: " + error);
|
||||
const sourceClient = gThreadClient.source(
|
||||
sources.filter(s => s.url == BLACK_BOXED_URL)[0]
|
||||
);
|
||||
|
||||
const sourceClient = await getSource(gThreadClient, BLACK_BOXED_URL);
|
||||
await blackBox(sourceClient);
|
||||
gThreadClient.pauseOnExceptions(true);
|
||||
|
||||
gClient.addOneTimeListener("paused", function(event, packet) {
|
||||
Assert.equal(packet.frame.where.source.url, SOURCE_URL,
|
||||
gClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const source = await getSourceById(gThreadClient, packet.frame.where.actor);
|
||||
|
||||
Assert.equal(source.url, SOURCE_URL,
|
||||
"We shouldn't pause while in the black boxed source.");
|
||||
finishClient(gClient);
|
||||
});
|
||||
|
|
|
@ -8,45 +8,44 @@
|
|||
* Check basic breakpoint functionality.
|
||||
*/
|
||||
|
||||
add_task(threadClientTest(({ threadClient, debuggee }) => {
|
||||
return new Promise(resolve => {
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
const location = {
|
||||
line: debuggee.line0 + 3,
|
||||
};
|
||||
|
||||
source.setBreakpoint(location).then(function([response, bpClient]) {
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
// Check the return value.
|
||||
Assert.equal(packet.type, "paused");
|
||||
Assert.equal(packet.frame.where.source.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.line, location.line);
|
||||
Assert.equal(packet.why.type, "breakpoint");
|
||||
Assert.equal(packet.why.actors[0], bpClient.actor);
|
||||
// Check that the breakpoint worked.
|
||||
Assert.equal(debuggee.a, 1);
|
||||
Assert.equal(debuggee.b, undefined);
|
||||
|
||||
// Remove the breakpoint.
|
||||
bpClient.remove(function(response) {
|
||||
threadClient.resume(resolve);
|
||||
});
|
||||
});
|
||||
|
||||
// Continue until the breakpoint is hit.
|
||||
threadClient.resume();
|
||||
});
|
||||
});
|
||||
|
||||
/* eslint-disable */
|
||||
Cu.evalInSandbox(
|
||||
"var line0 = Error().lineNumber;\n" +
|
||||
"debugger;\n" + // line0 + 1
|
||||
"var a = 1;\n" + // line0 + 2
|
||||
"var b = 2;\n", // line0 + 3
|
||||
debuggee
|
||||
add_task(threadClientTest(async ({ threadClient, debuggee }) => {
|
||||
(async () => {
|
||||
info("Wait for the debugger statement to be hit");
|
||||
let packet = await waitForPause(threadClient);
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
/* eslint-enable */
|
||||
});
|
||||
|
||||
const location = { line: debuggee.line0 + 3 };
|
||||
|
||||
const [, bpClient] = await source.setBreakpoint(location);
|
||||
|
||||
await threadClient.resume();
|
||||
packet = await waitForPause(threadClient);
|
||||
|
||||
info("Paused at the breakpoint");
|
||||
Assert.equal(packet.type, "paused");
|
||||
Assert.equal(packet.frame.where.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.line, location.line);
|
||||
Assert.equal(packet.why.type, "breakpoint");
|
||||
Assert.equal(packet.why.actors[0], bpClient.actor);
|
||||
|
||||
info("Check that the breakpoint worked.");
|
||||
Assert.equal(debuggee.a, 1);
|
||||
Assert.equal(debuggee.b, undefined);
|
||||
|
||||
await bpClient.remove();
|
||||
await threadClient.resume();
|
||||
})();
|
||||
|
||||
/* eslint-disable */
|
||||
Cu.evalInSandbox(
|
||||
"var line0 = Error().lineNumber;\n" +
|
||||
"debugger;\n" + // line0 + 1
|
||||
"var a = 1;\n" + // line0 + 2
|
||||
"var b = 2;\n", // line0 + 3
|
||||
debuggee
|
||||
);
|
||||
/* eslint-enable */
|
||||
}));
|
||||
|
|
|
@ -9,9 +9,13 @@
|
|||
*/
|
||||
|
||||
add_task(threadClientTest(({ threadClient, debuggee }) => {
|
||||
return new Promise(resolve => {
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
return new Promise((resolve) => {
|
||||
threadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const location = { line: debuggee.line0 + 3 };
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
|
||||
threadClient.resume();
|
||||
|
||||
|
@ -21,7 +25,6 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
|
|||
Assert.equal(packet.why.type, "interrupted");
|
||||
});
|
||||
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
source.setBreakpoint(location).then(function() {
|
||||
executeSoon(resolve);
|
||||
}, function(response) {
|
||||
|
|
|
@ -24,8 +24,10 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
|
|||
return new Promise(resolve => {
|
||||
threadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const location = { line: debuggee.line0 + 3 };
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
// First, make sure that we can disable sliding with the
|
||||
// `noSliding` option.
|
||||
await test_no_skip_breakpoint(source, location, debuggee);
|
||||
|
@ -39,7 +41,7 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
|
|||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
// Check the return value.
|
||||
Assert.equal(packet.type, "paused");
|
||||
Assert.equal(packet.frame.where.source.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.line, location.line + 1);
|
||||
Assert.equal(packet.why.type, "breakpoint");
|
||||
Assert.equal(packet.why.actors[0], bpClient.actor);
|
||||
|
|
|
@ -10,8 +10,11 @@
|
|||
|
||||
add_task(threadClientTest(({ threadClient, debuggee }) => {
|
||||
return new Promise(resolve => {
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
threadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
const location = { line: debuggee.line0 + 3 };
|
||||
|
||||
source.setBreakpoint(location).then(function([response, bpClient]) {
|
||||
|
@ -21,7 +24,7 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
|
|||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
// Check the return value.
|
||||
Assert.equal(packet.type, "paused");
|
||||
Assert.equal(packet.frame.where.source.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.line, location.line);
|
||||
Assert.equal(packet.why.type, "breakpoint");
|
||||
Assert.equal(packet.why.actors[0], bpClient.actor);
|
||||
|
|
|
@ -11,8 +11,11 @@
|
|||
|
||||
add_task(threadClientTest(({ threadClient, debuggee }) => {
|
||||
return new Promise(resolve => {
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
threadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
const location = { line: debuggee.line0 + 3 };
|
||||
|
||||
source.setBreakpoint(location).then(function([response, bpClient]) {
|
||||
|
@ -23,7 +26,7 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
|
|||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
// Check the return value.
|
||||
Assert.equal(packet.type, "paused");
|
||||
Assert.equal(packet.frame.where.source.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.line, location.line + 1);
|
||||
Assert.equal(packet.why.type, "breakpoint");
|
||||
Assert.equal(packet.why.actors[0], bpClient.actor);
|
||||
|
|
|
@ -11,8 +11,11 @@
|
|||
|
||||
add_task(threadClientTest(({ threadClient, debuggee }) => {
|
||||
return new Promise(resolve => {
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
threadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
const location = { line: debuggee.line0 + 5 };
|
||||
|
||||
source.setBreakpoint(location).then(function([response, bpClient]) {
|
||||
|
@ -23,7 +26,7 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
|
|||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
// Check the return value.
|
||||
Assert.equal(packet.type, "paused");
|
||||
Assert.equal(packet.frame.where.source.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.line, location.line + 1);
|
||||
Assert.equal(packet.why.type, "breakpoint");
|
||||
Assert.equal(packet.why.actors[0], bpClient.actor);
|
||||
|
|
|
@ -11,8 +11,11 @@
|
|||
|
||||
add_task(threadClientTest(({ threadClient, debuggee }) => {
|
||||
return new Promise(resolve => {
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
threadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
const location = { line: debuggee.line0 + 6 };
|
||||
|
||||
source.setBreakpoint(location).then(function([response, bpClient]) {
|
||||
|
@ -23,7 +26,7 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
|
|||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
// Check the return value.
|
||||
Assert.equal(packet.type, "paused");
|
||||
Assert.equal(packet.frame.where.source.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.line, location.line + 1);
|
||||
Assert.equal(packet.why.type, "breakpoint");
|
||||
Assert.equal(packet.why.actors[0], bpClient.actor);
|
||||
|
|
|
@ -13,42 +13,43 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
|
|||
return new Promise(resolve => {
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
threadClient.eval(packet.frame.actor, "foo", function(response) {
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
threadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const obj = threadClient.pauseGrip(packet.why.frameFinished.return);
|
||||
obj.getDefinitionSite(runWithBreakpoint);
|
||||
const site = await obj.getDefinitionSite();
|
||||
|
||||
const location = { line: debuggee.line0 + 3 };
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
site.source.actor
|
||||
);
|
||||
|
||||
source.setBreakpoint(location).then(function([response, bpClient]) {
|
||||
// Check that the breakpoint has properly skipped forward one line.
|
||||
Assert.equal(response.actualLocation.source.actor, source.actor);
|
||||
Assert.equal(response.actualLocation.line, location.line + 1);
|
||||
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
// Check the return value.
|
||||
Assert.equal(packet.type, "paused");
|
||||
Assert.equal(packet.frame.where.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.line, location.line + 1);
|
||||
Assert.equal(packet.why.type, "breakpoint");
|
||||
Assert.equal(packet.why.actors[0], bpClient.actor);
|
||||
// Check that the breakpoint worked.
|
||||
Assert.equal(debuggee.a, 1);
|
||||
Assert.equal(debuggee.b, undefined);
|
||||
|
||||
// Remove the breakpoint.
|
||||
bpClient.remove(function(response) {
|
||||
threadClient.resume(resolve);
|
||||
});
|
||||
});
|
||||
|
||||
// Continue until the breakpoint is hit.
|
||||
threadClient.resume();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function runWithBreakpoint(packet) {
|
||||
const source = threadClient.source(packet.source);
|
||||
const location = { line: debuggee.line0 + 3 };
|
||||
|
||||
source.setBreakpoint(location).then(function([response, bpClient]) {
|
||||
// Check that the breakpoint has properly skipped forward one line.
|
||||
Assert.equal(response.actualLocation.source.actor, source.actor);
|
||||
Assert.equal(response.actualLocation.line, location.line + 1);
|
||||
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
// Check the return value.
|
||||
Assert.equal(packet.type, "paused");
|
||||
Assert.equal(packet.frame.where.source.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.line, location.line + 1);
|
||||
Assert.equal(packet.why.type, "breakpoint");
|
||||
Assert.equal(packet.why.actors[0], bpClient.actor);
|
||||
// Check that the breakpoint worked.
|
||||
Assert.equal(debuggee.a, 1);
|
||||
Assert.equal(debuggee.b, undefined);
|
||||
|
||||
// Remove the breakpoint.
|
||||
bpClient.remove(function(response) {
|
||||
threadClient.resume(resolve);
|
||||
});
|
||||
});
|
||||
|
||||
// Continue until the breakpoint is hit.
|
||||
threadClient.resume();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/* eslint-disable */
|
||||
|
|
|
@ -11,15 +11,18 @@
|
|||
add_task(threadClientTest(({ threadClient, debuggee }) => {
|
||||
return new Promise(resolve => {
|
||||
let done = false;
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
threadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
const location = { line: debuggee.line0 + 2 };
|
||||
|
||||
source.setBreakpoint(location).then(function([response, bpClient]) {
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
// Check the return value.
|
||||
Assert.equal(packet.type, "paused");
|
||||
Assert.equal(packet.frame.where.source.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.line, location.line);
|
||||
Assert.equal(packet.why.type, "breakpoint");
|
||||
Assert.equal(packet.why.actors[0], bpClient.actor);
|
||||
|
|
|
@ -11,8 +11,11 @@
|
|||
|
||||
add_task(threadClientTest(({ threadClient, debuggee }) => {
|
||||
return new Promise(resolve => {
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
threadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
const location = { line: debuggee.line0 + 3 };
|
||||
|
||||
source.setBreakpoint(location).then(function([response, bpClient]) {
|
||||
|
|
|
@ -11,8 +11,11 @@
|
|||
|
||||
add_task(threadClientTest(({ threadClient, debuggee }) => {
|
||||
return new Promise(resolve => {
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
threadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
const location = { line: debuggee.line0 + 2 };
|
||||
|
||||
source.setBreakpoint(location).then(function([response, bpClient]) {
|
||||
|
|
|
@ -15,8 +15,11 @@ var gCount;
|
|||
|
||||
add_task(threadClientTest(({ threadClient, debuggee }) => {
|
||||
return new Promise(resolve => {
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
threadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
const location = { line: debuggee.line0 + 3};
|
||||
|
||||
source.setBreakpoint(location).then(function([response, bpClient]) {
|
||||
|
@ -62,7 +65,7 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
|
|||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
// Check the return value.
|
||||
Assert.equal(packet.type, "paused");
|
||||
Assert.equal(packet.frame.where.source.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.line, location.line + 1);
|
||||
Assert.equal(packet.why.type, "breakpoint");
|
||||
Assert.equal(packet.why.actors[0], bpClient.actor);
|
||||
|
|
|
@ -11,8 +11,11 @@
|
|||
|
||||
add_task(threadClientTest(({ threadClient, debuggee }) => {
|
||||
return new Promise(resolve => {
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
threadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
const location = { line: debuggee.line0 + 2 };
|
||||
|
||||
source.setBreakpoint(location).then(async function([response, bpClient]) {
|
||||
|
|
|
@ -11,8 +11,11 @@
|
|||
|
||||
add_task(threadClientTest(({ threadClient, debuggee }) => {
|
||||
return new Promise(resolve => {
|
||||
threadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
threadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
const location = { line: debuggee.line0 + 2 };
|
||||
|
||||
source.setBreakpoint(location).then(async function([response, bpClient]) {
|
||||
|
|
|
@ -29,7 +29,10 @@ const SOURCE_URL = "http://example.com/source.js";
|
|||
|
||||
const testSameBreakpoint = async function() {
|
||||
const packet = await executeOnNextTickAndWaitForPause(evalCode, gClient);
|
||||
const source = gThreadClient.source(packet.frame.where.source);
|
||||
const source = await getSourceById(
|
||||
gThreadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
|
||||
// Whole line
|
||||
const wholeLineLocation = {
|
||||
|
|
|
@ -11,8 +11,11 @@
|
|||
add_task(threadClientTest(({ threadClient, debuggee, client }) => {
|
||||
return new Promise(resolve => {
|
||||
// Debugger statement
|
||||
client.addOneTimeListener("paused", function(event, packet) {
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
client.addOneTimeListener("paused", async function(event, packet) {
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
const location = {
|
||||
line: debuggee.line0 + 1,
|
||||
column: 55,
|
||||
|
@ -24,7 +27,7 @@ add_task(threadClientTest(({ threadClient, debuggee, client }) => {
|
|||
Assert.equal(packet.type, "paused");
|
||||
Assert.equal(packet.why.type, "breakpoint");
|
||||
Assert.equal(packet.why.actors[0], bpClient.actor);
|
||||
Assert.equal(packet.frame.where.source.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.line, location.line);
|
||||
Assert.equal(packet.frame.where.column, location.column);
|
||||
|
||||
|
|
|
@ -42,9 +42,12 @@ add_task(threadClientTest(({ threadClient, debuggee, client }) => {
|
|||
}));
|
||||
|
||||
function set_breakpoints(packet, threadClient) {
|
||||
return new Promise(resolve => {
|
||||
return new Promise(async resolve => {
|
||||
let first, second;
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
|
||||
source.setBreakpoint(firstLocation).then(function([{ actualLocation },
|
||||
breakpointClient]) {
|
||||
|
|
|
@ -44,8 +44,11 @@ add_task(threadClientTest(({ threadClient, debuggee, client }) => {
|
|||
}));
|
||||
|
||||
function setBreakpoint(packet, threadClient, client) {
|
||||
return new Promise(resolve => {
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
return new Promise(async resolve => {
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
client.addOneTimeListener("resumed", resolve);
|
||||
|
||||
source.setBreakpoint({ line: 2 }).then(() => {
|
||||
|
|
|
@ -17,7 +17,10 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
|
|||
let packet = await executeOnNextTickAndWaitForPause(() => {
|
||||
evalCode(debuggee);
|
||||
}, client);
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
const location = {
|
||||
line: debuggee.line0 + 8,
|
||||
};
|
||||
|
@ -30,7 +33,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
|
|||
Assert.equal(packet.type, "paused");
|
||||
Assert.equal(packet.why.type, "breakpoint");
|
||||
Assert.equal(packet.why.actors[0], bpClient.actor);
|
||||
Assert.equal(packet.frame.where.source.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.actor, source.actor);
|
||||
Assert.equal(packet.frame.where.line, location.line);
|
||||
|
||||
await resume(threadClient);
|
||||
|
|
|
@ -16,7 +16,11 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
|
|||
const packet = await executeOnNextTickAndWaitForPause(() => {
|
||||
evalCode(debuggee);
|
||||
}, client);
|
||||
const source = threadClient.source(packet.frame.where.source);
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
|
||||
const location = {
|
||||
line: debuggee.line0 + 2,
|
||||
};
|
||||
|
|
|
@ -27,8 +27,11 @@ function run_test() {
|
|||
}
|
||||
|
||||
function test_simple_breakpoint() {
|
||||
gThreadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
const source = gThreadClient.source(packet.frame.where.source);
|
||||
gThreadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const source = await getSourceById(
|
||||
gThreadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
source.setBreakpoint({
|
||||
line: 3,
|
||||
condition: "a === 1",
|
||||
|
|
|
@ -27,8 +27,11 @@ function run_test() {
|
|||
}
|
||||
|
||||
function test_simple_breakpoint() {
|
||||
gThreadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
const source = gThreadClient.source(packet.frame.where.source);
|
||||
gThreadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const source = await getSourceById(
|
||||
gThreadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
source.setBreakpoint({
|
||||
line: 3,
|
||||
condition: "a === 2",
|
||||
|
|
|
@ -27,8 +27,11 @@ function run_test() {
|
|||
}
|
||||
|
||||
function test_simple_breakpoint() {
|
||||
gThreadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
const source = gThreadClient.source(packet.frame.where.source);
|
||||
gThreadClient.addOneTimeListener("paused", async function(event, packet) {
|
||||
const source = await getSourceById(
|
||||
gThreadClient,
|
||||
packet.frame.where.actor
|
||||
);
|
||||
source.setBreakpoint({
|
||||
line: 3,
|
||||
condition: "throw new Error()",
|
||||
|
|
|
@ -44,7 +44,7 @@ function run_test() {
|
|||
|
||||
function test_pause_frame() {
|
||||
gThreadClient.addOneTimeListener("paused", function(event, packet) {
|
||||
gThreadClient.getFrames(0, null, function(frameResponse) {
|
||||
gThreadClient.getFrames(0, null, async function(frameResponse) {
|
||||
Assert.equal(frameResponse.frames.length, 4);
|
||||
|
||||
const wasmFrame = frameResponse.frames[1];
|
||||
|
@ -52,9 +52,10 @@ function test_pause_frame() {
|
|||
Assert.equal(wasmFrame.this, undefined);
|
||||
|
||||
const location = wasmFrame.where;
|
||||
const source = await getSourceById(gThreadClient, location.actor);
|
||||
Assert.equal(location.line > 0, true);
|
||||
Assert.equal(location.column > 0, true);
|
||||
Assert.equal(/^wasm:(?:[^:]*:)*?[0-9a-f]{16}$/.test(location.source.url), true);
|
||||
Assert.equal(/^wasm:(?:[^:]*:)*?[0-9a-f]{16}$/.test(source.url), true);
|
||||
|
||||
finishClient(gClient);
|
||||
});
|
||||
|
|
|
@ -28,10 +28,9 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
|
|||
Assert.equal(why.actors[0], breakpointClient.actor);
|
||||
|
||||
const frame = packet.frame;
|
||||
const where = frame.where;
|
||||
Assert.equal(where.source.actor, source.actor);
|
||||
Assert.equal(where.line, location.line);
|
||||
Assert.equal(where.column, 6);
|
||||
Assert.equal(frame.where.actor, source.actor);
|
||||
Assert.equal(frame.where.line, location.line);
|
||||
Assert.equal(frame.where.column, 6);
|
||||
|
||||
const variables = frame.environment.bindings.variables;
|
||||
Assert.equal(variables.a.value.type, "undefined");
|
||||
|
|
|
@ -31,7 +31,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
|
|||
|
||||
const frame = packet.frame;
|
||||
const where = frame.where;
|
||||
Assert.equal(where.source.actor, source.actor);
|
||||
Assert.equal(where.actor, source.actor);
|
||||
Assert.equal(where.line, location.line);
|
||||
Assert.equal(where.column, 52);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
|
|||
|
||||
const frame = packet.frame;
|
||||
const where = frame.where;
|
||||
Assert.equal(where.source.actor, source.actor);
|
||||
Assert.equal(where.actor, source.actor);
|
||||
Assert.equal(where.line, location.line);
|
||||
Assert.equal(where.column, 28);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
|
|||
|
||||
const frame = packet.frame;
|
||||
const where = frame.where;
|
||||
Assert.equal(where.source.actor, source.actor);
|
||||
Assert.equal(where.actor, source.actor);
|
||||
Assert.equal(where.line, location.line);
|
||||
Assert.equal(where.column, 81);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client, targetFront }
|
|||
Assert.equal(why.actors[0], breakpointClient.actor);
|
||||
const frame = packet.frame;
|
||||
const where = frame.where;
|
||||
Assert.equal(where.source.actor, source.actor);
|
||||
Assert.equal(where.actor, source.actor);
|
||||
Assert.equal(where.line, location.line);
|
||||
Assert.equal(where.column, location.column);
|
||||
const variables = frame.environment.bindings.variables;
|
||||
|
|
|
@ -23,7 +23,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
|
|||
Assert.equal(why.actors[0], breakpointClient.actor);
|
||||
const frame = packet.frame;
|
||||
const where = frame.where;
|
||||
Assert.equal(where.source.actor, source.actor);
|
||||
Assert.equal(where.actor, source.actor);
|
||||
Assert.equal(where.line, location.line);
|
||||
Assert.equal(where.column, location.column);
|
||||
const variables = frame.environment.bindings.variables;
|
||||
|
|
|
@ -27,7 +27,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client, targetFront }
|
|||
Assert.equal(why.actors[0], breakpointClient.actor);
|
||||
const frame = packet.frame;
|
||||
const where = frame.where;
|
||||
Assert.equal(where.source.actor, source.actor);
|
||||
Assert.equal(where.actor, source.actor);
|
||||
Assert.equal(where.line, location.line);
|
||||
const variables = frame.environment.bindings.variables;
|
||||
Assert.equal(variables.a.value, 1);
|
||||
|
|
|
@ -23,14 +23,15 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
|
|||
Assert.equal(why.actors[0], breakpointClient.actor);
|
||||
let frame = packet.frame;
|
||||
let where = frame.where;
|
||||
Assert.equal(where.source.actor, source.actor);
|
||||
Assert.equal(where.actor, source.actor);
|
||||
Assert.equal(where.line, location.line);
|
||||
let variables = frame.environment.bindings.variables;
|
||||
Assert.equal(variables.i.value.type, "undefined");
|
||||
|
||||
packet = await executeOnNextTickAndWaitForPause(function() {
|
||||
resume(threadClient);
|
||||
}, client);
|
||||
packet = await executeOnNextTickAndWaitForPause(
|
||||
() => resume(threadClient),
|
||||
client
|
||||
);
|
||||
Assert.equal(packet.type, "paused");
|
||||
why = packet.why;
|
||||
Assert.equal(why.type, "breakpoint");
|
||||
|
@ -38,7 +39,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
|
|||
Assert.equal(why.actors[0], breakpointClient.actor);
|
||||
frame = packet.frame;
|
||||
where = frame.where;
|
||||
Assert.equal(where.source.actor, source.actor);
|
||||
Assert.equal(where.actor, source.actor);
|
||||
Assert.equal(where.line, location.line);
|
||||
variables = frame.environment.bindings.variables;
|
||||
Assert.equal(variables.i.value, 0);
|
||||
|
|
|
@ -23,7 +23,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
|
|||
Assert.equal(why.actors[0], breakpointClient.actor);
|
||||
const frame = packet.frame;
|
||||
const where = frame.where;
|
||||
Assert.equal(where.source.actor, source.actor);
|
||||
Assert.equal(where.actor, source.actor);
|
||||
Assert.equal(where.line, location.line);
|
||||
const variables = frame.environment.bindings.variables;
|
||||
Assert.equal(variables.a.value.type, "undefined");
|
||||
|
|
|
@ -27,7 +27,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client, targetFront }
|
|||
Assert.equal(why.actors[0], breakpointClient.actor);
|
||||
const frame = packet.frame;
|
||||
const where = frame.where;
|
||||
Assert.equal(where.source.actor, source.actor);
|
||||
Assert.equal(where.actor, source.actor);
|
||||
Assert.equal(where.line, 8);
|
||||
const variables = frame.environment.bindings.variables;
|
||||
Assert.equal(variables.a.value, 1);
|
||||
|
|
|
@ -25,7 +25,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
|
|||
Assert.equal(why.actors[0], breakpointClient.actor);
|
||||
const frame = packet.frame;
|
||||
const where = frame.where;
|
||||
Assert.equal(where.source.actor, source.actor);
|
||||
Assert.equal(where.actor, source.actor);
|
||||
Assert.equal(where.line, actualLocation.line);
|
||||
const variables = frame.environment.bindings.variables;
|
||||
Assert.equal(variables.a.value, 1);
|
||||
|
|
|
@ -23,7 +23,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
|
|||
Assert.equal(why.actors[0], breakpointClient.actor);
|
||||
const frame = packet.frame;
|
||||
const where = frame.where;
|
||||
Assert.equal(where.source.actor, source.actor);
|
||||
Assert.equal(where.actor, source.actor);
|
||||
Assert.equal(where.line, location.line);
|
||||
const variables = frame.environment.bindings.variables;
|
||||
Assert.equal(variables.a.value, 1);
|
||||
|
|
|
@ -14,7 +14,10 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
|
|||
equal(dbgStmt.frame.where.line, 3, "Should be at debugger statement on line 3");
|
||||
|
||||
dumpn("Setting breakpoint in innerFunction");
|
||||
const source = threadClient.source(dbgStmt.frame.where.source);
|
||||
const source = await getSourceById(
|
||||
threadClient,
|
||||
dbgStmt.frame.where.actor
|
||||
);
|
||||
await source.setBreakpoint({ line: 7 });
|
||||
|
||||
dumpn("Step in to innerFunction");
|
||||
|
|
|
@ -319,6 +319,8 @@ static LazyLogModule gDOMLeakPRLogOuter("DOMLeakOuter");
|
|||
|
||||
static int32_t gOpenPopupSpamCount = 0;
|
||||
|
||||
static bool gSyncContentBlockingNotifications = false;
|
||||
|
||||
nsGlobalWindowOuter::OuterWindowByIdTable*
|
||||
nsGlobalWindowOuter::sOuterWindowsById = nullptr;
|
||||
|
||||
|
@ -5405,100 +5407,130 @@ void nsGlobalWindowOuter::NotifyContentBlockingEvent(unsigned aEvent,
|
|||
nsCOMPtr<Document> doc = docShell->GetDocument();
|
||||
NS_ENSURE_TRUE_VOID(doc);
|
||||
|
||||
// This event might come after the user has navigated to another page.
|
||||
// To prevent showing the TrackingProtection UI on the wrong page, we need to
|
||||
// check that the loading URI for the channel is the same as the URI currently
|
||||
// loaded in the document.
|
||||
if (!SameLoadingURI(doc, aChannel) &&
|
||||
aEvent == nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT) {
|
||||
return;
|
||||
nsCOMPtr<nsIURI> uri(aURIHint);
|
||||
nsCOMPtr<nsIChannel> channel(aChannel);
|
||||
|
||||
static bool prefInitialized = false;
|
||||
if (!prefInitialized) {
|
||||
Preferences::AddBoolVarCache(
|
||||
&gSyncContentBlockingNotifications,
|
||||
"dom.testing.sync-content-blocking-notifications", false);
|
||||
prefInitialized = true;
|
||||
}
|
||||
|
||||
// Notify nsIWebProgressListeners of this content blocking event.
|
||||
// Can be used to change the UI state.
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsISecurityEventSink> eventSink = do_QueryInterface(docShell, &rv);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
uint32_t event = 0;
|
||||
nsCOMPtr<nsISecureBrowserUI> securityUI;
|
||||
docShell->GetSecurityUI(getter_AddRefs(securityUI));
|
||||
if (!securityUI) {
|
||||
return;
|
||||
}
|
||||
securityUI->GetContentBlockingEvent(&event);
|
||||
nsAutoCString origin;
|
||||
nsContentUtils::GetASCIIOrigin(aURIHint, origin);
|
||||
nsCOMPtr<nsIRunnable> func = NS_NewRunnableFunction(
|
||||
"NotifyContentBlockingEventDelayed",
|
||||
[doc, docShell, uri, channel, aEvent, aBlocked]() {
|
||||
// This event might come after the user has navigated to another
|
||||
// page. To prevent showing the TrackingProtection UI on the wrong
|
||||
// page, we need to check that the loading URI for the channel is
|
||||
// the same as the URI currently loaded in the document.
|
||||
if (!SameLoadingURI(doc, channel) &&
|
||||
aEvent == nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool blockedValue = aBlocked;
|
||||
bool unblocked = false;
|
||||
if (aEvent == nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT) {
|
||||
doc->SetHasTrackingContentBlocked(aBlocked, origin);
|
||||
if (!aBlocked) {
|
||||
unblocked = !doc->GetHasTrackingContentBlocked();
|
||||
}
|
||||
} else if (aEvent == nsIWebProgressListener::STATE_LOADED_TRACKING_CONTENT) {
|
||||
doc->SetHasTrackingContentLoaded(aBlocked, origin);
|
||||
if (!aBlocked) {
|
||||
unblocked = !doc->GetHasTrackingContentLoaded();
|
||||
}
|
||||
} else if (aEvent ==
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION) {
|
||||
doc->SetHasCookiesBlockedByPermission(aBlocked, origin);
|
||||
if (!aBlocked) {
|
||||
unblocked = !doc->GetHasCookiesBlockedByPermission();
|
||||
}
|
||||
} else if (aEvent == nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER) {
|
||||
doc->SetHasTrackingCookiesBlocked(aBlocked, origin);
|
||||
if (!aBlocked) {
|
||||
unblocked = !doc->GetHasTrackingCookiesBlocked();
|
||||
}
|
||||
} else if (aEvent == nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL) {
|
||||
doc->SetHasAllCookiesBlocked(aBlocked, origin);
|
||||
if (!aBlocked) {
|
||||
unblocked = !doc->GetHasAllCookiesBlocked();
|
||||
}
|
||||
} else if (aEvent == nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN) {
|
||||
doc->SetHasForeignCookiesBlocked(aBlocked, origin);
|
||||
if (!aBlocked) {
|
||||
unblocked = !doc->GetHasForeignCookiesBlocked();
|
||||
}
|
||||
} else if (aEvent == nsIWebProgressListener::STATE_COOKIES_LOADED) {
|
||||
MOZ_ASSERT(!aBlocked,
|
||||
"We don't expected to see blocked STATE_COOKIES_LOADED");
|
||||
// Note that the logic in this branch is the logical negation of the logic
|
||||
// in other branches, since the Document API we have is phrased in
|
||||
// "loaded" terms as opposed to "blocked" terms.
|
||||
blockedValue = !aBlocked;
|
||||
doc->SetHasCookiesLoaded(blockedValue, origin);
|
||||
if (!aBlocked) {
|
||||
unblocked = !doc->GetHasCookiesLoaded();
|
||||
}
|
||||
} else {
|
||||
// Ignore nsIWebProgressListener::STATE_BLOCKED_UNSAFE_CONTENT;
|
||||
}
|
||||
const uint32_t oldEvent = event;
|
||||
if (blockedValue) {
|
||||
event |= aEvent;
|
||||
} else if (unblocked) {
|
||||
event &= ~aEvent;
|
||||
}
|
||||
// Notify nsIWebProgressListeners of this content blocking event.
|
||||
// Can be used to change the UI state.
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsISecurityEventSink> eventSink =
|
||||
do_QueryInterface(docShell, &rv);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
uint32_t event = 0;
|
||||
nsCOMPtr<nsISecureBrowserUI> securityUI;
|
||||
docShell->GetSecurityUI(getter_AddRefs(securityUI));
|
||||
if (!securityUI) {
|
||||
return;
|
||||
}
|
||||
securityUI->GetContentBlockingEvent(&event);
|
||||
nsAutoCString origin;
|
||||
nsContentUtils::GetASCIIOrigin(uri, origin);
|
||||
|
||||
if (event == oldEvent
|
||||
bool blockedValue = aBlocked;
|
||||
bool unblocked = false;
|
||||
if (aEvent == nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT) {
|
||||
doc->SetHasTrackingContentBlocked(aBlocked, origin);
|
||||
if (!aBlocked) {
|
||||
unblocked = !doc->GetHasTrackingContentBlocked();
|
||||
}
|
||||
} else if (aEvent ==
|
||||
nsIWebProgressListener::STATE_LOADED_TRACKING_CONTENT) {
|
||||
doc->SetHasTrackingContentLoaded(aBlocked, origin);
|
||||
if (!aBlocked) {
|
||||
unblocked = !doc->GetHasTrackingContentLoaded();
|
||||
}
|
||||
} else if (aEvent == nsIWebProgressListener::
|
||||
STATE_COOKIES_BLOCKED_BY_PERMISSION) {
|
||||
doc->SetHasCookiesBlockedByPermission(aBlocked, origin);
|
||||
if (!aBlocked) {
|
||||
unblocked = !doc->GetHasCookiesBlockedByPermission();
|
||||
}
|
||||
} else if (aEvent ==
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER) {
|
||||
doc->SetHasTrackingCookiesBlocked(aBlocked, origin);
|
||||
if (!aBlocked) {
|
||||
unblocked = !doc->GetHasTrackingCookiesBlocked();
|
||||
}
|
||||
} else if (aEvent ==
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL) {
|
||||
doc->SetHasAllCookiesBlocked(aBlocked, origin);
|
||||
if (!aBlocked) {
|
||||
unblocked = !doc->GetHasAllCookiesBlocked();
|
||||
}
|
||||
} else if (aEvent ==
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN) {
|
||||
doc->SetHasForeignCookiesBlocked(aBlocked, origin);
|
||||
if (!aBlocked) {
|
||||
unblocked = !doc->GetHasForeignCookiesBlocked();
|
||||
}
|
||||
} else if (aEvent == nsIWebProgressListener::STATE_COOKIES_LOADED) {
|
||||
MOZ_ASSERT(!aBlocked,
|
||||
"We don't expected to see blocked STATE_COOKIES_LOADED");
|
||||
// Note that the logic in this branch is the logical negation of
|
||||
// the logic in other branches, since the Document API we have is
|
||||
// phrased in "loaded" terms as opposed to "blocked" terms.
|
||||
blockedValue = !aBlocked;
|
||||
doc->SetHasCookiesLoaded(blockedValue, origin);
|
||||
if (!aBlocked) {
|
||||
unblocked = !doc->GetHasCookiesLoaded();
|
||||
}
|
||||
} else {
|
||||
// Ignore nsIWebProgressListener::STATE_BLOCKED_UNSAFE_CONTENT;
|
||||
}
|
||||
const uint32_t oldEvent = event;
|
||||
if (blockedValue) {
|
||||
event |= aEvent;
|
||||
} else if (unblocked) {
|
||||
event &= ~aEvent;
|
||||
}
|
||||
|
||||
if (event == oldEvent
|
||||
#ifdef ANDROID
|
||||
// GeckoView always needs to notify about blocked trackers, since the
|
||||
// GeckoView API always needs to report the URI and type of any blocked
|
||||
// tracker.
|
||||
// We use a platform-dependent code path here because reporting this
|
||||
// notification on desktop platforms isn't necessary and doing so can have
|
||||
// a big performance cost.
|
||||
&& aEvent != nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT
|
||||
// GeckoView always needs to notify about blocked trackers,
|
||||
// since the GeckoView API always needs to report the URI and
|
||||
// type of any blocked tracker. We use a platform-dependent code
|
||||
// path here because reporting this notification on desktop
|
||||
// platforms isn't necessary and doing so can have a big
|
||||
// performance cost.
|
||||
&& aEvent != nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT
|
||||
#endif
|
||||
) {
|
||||
// Avoid dispatching repeated notifications when nothing has changed
|
||||
) {
|
||||
// Avoid dispatching repeated notifications when nothing has
|
||||
// changed
|
||||
return;
|
||||
}
|
||||
|
||||
eventSink->OnContentBlockingEvent(channel, event);
|
||||
});
|
||||
nsresult rv;
|
||||
if (gSyncContentBlockingNotifications) {
|
||||
rv = func->Run();
|
||||
} else {
|
||||
rv = NS_IdleDispatchToCurrentThread(func.forget(), 100);
|
||||
}
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
eventSink->OnContentBlockingEvent(aChannel, event);
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "mozilla/Compression.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "mozilla/Sprintf.h" // SprintfLiteral
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/Utf8.h" // mozilla::Utf8Unit
|
||||
#include "mozilla/Variant.h"
|
||||
|
|
|
@ -334,7 +334,7 @@ NS_MutatorMethod(Method aMethod, Args ...aArgs)
|
|||
nsCOMPtr<Interface> target = do_QueryInterface(aMutator, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = (target->*aMethod)(aArgs...);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return NS_OK;
|
||||
};
|
||||
}
|
||||
|
@ -493,7 +493,6 @@ public:
|
|||
return *this;
|
||||
}
|
||||
mStatus = aFunction(mMutator);
|
||||
NS_ENSURE_SUCCESS(mStatus, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -543,7 +542,7 @@ public:
|
|||
|
||||
MOZ_MUST_USE nsresult Finalize(nsIURI** aURI)
|
||||
{
|
||||
NS_ENSURE_SUCCESS(mStatus, mStatus);
|
||||
if (NS_FAILED(mStatus)) return mStatus;
|
||||
mStatus = mMutator->Finalize(aURI);
|
||||
NS_ENSURE_SUCCESS(mStatus, mStatus);
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"phabricator.uri" : "https://phabricator.services.mozilla.com/",
|
||||
"repository.callsign": "NSS",
|
||||
"history.immutable": false
|
||||
}
|
|
@ -1 +1 @@
|
|||
NSS_3_42_BETA1
|
||||
NSS_3_42_BETA2
|
||||
|
|
|
@ -50,6 +50,7 @@ fuzz=0
|
|||
fuzz_tls=0
|
||||
fuzz_oss=0
|
||||
no_local_nspr=0
|
||||
sslkeylogfile=1
|
||||
|
||||
gyp_params=(--depth="$cwd" --generator-output=".")
|
||||
ninja_params=()
|
||||
|
@ -103,6 +104,7 @@ while [ $# -gt 0 ]; do
|
|||
--enable-fips) gyp_params+=(-Ddisable_fips=0) ;;
|
||||
--enable-libpkix) gyp_params+=(-Ddisable_libpkix=0) ;;
|
||||
--mozpkix-only) gyp_params+=(-Dmozpkix_only=1 -Ddisable_tests=1 -Dsign_libs=0) ;;
|
||||
--disable-keylog) sslkeylogfile=0 ;;
|
||||
*) show_help; exit 2 ;;
|
||||
esac
|
||||
shift
|
||||
|
@ -116,6 +118,8 @@ else
|
|||
target=Debug
|
||||
fi
|
||||
|
||||
gyp_params+=(-Denable_sslkeylogfile="$sslkeylogfile")
|
||||
|
||||
# Do special setup.
|
||||
if [ "$fuzz" = 1 ]; then
|
||||
source "$cwd"/coreconf/fuzz.sh
|
||||
|
|
|
@ -10,3 +10,4 @@
|
|||
*/
|
||||
|
||||
#error "Do not include this header file."
|
||||
|
||||
|
|
|
@ -36,6 +36,12 @@ CPPSRCS := $(filter-out $(shell grep -l '^TEST_F' $(CPPSRCS)), $(CPPSRCS))
|
|||
CFLAGS += -DNSS_DISABLE_TLS_1_3
|
||||
endif
|
||||
|
||||
ifdef NSS_ALLOW_SSLKEYLOGFILE
|
||||
SSLKEYLOGFILE_FILES = ssl_keylog_unittest.cc
|
||||
else
|
||||
SSLKEYLOGFILE_FILES = $(NULL)
|
||||
endif
|
||||
|
||||
#######################################################################
|
||||
# (5) Execute "global" rules. (OPTIONAL) #
|
||||
#######################################################################
|
||||
|
|
|
@ -20,6 +20,7 @@ CPPSRCS = \
|
|||
ssl_ciphersuite_unittest.cc \
|
||||
ssl_custext_unittest.cc \
|
||||
ssl_damage_unittest.cc \
|
||||
ssl_debug_env_unittest.cc \
|
||||
ssl_dhe_unittest.cc \
|
||||
ssl_drop_unittest.cc \
|
||||
ssl_ecdh_unittest.cc \
|
||||
|
@ -31,7 +32,6 @@ CPPSRCS = \
|
|||
ssl_gather_unittest.cc \
|
||||
ssl_gtest.cc \
|
||||
ssl_hrr_unittest.cc \
|
||||
ssl_keylog_unittest.cc \
|
||||
ssl_keyupdate_unittest.cc \
|
||||
ssl_loopback_unittest.cc \
|
||||
ssl_misc_unittest.cc \
|
||||
|
@ -53,6 +53,7 @@ CPPSRCS = \
|
|||
tls_filter.cc \
|
||||
tls_protect.cc \
|
||||
tls_esni_unittest.cc \
|
||||
$(SSLKEYLOGFILE_FILES) \
|
||||
$(NULL)
|
||||
|
||||
INCLUDES += -I$(CORE_DEPTH)/gtests/google_test/gtest/include \
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "gtest_utils.h"
|
||||
#include "tls_connect.h"
|
||||
|
||||
namespace nss_test {
|
||||
|
||||
extern "C" {
|
||||
extern FILE* ssl_trace_iob;
|
||||
|
||||
#ifdef NSS_ALLOW_SSLKEYLOGFILE
|
||||
extern FILE* ssl_keylog_iob;
|
||||
#endif
|
||||
}
|
||||
|
||||
// These tests ensure that when the associated environment variables are unset
|
||||
// that the lazily-initialized defaults are what they are supposed to be.
|
||||
|
||||
#ifdef DEBUG
|
||||
TEST_P(TlsConnectGeneric, DebugEnvTraceFileNotSet) {
|
||||
char* ev = PR_GetEnvSecure("SSLDEBUGFILE");
|
||||
if (ev && ev[0]) {
|
||||
// note: should use GTEST_SKIP when GTest gets updated to support it
|
||||
return;
|
||||
}
|
||||
|
||||
Connect();
|
||||
EXPECT_EQ(stderr, ssl_trace_iob);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NSS_ALLOW_SSLKEYLOGFILE
|
||||
TEST_P(TlsConnectGeneric, DebugEnvKeylogFileNotSet) {
|
||||
char* ev = PR_GetEnvSecure("SSLKEYLOGFILE");
|
||||
if (ev && ev[0]) {
|
||||
// note: should use GTEST_SKIP when GTest gets updated to support it
|
||||
return;
|
||||
}
|
||||
|
||||
Connect();
|
||||
EXPECT_EQ(nullptr, ssl_keylog_iob);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace nss_test
|
|
@ -21,6 +21,7 @@
|
|||
'ssl_ciphersuite_unittest.cc',
|
||||
'ssl_custext_unittest.cc',
|
||||
'ssl_damage_unittest.cc',
|
||||
'ssl_debug_env_unittest.cc',
|
||||
'ssl_dhe_unittest.cc',
|
||||
'ssl_drop_unittest.cc',
|
||||
'ssl_ecdh_unittest.cc',
|
||||
|
@ -32,7 +33,6 @@
|
|||
'ssl_gather_unittest.cc',
|
||||
'ssl_gtest.cc',
|
||||
'ssl_hrr_unittest.cc',
|
||||
'ssl_keylog_unittest.cc',
|
||||
'ssl_keyupdate_unittest.cc',
|
||||
'ssl_loopback_unittest.cc',
|
||||
'ssl_misc_unittest.cc',
|
||||
|
@ -91,6 +91,14 @@
|
|||
'<(DEPTH)/lib/dbm/src/src.gyp:dbm',
|
||||
],
|
||||
}],
|
||||
[ 'enable_sslkeylogfile==1', {
|
||||
'sources': [
|
||||
'ssl_keylog_unittest.cc',
|
||||
],
|
||||
'defines': [
|
||||
'NSS_ALLOW_SSLKEYLOGFILE',
|
||||
],
|
||||
}],
|
||||
],
|
||||
}
|
||||
],
|
||||
|
@ -99,7 +107,7 @@
|
|||
'../../lib/ssl'
|
||||
],
|
||||
'defines': [
|
||||
'NSS_USE_STATIC_LIBS'
|
||||
'NSS_USE_STATIC_LIBS',
|
||||
],
|
||||
},
|
||||
'variables': {
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef NSS_ALLOW_SSLKEYLOGFILE
|
||||
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
@ -15,20 +13,59 @@
|
|||
|
||||
namespace nss_test {
|
||||
|
||||
static const std::string keylog_file_path = "keylog.txt";
|
||||
static const std::string keylog_env = "SSLKEYLOGFILE=" + keylog_file_path;
|
||||
static const std::string kKeylogFilePath = "keylog.txt";
|
||||
static const std::string kKeylogBlankEnv = "SSLKEYLOGFILE=";
|
||||
static const std::string kKeylogSetEnv = kKeylogBlankEnv + kKeylogFilePath;
|
||||
|
||||
extern "C" {
|
||||
extern FILE* ssl_keylog_iob;
|
||||
}
|
||||
|
||||
class KeyLogFileTestBase : public TlsConnectGeneric {
|
||||
private:
|
||||
std::string env_to_set_;
|
||||
|
||||
class KeyLogFileTest : public TlsConnectGeneric {
|
||||
public:
|
||||
virtual void CheckKeyLog() = 0;
|
||||
|
||||
KeyLogFileTestBase(std::string env) : env_to_set_(env) {}
|
||||
|
||||
void SetUp() override {
|
||||
TlsConnectGeneric::SetUp();
|
||||
// Remove previous results (if any).
|
||||
(void)remove(keylog_file_path.c_str());
|
||||
PR_SetEnv(keylog_env.c_str());
|
||||
(void)remove(kKeylogFilePath.c_str());
|
||||
PR_SetEnv(env_to_set_.c_str());
|
||||
}
|
||||
|
||||
void CheckKeyLog() {
|
||||
std::ifstream f(keylog_file_path);
|
||||
void ConnectAndCheck() {
|
||||
// This is a child process, ensure that error messages immediately
|
||||
// propagate or else it will not be visible.
|
||||
::testing::GTEST_FLAG(throw_on_failure) = true;
|
||||
|
||||
if (version_ == SSL_LIBRARY_VERSION_TLS_1_3) {
|
||||
SetupForZeroRtt();
|
||||
client_->Set0RttEnabled(true);
|
||||
server_->Set0RttEnabled(true);
|
||||
ExpectResumption(RESUME_TICKET);
|
||||
ZeroRttSendReceive(true, true);
|
||||
Handshake();
|
||||
ExpectEarlyDataAccepted(true);
|
||||
CheckConnected();
|
||||
SendReceive();
|
||||
} else {
|
||||
Connect();
|
||||
}
|
||||
CheckKeyLog();
|
||||
_exit(0);
|
||||
}
|
||||
};
|
||||
|
||||
class KeyLogFileTest : public KeyLogFileTestBase {
|
||||
public:
|
||||
KeyLogFileTest() : KeyLogFileTestBase(kKeylogSetEnv) {}
|
||||
|
||||
void CheckKeyLog() override {
|
||||
std::ifstream f(kKeylogFilePath);
|
||||
std::map<std::string, size_t> labels;
|
||||
std::set<std::string> client_randoms;
|
||||
for (std::string line; std::getline(f, line);) {
|
||||
|
@ -65,28 +102,6 @@ class KeyLogFileTest : public TlsConnectGeneric {
|
|||
ASSERT_EQ(4U, labels["EXPORTER_SECRET"]);
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectAndCheck() {
|
||||
// This is a child process, ensure that error messages immediately
|
||||
// propagate or else it will not be visible.
|
||||
::testing::GTEST_FLAG(throw_on_failure) = true;
|
||||
|
||||
if (version_ == SSL_LIBRARY_VERSION_TLS_1_3) {
|
||||
SetupForZeroRtt();
|
||||
client_->Set0RttEnabled(true);
|
||||
server_->Set0RttEnabled(true);
|
||||
ExpectResumption(RESUME_TICKET);
|
||||
ZeroRttSendReceive(true, true);
|
||||
Handshake();
|
||||
ExpectEarlyDataAccepted(true);
|
||||
CheckConnected();
|
||||
SendReceive();
|
||||
} else {
|
||||
Connect();
|
||||
}
|
||||
CheckKeyLog();
|
||||
_exit(0);
|
||||
}
|
||||
};
|
||||
|
||||
// Tests are run in a separate process to ensure that NSS is not initialized yet
|
||||
|
@ -113,6 +128,37 @@ INSTANTIATE_TEST_CASE_P(
|
|||
TlsConnectTestBase::kTlsV13));
|
||||
#endif
|
||||
|
||||
} // namespace nss_test
|
||||
class KeyLogFileUnsetTest : public KeyLogFileTestBase {
|
||||
public:
|
||||
KeyLogFileUnsetTest() : KeyLogFileTestBase(kKeylogBlankEnv) {}
|
||||
|
||||
#endif // NSS_ALLOW_SSLKEYLOGFILE
|
||||
void CheckKeyLog() override {
|
||||
std::ifstream f(kKeylogFilePath);
|
||||
EXPECT_FALSE(f.good());
|
||||
|
||||
EXPECT_EQ(nullptr, ssl_keylog_iob);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(KeyLogFileUnsetTest, KeyLogFile) {
|
||||
testing::GTEST_FLAG(death_test_style) = "threadsafe";
|
||||
|
||||
ASSERT_EXIT(ConnectAndCheck(), ::testing::ExitedWithCode(0), "");
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
KeyLogFileDTLS12, KeyLogFileUnsetTest,
|
||||
::testing::Combine(TlsConnectTestBase::kTlsVariantsDatagram,
|
||||
TlsConnectTestBase::kTlsV11V12));
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
KeyLogFileTLS12, KeyLogFileUnsetTest,
|
||||
::testing::Combine(TlsConnectTestBase::kTlsVariantsStream,
|
||||
TlsConnectTestBase::kTlsV10ToV12));
|
||||
#ifndef NSS_DISABLE_TLS_1_3
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
KeyLogFileTLS13, KeyLogFileUnsetTest,
|
||||
::testing::Combine(TlsConnectTestBase::kTlsVariantsStream,
|
||||
TlsConnectTestBase::kTlsV13));
|
||||
#endif
|
||||
|
||||
} // namespace nss_test
|
||||
|
|
|
@ -51,3 +51,5 @@ NSS build tool options:
|
|||
--enable-libpkix make libpkix part of the build
|
||||
--mozpkix-only build only static mozpkix and mozpkix-test libraries
|
||||
support for this build option is limited
|
||||
--disable-keylog enable support for logging key data to a file specified
|
||||
by the SSLKEYLOGFILE environment variable
|
||||
|
|
|
@ -73,6 +73,11 @@
|
|||
'-std=gnu99',
|
||||
],
|
||||
}],
|
||||
[ 'enable_sslkeylogfile==1', {
|
||||
'defines': [
|
||||
'NSS_ALLOW_SSLKEYLOGFILE',
|
||||
],
|
||||
}],
|
||||
],
|
||||
'dependencies': [
|
||||
'<(DEPTH)/exports.gyp:nss_exports',
|
||||
|
@ -92,11 +97,6 @@
|
|||
}
|
||||
}
|
||||
],
|
||||
'target_defaults': {
|
||||
'defines': [
|
||||
'NSS_ALLOW_SSLKEYLOGFILE=1'
|
||||
]
|
||||
},
|
||||
'variables': {
|
||||
'module': 'nss'
|
||||
}
|
||||
|
|
|
@ -3644,6 +3644,7 @@ ssl_SetDefaultsFromEnvironment(void)
|
|||
char *ev;
|
||||
firsttime = 0;
|
||||
#ifdef DEBUG
|
||||
ssl_trace_iob = NULL;
|
||||
ev = PR_GetEnvSecure("SSLDEBUGFILE");
|
||||
if (ev && ev[0]) {
|
||||
ssl_trace_iob = fopen(ev, "w");
|
||||
|
@ -3665,6 +3666,7 @@ ssl_SetDefaultsFromEnvironment(void)
|
|||
}
|
||||
#endif /* DEBUG */
|
||||
#ifdef NSS_ALLOW_SSLKEYLOGFILE
|
||||
ssl_keylog_iob = NULL;
|
||||
ev = PR_GetEnvSecure("SSLKEYLOGFILE");
|
||||
if (ev && ev[0]) {
|
||||
ssl_keylog_iob = fopen(ev, "a");
|
||||
|
|
|
@ -330,12 +330,6 @@ void ReportBlockingToConsole(nsPIDOMWindowOuter* aWindow, nsIURI* aURI,
|
|||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
NS_ConvertUTF8toUTF16 spec(exposableURI->GetSpecOrDefault());
|
||||
bool overflows = spec.Length() > sMaxSpecLength;
|
||||
spec.Truncate(std::min(spec.Length(), sMaxSpecLength));
|
||||
if (overflows) {
|
||||
NS_NAMED_LITERAL_STRING(kEllipsis, u"\x2026");
|
||||
spec.Append(kEllipsis);
|
||||
}
|
||||
const char16_t* params[] = {spec.get()};
|
||||
|
||||
nsContentUtils::ReportToConsole(
|
||||
|
|
|
@ -210,7 +210,10 @@ function testOnWindow(aTestData) {
|
|||
});
|
||||
}
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{"set": [["browser.safebrowsing.phishing.enabled", true]]},
|
||||
{"set": [
|
||||
["browser.safebrowsing.phishing.enabled", true],
|
||||
["dom.testing.sync-content-blocking-notifications", true],
|
||||
]},
|
||||
test);
|
||||
|
||||
function test() {
|
||||
|
|
|
@ -445,6 +445,7 @@ class ActivePS {
|
|||
mFilters[i] = aFilters[i];
|
||||
}
|
||||
|
||||
#if !defined(RELEASE_OR_BETA)
|
||||
if (mInterposeObserver) {
|
||||
// We need to register the observer on the main thread, because we want
|
||||
// to observe IO that happens on the main thread.
|
||||
|
@ -462,9 +463,11 @@ class ActivePS {
|
|||
}));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
~ActivePS() {
|
||||
#if !defined(RELEASE_OR_BETA)
|
||||
if (mInterposeObserver) {
|
||||
// We need to unregister the observer on the main thread, because that's
|
||||
// where we've registered it.
|
||||
|
@ -479,6 +482,7 @@ class ActivePS {
|
|||
}));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ThreadSelected(const char* aThreadName) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче