Merge branch 'chromium' into merge/chromium

This commit is contained in:
hackademix 2019-03-27 23:43:34 +01:00
commit b9373c65b1
23 changed files with 1288 additions and 41 deletions

View File

@ -51,6 +51,10 @@
}
};
if (!browser.contentScripts) { // #chromium fallback
Scripts.register = () => {};
}
let flatten = arr => arr.reduce((a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []);
let protocolRx = /^(\w+):/i;

View File

@ -20,7 +20,10 @@ var RequestGuard = (() => {
media: "media",
other: "",
};
const allTypes = Object.keys(policyTypesMap);
const allTypes = UA.isMozilla ? Object.keys(policyTypesMap)
: ["main_frame", "sub_frame", "stylesheet", "script", "image", "font",
"object", "xmlhttprequest", "ping", "csp_report", "media", "websocket", "other"];
Object.assign(policyTypesMap, {"webgl": "webgl"}); // fake types
const TabStatus = {
map: new Map(),
@ -254,7 +257,7 @@ var RequestGuard = (() => {
return redirected;
}
const ABORT = {cancel: true}, ALLOW = {};
const INTERNAL_SCHEME = /^(?:chrome|resource|moz-extension|about):/;
const INTERNAL_SCHEME = /^(?:chrome|resource|(?:moz|chrome)-extension|about):/;
const listeners = {
onBeforeRequest(request) {
try {
@ -326,7 +329,7 @@ var RequestGuard = (() => {
capabilities = perms.capabilities;
} else {
capabilities = perms.capabilities;
if (frameAncestors.length > 0 && ns.sync.cascadeRestrictions) {
if (frameAncestors && frameAncestors.length > 0 && ns.sync.cascadeRestrictions) {
// cascade top document's restrictions to subframes
let topUrl = frameAncestors.pop().url;
let topPerms = policy.get(topUrl, topUrl).perms;

View File

@ -31,7 +31,7 @@ function deferWebTraffic(promiseToWaitFor, next) {
if (type === "main_frame") {
seenTabs.add(tabId);
} else if (documentUrl) {
if (frameId !== 0) {
if (frameId !== 0 && request.frameAncestors) {
documentUrl = request.frameAncestors.pop().url;
}
reloadTab(tabId);

View File

@ -31,7 +31,7 @@
headCells[i].addEventListener("click", rowAction(i), true);
}
if (gUI_showHidden) {
gRows = Array.slice(gTBody.rows);
gRows = Array.from(gTBody.rows);
hiddenObjects = gRows.some(row => row.className == "hidden-object");
}
gTable.setAttribute("order", "");
@ -60,7 +60,7 @@
}
function orderBy(column) {
if (!gRows)
gRows = Array.slice(gTBody.rows);
gRows = Array.from(gTBody.rows);
var order;
if (gOrderBy == column) {
order = gTable.getAttribute("order") == "asc" ? "desc" : "asc";

12
src/lib/UA.js Normal file
View File

@ -0,0 +1,12 @@
var UA = {
isMozilla: document.URL.startsWith("moz-"),
}
if (!UA.isMozilla) {
if (typeof chrome === "object" && !chrome.tabs && typeof exportFunction === "undefined") {
// content script shims
window.exportFunction = () => {};
}
} else {
document.documentElement.classList.add("mozwebext");
}

1186
src/lib/browser-polyfill.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -7,12 +7,12 @@ if (typeof flextabs === "function") {
let rx = new RegExp(`(?:^|[#;])tab-${id}=(\\d+)(?:;|$)`);
let current = location.hash.match(rx);
console.log(`persisted %o`, current);
let toggles = tabs.querySelectorAll(".flextabs__toggle");
let toggles = Array.from(tabs.querySelectorAll(".flextabs__toggle"));
let currentToggle = toggles[current && parseInt(current[1]) || 0];
if (currentToggle) currentToggle.click();
for (let toggle of toggles) {
toggle.addEventListener("click", e => {
let currentIdx = Array.indexOf(toggles, toggle);
let currentIdx = toggles.indexOf(toggle);
location.hash = location.hash.split(";").filter(p => !rx.test(p))
.concat(`tab-${id}=${currentIdx}`).join(";");
});

View File

@ -1,22 +1,22 @@
{
// see https://bugzilla.mozilla.org/show_bug.cgi?id=1415644
let domains = [
"accounts-static.cdn.mozilla.net",
"accounts.firefox.com",
"addons.cdn.mozilla.net",
"addons.mozilla.org",
"api.accounts.firefox.com",
"content.cdn.mozilla.net",
"content.cdn.mozilla.net",
"discovery.addons.mozilla.org",
"input.mozilla.org",
"install.mozilla.org",
"oauth.accounts.firefox.com",
"profile.accounts.firefox.com",
"support.mozilla.org",
"sync.services.mozilla.com",
"testpilot.firefox.com",
];
let domains = UA.isMozilla ? [
"accounts-static.cdn.mozilla.net",
"accounts.firefox.com",
"addons.cdn.mozilla.net",
"addons.mozilla.org",
"api.accounts.firefox.com",
"content.cdn.mozilla.net",
"content.cdn.mozilla.net",
"discovery.addons.mozilla.org",
"input.mozilla.org",
"install.mozilla.org",
"oauth.accounts.firefox.com",
"profile.accounts.firefox.com",
"support.mozilla.org",
"sync.services.mozilla.com",
"testpilot.firefox.com",
] : [ "chrome.google.com" ];
function isRestrictedURL(u) {
try {

View File

@ -8,7 +8,7 @@
"strict_min_version": "59.0"
}
},
"version": "10.2.5",
"version": "10.5rc1",
"description": "__MSG_Description__",
"incognito": "spanning",
@ -35,6 +35,8 @@
"background": {
"persistent": true,
"scripts": [
"lib/UA.js",
"lib/browser-polyfill.js",
"lib/uuid.js",
"lib/log.js",
"lib/include.js",
@ -77,6 +79,8 @@
"match_about_blank": true,
"all_frames": true,
"js": [
"lib/UA.js",
"lib/browser-polyfill.js",
"lib/log.js",
"lib/uuid.js",
"lib/sha256.js",
@ -117,11 +121,13 @@
"commands": {
"_execute_browser_action": {
"description": "NoScript UI",
"suggested_key": {
"default": "Alt+Shift+N"
}
},
"togglePermissions": {
"description": "Toggle permissions",
"suggested_key": {
"default": "Ctrl+Shift+T"
}

View File

@ -26,7 +26,7 @@ var Test = (() => {
error(e);
}
this[r ? "passed" : "failed"]++;
log(`${r ? "PASSED" : "FAILED"} ${msg || uneval(test)}`);
log(`${r ? "PASSED" : "FAILED"} ${msg || test}`);
if (typeof callback === "function") try {
callback(r, test, msg);
} catch(e) {

View File

@ -7,14 +7,16 @@ var Prompts = (() => {
async open(data) {
promptData = data;
this.close();
this.currentWindow = await browser.windows.create({
let options = {
url: browser.extension.getURL("ui/prompt.html"),
type: "panel",
allowScriptsToClose: true,
// titlePreface: "NoScript ",
width: data.features.width,
height: data.features.height,
});
};
if (UA.isMozilla) {
options.allowScriptsToClose = true;
}
this.currentWindow = await browser.windows.create(options);
}
async close() {
if (this.currentWindow) {

View File

@ -195,3 +195,11 @@ input[type="file"] {
border-radius: .2em .2em 0 0;
padding: .2em .4em;
}
#xss-options {
display: none;
}
.mozwebext #xss-options {
display: block;
}

View File

@ -8,6 +8,8 @@
<link rel="stylesheet" href="/lib/flextabs.css" />
<link rel="stylesheet" href="options.css" />
<link rel="stylesheet" href="whirlpool.css" />
<script src="/lib/UA.js"></script>
<script src="/lib/browser-polyfill.js"></script>
<script src="/lib/include.js"></script>
<script src="/lib/log.js"></script>
<script src="/lib/flextabs.js"></script>

View File

@ -103,7 +103,7 @@
}
let button = document.querySelector("#btn-delete-xss-choices");
let choices = UI.xssUserChoices;
button.disabled = Object.keys(choices).length === 0;
button.disabled = !choices || Object.keys(choices).length === 0;
button.onclick = () => {
UI.updateSettings({
xssUserChoices: {}

View File

@ -16,6 +16,7 @@ body {
#top a {
appearance: none !important;
webkit-appearance: none !important;
-moz-appearance: none !important;
width: 2em;
height: 2em;
@ -119,8 +120,9 @@ body {
}
.hider-close {
-moz-appearance: none;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
color: black;
background: transparent;
padding: 0;

View File

@ -6,6 +6,8 @@
<title>NoScript Settings</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="popup.css" />
<script src="/lib/UA.js"></script>
<script src="/lib/browser-polyfill.js"></script>
<script src="/lib/include.js"></script>
<script src="/lib/log.js"></script>
<script src="/common/locale.js"></script>

View File

@ -5,6 +5,8 @@
<title></title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="prompt.css" />
<script src="/lib/UA.js"></script>
<script src="/lib/browser-polyfill.js"></script>
<script src="/lib/include.js"></script>
<script src="/lib/log.js"></script>
<script src="/common/locale.js"></script>

View File

@ -1,5 +1,7 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/lib/UA.js"></script>
<script src="/lib/browser-polyfill.js"></script>
<script src="/lib/log.js"></script>
<script src="/lib/include.js"></script>
<script src="siteInfo.js"></script>

View File

@ -87,7 +87,7 @@
}
UI.local.toolbarLayout = {
left, right,
hidden: Array.map(document.querySelectorAll("#top > .hider > .icon"), el => el.id),
hidden: Array.from(document.querySelectorAll("#top > .hider > .icon")).map(el => el.id),
};
debug("%o", UI.local);

View File

@ -5,10 +5,14 @@ input {
}
input[type="radio"] {
appearance: radio !important;
-webkit-appearance: radio !important;
-moz-appearance: radio !important;
padding-right: .2em !important;
}
input[type="checkbox"] {
appearance: checkbox !important;
-webkit-appearance: checkbox !important;
-moz-appearance: checkbox !important;
}

View File

@ -3,6 +3,7 @@ body {
font-family: sans-serif;
font: -moz-use-system-font;
font-size: 12px;
min-width: 600px;
}
.mobile > body {
@ -139,6 +140,8 @@ input[type="checkbox"] {
input.https-only {
font-size: 1em;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
background: url(/img/ui-http64.png) no-repeat center;
background-size: 1.5em;
@ -186,6 +189,8 @@ span.preset {
.presets input.preset {
font-size: 1em;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
background: url(/img/ui-no64.png) no-repeat center left;
background-size: 1.5em;
@ -264,6 +269,8 @@ input.preset:active, input.preset:focus, input.preset:hover {
}
button.options {
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
border: none;
background: none transparent;
@ -276,6 +283,8 @@ button.options {
}
.preset .options {
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
border: 0;
@ -315,6 +324,8 @@ input.preset[value="CUSTOM"] {
input.temp {
font-size: 1em;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
margin: 0;
padding: 0;

View File

@ -107,11 +107,10 @@ XSS.InjectionChecker = (async () => {
var bs = {
nq: new RegExp("[" + def + "]")
};
Array.forEach("'\"`", // special treatment for quotes
function(c) {
bs[c] = new RegExp("[" + def + c + "]");
}
);
for (let c of ['"', '"', '`']) {
// special treatment for quotes
bs[c] = new RegExp("[" + def + c + "]");
}
delete this.breakStops;
return (this.breakStops = bs);
},

View File

@ -113,6 +113,8 @@ var XSS = (() => {
return {
async start() {
if (!UA.isMozilla) return; // async webRequest is supported on Mozilla only
let {onBeforeRequest} = browser.webRequest;
let {xssScanRequestBody} = ns.sync;
if (xssScanRequestBody !== this.xssScanRequestBody) {