Bug 1580104 - Wait for recording to initialize before loading URLs, r=jlast.

Differential Revision: https://phabricator.services.mozilla.com/D49090

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brian Hackett 2019-10-13 19:10:14 +00:00
parent 8a7bc2ad4e
commit 5be1c5612c
7 changed files with 30 additions and 25 deletions

View File

@ -44,8 +44,11 @@ function ReloadAndRecordTab() {
newFrameloader: true,
remoteType: E10SUtils.DEFAULT_REMOTE_TYPE,
});
gBrowser.loadURI(url, {
triggeringPrincipal: gBrowser.selectedBrowser.contentPrincipal,
Services.ppmm.addMessageListener("RecordingInitialized", function listener() {
Services.ppmm.removeMessageListener("RecordingInitialized", listener);
gBrowser.loadURI(url, {
triggeringPrincipal: gBrowser.selectedBrowser.contentPrincipal,
});
});
Services.telemetry.scalarAdd("devtools.webreplay.reload_recording", 1);
}

View File

@ -6,11 +6,7 @@
// Test basic recording of a tab without any debugging.
add_task(async function() {
const recordingTab = BrowserTestUtils.addTab(gBrowser, null, {
recordExecution: "*",
});
gBrowser.selectedTab = recordingTab;
openTrustedLinkIn(EXAMPLE_URL + "doc_rr_basic.html", "current");
const recordingTab = await openRecordingTab("doc_rr_basic.html");
await once(Services.ppmm, "RecordingFinished");
await gBrowser.removeTab(recordingTab);

View File

@ -7,11 +7,7 @@
// Basic test for saving a recording and then replaying it in a new tab.
add_task(async function() {
const recordingFile = newRecordingFile();
const recordingTab = BrowserTestUtils.addTab(gBrowser, null, {
recordExecution: "*",
});
gBrowser.selectedTab = recordingTab;
openTrustedLinkIn(EXAMPLE_URL + "doc_rr_basic.html", "current");
const recordingTab = await openRecordingTab("doc_rr_basic.html");
await once(Services.ppmm, "RecordingFinished");
const remoteTab = recordingTab.linkedBrowser.frameLoader.remoteTab;

View File

@ -9,11 +9,7 @@ add_task(async function() {
waitForExplicitFinish();
const recordingFile = newRecordingFile();
const recordingTab = BrowserTestUtils.addTab(gBrowser, null, {
recordExecution: "*",
});
gBrowser.selectedTab = recordingTab;
openTrustedLinkIn(EXAMPLE_URL + "doc_rr_continuous.html", "current");
const recordingTab = await openRecordingTab("doc_rr_continuous.html");
let dbg = await attachDebugger(recordingTab);

View File

@ -10,11 +10,7 @@ add_task(async function() {
await pushPref("devtools.recordreplay.enableRewinding", false);
const recordingFile = newRecordingFile();
const recordingTab = BrowserTestUtils.addTab(gBrowser, null, {
recordExecution: "*",
});
gBrowser.selectedTab = recordingTab;
openTrustedLinkIn(EXAMPLE_URL + "doc_rr_basic.html", "current");
const recordingTab = await openRecordingTab("doc_rr_basic.html");
await once(Services.ppmm, "RecordingFinished");
const remoteTab = recordingTab.linkedBrowser.frameLoader.remoteTab;

View File

@ -27,6 +27,14 @@ async function attachDebugger(tab) {
return { ...dbg, tab, threadFront };
}
async function openRecordingTab(url) {
const tab = BrowserTestUtils.addTab(gBrowser, null, { recordExecution: "*" });
gBrowser.selectedTab = tab;
await once(Services.ppmm, "RecordingInitialized");
openTrustedLinkIn(EXAMPLE_URL + url, "current");
return tab;
}
async function attachRecordingDebugger(
url,
{ waitForRecording, disableLogging, skipInterrupt } = {}
@ -35,9 +43,7 @@ async function attachRecordingDebugger(
await pushPref("devtools.recordreplay.logging", true);
}
const tab = BrowserTestUtils.addTab(gBrowser, null, { recordExecution: "*" });
gBrowser.selectedTab = tab;
openTrustedLinkIn(EXAMPLE_URL + url, "current");
const tab = await openRecordingTab(url);
if (waitForRecording) {
await once(Services.ppmm, "RecordingFinished");

View File

@ -80,6 +80,18 @@ dbg.onNewGlobalObject = function(global) {
}
};
// If we are recording, we need to notify the UI process when the content global
// has been initialized in this process, which will allow URLs to be loaded.
Services.obs.addObserver(
{
observe(subject, topic, data) {
assert(topic == "content-document-global-created");
Services.cpmm.sendAsyncMessage("RecordingInitialized");
},
},
"content-document-global-created"
);
///////////////////////////////////////////////////////////////////////////////
// Utilities
///////////////////////////////////////////////////////////////////////////////