Bug 1606949 - Revert "Bug 1606949 - Add about:replay. "

This reverts commit 5721aff7c1f3ffe5491d277dc01f6eec32771f12.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jason Laster 2020-01-05 05:58:37 +00:00
parent d3eb64cb4d
commit 9b99e1d9c6
7 changed files with 0 additions and 251 deletions

View File

@ -118,8 +118,6 @@ static const RedirEntry kRedirMap[] = {
nsIAboutModule::ALLOW_SCRIPT},
{"telemetry", "chrome://global/content/aboutTelemetry.xhtml",
nsIAboutModule::ALLOW_SCRIPT},
{"replay", "chrome://global/content/aboutReplay.xhtml",
nsIAboutModule::ALLOW_SCRIPT},
{"url-classifier", "chrome://global/content/aboutUrlClassifier.xhtml",
nsIAboutModule::ALLOW_SCRIPT},
{"webrtc", "chrome://global/content/aboutwebrtc/aboutWebrtc.html",

View File

@ -1,26 +0,0 @@
/* 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/. */
.recording {
margin: 15px 0;
padding: 10px;
border-radius: 5px;
}
.recording:hover {
cursor: pointer;
background: #404043;
}
.container.is-recording #start-recording {
display: none;
}
#save-recording {
display: none;
}
.container.is-recording #save-recording {
display: block;
}

View File

@ -1,176 +0,0 @@
/* 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/. */
"use strict";
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
let activeRecording;
let recordings;
function recordNewTab() {
const { gBrowser } = Services.wm.getMostRecentWindow("navigator:browser");
const id = createRecordingId();
const startTime = formatTime();
gBrowser.selectedTab = gBrowser.addWebTab("about:blank", {
recordExecution: "*",
});
activeRecording = { tab: gBrowser.selectedTab, id, start: Date.now() };
recordings[id] = { id, startTime };
const container = document.querySelector(".container");
container.classList.add("is-recording");
Services.telemetry.scalarAdd("devtools.webreplay.new_recording", 1);
}
function openRecording({ id }) {
const { gBrowser } = Services.wm.getMostRecentWindow("navigator:browser");
const dir = replayDir();
dir.append(id);
const path = dir.path;
gBrowser.selectedTab = gBrowser.addWebTab(null, {
replayExecution: path,
});
Services.telemetry.scalarAdd("devtools.webreplay.load_recording", 1);
}
function createRecordingId() {
const d = new Date();
return `${d.getFullYear()}-${d.getMonth() +
1}-${d.getDate()}-${d.getHours()}-${d.getMinutes()}-${d.getSeconds()}.rec`;
}
function formatTime() {
return new Intl.DateTimeFormat("default", {
month: "short",
day: "numeric",
hour: "numeric",
minute: "numeric",
}).format(new Date());
}
function formatDuration(time) {
if (time < 60) {
return time + " seconds";
}
if (time < 60 * 60) {
return time + " minutes";
}
if (time < 60 * 60 * 30) {
return time + " days";
}
return time + " months";
}
function saveRecording() {
if (!activeRecording) {
return;
}
const remoteTab = activeRecording.tab.linkedBrowser.frameLoader.remoteTab;
const url =
activeRecording.tab.linkedBrowser.frameLoader.ownerElement.documentURI
.displaySpec;
const title = activeRecording.tab.label;
const duration = formatDuration(
Math.floor((Date.now() - activeRecording.start) / 1000)
);
const endTime = formatTime();
const path = replayDir();
const id = activeRecording.id;
path.append(id);
const recordingPath = path.path;
const recordingData = {
...recordings[id],
url,
title,
endTime,
duration,
};
console.log(recordingData);
if (!remoteTab || !remoteTab.saveRecording(recordingPath)) {
window.alert("Current tab is not recording");
}
recordings[id] = recordingData;
OS.File.writeAtomic(getRecordingsPath(), JSON.stringify(recordings));
showRecordings();
const container = document.querySelector(".container");
container.classList.remove("is-recording");
}
function replayDir() {
let dir = Services.dirsvc.get("UAppData", Ci.nsIFile);
dir.append("Replay");
if (!dir.exists()) {
OS.File.makeDir(dir.path);
}
return dir;
}
function getRecordingsPath() {
const dir = replayDir();
dir.append("recordings.json");
return dir.path;
}
async function readRecordingsFile() {
if (!(await OS.File.exists(getRecordingsPath()))) {
return {};
}
const file = await OS.File.read(getRecordingsPath());
const string = new TextDecoder("utf-8").decode(file);
return JSON.parse(string);
}
async function showRecordings() {
const container = document.querySelector(".recordings-list");
const template = document.querySelector("#recording-row");
container.innerHTML = "";
for (const id in recordings) {
if (!id) {
continue;
}
const recording = recordings[id];
var newRow = document.importNode(template.content, true);
newRow.querySelector(".recording-title").innerText = recording.title;
newRow.querySelector(".recording-url").innerText = recording.url;
newRow.querySelector(".recording-start").innerText = recording.startTime;
newRow.querySelector(".recording-duration").innerText = recording.duration;
newRow.querySelector(".recording").addEventListener("click", e => {
e.preventDefault();
openRecording(recording);
});
container.appendChild(newRow);
}
}
window.onload = async function() {
document
.querySelector("#start-recording")
.addEventListener("click", () => recordNewTab());
document
.querySelector("#save-recording")
.addEventListener("click", () => saveRecording());
recordings = await readRecordingsFile();
showRecordings();
};

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<!-- 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/. -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Security-Policy" content="default-src chrome:; object-src 'none'" />
<title data-l10n-id="about-replay-title"></title>
<link rel="stylesheet" href="chrome://global/skin/in-content/info-pages.css" type="text/css"/>
<link rel="stylesheet" href="chrome://global/content/aboutReplay.css" type="text/css"/>
<link rel="localization" href="toolkit/about/aboutReplay.ftl"/>
</head>
<body>
<div class="container">
<button id="start-recording">Start Recording</button>
<button id="save-recording">Save Recording</button>
<div class="recordings-list"></div>
</div>
<template id="recording-row">
<div class="recording">
<div class="recording-title"></div>
<div class="recording-url"></div>
<div><span class="recording-start"></span> - <span class="recording-duration"></span></div>
</div>
</template>
<script src="chrome://global/content/aboutReplay.js"></script>
</body>
</html>

View File

@ -23,9 +23,6 @@ toolkit.jar:
content/global/aboutwebrtc/aboutWebrtc.css (aboutwebrtc/aboutWebrtc.css)
content/global/aboutwebrtc/aboutWebrtc.js (aboutwebrtc/aboutWebrtc.js)
content/global/aboutwebrtc/aboutWebrtc.html (aboutwebrtc/aboutWebrtc.html)
content/global/aboutReplay.js
content/global/aboutReplay.xhtml
content/global/aboutReplay.css
content/global/aboutSupport.js
* content/global/aboutSupport.xhtml
content/global/aboutTelemetry.js

View File

@ -233,9 +233,6 @@ with Files('aboutNetworking*'):
with Files('aboutProfile*'):
BUG_COMPONENT = ('Toolkit', 'Startup and Profile System')
with Files('aboutReplay*'):
BUG_COMPONENT = ('Core', 'Web Replay')
with Files('aboutRights*'):
BUG_COMPONENT = ('Toolkit', 'General')

View File

@ -1,5 +0,0 @@
# 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/.
about-replay-title = About Replay