From e7a3fe847ed35906eed32f17cd37df45bd90cf66 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 3 Jul 2019 10:23:29 +0000 Subject: [PATCH 01/81] Bug 1552168 - Remove Pref data_uri.unique_opaque_origin r=ckerschb Differential Revision: https://phabricator.services.mozilla.com/D35005 --HG-- extra : moz-landing-system : lando --- docshell/base/nsDocShell.cpp | 4 +--- dom/base/nsObjectLoadingContent.cpp | 5 ++-- dom/clients/manager/ClientManager.cpp | 3 --- dom/clients/manager/ClientPrefs.cpp | 30 ------------------------ dom/clients/manager/ClientPrefs.h | 19 --------------- dom/clients/manager/ClientValidation.cpp | 13 +--------- dom/clients/manager/moz.build | 1 - dom/workers/ScriptLoader.cpp | 4 +--- modules/libpref/init/all.js | 6 ----- netwerk/base/nsIOService.cpp | 8 ------- netwerk/base/nsIOService.h | 2 -- 11 files changed, 5 insertions(+), 90 deletions(-) delete mode 100644 dom/clients/manager/ClientPrefs.cpp delete mode 100644 dom/clients/manager/ClientPrefs.h diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index c60f048ad8b9..cb2f7b6fc55c 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -9989,9 +9989,7 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState, true, // aInheritForAboutBlank isSrcdoc); - bool isURIUniqueOrigin = nsIOService::IsDataURIUniqueOpaqueOrigin() && - SchemeIsData(aLoadState->URI()); - inheritPrincipal = inheritAttrs && !isURIUniqueOrigin; + inheritPrincipal = inheritAttrs && !SchemeIsData(aLoadState->URI()); } nsLoadFlags loadFlags = mDefaultLoadFlags; diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index 54cdf9a089fb..d245d826e520 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -2291,9 +2291,8 @@ nsresult nsObjectLoadingContent::OpenChannel() { nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL; bool isData; - bool isURIUniqueOrigin = nsIOService::IsDataURIUniqueOpaqueOrigin() && - NS_SUCCEEDED(mURI->SchemeIs("data", &isData)) && - isData; + bool isURIUniqueOrigin = + NS_SUCCEEDED(mURI->SchemeIs("data", &isData)) && isData; if (inherit && !isURIUniqueOrigin) { securityFlags |= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL; diff --git a/dom/clients/manager/ClientManager.cpp b/dom/clients/manager/ClientManager.cpp index c62ca4f0474e..0a4ab24a1107 100644 --- a/dom/clients/manager/ClientManager.cpp +++ b/dom/clients/manager/ClientManager.cpp @@ -9,7 +9,6 @@ #include "ClientHandle.h" #include "ClientManagerChild.h" #include "ClientManagerOpChild.h" -#include "ClientPrefs.h" #include "ClientSource.h" #include "mozilla/dom/WorkerHolderToken.h" #include "mozilla/dom/WorkerPrivate.h" @@ -241,8 +240,6 @@ void ClientManager::Startup() { #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED sClientManagerThreadLocalIndexDuplicate = sClientManagerThreadLocalIndex; #endif - - ClientPrefsInit(); } // static diff --git a/dom/clients/manager/ClientPrefs.cpp b/dom/clients/manager/ClientPrefs.cpp deleted file mode 100644 index 576eb9c83b69..000000000000 --- a/dom/clients/manager/ClientPrefs.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=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 "ClientPrefs.h" - -#include "mozilla/Preferences.h" - -namespace mozilla { -namespace dom { - -namespace { - -bool gDataURLUniqueOpaqueOrigin = false; - -} // anonymous namespace - -void ClientPrefsInit() { - Preferences::AddBoolVarCache(&gDataURLUniqueOpaqueOrigin, - "security.data_uri.unique_opaque_origin", false); -} - -bool ClientPrefsGetDataURLUniqueOpaqueOrigin() { - return gDataURLUniqueOpaqueOrigin; -} - -} // namespace dom -} // namespace mozilla diff --git a/dom/clients/manager/ClientPrefs.h b/dom/clients/manager/ClientPrefs.h deleted file mode 100644 index 594eda9af61e..000000000000 --- a/dom/clients/manager/ClientPrefs.h +++ /dev/null @@ -1,19 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=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/. */ -#ifndef _mozilla_dom_ClientPrefs_h -#define _mozilla_dom_ClientPrefs_h - -namespace mozilla { -namespace dom { - -void ClientPrefsInit(); - -bool ClientPrefsGetAllowUniqueOpaqueOrigin(); - -} // namespace dom -} // namespace mozilla - -#endif // _mozilla_dom_ClientPrefs_h diff --git a/dom/clients/manager/ClientValidation.cpp b/dom/clients/manager/ClientValidation.cpp index 1dcea78f08f4..cc5d92685fc5 100644 --- a/dom/clients/manager/ClientValidation.cpp +++ b/dom/clients/manager/ClientValidation.cpp @@ -6,7 +6,6 @@ #include "ClientValidation.h" -#include "ClientPrefs.h" #include "mozilla/net/MozURL.h" namespace mozilla { @@ -109,13 +108,6 @@ bool ClientIsValidCreationURL(const PrincipalInfo& aPrincipalInfo, return true; } - // We have some tests that use data: URL windows without an opaque - // origin. This should only happen when a pref is set. - if (!ClientPrefsGetDataURLUniqueOpaqueOrigin() && - scheme.LowerCaseEqualsLiteral("data")) { - return true; - } - // Otherwise don't support this URL type in the clients sub-system for // now. This will exclude a variety of internal browser clients, but // currently we don't need to support those. This function can be @@ -133,10 +125,7 @@ bool ClientIsValidCreationURL(const PrincipalInfo& aPrincipalInfo, scheme.LowerCaseEqualsLiteral("resource") || scheme.LowerCaseEqualsLiteral("blob") || scheme.LowerCaseEqualsLiteral("javascript") || - scheme.LowerCaseEqualsLiteral("view-source") || - - (!ClientPrefsGetDataURLUniqueOpaqueOrigin() && - scheme.LowerCaseEqualsLiteral("data")); + scheme.LowerCaseEqualsLiteral("view-source"); } case PrincipalInfo::TNullPrincipalInfo: { // A wide variety of clients can have a null principal. For example, diff --git a/dom/clients/manager/moz.build b/dom/clients/manager/moz.build index 5005b3a91580..04dca5001676 100644 --- a/dom/clients/manager/moz.build +++ b/dom/clients/manager/moz.build @@ -40,7 +40,6 @@ UNIFIED_SOURCES += [ 'ClientOpenWindowOpChild.cpp', 'ClientOpenWindowOpParent.cpp', 'ClientOpenWindowUtils.cpp', - 'ClientPrefs.cpp', 'ClientPrincipalUtils.cpp', 'ClientSource.cpp', 'ClientSourceChild.cpp', diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp index 4b1b2621dfb3..86927a10a0ff 100644 --- a/dom/workers/ScriptLoader.cpp +++ b/dom/workers/ScriptLoader.cpp @@ -161,9 +161,7 @@ nsresult ChannelFromScriptURL( rv = uri->SchemeIs("data", &isData); NS_ENSURE_SUCCESS(rv, rv); - bool isURIUniqueOrigin = - net::nsIOService::IsDataURIUniqueOpaqueOrigin() && isData; - if (inheritAttrs && !isURIUniqueOrigin) { + if (inheritAttrs && !isData) { secFlags |= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL; } diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 96855602dc66..eb248f29c827 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -5505,12 +5505,6 @@ pref("osfile.reset_worker_delay", 30000); pref("media.block-autoplay-until-in-foreground", true); -// TODO: Bug 1324406: Treat 'data:' documents as unique, opaque origins -// If true, data: URIs will be treated as unique opaque origins, hence will use -// a NullPrincipal as the security context. -// Otherwise it will inherit the origin from parent node, this is the legacy -// behavior of Firefox. -pref("security.data_uri.unique_opaque_origin", true); // If true, all toplevel data: URI navigations will be blocked. // Please note that manually entering a data: URI in the diff --git a/netwerk/base/nsIOService.cpp b/netwerk/base/nsIOService.cpp index e5e8719ae124..43bf9223a521 100644 --- a/netwerk/base/nsIOService.cpp +++ b/netwerk/base/nsIOService.cpp @@ -183,7 +183,6 @@ static const char kProfileDoChange[] = "profile-do-change"; uint32_t nsIOService::gDefaultSegmentSize = 4096; uint32_t nsIOService::gDefaultSegmentCount = 24; -bool nsIOService::sIsDataURIUniqueOpaqueOrigin = false; bool nsIOService::sBlockToplevelDataUriNavigations = false; bool nsIOService::sBlockFTPSubresources = false; @@ -260,8 +259,6 @@ nsresult nsIOService::Init() { } else NS_WARNING("failed to get observer service"); - Preferences::AddBoolVarCache(&sIsDataURIUniqueOpaqueOrigin, - "security.data_uri.unique_opaque_origin", false); Preferences::AddBoolVarCache( &sBlockToplevelDataUriNavigations, "security.data_uri.block_toplevel_data_uri_navigations", false); @@ -1803,11 +1800,6 @@ nsIOService::SpeculativeAnonymousConnect(nsIURI* aURI, nsIPrincipal* aPrincipal, return SpeculativeConnectInternal(aURI, aPrincipal, aCallbacks, true); } -/*static*/ -bool nsIOService::IsDataURIUniqueOpaqueOrigin() { - return sIsDataURIUniqueOpaqueOrigin; -} - /*static*/ bool nsIOService::BlockToplevelDataUriNavigations() { return sBlockToplevelDataUriNavigations; diff --git a/netwerk/base/nsIOService.h b/netwerk/base/nsIOService.h index 9f2d1a06db13..5aadfe7776f1 100644 --- a/netwerk/base/nsIOService.h +++ b/netwerk/base/nsIOService.h @@ -99,7 +99,6 @@ class nsIOService final : public nsIIOService, bool IsLinkUp(); - static bool IsDataURIUniqueOpaqueOrigin(); static bool BlockToplevelDataUriNavigations(); static bool BlockFTPSubresources(); @@ -220,7 +219,6 @@ class nsIOService final : public nsIIOService, bool mNetworkNotifyChanged; - static bool sIsDataURIUniqueOpaqueOrigin; static bool sBlockToplevelDataUriNavigations; static bool sBlockFTPSubresources; From ce99ef5438f995b40d9eebb0a695189ff4a46015 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 3 Jul 2019 10:23:46 +0000 Subject: [PATCH 02/81] Bug 1552168 - Fix Tests that rely on data_uri.unique_opaque_origin r=ckerschb Differential Revision: https://phabricator.services.mozilla.com/D35006 --HG-- extra : moz-landing-system : lando --- .../browser_viewport_resizing_scrollbar.js | 2 +- .../webconsole/test/test_commands_other.html | 9 ++--- .../test/test_jsterm_queryselector.html | 9 ++--- docshell/base/crashtests/914521.html | 2 -- .../browser_dataURI_unique_opaque_origin.js | 8 ----- .../browser/browser_loadDisallowInherit.js | 5 +-- docshell/test/chrome/test_bug565388.xul | 5 +-- .../test/chrome/test_principalInherit.xul | 33 ++----------------- dom/base/test/test_data_uri.html | 2 -- dom/base/test/test_x-frame-options.html | 2 +- dom/html/test/test_fullscreen-api-race.html | 1 - .../test/mochitest/browser_data_url_plugin.js | 3 -- dom/security/test/csp/test_meta_csp_self.html | 9 ++--- .../bugs/test_resize_move_windows.html | 1 - .../chrome/test_resize_move_windows.xul | 4 +-- .../whatwg/test_postMessage_special.xhtml | 2 +- netwerk/test/crashtests/675518.html | 2 -- .../meta/webmessaging/with-ports/016.html.ini | 2 -- .../webmessaging/without-ports/016.html.ini | 2 -- .../content/tests/widgets/test_menubar.xul | 3 +- widget/tests/test_mouse_scroll.xul | 3 +- 21 files changed, 18 insertions(+), 91 deletions(-) delete mode 100644 testing/web-platform/meta/webmessaging/with-ports/016.html.ini delete mode 100644 testing/web-platform/meta/webmessaging/without-ports/016.html.ini diff --git a/devtools/client/responsive.html/test/browser/browser_viewport_resizing_scrollbar.js b/devtools/client/responsive.html/test/browser/browser_viewport_resizing_scrollbar.js index 3ef99861da10..bfcf31bc50eb 100644 --- a/devtools/client/responsive.html/test/browser/browser_viewport_resizing_scrollbar.js +++ b/devtools/client/responsive.html/test/browser/browser_viewport_resizing_scrollbar.js @@ -52,7 +52,7 @@ addRDMTask(TEST_URL, async function({ ui, manager }) { await SpecialPowers.pushPrefEnv({ set: [["devtools.responsive.metaViewport.enabled", true], ["layout.testing.overlay-scrollbars.always-visible", true], - ["security.data_uri.unique_opaque_origin", false]], + ], }); const store = ui.toolWindow.store; diff --git a/devtools/shared/webconsole/test/test_commands_other.html b/devtools/shared/webconsole/test/test_commands_other.html index 768ad73f5a2a..0a94e52c0d2f 100644 --- a/devtools/shared/webconsole/test/test_commands_other.html +++ b/devtools/shared/webconsole/test/test_commands_other.html @@ -75,14 +75,8 @@ function testEnd() { let load = async function () { removeEventListener("load", load); - await new Promise(resolve => { - SpecialPowers.pushPrefEnv({"set": [ - ["security.data_uri.unique_opaque_origin", false], - ]}, resolve); - }); - // Open a content window to test XRay functionality on built in functions. - gWin = window.open("data:text/html,"); + gWin = window.open("javascript:1"); info ("Waiting for content window to load"); gWin.onload = startTest; }; @@ -91,3 +85,4 @@ addEventListener("load", load); + \ No newline at end of file diff --git a/devtools/shared/webconsole/test/test_jsterm_queryselector.html b/devtools/shared/webconsole/test/test_jsterm_queryselector.html index 3a41dc19e9d1..9c93da37ebc0 100644 --- a/devtools/shared/webconsole/test/test_jsterm_queryselector.html +++ b/devtools/shared/webconsole/test/test_jsterm_queryselector.html @@ -148,14 +148,8 @@ function testEnd() { let load = async function () { removeEventListener("load", load); - await new Promise(resolve => { - SpecialPowers.pushPrefEnv({"set": [ - ["security.data_uri.unique_opaque_origin", false], - ]}, resolve); - }); - // Open a content window to test XRay functionality on built in functions. - gWin = window.open("data:text/html,"); + gWin = window.open("javascript:1"); info ("Waiting for content window to load"); gWin.onload = startTest; }; @@ -164,3 +158,4 @@ addEventListener("load", load); + diff --git a/docshell/base/crashtests/914521.html b/docshell/base/crashtests/914521.html index ca3e9b63fdf8..a65e6819d97d 100644 --- a/docshell/base/crashtests/914521.html +++ b/docshell/base/crashtests/914521.html @@ -23,7 +23,6 @@ function f() function init() { SpecialPowers.pushPrefEnv({"set": [ - ["security.data_uri.unique_opaque_origin", false], ["security.data_uri.block_toplevel_data_uri_navigations", false], ]}, start); } @@ -33,7 +32,6 @@ function start() var html = " diff --git a/docshell/test/chrome/test_principalInherit.xul b/docshell/test/chrome/test_principalInherit.xul index 47957b76a3cc..ffa82791782c 100644 --- a/docshell/test/chrome/test_principalInherit.xul +++ b/docshell/test/chrome/test_principalInherit.xul @@ -37,15 +37,11 @@ var gFrame; // fail to load when there's no principal to load them against. This only // matters when these tests fail (produces better error messages). var tests = [ - function testInheritFromParent(cb) { + function testInitiation(cb) { gFrame = document.createXULElement("iframe"); - loadListener(gFrame, function () { - is(window.inheritedFromParent, true, "load in type=content iframe inherited principal of same type parent"); - cb(); - }); gFrame.setAttribute("type", "content"); - gFrame.setAttribute("src", "data:text/html,"); document.documentElement.appendChild(gFrame); + cb(); }, function testInheritFromCurrent_system(cb) { loadListener(gFrame, function () { @@ -53,35 +49,12 @@ var tests = [ cb(); }, true); gFrame.setAttribute("src", "data:text/html,"); - }, - function testInheritFromCreated(cb) { - // Open a new chrome window with a type="content" iframe, so that it has no - // same-type parent. - // Load a javascript: URI in it to ensure that GetInheritedPrincipal will - // force creation of a content viewer. - let xulWinURL = 'data:application/vnd.mozilla.xul+xml,' + - ''; - let newWin = window.openDialog(xulWinURL, "chrome_window", "chrome"); - loadListener(newWin, function () { - let frame = newWin.document.createXULElement("iframe"); - frame.setAttribute("type", "content"); - frame.setAttribute("src", "javascript:'1';"); - loadListener(frame, function () { - is(frame.contentWindow.document.body.textContent, "1", "content viewer was created"); - SimpleTest.executeSoon(function () { - newWin.close(); - cb(); - }) - }); - newWin.document.documentElement.appendChild(frame); - }); } ]; addLoadEvent(function onLoad() { ok(Components.stack, "this test must be run with the system principal"); - SpecialPowers.pushPrefEnv({"set": [ - ["security.data_uri.unique_opaque_origin", false]]}, nextTest); + nextTest(); }); function loadListener(target, func) { diff --git a/dom/base/test/test_data_uri.html b/dom/base/test/test_data_uri.html index c42c9e70e094..aa1c0fdbda77 100644 --- a/dom/base/test/test_data_uri.html +++ b/dom/base/test/test_data_uri.html @@ -14,10 +14,8 @@ diff --git a/dom/tests/mochitest/bugs/test_resize_move_windows.html b/dom/tests/mochitest/bugs/test_resize_move_windows.html index 10f383e41f15..59352a08eac6 100644 --- a/dom/tests/mochitest/bugs/test_resize_move_windows.html +++ b/dom/tests/mochitest/bugs/test_resize_move_windows.html @@ -314,7 +314,6 @@ function checkChangeIsEnabled(aWindow, aNext) SpecialPowers.pushPrefEnv({ "set": [["dom.disable_window_move_resize", false], - ["security.data_uri.unique_opaque_origin", false], ["security.data_uri.block_toplevel_data_uri_navigations", false],]}, function() { SimpleTest.waitForFocus(function() { diff --git a/dom/tests/mochitest/chrome/test_resize_move_windows.xul b/dom/tests/mochitest/chrome/test_resize_move_windows.xul index 099fb9cac29f..f2b7e5fcc4eb 100644 --- a/dom/tests/mochitest/chrome/test_resize_move_windows.xul +++ b/dom/tests/mochitest/chrome/test_resize_move_windows.xul @@ -282,9 +282,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=565541 } addLoadEvent(function onLoad() { - SpecialPowers.pushPrefEnv({"set": [ - ["security.data_uri.unique_opaque_origin", false]]}, test); - }); + test(); ]]> diff --git a/dom/tests/mochitest/whatwg/test_postMessage_special.xhtml b/dom/tests/mochitest/whatwg/test_postMessage_special.xhtml index b98133c8bef0..af468085af60 100644 --- a/dom/tests/mochitest/whatwg/test_postMessage_special.xhtml +++ b/dom/tests/mochitest/whatwg/test_postMessage_special.xhtml @@ -19,7 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage SimpleTest.waitForExplicitFinish(); -var isDataUnique = SpecialPowers.Services.prefs.getBoolPref("security.data_uri.unique_opaque_origin"); +var isDataUnique = true; var B64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /** diff --git a/netwerk/test/crashtests/675518.html b/netwerk/test/crashtests/675518.html index 191c0b618f8e..5a181f5c2795 100644 --- a/netwerk/test/crashtests/675518.html +++ b/netwerk/test/crashtests/675518.html @@ -3,7 +3,6 @@ function init() { SpecialPowers.pushPrefEnv({"set": [ - ["security.data_uri.unique_opaque_origin", false], ["security.data_uri.block_toplevel_data_uri_navigations", false], ]}, boom); } @@ -23,7 +22,6 @@ function boom() frameWin.document.write("2..."); - SpecialPowers.clearUserPref("security.data_uri.unique_opaque_origin"); } diff --git a/testing/web-platform/meta/webmessaging/with-ports/016.html.ini b/testing/web-platform/meta/webmessaging/with-ports/016.html.ini deleted file mode 100644 index 5a178fac05f0..000000000000 --- a/testing/web-platform/meta/webmessaging/with-ports/016.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[016.html] - prefs: [security.data_uri.unique_opaque_origin:true] diff --git a/testing/web-platform/meta/webmessaging/without-ports/016.html.ini b/testing/web-platform/meta/webmessaging/without-ports/016.html.ini deleted file mode 100644 index 5a178fac05f0..000000000000 --- a/testing/web-platform/meta/webmessaging/without-ports/016.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[016.html] - prefs: [security.data_uri.unique_opaque_origin:true] diff --git a/toolkit/content/tests/widgets/test_menubar.xul b/toolkit/content/tests/widgets/test_menubar.xul index 81353467f560..aa0a3f1ffcd0 100644 --- a/toolkit/content/tests/widgets/test_menubar.xul +++ b/toolkit/content/tests/widgets/test_menubar.xul @@ -14,8 +14,7 @@ SimpleTest.waitForExplicitFinish(); function onLoad() { - SpecialPowers.pushPrefEnv({"set": [ - ["security.data_uri.unique_opaque_origin", false]]}, runTest); + runTest(); } function runTest() diff --git a/widget/tests/test_mouse_scroll.xul b/widget/tests/test_mouse_scroll.xul index 427274dd91b2..56c1862b4509 100644 --- a/widget/tests/test_mouse_scroll.xul +++ b/widget/tests/test_mouse_scroll.xul @@ -22,8 +22,7 @@ SimpleTest.waitForExplicitFinish(); function onLoad() { - SpecialPowers.pushPrefEnv({"set": [ - ["security.data_uri.unique_opaque_origin", false]]}, runTest); + runTest(); } function runTest() From 6c503184a9e489e47c8a5dc7c0e1d402b89607e3 Mon Sep 17 00:00:00 2001 From: Nihanth Subramanya Date: Wed, 3 Jul 2019 11:28:14 +0000 Subject: [PATCH 03/81] Bug 1555236 - Implement "Site Not Working?" sub-panel. r=johannh Differential Revision: https://phabricator.services.mozilla.com/D34516 --HG-- extra : moz-landing-system : lando --- .../base/content/browser-siteProtections.js | 28 +++++++--- .../content/protectionsPanel.inc.xul | 54 ++++++++++++++++--- .../themes/shared/controlcenter/panel.inc.css | 39 +++++++++----- 3 files changed, 95 insertions(+), 26 deletions(-) diff --git a/browser/base/content/browser-siteProtections.js b/browser/base/content/browser-siteProtections.js index d56fcdb1533b..4e97c88d92bb 100644 --- a/browser/base/content/browser-siteProtections.js +++ b/browser/base/content/browser-siteProtections.js @@ -17,6 +17,11 @@ var gProtectionsHandler = { delete this._protectionsIconBox; return this._protectionsIconBox = document.getElementById("tracking-protection-icon-animatable-box"); }, + get _protectionsPopupMultiView() { + delete this._protectionsPopupMultiView; + return this._protectionsPopupMultiView = + document.getElementById("protections-popup-multiView"); + }, get _protectionsPopupMainView() { delete this._protectionsPopupMainView; return this._protectionsPopupMainView = @@ -52,6 +57,11 @@ var gProtectionsHandler = { return this._protectionPopupTrackersCounterDescription = document.getElementById("protections-popup-trackers-blocked-counter-description"); }, + get _protectionsPopupSiteNotWorkingTPSwitch() { + delete this._protectionsPopupSiteNotWorkingTPSwitch; + return this._protectionsPopupSiteNotWorkingTPSwitch = + document.getElementById("protections-popup-siteNotWorking-tp-switch"); + }, get _protectionsPopupToastTimeout() { delete this._protectionsPopupToastTimeout; XPCOMUtils.defineLazyPreferenceGetter(this, "_protectionsPopupToastTimeout", @@ -128,10 +138,6 @@ var gProtectionsHandler = { }, refreshProtectionsPopup() { - // Refresh the state of the TP toggle switch. - this._protectionsPopupTPSwitch.toggleAttribute("enabled", - !this._protectionsPopup.hasAttribute("hasException")); - let host = gIdentityHandler.getHostForDisplay(); // Push the appropriate strings out to the UI. @@ -142,7 +148,10 @@ var gProtectionsHandler = { let currentlyEnabled = !this._protectionsPopup.hasAttribute("hasException"); - this._protectionsPopupTPSwitch.toggleAttribute("enabled", currentlyEnabled); + for (let tpSwitch of [this._protectionsPopupTPSwitch, + this._protectionsPopupSiteNotWorkingTPSwitch]) { + tpSwitch.toggleAttribute("enabled", currentlyEnabled); + } // Display the breakage link according to the current enable state. // The display state of the breakage link will be fixed once the protections @@ -171,7 +180,10 @@ var gProtectionsHandler = { // styling after toggling the TP switch. let newExceptionState = this._protectionsPopup.toggleAttribute("hasException"); - this._protectionsPopupTPSwitch.toggleAttribute("enabled", !newExceptionState); + for (let tpSwitch of [this._protectionsPopupTPSwitch, + this._protectionsPopupSiteNotWorkingTPSwitch]) { + tpSwitch.toggleAttribute("enabled", !newExceptionState); + } // Indicating that we need to show a toast after refreshing the page. // And caching the current URI and window ID in order to only show the mini @@ -248,4 +260,8 @@ var gProtectionsHandler = { triggerEvent: event, }).catch(Cu.reportError); }, + + showSiteNotWorkingView() { + this._protectionsPopupMultiView.showSubView("protections-popup-siteNotWorkingView"); + }, }; diff --git a/browser/components/controlcenter/content/protectionsPanel.inc.xul b/browser/components/controlcenter/content/protectionsPanel.inc.xul index 42c5ad597ea1..e387f1f4d9a8 100644 --- a/browser/components/controlcenter/content/protectionsPanel.inc.xul +++ b/browser/components/controlcenter/content/protectionsPanel.inc.xul @@ -25,19 +25,21 @@ - - - + + class="protections-popup-tp-switch" + enabled="false" + oncommand="gProtectionsHandler.onTPSwitchCommand();" /> @@ -59,5 +61,45 @@ href="about:protections">Show Full Report + + + + + + + + + + + + + + + + + + + + + diff --git a/browser/themes/shared/controlcenter/panel.inc.css b/browser/themes/shared/controlcenter/panel.inc.css index 9fdfc4eb4e7b..f1e1bcb60399 100644 --- a/browser/themes/shared/controlcenter/panel.inc.css +++ b/browser/themes/shared/controlcenter/panel.inc.css @@ -210,7 +210,8 @@ } #identity-popup-mainView-panel-header, -#protections-popup-mainView-panel-header { +#protections-popup-mainView-panel-header, +#protections-popup-siteNotWorkingView-footer { padding: 4px 1em; min-height: 40px; -moz-box-pack: center; @@ -811,8 +812,8 @@ description#identity-popup-content-verifier, display: none; } -#protections-popup:not([hasException]) #protections-popup-tp-switch-on-header, -#protections-popup[hasException] #protections-popup-tp-switch-off-header, +#protections-popup:not([hasException]) .protections-popup-tp-switch-on-header, +#protections-popup[hasException] .protections-popup-tp-switch-off-header, #protections-popup:not([hasException])[toast] #protections-popup-toast-panel-tp-on-desc, #protections-popup[hasException][toast] #protections-popup-toast-panel-tp-off-desc { display: unset; @@ -832,8 +833,9 @@ description#identity-popup-content-verifier, ); } -#protections-popup-tp-switch-label-box, -#protections-popup-tp-switch-box { +#protections-popup-siteNotWorkingView-body, +.protections-popup-tp-switch-label-box, +.protections-popup-tp-switch-box { padding: 4px 1em; min-height: 40px; -moz-box-pack: center; @@ -842,12 +844,12 @@ description#identity-popup-content-verifier, position: relative; } -#protections-popup-tp-switch-on-header, -#protections-popup-tp-switch-off-header { +.protections-popup-tp-switch-on-header, +.protections-popup-tp-switch-off-header { font-weight: 600; } -#protections-popup-tp-switch { +.protections-popup-tp-switch { -moz-appearance: none; box-sizing: border-box; min-width: 26px; @@ -859,10 +861,11 @@ description#identity-popup-content-verifier, margin-inline-start: 1px; margin-inline-end: 7px; padding: 2px; + padding-inline-end: 0; transition: padding .2s ease; } -#protections-popup-tp-switch::before { +.protections-popup-tp-switch::before { position: relative; display: block; content: ""; @@ -872,23 +875,31 @@ description#identity-popup-content-verifier, background: white; } -#protections-popup-tp-switch[enabled] { +.protections-popup-tp-switch[enabled] { background-color: #0a84ff; border: 1px solid #0a84ff; /* Push the toggle to the right. */ padding-inline-start: 12px; } -#protections-popup-tp-switch:hover, -#protections-popup-tp-switch:-moz-focusring { +.protections-popup-tp-switch:hover, +.protections-popup-tp-switch:-moz-focusring { border: 1px solid var(--panel-separator-color); } -#protections-popup-tp-switch[enabled=true]:hover, -#protections-popup-tp-switch[enabled=true]:-moz-focusring { +.protections-popup-tp-switch[enabled=true]:hover, +.protections-popup-tp-switch[enabled=true]:-moz-focusring { background-color: #45a1ff; } +#protections-popup-siteNotWorkingView-body-issue-list { + padding-inline-start: 1em; +} + +#protections-popup-siteNotWorkingView-footer { + border-top: 1px solid var(--panel-separator-color); +} + #protections-popup-settings-section { padding: 4px; -moz-context-properties: fill, fill-opacity; From 1f66319c45945b4734b6d1bc532705f475bffc8c Mon Sep 17 00:00:00 2001 From: Nihanth Subramanya Date: Wed, 3 Jul 2019 11:28:31 +0000 Subject: [PATCH 04/81] Bug 1555236 - Properly align TP toggle switch with the rest of the panel. r=johannh Differential Revision: https://phabricator.services.mozilla.com/D34517 --HG-- extra : moz-landing-system : lando --- browser/themes/shared/controlcenter/panel.inc.css | 1 - 1 file changed, 1 deletion(-) diff --git a/browser/themes/shared/controlcenter/panel.inc.css b/browser/themes/shared/controlcenter/panel.inc.css index f1e1bcb60399..28ed5ff054b2 100644 --- a/browser/themes/shared/controlcenter/panel.inc.css +++ b/browser/themes/shared/controlcenter/panel.inc.css @@ -859,7 +859,6 @@ description#identity-popup-content-verifier, margin-top: 4px; margin-bottom: 4px; margin-inline-start: 1px; - margin-inline-end: 7px; padding: 2px; padding-inline-end: 0; transition: padding .2s ease; From 1cbef07741e5f15375de2564fc2e1ce27eae8fbd Mon Sep 17 00:00:00 2001 From: Nihanth Subramanya Date: Wed, 3 Jul 2019 11:28:43 +0000 Subject: [PATCH 05/81] Bug 1555236 - Implement Send Report subview stub. r=johannh Differential Revision: https://phabricator.services.mozilla.com/D34519 --HG-- extra : moz-landing-system : lando --- browser/base/content/browser-siteProtections.js | 4 ++++ .../controlcenter/content/protectionsPanel.inc.xul | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/browser/base/content/browser-siteProtections.js b/browser/base/content/browser-siteProtections.js index 4e97c88d92bb..be3351665dca 100644 --- a/browser/base/content/browser-siteProtections.js +++ b/browser/base/content/browser-siteProtections.js @@ -264,4 +264,8 @@ var gProtectionsHandler = { showSiteNotWorkingView() { this._protectionsPopupMultiView.showSubView("protections-popup-siteNotWorkingView"); }, + + showSendReportView() { + this._protectionsPopupMultiView.showSubView("protections-popup-sendReportView"); + }, }; diff --git a/browser/components/controlcenter/content/protectionsPanel.inc.xul b/browser/components/controlcenter/content/protectionsPanel.inc.xul index e387f1f4d9a8..7a1c07d61539 100644 --- a/browser/components/controlcenter/content/protectionsPanel.inc.xul +++ b/browser/components/controlcenter/content/protectionsPanel.inc.xul @@ -101,5 +101,14 @@ class="text-link">Send Report + + + + + + From cbb51815f58fd5e2c827a0f19bf8f1495a17f842 Mon Sep 17 00:00:00 2001 From: Nihanth Subramanya Date: Wed, 3 Jul 2019 11:29:00 +0000 Subject: [PATCH 06/81] Bug 1555236 - Port breakage report UI into protections panel. r=ewright Differential Revision: https://phabricator.services.mozilla.com/D35626 --HG-- extra : moz-landing-system : lando --- .../base/content/browser-contentblocking.js | 15 ++++++---- .../base/content/browser-siteProtections.js | 25 ++++++++++++++++ .../content/identityPanel.inc.xul | 2 +- .../content/protectionsPanel.inc.xul | 29 +++++++++++++++++-- .../themes/shared/controlcenter/panel.inc.css | 23 ++++++++++----- 5 files changed, 78 insertions(+), 16 deletions(-) diff --git a/browser/base/content/browser-contentblocking.js b/browser/base/content/browser-contentblocking.js index 9c64bd1150db..0f1191e749f8 100644 --- a/browser/base/content/browser-contentblocking.js +++ b/browser/base/content/browser-contentblocking.js @@ -971,19 +971,25 @@ var ContentBlocking = { this.identityPopupMultiView.goBack(); }, - submitBreakageReport() { + onSubmitBreakageReportClicked() { this.identityPopup.hidePopup(); + let comments = document.getElementById( + "identity-popup-breakageReportView-collection-comments").value; + this.submitBreakageReport(this.reportURI, comments); + }, + + submitBreakageReport(uri, comments) { let reportEndpoint = Services.prefs.getStringPref(this.PREF_REPORT_BREAKAGE_URL); if (!reportEndpoint) { return; } let formData = new FormData(); - formData.set("title", this.reportURI.host); + formData.set("title", uri.host); // Leave the ? at the end of the URL to signify that this URL had its query stripped. - let urlWithoutQuery = this.reportURI.asciiSpec.replace(this.reportURI.query, ""); + let urlWithoutQuery = uri.asciiSpec.replace(uri.query, ""); let body = `Full URL: ${urlWithoutQuery}\n`; body += `userAgent: ${navigator.userAgent}\n`; @@ -999,8 +1005,7 @@ var ContentBlocking = { body += `${Fingerprinting.PREF_ENABLED}: ${Services.prefs.getBoolPref(Fingerprinting.PREF_ENABLED)}\n`; body += `${Cryptomining.PREF_ENABLED}: ${Services.prefs.getBoolPref(Cryptomining.PREF_ENABLED)}\n`; - let comments = document.getElementById("identity-popup-breakageReportView-collection-comments"); - body += "\n**Comments**\n" + comments.value; + body += "\n**Comments**\n" + comments; formData.set("body", body); diff --git a/browser/base/content/browser-siteProtections.js b/browser/base/content/browser-siteProtections.js index be3351665dca..7926fb12e3b0 100644 --- a/browser/base/content/browser-siteProtections.js +++ b/browser/base/content/browser-siteProtections.js @@ -62,6 +62,16 @@ var gProtectionsHandler = { return this._protectionsPopupSiteNotWorkingTPSwitch = document.getElementById("protections-popup-siteNotWorking-tp-switch"); }, + get _protectionsPopupSendReportLearnMore() { + delete this._protectionsPopupSendReportLearnMore; + return this._protectionsPopupSendReportLearnMore = + document.getElementById("protections-popup-sendReportView-learn-more"); + }, + get _protectionsPopupSendReportURL() { + delete this._protectionsPopupSendReportURL; + return this._protectionsPopupSendReportURL = + document.getElementById("protections-popup-sendReportView-collection-url"); + }, get _protectionsPopupToastTimeout() { delete this._protectionsPopupToastTimeout; XPCOMUtils.defineLazyPreferenceGetter(this, "_protectionsPopupToastTimeout", @@ -266,6 +276,21 @@ var gProtectionsHandler = { }, showSendReportView() { + // Save this URI to make sure that the user really only submits the location + // they see in the report breakage dialog. + this.reportURI = gBrowser.currentURI; + let urlWithoutQuery = this.reportURI.asciiSpec.replace("?" + this.reportURI.query, ""); + this._protectionsPopupSendReportURL.value = urlWithoutQuery; this._protectionsPopupMultiView.showSubView("protections-popup-sendReportView"); }, + + onSendReportClicked() { + this._protectionsPopup.hidePopup(); + let comments = document.getElementById( + "protections-popup-sendReportView-collection-comments").value; + ContentBlocking.submitBreakageReport(this.reportURI, comments); + }, }; + +let baseURL = Services.urlFormatter.formatURLPref("app.support.baseURL"); +gProtectionsHandler._protectionsPopupSendReportLearnMore.href = baseURL + "blocking-breakage"; diff --git a/browser/components/controlcenter/content/identityPanel.inc.xul b/browser/components/controlcenter/content/identityPanel.inc.xul index 6c72ab493acc..21e07888a260 100644 --- a/browser/components/controlcenter/content/identityPanel.inc.xul +++ b/browser/components/controlcenter/content/identityPanel.inc.xul @@ -346,7 +346,7 @@