Merge inbound to mozilla-central. a=merge

This commit is contained in:
Ciure Andrei 2019-01-26 11:37:07 +02:00
Родитель ef7d8198eb 36095f0e1e
Коммит fbdba3f818
67 изменённых файлов: 619 добавлений и 359 удалений

Просмотреть файл

@ -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 BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/benignPage.html";
const TP_PREF = "privacy.trackingprotection.enabled"; const TP_PREF = "privacy.trackingprotection.enabled";
const ANIMATIONS_PREF = "toolkit.cosmeticAnimations.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 // 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. // animations pref and that one of the icons is visible in each case.
add_task(async function testShieldAnimation() { add_task(async function testShieldAnimation() {
await UrlClassifierTestUtils.addTestTrackers(); await UrlClassifierTestUtils.addTestTrackers();
Services.prefs.setBoolPref(TP_PREF, true); Services.prefs.setBoolPref(TP_PREF, true);
Services.prefs.setBoolPref(DTSCBN_PREF, true);
let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser); let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
@ -20,7 +22,8 @@ add_task(async function testShieldAnimation() {
let noAnimationIcon = document.getElementById("tracking-protection-icon"); let noAnimationIcon = document.getElementById("tracking-protection-icon");
Services.prefs.setBoolPref(ANIMATIONS_PREF, true); 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_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"); 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"); ok(BrowserTestUtils.is_hidden(noAnimationIcon), "the default icon is hidden");
Services.prefs.setBoolPref(ANIMATIONS_PREF, false); 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_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"); ok(BrowserTestUtils.is_hidden(animationIcon), "the animated icon is hidden when animations are disabled");
gBrowser.removeCurrentTab(); gBrowser.removeCurrentTab();
Services.prefs.clearUserPref(ANIMATIONS_PREF); Services.prefs.clearUserPref(ANIMATIONS_PREF);
Services.prefs.clearUserPref(TP_PREF); Services.prefs.clearUserPref(TP_PREF);
Services.prefs.clearUserPref(DTSCBN_PREF);
UrlClassifierTestUtils.cleanupTestTrackers(); 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 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 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 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); requestLongerTimeout(2);
@ -19,10 +20,13 @@ registerCleanupFunction(function() {
Services.prefs.clearUserPref(TP_PREF); Services.prefs.clearUserPref(TP_PREF);
Services.prefs.clearUserPref(TP_PB_PREF); Services.prefs.clearUserPref(TP_PB_PREF);
Services.prefs.clearUserPref(NCB_PREF); Services.prefs.clearUserPref(NCB_PREF);
Services.prefs.clearUserPref(DTSCBN_PREF);
Services.prefs.clearUserPref(ContentBlocking.prefIntroCount); Services.prefs.clearUserPref(ContentBlocking.prefIntroCount);
}); });
async function testTrackingProtectionAnimation(tabbrowser) { async function testTrackingProtectionAnimation(tabbrowser) {
Services.prefs.setBoolPref(DTSCBN_PREF, true);
info("Load a test page not containing tracking elements"); info("Load a test page not containing tracking elements");
let benignTab = await BrowserTestUtils.openNewForegroundTab(tabbrowser, BENIGN_PAGE); let benignTab = await BrowserTestUtils.openNewForegroundTab(tabbrowser, BENIGN_PAGE);
let ContentBlocking = tabbrowser.ownerGlobal.ContentBlocking; let ContentBlocking = tabbrowser.ownerGlobal.ContentBlocking;

Просмотреть файл

@ -6,12 +6,14 @@
const TP_PB_PREF = "privacy.trackingprotection.enabled"; const TP_PB_PREF = "privacy.trackingprotection.enabled";
const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html"; 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 TrackingProtection = null;
var ContentBlocking = null; var ContentBlocking = null;
var browser = null; var browser = null;
registerCleanupFunction(function() { registerCleanupFunction(function() {
Services.prefs.clearUserPref(TP_PB_PREF); Services.prefs.clearUserPref(TP_PB_PREF);
Services.prefs.clearUserPref(DTSCBN_PREF);
ContentBlocking = TrackingProtection = browser = null; ContentBlocking = TrackingProtection = browser = null;
UrlClassifierTestUtils.cleanupTestTrackers(); UrlClassifierTestUtils.cleanupTestTrackers();
}); });
@ -79,6 +81,7 @@ function testTrackingPageUnblocked() {
add_task(async function testExceptionAddition() { add_task(async function testExceptionAddition() {
await UrlClassifierTestUtils.addTestTrackers(); await UrlClassifierTestUtils.addTestTrackers();
Services.prefs.setBoolPref(DTSCBN_PREF, true);
let privateWin = await BrowserTestUtils.openNewBrowserWindow({private: true}); let privateWin = await BrowserTestUtils.openNewBrowserWindow({private: true});
browser = privateWin.gBrowser; browser = privateWin.gBrowser;
let tab = await BrowserTestUtils.openNewForegroundTab({ gBrowser: browser, waitForLoad: true, waitForStateStop: true }); 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"); ok(TrackingProtection.enabled, "TP is enabled after setting the pref");
info("Load a test page containing tracking elements"); 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); testTrackingPage(tab.ownerGlobal);
@ -128,7 +132,8 @@ add_task(async function testExceptionPersistence() {
ok(TrackingProtection.enabled, "TP is still enabled"); ok(TrackingProtection.enabled, "TP is still enabled");
info("Load a test page containing tracking elements"); 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); testTrackingPage(tab.ownerGlobal);
@ -137,7 +142,8 @@ add_task(async function testExceptionPersistence() {
clickButton("#tracking-action-unblock"); clickButton("#tracking-action-unblock");
is(identityPopupState(), "closed", "Identity popup is closed"); is(identityPopupState(), "closed", "Identity popup is closed");
await tabReloadPromise; await Promise.all([tabReloadPromise,
waitForContentBlockingEvent(2, tab.ownerGlobal)]);
testTrackingPageUnblocked(); testTrackingPageUnblocked();
privateWin.close(); privateWin.close();

Просмотреть файл

@ -17,6 +17,7 @@
const TP_PREF = "privacy.trackingprotection.enabled"; const TP_PREF = "privacy.trackingprotection.enabled";
const TP_PB_PREF = "privacy.trackingprotection.pbmode.enabled"; const TP_PB_PREF = "privacy.trackingprotection.pbmode.enabled";
const TPC_PREF = "network.cookie.cookieBehavior"; 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 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 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"; 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_PREF);
Services.prefs.clearUserPref(TP_PB_PREF); Services.prefs.clearUserPref(TP_PB_PREF);
Services.prefs.clearUserPref(TPC_PREF); Services.prefs.clearUserPref(TPC_PREF);
Services.prefs.clearUserPref(DTSCBN_PREF);
}); });
// This is a special version of "hidden" that doesn't check for item // 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("detected"), "trackers are detected");
ok(!ContentBlocking.content.hasAttribute("hasException"), "content shows no exception"); ok(!ContentBlocking.content.hasAttribute("hasException"), "content shows no exception");
let isPrivateBrowsing = PrivateBrowsingUtils.isWindowPrivate(window); let isWindowPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
let blockedByTP = areTrackersBlocked(isPrivateBrowsing); let blockedByTP = areTrackersBlocked(isWindowPrivate);
is(BrowserTestUtils.is_visible(ContentBlocking.iconBox), blockedByTP, is(BrowserTestUtils.is_visible(ContentBlocking.iconBox), blockedByTP,
"icon box is" + (blockedByTP ? "" : " not") + " visible"); "icon box is" + (blockedByTP ? "" : " not") + " visible");
is(ContentBlocking.iconBox.hasAttribute("active"), blockedByTP, is(ContentBlocking.iconBox.hasAttribute("active"), blockedByTP,
@ -119,7 +121,6 @@ function testTrackingPage(window) {
ok(hidden("#tracking-action-block"), "blockButton is hidden"); ok(hidden("#tracking-action-block"), "blockButton is hidden");
let isWindowPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
if (isWindowPrivate) { if (isWindowPrivate) {
ok(hidden("#tracking-action-unblock"), "unblockButton is hidden"); ok(hidden("#tracking-action-unblock"), "unblockButton is hidden");
is(!hidden("#tracking-action-unblock-private"), blockedByTP, is(!hidden("#tracking-action-unblock-private"), blockedByTP,
@ -218,6 +219,8 @@ async function testContentBlocking(tab) {
add_task(async function testNormalBrowsing() { add_task(async function testNormalBrowsing() {
await UrlClassifierTestUtils.addTestTrackers(); await UrlClassifierTestUtils.addTestTrackers();
Services.prefs.setBoolPref(DTSCBN_PREF, true);
tabbrowser = gBrowser; tabbrowser = gBrowser;
let tab = tabbrowser.selectedTab = BrowserTestUtils.addTab(tabbrowser); 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 TP_PREF = "privacy.trackingprotection.enabled";
const COOKIE_PREF = "network.cookie.cookieBehavior"; const COOKIE_PREF = "network.cookie.cookieBehavior";
const ANIMATIONS_PREF = "toolkit.cosmeticAnimations.enabled"; 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 // Check that the shield icon is always hidden when all content blocking
// categories are turned off, even when content blocking is on. // categories are turned off, even when content blocking is on.
@ -15,6 +16,7 @@ add_task(async function testContentBlockingAllDisabled() {
await SpecialPowers.pushPrefEnv({set: [ await SpecialPowers.pushPrefEnv({set: [
[TP_PREF, false], [TP_PREF, false],
[COOKIE_PREF, Ci.nsICookieService.BEHAVIOR_ACCEPT], [COOKIE_PREF, Ci.nsICookieService.BEHAVIOR_ACCEPT],
[DTSCBN_PREF, true],
]}); ]});
await UrlClassifierTestUtils.addTestTrackers(); await UrlClassifierTestUtils.addTestTrackers();
@ -30,7 +32,8 @@ add_task(async function testContentBlockingAllDisabled() {
let animationIcon = document.getElementById("tracking-protection-icon-animatable-image"); let animationIcon = document.getElementById("tracking-protection-icon-animatable-image");
let noAnimationIcon = document.getElementById("tracking-protection-icon"); 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(noAnimationIcon), "the default icon is hidden");
ok(BrowserTestUtils.is_hidden(animationIcon), "the animated 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: [ await SpecialPowers.pushPrefEnv({set: [
[TP_PREF, true], [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"); ok(BrowserTestUtils.is_visible(noAnimationIcon), "the default icon is shown");
}); });

Просмотреть файл

@ -26,8 +26,10 @@ export function createFrame(frame: FramePacket): ?Frame {
} else { } else {
title = `(${frame.type})`; title = `(${frame.type})`;
} }
// NOTE: Firefox 66 switched from where.source to where.actor
const location = { const location = {
sourceId: frame.where.source.actor, sourceId: frame.where.source ? frame.where.source.actor : frame.where.actor,
line: frame.where.line, line: frame.where.line,
column: frame.where.column column: frame.where.column
}; };

Просмотреть файл

@ -99,7 +99,7 @@ const FrameActor = ActorClassWithSpec(frameSpec, {
if (this.frame.script) { if (this.frame.script) {
const generatedLocation = this.threadActor.sources.getFrameLocation(this.frame); const generatedLocation = this.threadActor.sources.getFrameLocation(this.frame);
form.where = { form.where = {
source: generatedLocation.generatedSourceActor.form(), actor: generatedLocation.generatedSourceActor.actorID,
line: generatedLocation.generatedLine, line: generatedLocation.generatedLine,
column: generatedLocation.generatedColumn, column: generatedLocation.generatedColumn,
}; };

Просмотреть файл

@ -483,7 +483,7 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
} }
packet.frame.where = { packet.frame.where = {
source: generatedSourceActor.form(), actor: generatedSourceActor.actorID,
line: generatedLine, line: generatedLine,
column: generatedColumn, column: generatedColumn,
}; };
@ -1191,19 +1191,17 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
const frameSourceActor = this.sources.createSourceActor(frame.script.source); const frameSourceActor = this.sources.createSourceActor(frame.script.source);
if (frameSourceActor) { if (frameSourceActor) {
const sourceForm = frameSourceActor.form();
form.where = { form.where = {
source: sourceForm, actor: frameSourceActor.actorID,
line: form.where.line, line: form.where.line,
column: form.where.column, column: form.where.column,
}; };
form.source = sourceForm;
frameItem = form; frameItem = form;
} }
frames.push(frameItem); 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) }; return { frames: frames.filter(x => !!x) };
}, },

Просмотреть файл

@ -804,19 +804,26 @@ function getSourceContent(sourceClient) {
* @param string url * @param string url
* @returns Promise<SourceClient> * @returns Promise<SourceClient>
*/ */
function getSource(threadClient, url) { async function getSource(threadClient, url) {
const deferred = defer(); const {sources} = await threadClient.getSources();
threadClient.getSources((res) => { const source = sources.find((s) => s.url === url);
const source = res.sources.filter(function(s) {
return s.url === url; if (source) {
}); return threadClient.source(source);
if (source.length) { }
deferred.resolve(threadClient.source(source[0]));
} else { throw new Error("source not found");
deferred.reject(new Error("source not found")); }
}
}); async function getSourceById(threadClient, id) {
return deferred.promise; 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 testBlackBox = async function() {
const packet = await executeOnNextTickAndWaitForPause(evalCode, gClient); 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, { await setBreakpoint(bpSource, { line: 2 });
line: 2,
});
await resume(gThreadClient); await resume(gThreadClient);
const { sources } = await getSources(gThreadClient); const sourceClient = await getSource(gThreadClient, BLACK_BOXED_URL);
const sourceClient = gThreadClient.source(
sources.filter(s => s.url == BLACK_BOXED_URL)[0]
);
Assert.ok(!sourceClient.isBlackBoxed, Assert.ok(!sourceClient.isBlackBoxed,
"By default the source is not black boxed."); "By default the source is not black boxed.");
// Test that we can step into `doStuff` when we are not black boxed. // Test that we can step into `doStuff` when we are not black boxed.
await runTest( await runTest(
function onSteppedLocation(location) { async function onSteppedLocation(location) {
Assert.equal(location.source.url, BLACK_BOXED_URL); const source = await getSourceFormById(gThreadClient, location.actor);
Assert.equal(source.url, BLACK_BOXED_URL);
Assert.equal(location.line, 2); Assert.equal(location.line, 2);
}, },
function onDebuggerStatementFrames(frames) { async function onDebuggerStatementFrames(frames) {
Assert.ok(!frames.some(f => f.where.source.isBlackBoxed)); 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 // Test that we step through `doStuff` when we are black boxed and its frame
// doesn't show up. // doesn't show up.
await runTest( await runTest(
function onSteppedLocation(location) { async function onSteppedLocation(location) {
Assert.equal(location.source.url, SOURCE_URL); const source = await getSourceFormById(gThreadClient, location.actor);
Assert.equal(source.url, SOURCE_URL);
Assert.equal(location.line, 4); Assert.equal(location.line, 4);
}, },
function onDebuggerStatementFrames(frames) { async function onDebuggerStatementFrames(frames) {
for (const f of frames) { for (const frame of frames) {
if (f.where.source.url == BLACK_BOXED_URL) { const source = await getSourceFormById(gThreadClient, frame.where.actor);
Assert.ok(f.where.source.isBlackBoxed); if (source.url == BLACK_BOXED_URL) {
Assert.ok(source.isBlackBoxed);
} else { } 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. // Test that we can step into `doStuff` again.
await runTest( await runTest(
function onSteppedLocation(location) { async function onSteppedLocation(location) {
Assert.equal(location.source.url, BLACK_BOXED_URL); const source = await getSourceFormById(gThreadClient, location.actor);
Assert.equal(source.url, BLACK_BOXED_URL);
Assert.equal(location.line, 2); Assert.equal(location.line, 2);
}, },
function onDebuggerStatementFrames(frames) { async function onDebuggerStatementFrames(frames) {
Assert.ok(!frames.some(f => f.where.source.isBlackBoxed)); 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); await stepIn(gClient, gThreadClient);
const location = await getCurrentLocation(); const location = await getCurrentLocation();
onSteppedLocation(location); await onSteppedLocation(location);
packet = await resumeAndWaitForPause(gClient, gThreadClient); packet = await resumeAndWaitForPause(gClient, gThreadClient);
Assert.equal(packet.why.type, "debuggerStatement"); Assert.equal(packet.why.type, "debuggerStatement");
const { frames } = await getFrames(gThreadClient, 0, 100); const { frames } = await getFrames(gThreadClient, 0, 100);
onDebuggerStatementFrames(frames); await onDebuggerStatementFrames(frames);
return resume(gThreadClient); return resume(gThreadClient);
}; };

Просмотреть файл

@ -31,14 +31,12 @@ const BLACK_BOXED_URL = "http://example.com/blackboxme.js";
const SOURCE_URL = "http://example.com/source.js"; const SOURCE_URL = "http://example.com/source.js";
function test_black_box() { function test_black_box() {
gClient.addOneTimeListener("paused", function(event, packet) { gClient.addOneTimeListener("paused", async function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source); const source = await getSourceById(gThreadClient, packet.frame.where.actor);
source.setBreakpoint({ const [, bpClient] = await source.setBreakpoint({ line: 4 });
line: 4, gBpClient = bpClient;
}).then(function([response, bpClient]) { await gThreadClient.resume();
gBpClient = bpClient; test_black_box_dbg_statement();
gThreadClient.resume(test_black_box_dbg_statement);
});
}); });
/* eslint-disable no-multi-spaces, no-undef */ /* eslint-disable no-multi-spaces, no-undef */
@ -73,19 +71,17 @@ function test_black_box() {
function test_black_box_dbg_statement() { function test_black_box_dbg_statement() {
gThreadClient.getSources(async function({error, sources}) { gThreadClient.getSources(async function({error, sources}) {
Assert.ok(!error, "Should not get an error: " + error); Assert.ok(!error, "Should not get an error: " + error);
const sourceClient = gThreadClient.source( const sourceClient = await getSource(gThreadClient, BLACK_BOXED_URL);
sources.filter(s => s.url == BLACK_BOXED_URL)[0]
);
await blackBox(sourceClient); await blackBox(sourceClient);
gClient.addOneTimeListener("paused", function(event, packet) { gThreadClient.addOneTimeListener("paused", async function(event, packet) {
Assert.equal(packet.why.type, "breakpoint", Assert.equal(packet.why.type, "breakpoint",
"We should pass over the debugger statement."); "We should pass over the debugger statement.");
gBpClient.remove(function({error}) {
Assert.ok(!error, "Should not get an error: " + error); await gBpClient.remove();
gThreadClient.resume(test_unblack_box_dbg_statement.bind(null, sourceClient)); await gThreadClient.resume();
}); await test_unblack_box_dbg_statement(sourceClient);
}); });
gDebuggee.runTest(); gDebuggee.runTest();
}); });

Просмотреть файл

@ -71,15 +71,14 @@ function test_black_box() {
function test_black_box_exception() { function test_black_box_exception() {
gThreadClient.getSources(async function({error, sources}) { gThreadClient.getSources(async function({error, sources}) {
Assert.ok(!error, "Should not get an error: " + error); Assert.ok(!error, "Should not get an error: " + error);
const sourceClient = gThreadClient.source( const sourceClient = await getSource(gThreadClient, BLACK_BOXED_URL);
sources.filter(s => s.url == BLACK_BOXED_URL)[0]
);
await blackBox(sourceClient); await blackBox(sourceClient);
gThreadClient.pauseOnExceptions(true); gThreadClient.pauseOnExceptions(true);
gClient.addOneTimeListener("paused", function(event, packet) { gClient.addOneTimeListener("paused", async function(event, packet) {
Assert.equal(packet.frame.where.source.url, SOURCE_URL, 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."); "We shouldn't pause while in the black boxed source.");
finishClient(gClient); finishClient(gClient);
}); });

Просмотреть файл

@ -8,45 +8,44 @@
* Check basic breakpoint functionality. * Check basic breakpoint functionality.
*/ */
add_task(threadClientTest(({ threadClient, debuggee }) => { add_task(threadClientTest(async ({ threadClient, debuggee }) => {
return new Promise(resolve => { (async () => {
threadClient.addOneTimeListener("paused", function(event, packet) { info("Wait for the debugger statement to be hit");
const source = threadClient.source(packet.frame.where.source); let packet = await waitForPause(threadClient);
const location = { const source = await getSourceById(
line: debuggee.line0 + 3, threadClient,
}; packet.frame.where.actor
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
); );
/* 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 }) => { add_task(threadClientTest(({ threadClient, debuggee }) => {
return new Promise(resolve => { return new Promise((resolve) => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", async function(event, packet) {
const location = { line: debuggee.line0 + 3 }; const location = { line: debuggee.line0 + 3 };
const source = await getSourceById(
threadClient,
packet.frame.where.actor
);
threadClient.resume(); threadClient.resume();
@ -21,7 +25,6 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
Assert.equal(packet.why.type, "interrupted"); Assert.equal(packet.why.type, "interrupted");
}); });
const source = threadClient.source(packet.frame.where.source);
source.setBreakpoint(location).then(function() { source.setBreakpoint(location).then(function() {
executeSoon(resolve); executeSoon(resolve);
}, function(response) { }, function(response) {

Просмотреть файл

@ -24,8 +24,10 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
return new Promise(resolve => { return new Promise(resolve => {
threadClient.addOneTimeListener("paused", async function(event, packet) { threadClient.addOneTimeListener("paused", async function(event, packet) {
const location = { line: debuggee.line0 + 3 }; 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 // First, make sure that we can disable sliding with the
// `noSliding` option. // `noSliding` option.
await test_no_skip_breakpoint(source, location, debuggee); await test_no_skip_breakpoint(source, location, debuggee);
@ -39,7 +41,7 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value. // Check the return value.
Assert.equal(packet.type, "paused"); 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.frame.where.line, location.line + 1);
Assert.equal(packet.why.type, "breakpoint"); Assert.equal(packet.why.type, "breakpoint");
Assert.equal(packet.why.actors[0], bpClient.actor); Assert.equal(packet.why.actors[0], bpClient.actor);

Просмотреть файл

@ -10,8 +10,11 @@
add_task(threadClientTest(({ threadClient, debuggee }) => { add_task(threadClientTest(({ threadClient, debuggee }) => {
return new Promise(resolve => { return new Promise(resolve => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", async function(event, packet) {
const source = threadClient.source(packet.frame.where.source); const source = await getSourceById(
threadClient,
packet.frame.where.actor
);
const location = { line: debuggee.line0 + 3 }; const location = { line: debuggee.line0 + 3 };
source.setBreakpoint(location).then(function([response, bpClient]) { source.setBreakpoint(location).then(function([response, bpClient]) {
@ -21,7 +24,7 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value. // Check the return value.
Assert.equal(packet.type, "paused"); 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.frame.where.line, location.line);
Assert.equal(packet.why.type, "breakpoint"); Assert.equal(packet.why.type, "breakpoint");
Assert.equal(packet.why.actors[0], bpClient.actor); Assert.equal(packet.why.actors[0], bpClient.actor);

Просмотреть файл

@ -11,8 +11,11 @@
add_task(threadClientTest(({ threadClient, debuggee }) => { add_task(threadClientTest(({ threadClient, debuggee }) => {
return new Promise(resolve => { return new Promise(resolve => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", async function(event, packet) {
const source = threadClient.source(packet.frame.where.source); const source = await getSourceById(
threadClient,
packet.frame.where.actor
);
const location = { line: debuggee.line0 + 3 }; const location = { line: debuggee.line0 + 3 };
source.setBreakpoint(location).then(function([response, bpClient]) { source.setBreakpoint(location).then(function([response, bpClient]) {
@ -23,7 +26,7 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value. // Check the return value.
Assert.equal(packet.type, "paused"); 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.frame.where.line, location.line + 1);
Assert.equal(packet.why.type, "breakpoint"); Assert.equal(packet.why.type, "breakpoint");
Assert.equal(packet.why.actors[0], bpClient.actor); Assert.equal(packet.why.actors[0], bpClient.actor);

Просмотреть файл

@ -11,8 +11,11 @@
add_task(threadClientTest(({ threadClient, debuggee }) => { add_task(threadClientTest(({ threadClient, debuggee }) => {
return new Promise(resolve => { return new Promise(resolve => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", async function(event, packet) {
const source = threadClient.source(packet.frame.where.source); const source = await getSourceById(
threadClient,
packet.frame.where.actor
);
const location = { line: debuggee.line0 + 5 }; const location = { line: debuggee.line0 + 5 };
source.setBreakpoint(location).then(function([response, bpClient]) { source.setBreakpoint(location).then(function([response, bpClient]) {
@ -23,7 +26,7 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value. // Check the return value.
Assert.equal(packet.type, "paused"); 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.frame.where.line, location.line + 1);
Assert.equal(packet.why.type, "breakpoint"); Assert.equal(packet.why.type, "breakpoint");
Assert.equal(packet.why.actors[0], bpClient.actor); Assert.equal(packet.why.actors[0], bpClient.actor);

Просмотреть файл

@ -11,8 +11,11 @@
add_task(threadClientTest(({ threadClient, debuggee }) => { add_task(threadClientTest(({ threadClient, debuggee }) => {
return new Promise(resolve => { return new Promise(resolve => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", async function(event, packet) {
const source = threadClient.source(packet.frame.where.source); const source = await getSourceById(
threadClient,
packet.frame.where.actor
);
const location = { line: debuggee.line0 + 6 }; const location = { line: debuggee.line0 + 6 };
source.setBreakpoint(location).then(function([response, bpClient]) { source.setBreakpoint(location).then(function([response, bpClient]) {
@ -23,7 +26,7 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value. // Check the return value.
Assert.equal(packet.type, "paused"); 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.frame.where.line, location.line + 1);
Assert.equal(packet.why.type, "breakpoint"); Assert.equal(packet.why.type, "breakpoint");
Assert.equal(packet.why.actors[0], bpClient.actor); Assert.equal(packet.why.actors[0], bpClient.actor);

Просмотреть файл

@ -13,42 +13,43 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
return new Promise(resolve => { return new Promise(resolve => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", function(event, packet) {
threadClient.eval(packet.frame.actor, "foo", function(response) { 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); 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 */ /* eslint-disable */

Просмотреть файл

@ -11,15 +11,18 @@
add_task(threadClientTest(({ threadClient, debuggee }) => { add_task(threadClientTest(({ threadClient, debuggee }) => {
return new Promise(resolve => { return new Promise(resolve => {
let done = false; let done = false;
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", async function(event, packet) {
const source = threadClient.source(packet.frame.where.source); const source = await getSourceById(
threadClient,
packet.frame.where.actor
);
const location = { line: debuggee.line0 + 2 }; const location = { line: debuggee.line0 + 2 };
source.setBreakpoint(location).then(function([response, bpClient]) { source.setBreakpoint(location).then(function([response, bpClient]) {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value. // Check the return value.
Assert.equal(packet.type, "paused"); 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.frame.where.line, location.line);
Assert.equal(packet.why.type, "breakpoint"); Assert.equal(packet.why.type, "breakpoint");
Assert.equal(packet.why.actors[0], bpClient.actor); Assert.equal(packet.why.actors[0], bpClient.actor);

Просмотреть файл

@ -11,8 +11,11 @@
add_task(threadClientTest(({ threadClient, debuggee }) => { add_task(threadClientTest(({ threadClient, debuggee }) => {
return new Promise(resolve => { return new Promise(resolve => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", async function(event, packet) {
const source = threadClient.source(packet.frame.where.source); const source = await getSourceById(
threadClient,
packet.frame.where.actor
);
const location = { line: debuggee.line0 + 3 }; const location = { line: debuggee.line0 + 3 };
source.setBreakpoint(location).then(function([response, bpClient]) { source.setBreakpoint(location).then(function([response, bpClient]) {

Просмотреть файл

@ -11,8 +11,11 @@
add_task(threadClientTest(({ threadClient, debuggee }) => { add_task(threadClientTest(({ threadClient, debuggee }) => {
return new Promise(resolve => { return new Promise(resolve => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", async function(event, packet) {
const source = threadClient.source(packet.frame.where.source); const source = await getSourceById(
threadClient,
packet.frame.where.actor
);
const location = { line: debuggee.line0 + 2 }; const location = { line: debuggee.line0 + 2 };
source.setBreakpoint(location).then(function([response, bpClient]) { source.setBreakpoint(location).then(function([response, bpClient]) {

Просмотреть файл

@ -15,8 +15,11 @@ var gCount;
add_task(threadClientTest(({ threadClient, debuggee }) => { add_task(threadClientTest(({ threadClient, debuggee }) => {
return new Promise(resolve => { return new Promise(resolve => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", async function(event, packet) {
const source = threadClient.source(packet.frame.where.source); const source = await getSourceById(
threadClient,
packet.frame.where.actor
);
const location = { line: debuggee.line0 + 3}; const location = { line: debuggee.line0 + 3};
source.setBreakpoint(location).then(function([response, bpClient]) { source.setBreakpoint(location).then(function([response, bpClient]) {
@ -62,7 +65,7 @@ add_task(threadClientTest(({ threadClient, debuggee }) => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value. // Check the return value.
Assert.equal(packet.type, "paused"); 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.frame.where.line, location.line + 1);
Assert.equal(packet.why.type, "breakpoint"); Assert.equal(packet.why.type, "breakpoint");
Assert.equal(packet.why.actors[0], bpClient.actor); Assert.equal(packet.why.actors[0], bpClient.actor);

Просмотреть файл

@ -11,8 +11,11 @@
add_task(threadClientTest(({ threadClient, debuggee }) => { add_task(threadClientTest(({ threadClient, debuggee }) => {
return new Promise(resolve => { return new Promise(resolve => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", async function(event, packet) {
const source = threadClient.source(packet.frame.where.source); const source = await getSourceById(
threadClient,
packet.frame.where.actor
);
const location = { line: debuggee.line0 + 2 }; const location = { line: debuggee.line0 + 2 };
source.setBreakpoint(location).then(async function([response, bpClient]) { source.setBreakpoint(location).then(async function([response, bpClient]) {

Просмотреть файл

@ -11,8 +11,11 @@
add_task(threadClientTest(({ threadClient, debuggee }) => { add_task(threadClientTest(({ threadClient, debuggee }) => {
return new Promise(resolve => { return new Promise(resolve => {
threadClient.addOneTimeListener("paused", function(event, packet) { threadClient.addOneTimeListener("paused", async function(event, packet) {
const source = threadClient.source(packet.frame.where.source); const source = await getSourceById(
threadClient,
packet.frame.where.actor
);
const location = { line: debuggee.line0 + 2 }; const location = { line: debuggee.line0 + 2 };
source.setBreakpoint(location).then(async function([response, bpClient]) { 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 testSameBreakpoint = async function() {
const packet = await executeOnNextTickAndWaitForPause(evalCode, gClient); 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 // Whole line
const wholeLineLocation = { const wholeLineLocation = {

Просмотреть файл

@ -11,8 +11,11 @@
add_task(threadClientTest(({ threadClient, debuggee, client }) => { add_task(threadClientTest(({ threadClient, debuggee, client }) => {
return new Promise(resolve => { return new Promise(resolve => {
// Debugger statement // Debugger statement
client.addOneTimeListener("paused", function(event, packet) { client.addOneTimeListener("paused", async function(event, packet) {
const source = threadClient.source(packet.frame.where.source); const source = await getSourceById(
threadClient,
packet.frame.where.actor
);
const location = { const location = {
line: debuggee.line0 + 1, line: debuggee.line0 + 1,
column: 55, column: 55,
@ -24,7 +27,7 @@ add_task(threadClientTest(({ threadClient, debuggee, client }) => {
Assert.equal(packet.type, "paused"); Assert.equal(packet.type, "paused");
Assert.equal(packet.why.type, "breakpoint"); Assert.equal(packet.why.type, "breakpoint");
Assert.equal(packet.why.actors[0], bpClient.actor); 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.line, location.line);
Assert.equal(packet.frame.where.column, location.column); Assert.equal(packet.frame.where.column, location.column);

Просмотреть файл

@ -42,9 +42,12 @@ add_task(threadClientTest(({ threadClient, debuggee, client }) => {
})); }));
function set_breakpoints(packet, threadClient) { function set_breakpoints(packet, threadClient) {
return new Promise(resolve => { return new Promise(async resolve => {
let first, second; 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 }, source.setBreakpoint(firstLocation).then(function([{ actualLocation },
breakpointClient]) { breakpointClient]) {

Просмотреть файл

@ -44,8 +44,11 @@ add_task(threadClientTest(({ threadClient, debuggee, client }) => {
})); }));
function setBreakpoint(packet, threadClient, client) { function setBreakpoint(packet, threadClient, client) {
return new Promise(resolve => { return new Promise(async resolve => {
const source = threadClient.source(packet.frame.where.source); const source = await getSourceById(
threadClient,
packet.frame.where.actor
);
client.addOneTimeListener("resumed", resolve); client.addOneTimeListener("resumed", resolve);
source.setBreakpoint({ line: 2 }).then(() => { source.setBreakpoint({ line: 2 }).then(() => {

Просмотреть файл

@ -17,7 +17,10 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
let packet = await executeOnNextTickAndWaitForPause(() => { let packet = await executeOnNextTickAndWaitForPause(() => {
evalCode(debuggee); evalCode(debuggee);
}, client); }, client);
const source = threadClient.source(packet.frame.where.source); const source = await getSourceById(
threadClient,
packet.frame.where.actor
);
const location = { const location = {
line: debuggee.line0 + 8, line: debuggee.line0 + 8,
}; };
@ -30,7 +33,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
Assert.equal(packet.type, "paused"); Assert.equal(packet.type, "paused");
Assert.equal(packet.why.type, "breakpoint"); Assert.equal(packet.why.type, "breakpoint");
Assert.equal(packet.why.actors[0], bpClient.actor); 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.line, location.line);
await resume(threadClient); await resume(threadClient);

Просмотреть файл

@ -16,7 +16,11 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
const packet = await executeOnNextTickAndWaitForPause(() => { const packet = await executeOnNextTickAndWaitForPause(() => {
evalCode(debuggee); evalCode(debuggee);
}, client); }, client);
const source = threadClient.source(packet.frame.where.source); const source = await getSourceById(
threadClient,
packet.frame.where.actor
);
const location = { const location = {
line: debuggee.line0 + 2, line: debuggee.line0 + 2,
}; };

Просмотреть файл

@ -27,8 +27,11 @@ function run_test() {
} }
function test_simple_breakpoint() { function test_simple_breakpoint() {
gThreadClient.addOneTimeListener("paused", function(event, packet) { gThreadClient.addOneTimeListener("paused", async function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source); const source = await getSourceById(
gThreadClient,
packet.frame.where.actor
);
source.setBreakpoint({ source.setBreakpoint({
line: 3, line: 3,
condition: "a === 1", condition: "a === 1",

Просмотреть файл

@ -27,8 +27,11 @@ function run_test() {
} }
function test_simple_breakpoint() { function test_simple_breakpoint() {
gThreadClient.addOneTimeListener("paused", function(event, packet) { gThreadClient.addOneTimeListener("paused", async function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source); const source = await getSourceById(
gThreadClient,
packet.frame.where.actor
);
source.setBreakpoint({ source.setBreakpoint({
line: 3, line: 3,
condition: "a === 2", condition: "a === 2",

Просмотреть файл

@ -27,8 +27,11 @@ function run_test() {
} }
function test_simple_breakpoint() { function test_simple_breakpoint() {
gThreadClient.addOneTimeListener("paused", function(event, packet) { gThreadClient.addOneTimeListener("paused", async function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source); const source = await getSourceById(
gThreadClient,
packet.frame.where.actor
);
source.setBreakpoint({ source.setBreakpoint({
line: 3, line: 3,
condition: "throw new Error()", condition: "throw new Error()",

Просмотреть файл

@ -44,7 +44,7 @@ function run_test() {
function test_pause_frame() { function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function(event, packet) { 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); Assert.equal(frameResponse.frames.length, 4);
const wasmFrame = frameResponse.frames[1]; const wasmFrame = frameResponse.frames[1];
@ -52,9 +52,10 @@ function test_pause_frame() {
Assert.equal(wasmFrame.this, undefined); Assert.equal(wasmFrame.this, undefined);
const location = wasmFrame.where; const location = wasmFrame.where;
const source = await getSourceById(gThreadClient, location.actor);
Assert.equal(location.line > 0, true); Assert.equal(location.line > 0, true);
Assert.equal(location.column > 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); finishClient(gClient);
}); });

Просмотреть файл

@ -28,10 +28,9 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
Assert.equal(why.actors[0], breakpointClient.actor); Assert.equal(why.actors[0], breakpointClient.actor);
const frame = packet.frame; const frame = packet.frame;
const where = frame.where; Assert.equal(frame.where.actor, source.actor);
Assert.equal(where.source.actor, source.actor); Assert.equal(frame.where.line, location.line);
Assert.equal(where.line, location.line); Assert.equal(frame.where.column, 6);
Assert.equal(where.column, 6);
const variables = frame.environment.bindings.variables; const variables = frame.environment.bindings.variables;
Assert.equal(variables.a.value.type, "undefined"); Assert.equal(variables.a.value.type, "undefined");

Просмотреть файл

@ -31,7 +31,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
const frame = packet.frame; const frame = packet.frame;
const where = frame.where; 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.line, location.line);
Assert.equal(where.column, 52); Assert.equal(where.column, 52);

Просмотреть файл

@ -29,7 +29,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
const frame = packet.frame; const frame = packet.frame;
const where = frame.where; 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.line, location.line);
Assert.equal(where.column, 28); Assert.equal(where.column, 28);

Просмотреть файл

@ -31,7 +31,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
const frame = packet.frame; const frame = packet.frame;
const where = frame.where; 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.line, location.line);
Assert.equal(where.column, 81); Assert.equal(where.column, 81);

Просмотреть файл

@ -27,7 +27,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client, targetFront }
Assert.equal(why.actors[0], breakpointClient.actor); Assert.equal(why.actors[0], breakpointClient.actor);
const frame = packet.frame; const frame = packet.frame;
const where = frame.where; 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.line, location.line);
Assert.equal(where.column, location.column); Assert.equal(where.column, location.column);
const variables = frame.environment.bindings.variables; const variables = frame.environment.bindings.variables;

Просмотреть файл

@ -23,7 +23,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
Assert.equal(why.actors[0], breakpointClient.actor); Assert.equal(why.actors[0], breakpointClient.actor);
const frame = packet.frame; const frame = packet.frame;
const where = frame.where; 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.line, location.line);
Assert.equal(where.column, location.column); Assert.equal(where.column, location.column);
const variables = frame.environment.bindings.variables; 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); Assert.equal(why.actors[0], breakpointClient.actor);
const frame = packet.frame; const frame = packet.frame;
const where = frame.where; 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.line, location.line);
const variables = frame.environment.bindings.variables; const variables = frame.environment.bindings.variables;
Assert.equal(variables.a.value, 1); Assert.equal(variables.a.value, 1);

Просмотреть файл

@ -23,14 +23,15 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
Assert.equal(why.actors[0], breakpointClient.actor); Assert.equal(why.actors[0], breakpointClient.actor);
let frame = packet.frame; let frame = packet.frame;
let where = frame.where; let 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.line, location.line);
let variables = frame.environment.bindings.variables; let variables = frame.environment.bindings.variables;
Assert.equal(variables.i.value.type, "undefined"); Assert.equal(variables.i.value.type, "undefined");
packet = await executeOnNextTickAndWaitForPause(function() { packet = await executeOnNextTickAndWaitForPause(
resume(threadClient); () => resume(threadClient),
}, client); client
);
Assert.equal(packet.type, "paused"); Assert.equal(packet.type, "paused");
why = packet.why; why = packet.why;
Assert.equal(why.type, "breakpoint"); Assert.equal(why.type, "breakpoint");
@ -38,7 +39,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
Assert.equal(why.actors[0], breakpointClient.actor); Assert.equal(why.actors[0], breakpointClient.actor);
frame = packet.frame; frame = packet.frame;
where = frame.where; 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.line, location.line);
variables = frame.environment.bindings.variables; variables = frame.environment.bindings.variables;
Assert.equal(variables.i.value, 0); Assert.equal(variables.i.value, 0);

Просмотреть файл

@ -23,7 +23,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
Assert.equal(why.actors[0], breakpointClient.actor); Assert.equal(why.actors[0], breakpointClient.actor);
const frame = packet.frame; const frame = packet.frame;
const where = frame.where; 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.line, location.line);
const variables = frame.environment.bindings.variables; const variables = frame.environment.bindings.variables;
Assert.equal(variables.a.value.type, "undefined"); 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); Assert.equal(why.actors[0], breakpointClient.actor);
const frame = packet.frame; const frame = packet.frame;
const where = frame.where; const where = frame.where;
Assert.equal(where.source.actor, source.actor); Assert.equal(where.actor, source.actor);
Assert.equal(where.line, 8); Assert.equal(where.line, 8);
const variables = frame.environment.bindings.variables; const variables = frame.environment.bindings.variables;
Assert.equal(variables.a.value, 1); Assert.equal(variables.a.value, 1);

Просмотреть файл

@ -25,7 +25,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
Assert.equal(why.actors[0], breakpointClient.actor); Assert.equal(why.actors[0], breakpointClient.actor);
const frame = packet.frame; const frame = packet.frame;
const where = frame.where; const where = frame.where;
Assert.equal(where.source.actor, source.actor); Assert.equal(where.actor, source.actor);
Assert.equal(where.line, actualLocation.line); Assert.equal(where.line, actualLocation.line);
const variables = frame.environment.bindings.variables; const variables = frame.environment.bindings.variables;
Assert.equal(variables.a.value, 1); Assert.equal(variables.a.value, 1);

Просмотреть файл

@ -23,7 +23,7 @@ add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
Assert.equal(why.actors[0], breakpointClient.actor); Assert.equal(why.actors[0], breakpointClient.actor);
const frame = packet.frame; const frame = packet.frame;
const where = frame.where; 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.line, location.line);
const variables = frame.environment.bindings.variables; const variables = frame.environment.bindings.variables;
Assert.equal(variables.a.value, 1); 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"); equal(dbgStmt.frame.where.line, 3, "Should be at debugger statement on line 3");
dumpn("Setting breakpoint in innerFunction"); 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 }); await source.setBreakpoint({ line: 7 });
dumpn("Step in to innerFunction"); dumpn("Step in to innerFunction");

Просмотреть файл

@ -319,6 +319,8 @@ static LazyLogModule gDOMLeakPRLogOuter("DOMLeakOuter");
static int32_t gOpenPopupSpamCount = 0; static int32_t gOpenPopupSpamCount = 0;
static bool gSyncContentBlockingNotifications = false;
nsGlobalWindowOuter::OuterWindowByIdTable* nsGlobalWindowOuter::OuterWindowByIdTable*
nsGlobalWindowOuter::sOuterWindowsById = nullptr; nsGlobalWindowOuter::sOuterWindowsById = nullptr;
@ -5405,100 +5407,130 @@ void nsGlobalWindowOuter::NotifyContentBlockingEvent(unsigned aEvent,
nsCOMPtr<Document> doc = docShell->GetDocument(); nsCOMPtr<Document> doc = docShell->GetDocument();
NS_ENSURE_TRUE_VOID(doc); NS_ENSURE_TRUE_VOID(doc);
// This event might come after the user has navigated to another page. nsCOMPtr<nsIURI> uri(aURIHint);
// To prevent showing the TrackingProtection UI on the wrong page, we need to nsCOMPtr<nsIChannel> channel(aChannel);
// check that the loading URI for the channel is the same as the URI currently
// loaded in the document. static bool prefInitialized = false;
if (!SameLoadingURI(doc, aChannel) && if (!prefInitialized) {
aEvent == nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT) { Preferences::AddBoolVarCache(
return; &gSyncContentBlockingNotifications,
"dom.testing.sync-content-blocking-notifications", false);
prefInitialized = true;
} }
// Notify nsIWebProgressListeners of this content blocking event. nsCOMPtr<nsIRunnable> func = NS_NewRunnableFunction(
// Can be used to change the UI state. "NotifyContentBlockingEventDelayed",
nsresult rv = NS_OK; [doc, docShell, uri, channel, aEvent, aBlocked]() {
nsCOMPtr<nsISecurityEventSink> eventSink = do_QueryInterface(docShell, &rv); // This event might come after the user has navigated to another
NS_ENSURE_SUCCESS_VOID(rv); // page. To prevent showing the TrackingProtection UI on the wrong
uint32_t event = 0; // page, we need to check that the loading URI for the channel is
nsCOMPtr<nsISecureBrowserUI> securityUI; // the same as the URI currently loaded in the document.
docShell->GetSecurityUI(getter_AddRefs(securityUI)); if (!SameLoadingURI(doc, channel) &&
if (!securityUI) { aEvent == nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT) {
return; return;
} }
securityUI->GetContentBlockingEvent(&event);
nsAutoCString origin;
nsContentUtils::GetASCIIOrigin(aURIHint, origin);
bool blockedValue = aBlocked; // Notify nsIWebProgressListeners of this content blocking event.
bool unblocked = false; // Can be used to change the UI state.
if (aEvent == nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT) { nsresult rv = NS_OK;
doc->SetHasTrackingContentBlocked(aBlocked, origin); nsCOMPtr<nsISecurityEventSink> eventSink =
if (!aBlocked) { do_QueryInterface(docShell, &rv);
unblocked = !doc->GetHasTrackingContentBlocked(); NS_ENSURE_SUCCESS_VOID(rv);
} uint32_t event = 0;
} else if (aEvent == nsIWebProgressListener::STATE_LOADED_TRACKING_CONTENT) { nsCOMPtr<nsISecureBrowserUI> securityUI;
doc->SetHasTrackingContentLoaded(aBlocked, origin); docShell->GetSecurityUI(getter_AddRefs(securityUI));
if (!aBlocked) { if (!securityUI) {
unblocked = !doc->GetHasTrackingContentLoaded(); return;
} }
} else if (aEvent == securityUI->GetContentBlockingEvent(&event);
nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION) { nsAutoCString origin;
doc->SetHasCookiesBlockedByPermission(aBlocked, origin); nsContentUtils::GetASCIIOrigin(uri, 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 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 #ifdef ANDROID
// GeckoView always needs to notify about blocked trackers, since the // GeckoView always needs to notify about blocked trackers,
// GeckoView API always needs to report the URI and type of any blocked // since the GeckoView API always needs to report the URI and
// tracker. // type of any blocked tracker. We use a platform-dependent code
// We use a platform-dependent code path here because reporting this // path here because reporting this notification on desktop
// notification on desktop platforms isn't necessary and doing so can have // platforms isn't necessary and doing so can have a big
// a big performance cost. // performance cost.
&& aEvent != nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT && aEvent != nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT
#endif #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; return;
} }
eventSink->OnContentBlockingEvent(aChannel, event);
} }
// static // static

Просмотреть файл

@ -23,6 +23,7 @@
#include "mozilla/Compression.h" #include "mozilla/Compression.h"
#include "mozilla/MathAlgorithms.h" #include "mozilla/MathAlgorithms.h"
#include "mozilla/ScopeExit.h" #include "mozilla/ScopeExit.h"
#include "mozilla/Sprintf.h" // SprintfLiteral
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
#include "mozilla/Utf8.h" // mozilla::Utf8Unit #include "mozilla/Utf8.h" // mozilla::Utf8Unit
#include "mozilla/Variant.h" #include "mozilla/Variant.h"

Просмотреть файл

@ -334,7 +334,7 @@ NS_MutatorMethod(Method aMethod, Args ...aArgs)
nsCOMPtr<Interface> target = do_QueryInterface(aMutator, &rv); nsCOMPtr<Interface> target = do_QueryInterface(aMutator, &rv);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = (target->*aMethod)(aArgs...); rv = (target->*aMethod)(aArgs...);
NS_ENSURE_SUCCESS(rv, rv); if (NS_FAILED(rv)) return rv;
return NS_OK; return NS_OK;
}; };
} }
@ -493,7 +493,6 @@ public:
return *this; return *this;
} }
mStatus = aFunction(mMutator); mStatus = aFunction(mMutator);
NS_ENSURE_SUCCESS(mStatus, *this);
return *this; return *this;
} }
@ -543,7 +542,7 @@ public:
MOZ_MUST_USE nsresult Finalize(nsIURI** aURI) MOZ_MUST_USE nsresult Finalize(nsIURI** aURI)
{ {
NS_ENSURE_SUCCESS(mStatus, mStatus); if (NS_FAILED(mStatus)) return mStatus;
mStatus = mMutator->Finalize(aURI); mStatus = mMutator->Finalize(aURI);
NS_ENSURE_SUCCESS(mStatus, mStatus); NS_ENSURE_SUCCESS(mStatus, mStatus);

5
security/nss/.arcconfig Normal file
Просмотреть файл

@ -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_tls=0
fuzz_oss=0 fuzz_oss=0
no_local_nspr=0 no_local_nspr=0
sslkeylogfile=1
gyp_params=(--depth="$cwd" --generator-output=".") gyp_params=(--depth="$cwd" --generator-output=".")
ninja_params=() ninja_params=()
@ -103,6 +104,7 @@ while [ $# -gt 0 ]; do
--enable-fips) gyp_params+=(-Ddisable_fips=0) ;; --enable-fips) gyp_params+=(-Ddisable_fips=0) ;;
--enable-libpkix) gyp_params+=(-Ddisable_libpkix=0) ;; --enable-libpkix) gyp_params+=(-Ddisable_libpkix=0) ;;
--mozpkix-only) gyp_params+=(-Dmozpkix_only=1 -Ddisable_tests=1 -Dsign_libs=0) ;; --mozpkix-only) gyp_params+=(-Dmozpkix_only=1 -Ddisable_tests=1 -Dsign_libs=0) ;;
--disable-keylog) sslkeylogfile=0 ;;
*) show_help; exit 2 ;; *) show_help; exit 2 ;;
esac esac
shift shift
@ -116,6 +118,8 @@ else
target=Debug target=Debug
fi fi
gyp_params+=(-Denable_sslkeylogfile="$sslkeylogfile")
# Do special setup. # Do special setup.
if [ "$fuzz" = 1 ]; then if [ "$fuzz" = 1 ]; then
source "$cwd"/coreconf/fuzz.sh source "$cwd"/coreconf/fuzz.sh

Просмотреть файл

@ -10,3 +10,4 @@
*/ */
#error "Do not include this header file." #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 CFLAGS += -DNSS_DISABLE_TLS_1_3
endif endif
ifdef NSS_ALLOW_SSLKEYLOGFILE
SSLKEYLOGFILE_FILES = ssl_keylog_unittest.cc
else
SSLKEYLOGFILE_FILES = $(NULL)
endif
####################################################################### #######################################################################
# (5) Execute "global" rules. (OPTIONAL) # # (5) Execute "global" rules. (OPTIONAL) #
####################################################################### #######################################################################

Просмотреть файл

@ -20,6 +20,7 @@ CPPSRCS = \
ssl_ciphersuite_unittest.cc \ ssl_ciphersuite_unittest.cc \
ssl_custext_unittest.cc \ ssl_custext_unittest.cc \
ssl_damage_unittest.cc \ ssl_damage_unittest.cc \
ssl_debug_env_unittest.cc \
ssl_dhe_unittest.cc \ ssl_dhe_unittest.cc \
ssl_drop_unittest.cc \ ssl_drop_unittest.cc \
ssl_ecdh_unittest.cc \ ssl_ecdh_unittest.cc \
@ -31,7 +32,6 @@ CPPSRCS = \
ssl_gather_unittest.cc \ ssl_gather_unittest.cc \
ssl_gtest.cc \ ssl_gtest.cc \
ssl_hrr_unittest.cc \ ssl_hrr_unittest.cc \
ssl_keylog_unittest.cc \
ssl_keyupdate_unittest.cc \ ssl_keyupdate_unittest.cc \
ssl_loopback_unittest.cc \ ssl_loopback_unittest.cc \
ssl_misc_unittest.cc \ ssl_misc_unittest.cc \
@ -53,6 +53,7 @@ CPPSRCS = \
tls_filter.cc \ tls_filter.cc \
tls_protect.cc \ tls_protect.cc \
tls_esni_unittest.cc \ tls_esni_unittest.cc \
$(SSLKEYLOGFILE_FILES) \
$(NULL) $(NULL)
INCLUDES += -I$(CORE_DEPTH)/gtests/google_test/gtest/include \ 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_ciphersuite_unittest.cc',
'ssl_custext_unittest.cc', 'ssl_custext_unittest.cc',
'ssl_damage_unittest.cc', 'ssl_damage_unittest.cc',
'ssl_debug_env_unittest.cc',
'ssl_dhe_unittest.cc', 'ssl_dhe_unittest.cc',
'ssl_drop_unittest.cc', 'ssl_drop_unittest.cc',
'ssl_ecdh_unittest.cc', 'ssl_ecdh_unittest.cc',
@ -32,7 +33,6 @@
'ssl_gather_unittest.cc', 'ssl_gather_unittest.cc',
'ssl_gtest.cc', 'ssl_gtest.cc',
'ssl_hrr_unittest.cc', 'ssl_hrr_unittest.cc',
'ssl_keylog_unittest.cc',
'ssl_keyupdate_unittest.cc', 'ssl_keyupdate_unittest.cc',
'ssl_loopback_unittest.cc', 'ssl_loopback_unittest.cc',
'ssl_misc_unittest.cc', 'ssl_misc_unittest.cc',
@ -91,6 +91,14 @@
'<(DEPTH)/lib/dbm/src/src.gyp:dbm', '<(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' '../../lib/ssl'
], ],
'defines': [ 'defines': [
'NSS_USE_STATIC_LIBS' 'NSS_USE_STATIC_LIBS',
], ],
}, },
'variables': { 'variables': {

Просмотреть файл

@ -4,8 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef NSS_ALLOW_SSLKEYLOGFILE
#include <cstdlib> #include <cstdlib>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
@ -15,20 +13,59 @@
namespace nss_test { namespace nss_test {
static const std::string keylog_file_path = "keylog.txt"; static const std::string kKeylogFilePath = "keylog.txt";
static const std::string keylog_env = "SSLKEYLOGFILE=" + keylog_file_path; 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: public:
virtual void CheckKeyLog() = 0;
KeyLogFileTestBase(std::string env) : env_to_set_(env) {}
void SetUp() override { void SetUp() override {
TlsConnectGeneric::SetUp(); TlsConnectGeneric::SetUp();
// Remove previous results (if any). // Remove previous results (if any).
(void)remove(keylog_file_path.c_str()); (void)remove(kKeylogFilePath.c_str());
PR_SetEnv(keylog_env.c_str()); PR_SetEnv(env_to_set_.c_str());
} }
void CheckKeyLog() { void ConnectAndCheck() {
std::ifstream f(keylog_file_path); // 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::map<std::string, size_t> labels;
std::set<std::string> client_randoms; std::set<std::string> client_randoms;
for (std::string line; std::getline(f, line);) { for (std::string line; std::getline(f, line);) {
@ -65,28 +102,6 @@ class KeyLogFileTest : public TlsConnectGeneric {
ASSERT_EQ(4U, labels["EXPORTER_SECRET"]); 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 // 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)); TlsConnectTestBase::kTlsV13));
#endif #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 --enable-libpkix make libpkix part of the build
--mozpkix-only build only static mozpkix and mozpkix-test libraries --mozpkix-only build only static mozpkix and mozpkix-test libraries
support for this build option is limited 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', '-std=gnu99',
], ],
}], }],
[ 'enable_sslkeylogfile==1', {
'defines': [
'NSS_ALLOW_SSLKEYLOGFILE',
],
}],
], ],
'dependencies': [ 'dependencies': [
'<(DEPTH)/exports.gyp:nss_exports', '<(DEPTH)/exports.gyp:nss_exports',
@ -92,11 +97,6 @@
} }
} }
], ],
'target_defaults': {
'defines': [
'NSS_ALLOW_SSLKEYLOGFILE=1'
]
},
'variables': { 'variables': {
'module': 'nss' 'module': 'nss'
} }

Просмотреть файл

@ -3644,6 +3644,7 @@ ssl_SetDefaultsFromEnvironment(void)
char *ev; char *ev;
firsttime = 0; firsttime = 0;
#ifdef DEBUG #ifdef DEBUG
ssl_trace_iob = NULL;
ev = PR_GetEnvSecure("SSLDEBUGFILE"); ev = PR_GetEnvSecure("SSLDEBUGFILE");
if (ev && ev[0]) { if (ev && ev[0]) {
ssl_trace_iob = fopen(ev, "w"); ssl_trace_iob = fopen(ev, "w");
@ -3665,6 +3666,7 @@ ssl_SetDefaultsFromEnvironment(void)
} }
#endif /* DEBUG */ #endif /* DEBUG */
#ifdef NSS_ALLOW_SSLKEYLOGFILE #ifdef NSS_ALLOW_SSLKEYLOGFILE
ssl_keylog_iob = NULL;
ev = PR_GetEnvSecure("SSLKEYLOGFILE"); ev = PR_GetEnvSecure("SSLKEYLOGFILE");
if (ev && ev[0]) { if (ev && ev[0]) {
ssl_keylog_iob = fopen(ev, "a"); ssl_keylog_iob = fopen(ev, "a");

Просмотреть файл

@ -330,12 +330,6 @@ void ReportBlockingToConsole(nsPIDOMWindowOuter* aWindow, nsIURI* aURI,
NS_ENSURE_SUCCESS_VOID(rv); NS_ENSURE_SUCCESS_VOID(rv);
NS_ConvertUTF8toUTF16 spec(exposableURI->GetSpecOrDefault()); 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()}; const char16_t* params[] = {spec.get()};
nsContentUtils::ReportToConsole( nsContentUtils::ReportToConsole(

Просмотреть файл

@ -210,7 +210,10 @@ function testOnWindow(aTestData) {
}); });
} }
SpecialPowers.pushPrefEnv( SpecialPowers.pushPrefEnv(
{"set": [["browser.safebrowsing.phishing.enabled", true]]}, {"set": [
["browser.safebrowsing.phishing.enabled", true],
["dom.testing.sync-content-blocking-notifications", true],
]},
test); test);
function test() { function test() {

Просмотреть файл

@ -445,6 +445,7 @@ class ActivePS {
mFilters[i] = aFilters[i]; mFilters[i] = aFilters[i];
} }
#if !defined(RELEASE_OR_BETA)
if (mInterposeObserver) { if (mInterposeObserver) {
// We need to register the observer on the main thread, because we want // We need to register the observer on the main thread, because we want
// to observe IO that happens on the main thread. // to observe IO that happens on the main thread.
@ -462,9 +463,11 @@ class ActivePS {
})); }));
} }
} }
#endif
} }
~ActivePS() { ~ActivePS() {
#if !defined(RELEASE_OR_BETA)
if (mInterposeObserver) { if (mInterposeObserver) {
// We need to unregister the observer on the main thread, because that's // We need to unregister the observer on the main thread, because that's
// where we've registered it. // where we've registered it.
@ -479,6 +482,7 @@ class ActivePS {
})); }));
} }
} }
#endif
} }
bool ThreadSelected(const char* aThreadName) { bool ThreadSelected(const char* aThreadName) {