зеркало из https://github.com/mozilla/gecko-dev.git
Merge m-c to m-i
MozReview-Commit-ID: 8cFOopE3aHd
This commit is contained in:
Коммит
592b02e148
|
@ -106,7 +106,6 @@ const SESSION_DATA_OA = `
|
|||
"addonId": "",
|
||||
"appId": 0,
|
||||
"inIsolatedMozBrowser": false,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
}
|
||||
}]
|
||||
|
|
|
@ -177,7 +177,6 @@ var PocketContextMenu = {
|
|||
observe: function(aSubject, aTopic, aData) {
|
||||
let subject = aSubject.wrappedJSObject;
|
||||
let document = subject.menu.ownerDocument;
|
||||
let window = document.defaultView;
|
||||
let pocketEnabled = CustomizableUI.getPlacementOfWidget("pocket-button");
|
||||
|
||||
let showSaveCurrentPageToPocket = !(subject.onTextInput || subject.onLink ||
|
||||
|
|
|
@ -52,19 +52,14 @@ XPCOMUtils.defineLazyModuleGetter(this, "pktApi",
|
|||
var pktUI = (function() {
|
||||
|
||||
// -- Initialization (on startup and new windows) -- //
|
||||
var inited = false;
|
||||
var _currentPanelDidShow;
|
||||
var _currentPanelDidHide;
|
||||
var _isHidden = false;
|
||||
var _notificationTimeout;
|
||||
|
||||
// Init panel id at 0. The first actual panel id will have the number 1 so
|
||||
// in case at some point any panel has the id 0 we know there is something
|
||||
// wrong
|
||||
var _panelId = 0;
|
||||
|
||||
var prefBranch = Services.prefs.getBranch("extensions.pocket.settings.");
|
||||
|
||||
var overflowMenuWidth = 230;
|
||||
var overflowMenuHeight = 475;
|
||||
var savePanelWidth = 350;
|
||||
|
@ -93,13 +88,6 @@ var pktUI = (function() {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Event handler when Pocket bookmark bar entry is pressed
|
||||
*/
|
||||
function pocketBookmarkBarOpenPocketCommand(event) {
|
||||
openTabWithUrl('https://getpocket.com/a/', true);
|
||||
}
|
||||
|
||||
// -- Communication to API -- //
|
||||
|
||||
/**
|
||||
|
@ -173,7 +161,7 @@ var pktUI = (function() {
|
|||
variant = 'storyboard_lm';
|
||||
}
|
||||
|
||||
var panelId = showPanel("about:pocket-signup?pockethost="
|
||||
showPanel("about:pocket-signup?pockethost="
|
||||
+ Services.prefs.getCharPref("extensions.pocket.site")
|
||||
+ "&fxasignedin="
|
||||
+ fxasignedin
|
||||
|
@ -574,14 +562,6 @@ var pktUI = (function() {
|
|||
return !!subview;
|
||||
}
|
||||
|
||||
function hasLegacyExtension() {
|
||||
return !!document.getElementById('RIL_urlbar_add');
|
||||
}
|
||||
|
||||
function isHidden() {
|
||||
return _isHidden;
|
||||
}
|
||||
|
||||
function getFirefoxAccountSignedInUser(callback) {
|
||||
fxAccounts.getSignedInUser().then(userData => {
|
||||
callback(userData);
|
||||
|
|
|
@ -28,14 +28,11 @@ var PKT_SAVED_OVERLAY = function (options)
|
|||
this.cxt_removed = 0;
|
||||
this.justaddedsuggested = false;
|
||||
this.fillTagContainer = function(tags, container, tagclass) {
|
||||
var newtagleft = 0;
|
||||
container.children().remove();
|
||||
for (var i = 0; i < tags.length; i++) {
|
||||
var newtag = $('<li><a href="#" class="token_tag ' + tagclass + '">' + tags[i] + '</a></li>');
|
||||
container.append(newtag);
|
||||
var templeft = newtag.position().left;
|
||||
this.cxt_suggested_available++;
|
||||
newtagleft = templeft;
|
||||
}
|
||||
};
|
||||
this.fillUserTags = function() {
|
||||
|
@ -607,4 +604,3 @@ $(function()
|
|||
window.thePKT_SAVED.create();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -63,8 +63,6 @@ var PKT_SIGNUP_OVERLAY = function (options)
|
|||
PKT_SIGNUP_OVERLAY.prototype = {
|
||||
create : function()
|
||||
{
|
||||
var myself = this;
|
||||
|
||||
var controlvariant = window.location.href.match(/controlvariant=([\w|\.]*)&?/);
|
||||
if (controlvariant && controlvariant.length > 1)
|
||||
{
|
||||
|
@ -193,4 +191,3 @@ $(function()
|
|||
window.thePKT_SIGNUP.create();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ support-files =
|
|||
[browser_BrowserUITelemetry_sidebar.js]
|
||||
[browser_BrowserUITelemetry_syncedtabs.js]
|
||||
[browser_CaptivePortalWatcher.js]
|
||||
skip-if = os == "win" # Bug 1313894
|
||||
[browser_ContentSearch.js]
|
||||
support-files =
|
||||
contentSearch.js
|
||||
|
|
|
@ -43,11 +43,6 @@ PrincipalOriginAttributes::InheritFromDocShellToDoc(const DocShellOriginAttribut
|
|||
// addonId is computed from the principal URI and never propagated
|
||||
mUserContextId = aAttrs.mUserContextId;
|
||||
|
||||
// TODO:
|
||||
// Bug 1225349 - PrincipalOriginAttributes should inherit mSignedPkg
|
||||
// accordingly by URI
|
||||
mSignedPkg = aAttrs.mSignedPkg;
|
||||
|
||||
mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
|
||||
mFirstPartyDomain = aAttrs.mFirstPartyDomain;
|
||||
}
|
||||
|
@ -60,7 +55,6 @@ PrincipalOriginAttributes::InheritFromNecko(const NeckoOriginAttributes& aAttrs)
|
|||
|
||||
// addonId is computed from the principal URI and never propagated
|
||||
mUserContextId = aAttrs.mUserContextId;
|
||||
mSignedPkg = aAttrs.mSignedPkg;
|
||||
|
||||
mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
|
||||
mFirstPartyDomain = aAttrs.mFirstPartyDomain;
|
||||
|
@ -82,11 +76,6 @@ DocShellOriginAttributes::InheritFromDocToChildDocShell(const PrincipalOriginAtt
|
|||
// addonId is computed from the principal URI and never propagated
|
||||
mUserContextId = aAttrs.mUserContextId;
|
||||
|
||||
// TODO:
|
||||
// Bug 1225353 - DocShell/NeckoOriginAttributes should inherit
|
||||
// mSignedPkg accordingly by mSignedPkgInBrowser
|
||||
mSignedPkg = aAttrs.mSignedPkg;
|
||||
|
||||
mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
|
||||
mFirstPartyDomain = aAttrs.mFirstPartyDomain;
|
||||
}
|
||||
|
@ -100,10 +89,6 @@ NeckoOriginAttributes::InheritFromDocToNecko(const PrincipalOriginAttributes& aA
|
|||
// addonId is computed from the principal URI and never propagated
|
||||
mUserContextId = aAttrs.mUserContextId;
|
||||
|
||||
// TODO:
|
||||
// Bug 1225353 - DocShell/NeckoOriginAttributes should inherit
|
||||
// mSignedPkg accordingly by mSignedPkgInBrowser
|
||||
|
||||
mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
|
||||
mFirstPartyDomain = aAttrs.mFirstPartyDomain;
|
||||
}
|
||||
|
@ -119,10 +104,6 @@ NeckoOriginAttributes::InheritFromDocShellToNecko(const DocShellOriginAttributes
|
|||
// addonId is computed from the principal URI and never propagated
|
||||
mUserContextId = aAttrs.mUserContextId;
|
||||
|
||||
// TODO:
|
||||
// Bug 1225353 - DocShell/NeckoOriginAttributes should inherit
|
||||
// mSignedPkg accordingly by mSignedPkgInBrowser
|
||||
|
||||
mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
|
||||
|
||||
bool isFirstPartyEnabled = IsFirstPartyEnabled();
|
||||
|
@ -183,10 +164,6 @@ OriginAttributes::CreateSuffix(nsACString& aStr) const
|
|||
params->Set(NS_LITERAL_STRING("userContextId"), value);
|
||||
}
|
||||
|
||||
if (!mSignedPkg.IsEmpty()) {
|
||||
MOZ_RELEASE_ASSERT(mSignedPkg.FindCharInSet(dom::quota::QuotaManager::kReplaceChars) == kNotFound);
|
||||
params->Set(NS_LITERAL_STRING("signedPkg"), mSignedPkg);
|
||||
}
|
||||
|
||||
if (mPrivateBrowsingId) {
|
||||
value.Truncate();
|
||||
|
@ -269,12 +246,6 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
if (aName.EqualsLiteral("signedPkg")) {
|
||||
MOZ_RELEASE_ASSERT(mOriginAttributes->mSignedPkg.IsEmpty());
|
||||
mOriginAttributes->mSignedPkg.Assign(aValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (aName.EqualsLiteral("privateBrowsingId")) {
|
||||
nsresult rv;
|
||||
int64_t val = aValue.ToInteger64(&rv);
|
||||
|
@ -349,7 +320,6 @@ OriginAttributes::SetFromGenericAttributes(const GenericOriginAttributes& aAttrs
|
|||
mInIsolatedMozBrowser = aAttrs.mInIsolatedMozBrowser;
|
||||
mAddonId = aAttrs.mAddonId;
|
||||
mUserContextId = aAttrs.mUserContextId;
|
||||
mSignedPkg = aAttrs.mSignedPkg;
|
||||
mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
|
||||
mFirstPartyDomain = aAttrs.mFirstPartyDomain;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ public:
|
|||
mInIsolatedMozBrowser == aOther.mInIsolatedMozBrowser &&
|
||||
mAddonId == aOther.mAddonId &&
|
||||
mUserContextId == aOther.mUserContextId &&
|
||||
mSignedPkg == aOther.mSignedPkg &&
|
||||
mPrivateBrowsingId == aOther.mPrivateBrowsingId &&
|
||||
mFirstPartyDomain == aOther.mFirstPartyDomain;
|
||||
}
|
||||
|
@ -191,10 +190,6 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
if (mSignedPkg.WasPassed() && mSignedPkg.Value() != aAttrs.mSignedPkg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mPrivateBrowsingId.WasPassed() && mPrivateBrowsingId.Value() != aAttrs.mPrivateBrowsingId) {
|
||||
return false;
|
||||
}
|
||||
|
@ -229,11 +224,6 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
if (mSignedPkg.WasPassed() && aOther.mSignedPkg.WasPassed() &&
|
||||
mSignedPkg.Value() != aOther.mSignedPkg.Value()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mPrivateBrowsingId.WasPassed() && aOther.mPrivateBrowsingId.WasPassed() &&
|
||||
mPrivateBrowsingId.Value() != aOther.mPrivateBrowsingId.Value()) {
|
||||
return false;
|
||||
|
|
|
@ -49,7 +49,6 @@ function printAttrs(name, attrs) {
|
|||
"\tuserContextId: " + attrs.userContextId + ",\n" +
|
||||
"\tinIsolatedMozBrowser: " + attrs.inIsolatedMozBrowser + ",\n" +
|
||||
"\taddonId: '" + attrs.addonId + "',\n" +
|
||||
"\tsignedPkg: '" + attrs.signedPkg + "',\n" +
|
||||
"\tprivateBrowsingId: '" + attrs.privateBrowsingId + "',\n" +
|
||||
"\tfirstPartyDomain: '" + attrs.firstPartyDomain + "'\n}");
|
||||
}
|
||||
|
@ -63,7 +62,6 @@ function checkValues(attrs, values) {
|
|||
do_check_eq(attrs.userContextId, values.userContextId || 0);
|
||||
do_check_eq(attrs.inIsolatedMozBrowser, values.inIsolatedMozBrowser || false);
|
||||
do_check_eq(attrs.addonId, values.addonId || '');
|
||||
do_check_eq(attrs.signedPkg, values.signedPkg || '');
|
||||
do_check_eq(attrs.privateBrowsingId, values.privateBrowsingId || '');
|
||||
do_check_eq(attrs.firstPartyDomain, values.firstPartyDomain || '');
|
||||
}
|
||||
|
@ -171,19 +169,6 @@ function run_test() {
|
|||
checkOriginAttributes(nullPrin_userContextApp, {appId: 24, userContextId: 42}, '^appId=24&userContextId=42');
|
||||
do_check_eq(exampleOrg_userContextApp.origin, 'http://example.org^appId=24&userContextId=42');
|
||||
|
||||
// Just signedPkg
|
||||
var exampleOrg_signedPkg = ssm.createCodebasePrincipal(makeURI('http://example.org'), {signedPkg: 'whatever'});
|
||||
checkOriginAttributes(exampleOrg_signedPkg, { signedPkg: 'whatever' }, '^signedPkg=whatever');
|
||||
do_check_eq(exampleOrg_signedPkg.origin, 'http://example.org^signedPkg=whatever');
|
||||
|
||||
// signedPkg and browser
|
||||
var exampleOrg_signedPkg_browser = ssm.createCodebasePrincipal(makeURI('http://example.org'), {signedPkg: 'whatever', inIsolatedMozBrowser: true});
|
||||
checkOriginAttributes(exampleOrg_signedPkg_browser, { signedPkg: 'whatever', inIsolatedMozBrowser: true }, '^inBrowser=1&signedPkg=whatever');
|
||||
do_check_eq(exampleOrg_signedPkg_browser.origin, 'http://example.org^inBrowser=1&signedPkg=whatever');
|
||||
|
||||
// Just signedPkg (but different value from 'exampleOrg_signedPkg_app')
|
||||
var exampleOrg_signedPkg_another = ssm.createCodebasePrincipal(makeURI('http://example.org'), {signedPkg: 'whatup'});
|
||||
|
||||
checkSandboxOriginAttributes(null, {});
|
||||
checkSandboxOriginAttributes('http://example.org', {});
|
||||
checkSandboxOriginAttributes('http://example.org', {}, {originAttributes: {}});
|
||||
|
@ -191,22 +176,6 @@ function run_test() {
|
|||
checkSandboxOriginAttributes(['http://example.org'], {});
|
||||
checkSandboxOriginAttributes(['http://example.org'], {}, {originAttributes: {}});
|
||||
checkSandboxOriginAttributes(['http://example.org'], {appId: 42}, {originAttributes: {appId: 42}});
|
||||
checkSandboxOriginAttributes([exampleOrg_signedPkg, 'http://example.org'], {signedPkg: 'whatever'});
|
||||
checkSandboxOriginAttributes(['http://example.org', exampleOrg_signedPkg], {signedPkg: 'whatever'});
|
||||
checkSandboxOriginAttributes(['http://example.org', exampleOrg_app, exampleOrg_signedPkg], {signedPkg: 'whatever'}, {originAttributes: {signedPkg: 'whatever'}});
|
||||
checkSandboxOriginAttributes(['http://example.org', exampleOrg_signedPkg, exampleOrg_app], {signedPkg: 'whatever'}, {originAttributes: {signedPkg: 'whatever'}});
|
||||
checkSandboxOriginAttributes([exampleOrg_app, exampleOrg_signedPkg, 'http://example.org'], {signedPkg: 'whatever'}, {originAttributes: {signedPkg: 'whatever'}});
|
||||
checkSandboxOriginAttributes([exampleOrg_app, 'http://example.org', exampleOrg_signedPkg], {signedPkg: 'whatever'}, {originAttributes: {signedPkg: 'whatever'}});
|
||||
checkSandboxOriginAttributes([exampleOrg_signedPkg, exampleOrg_app, 'http://example.org'], {signedPkg: 'whatever'}, {originAttributes: {signedPkg: 'whatever'}});
|
||||
checkSandboxOriginAttributes([exampleOrg_signedPkg, 'http://example.org', exampleOrg_app], {signedPkg: 'whatever'}, {originAttributes: {signedPkg: 'whatever'}});
|
||||
checkThrows(() => Cu.Sandbox([exampleOrg_app, exampleOrg_signedPkg]));
|
||||
checkThrows(() => Cu.Sandbox([exampleOrg_signedPkg, exampleOrg_app]));
|
||||
checkThrows(() => Cu.Sandbox(['http://example.org', exampleOrg_app, exampleOrg_signedPkg]));
|
||||
checkThrows(() => Cu.Sandbox(['http://example.org', exampleOrg_signedPkg, exampleOrg_app]));
|
||||
checkThrows(() => Cu.Sandbox([exampleOrg_app, exampleOrg_signedPkg, 'http://example.org']));
|
||||
checkThrows(() => Cu.Sandbox([exampleOrg_app, 'http://example.org', exampleOrg_signedPkg]));
|
||||
checkThrows(() => Cu.Sandbox([exampleOrg_signedPkg, exampleOrg_app, 'http://example.org']));
|
||||
checkThrows(() => Cu.Sandbox([exampleOrg_signedPkg, 'http://example.org', exampleOrg_app]));
|
||||
|
||||
// Check that all of the above are cross-origin.
|
||||
checkCrossOrigin(exampleOrg_app, exampleOrg);
|
||||
|
@ -222,9 +191,6 @@ function run_test() {
|
|||
checkCrossOrigin(exampleOrg_userContextAddon, exampleOrg);
|
||||
checkCrossOrigin(exampleOrg_userContext, exampleOrg_userContextAddon);
|
||||
checkCrossOrigin(exampleOrg_userContext, exampleOrg_userContextApp);
|
||||
checkCrossOrigin(exampleOrg_signedPkg, exampleOrg);
|
||||
checkCrossOrigin(exampleOrg_signedPkg, exampleOrg_signedPkg_browser);
|
||||
checkCrossOrigin(exampleOrg_signedPkg, exampleOrg_signedPkg_another);
|
||||
|
||||
// Check Principal kinds.
|
||||
function checkKind(prin, kind) {
|
||||
|
@ -255,7 +221,6 @@ function run_test() {
|
|||
[ "^addonId=fooBar", {addonId: "fooBar"} ],
|
||||
[ "^inBrowser=1", {inIsolatedMozBrowser: true} ],
|
||||
[ "^firstPartyDomain=example.org", {firstPartyDomain: "example.org"} ],
|
||||
[ "^signedPkg=bazQux", {signedPkg: "bazQux"} ],
|
||||
[ "^appId=3&inBrowser=1&userContextId=6",
|
||||
{appId: 3, userContextId: 6, inIsolatedMozBrowser: true} ] ];
|
||||
|
||||
|
|
|
@ -69,3 +69,13 @@ responsive.noContainerTabs=Responsive Design Mode is currently unavailable in co
|
|||
# just have normal network conditions. There is not very much room in the UI
|
||||
# so a short string would be best if possible.
|
||||
responsive.noThrottling=No throttling
|
||||
|
||||
# LOCALIZATION NOTE (responsive.devicePixelRatio): tooltip for the
|
||||
# DevicePixelRatio (DPR) dropdown when is enabled.
|
||||
responsive.devicePixelRatio=Device Pixel Ratio
|
||||
|
||||
# LOCALIZATION NOTE (responsive.autoDPR): tooltip for the DevicePixelRatio
|
||||
# (DPR) dropdown when is disabled because a device is selected.
|
||||
# The argument (%1$S) is the selected device (e.g. iPhone 6) that set
|
||||
# automatically the DPR value.
|
||||
responsive.autoDPR=DPR automatically set by %1$S
|
||||
|
|
|
@ -20,7 +20,7 @@ add_task(function* () {
|
|||
tab.linkedBrowser.reload();
|
||||
yield wait;
|
||||
|
||||
yield RequestsMenu.copyAllAsHar();
|
||||
yield RequestsMenu.contextMenu.copyAllAsHar();
|
||||
|
||||
let jsonString = SpecialPowers.getClipboardData("text/unicode");
|
||||
let har = JSON.parse(jsonString);
|
||||
|
|
|
@ -25,7 +25,7 @@ add_task(function* () {
|
|||
yield wait;
|
||||
|
||||
// Copy HAR into the clipboard (asynchronous).
|
||||
let jsonString = yield RequestsMenu.copyAllAsHar();
|
||||
let jsonString = yield RequestsMenu.contextMenu.copyAllAsHar();
|
||||
let har = JSON.parse(jsonString);
|
||||
|
||||
// Check out the HAR log.
|
||||
|
|
|
@ -51,7 +51,7 @@ function* throttleUploadTest(actuallyThrottle) {
|
|||
yield wait;
|
||||
|
||||
// Copy HAR into the clipboard (asynchronous).
|
||||
let jsonString = yield RequestsMenu.copyAllAsHar();
|
||||
let jsonString = yield RequestsMenu.contextMenu.copyAllAsHar();
|
||||
let har = JSON.parse(jsonString);
|
||||
|
||||
// Check out the HAR log.
|
||||
|
|
|
@ -20,6 +20,7 @@ DevToolsModules(
|
|||
'panel.js',
|
||||
'performance-statistics-view.js',
|
||||
'prefs.js',
|
||||
'request-list-context-menu.js',
|
||||
'request-utils.js',
|
||||
'requests-menu-view.js',
|
||||
'sort-predicates.js',
|
||||
|
|
|
@ -144,7 +144,7 @@ PerformanceStatisticsView.prototype = {
|
|||
|
||||
chart.on("click", (_, item) => {
|
||||
// Reset FilterButtons and enable one filter exclusively
|
||||
this.store.dispatch(Actions.enableFilterOnly(item.label));
|
||||
this.store.dispatch(Actions.enableFilterTypeOnly(item.label));
|
||||
NetMonitorView.showNetworkInspectorView();
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,357 @@
|
|||
/* 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/. */
|
||||
|
||||
/* globals NetMonitorController, NetMonitorView, gNetwork */
|
||||
|
||||
"use strict";
|
||||
|
||||
const Services = require("Services");
|
||||
const { Task } = require("devtools/shared/task");
|
||||
const { Curl } = require("devtools/client/shared/curl");
|
||||
const { gDevTools } = require("devtools/client/framework/devtools");
|
||||
const Menu = require("devtools/client/framework/menu");
|
||||
const MenuItem = require("devtools/client/framework/menu-item");
|
||||
const { L10N } = require("./l10n");
|
||||
const { formDataURI, getFormDataSections } = require("./request-utils");
|
||||
|
||||
loader.lazyRequireGetter(this, "HarExporter",
|
||||
"devtools/client/netmonitor/har/har-exporter", true);
|
||||
|
||||
loader.lazyServiceGetter(this, "clipboardHelper",
|
||||
"@mozilla.org/widget/clipboardhelper;1", "nsIClipboardHelper");
|
||||
|
||||
loader.lazyRequireGetter(this, "NetworkHelper",
|
||||
"devtools/shared/webconsole/network-helper");
|
||||
|
||||
function RequestListContextMenu() {}
|
||||
|
||||
RequestListContextMenu.prototype = {
|
||||
get selectedItem() {
|
||||
return NetMonitorView.RequestsMenu.selectedItem;
|
||||
},
|
||||
|
||||
get items() {
|
||||
return NetMonitorView.RequestsMenu.items;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle the context menu opening. Hide items if no request is selected.
|
||||
* Since visible attribute only accept boolean value but the method call may
|
||||
* return undefined, we use !! to force convert any object to boolean
|
||||
*/
|
||||
open({ screenX = 0, screenY = 0 } = {}) {
|
||||
let selectedItem = this.selectedItem;
|
||||
|
||||
let menu = new Menu();
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-copy-url",
|
||||
label: L10N.getStr("netmonitor.context.copyUrl"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyUrl.accesskey"),
|
||||
visible: !!selectedItem,
|
||||
click: () => this.copyUrl(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-copy-url-params",
|
||||
label: L10N.getStr("netmonitor.context.copyUrlParams"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyUrlParams.accesskey"),
|
||||
visible: !!(selectedItem &&
|
||||
NetworkHelper.nsIURL(selectedItem.attachment.url).query),
|
||||
click: () => this.copyUrlParams(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-copy-post-data",
|
||||
label: L10N.getStr("netmonitor.context.copyPostData"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyPostData.accesskey"),
|
||||
visible: !!(selectedItem && selectedItem.attachment.requestPostData),
|
||||
click: () => this.copyPostData(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-copy-as-curl",
|
||||
label: L10N.getStr("netmonitor.context.copyAsCurl"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyAsCurl.accesskey"),
|
||||
visible: !!(selectedItem && selectedItem.attachment),
|
||||
click: () => this.copyAsCurl(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
type: "separator",
|
||||
visible: !!selectedItem,
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-copy-request-headers",
|
||||
label: L10N.getStr("netmonitor.context.copyRequestHeaders"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyRequestHeaders.accesskey"),
|
||||
visible: !!(selectedItem && selectedItem.attachment.requestHeaders),
|
||||
click: () => this.copyRequestHeaders(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "response-menu-context-copy-response-headers",
|
||||
label: L10N.getStr("netmonitor.context.copyResponseHeaders"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyResponseHeaders.accesskey"),
|
||||
visible: !!(selectedItem && selectedItem.attachment.responseHeaders),
|
||||
click: () => this.copyResponseHeaders(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-copy-response",
|
||||
label: L10N.getStr("netmonitor.context.copyResponse"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyResponse.accesskey"),
|
||||
visible: !!(selectedItem &&
|
||||
selectedItem.attachment.responseContent &&
|
||||
selectedItem.attachment.responseContent.content.text &&
|
||||
selectedItem.attachment.responseContent.content.text.length !== 0),
|
||||
click: () => this.copyResponse(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-copy-image-as-data-uri",
|
||||
label: L10N.getStr("netmonitor.context.copyImageAsDataUri"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyImageAsDataUri.accesskey"),
|
||||
visible: !!(selectedItem &&
|
||||
selectedItem.attachment.responseContent &&
|
||||
selectedItem.attachment.responseContent.content
|
||||
.mimeType.includes("image/")),
|
||||
click: () => this.copyImageAsDataUri(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
type: "separator",
|
||||
visible: !!selectedItem,
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-copy-all-as-har",
|
||||
label: L10N.getStr("netmonitor.context.copyAllAsHar"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyAllAsHar.accesskey"),
|
||||
visible: !!this.items.length,
|
||||
click: () => this.copyAllAsHar(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-save-all-as-har",
|
||||
label: L10N.getStr("netmonitor.context.saveAllAsHar"),
|
||||
accesskey: L10N.getStr("netmonitor.context.saveAllAsHar.accesskey"),
|
||||
visible: !!this.items.length,
|
||||
click: () => this.saveAllAsHar(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
type: "separator",
|
||||
visible: !!selectedItem,
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-resend",
|
||||
label: L10N.getStr("netmonitor.context.editAndResend"),
|
||||
accesskey: L10N.getStr("netmonitor.context.editAndResend.accesskey"),
|
||||
visible: !!(NetMonitorController.supportsCustomRequest &&
|
||||
selectedItem &&
|
||||
!selectedItem.attachment.isCustom),
|
||||
click: () => NetMonitorView.RequestsMenu.cloneSelectedRequest(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
type: "separator",
|
||||
visible: !!selectedItem,
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-newtab",
|
||||
label: L10N.getStr("netmonitor.context.newTab"),
|
||||
accesskey: L10N.getStr("netmonitor.context.newTab.accesskey"),
|
||||
visible: !!selectedItem,
|
||||
click: () => this.openRequestInTab()
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-perf",
|
||||
label: L10N.getStr("netmonitor.context.perfTools"),
|
||||
accesskey: L10N.getStr("netmonitor.context.perfTools.accesskey"),
|
||||
visible: !!NetMonitorController.supportsPerfStats,
|
||||
click: () => NetMonitorView.toggleFrontendMode()
|
||||
}));
|
||||
|
||||
menu.popup(screenX, screenY, NetMonitorController._toolbox);
|
||||
return menu;
|
||||
},
|
||||
|
||||
/**
|
||||
* Opens selected item in a new tab.
|
||||
*/
|
||||
openRequestInTab() {
|
||||
let win = Services.wm.getMostRecentWindow(gDevTools.chromeWindowType);
|
||||
let { url } = this.selectedItem.attachment;
|
||||
win.openUILinkIn(url, "tab", { relatedToCurrent: true });
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy the request url from the currently selected item.
|
||||
*/
|
||||
copyUrl() {
|
||||
clipboardHelper.copyString(this.selectedItem.attachment.url);
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy the request url query string parameters from the currently
|
||||
* selected item.
|
||||
*/
|
||||
copyUrlParams() {
|
||||
let { url } = this.selectedItem.attachment;
|
||||
let params = NetworkHelper.nsIURL(url).query.split("&");
|
||||
let string = params.join(Services.appinfo.OS === "WINNT" ? "\r\n" : "\n");
|
||||
clipboardHelper.copyString(string);
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy the request form data parameters (or raw payload) from
|
||||
* the currently selected item.
|
||||
*/
|
||||
copyPostData: Task.async(function* () {
|
||||
let selected = this.selectedItem.attachment;
|
||||
|
||||
// Try to extract any form data parameters.
|
||||
let formDataSections = yield getFormDataSections(
|
||||
selected.requestHeaders,
|
||||
selected.requestHeadersFromUploadStream,
|
||||
selected.requestPostData,
|
||||
gNetwork.getString.bind(gNetwork));
|
||||
|
||||
let params = [];
|
||||
formDataSections.forEach(section => {
|
||||
let paramsArray = NetworkHelper.parseQueryString(section);
|
||||
if (paramsArray) {
|
||||
params = [...params, ...paramsArray];
|
||||
}
|
||||
});
|
||||
|
||||
let string = params
|
||||
.map(param => param.name + (param.value ? "=" + param.value : ""))
|
||||
.join(Services.appinfo.OS === "WINNT" ? "\r\n" : "\n");
|
||||
|
||||
// Fall back to raw payload.
|
||||
if (!string) {
|
||||
let postData = selected.requestPostData.postData.text;
|
||||
string = yield gNetwork.getString(postData);
|
||||
if (Services.appinfo.OS !== "WINNT") {
|
||||
string = string.replace(/\r/g, "");
|
||||
}
|
||||
}
|
||||
|
||||
clipboardHelper.copyString(string);
|
||||
}),
|
||||
|
||||
/**
|
||||
* Copy a cURL command from the currently selected item.
|
||||
*/
|
||||
copyAsCurl: Task.async(function* () {
|
||||
let selected = this.selectedItem.attachment;
|
||||
|
||||
// Create a sanitized object for the Curl command generator.
|
||||
let data = {
|
||||
url: selected.url,
|
||||
method: selected.method,
|
||||
headers: [],
|
||||
httpVersion: selected.httpVersion,
|
||||
postDataText: null
|
||||
};
|
||||
|
||||
// Fetch header values.
|
||||
for (let { name, value } of selected.requestHeaders.headers) {
|
||||
let text = yield gNetwork.getString(value);
|
||||
data.headers.push({ name: name, value: text });
|
||||
}
|
||||
|
||||
// Fetch the request payload.
|
||||
if (selected.requestPostData) {
|
||||
let postData = selected.requestPostData.postData.text;
|
||||
data.postDataText = yield gNetwork.getString(postData);
|
||||
}
|
||||
|
||||
clipboardHelper.copyString(Curl.generateCommand(data));
|
||||
}),
|
||||
|
||||
/**
|
||||
* Copy the raw request headers from the currently selected item.
|
||||
*/
|
||||
copyRequestHeaders() {
|
||||
let selected = this.selectedItem.attachment;
|
||||
let rawHeaders = selected.requestHeaders.rawHeaders.trim();
|
||||
if (Services.appinfo.OS !== "WINNT") {
|
||||
rawHeaders = rawHeaders.replace(/\r/g, "");
|
||||
}
|
||||
clipboardHelper.copyString(rawHeaders);
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy the raw response headers from the currently selected item.
|
||||
*/
|
||||
copyResponseHeaders() {
|
||||
let selected = this.selectedItem.attachment;
|
||||
let rawHeaders = selected.responseHeaders.rawHeaders.trim();
|
||||
if (Services.appinfo.OS !== "WINNT") {
|
||||
rawHeaders = rawHeaders.replace(/\r/g, "");
|
||||
}
|
||||
clipboardHelper.copyString(rawHeaders);
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy image as data uri.
|
||||
*/
|
||||
copyImageAsDataUri() {
|
||||
let selected = this.selectedItem.attachment;
|
||||
let { mimeType, text, encoding } = selected.responseContent.content;
|
||||
|
||||
gNetwork.getString(text).then(string => {
|
||||
let data = formDataURI(mimeType, encoding, string);
|
||||
clipboardHelper.copyString(data);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy response data as a string.
|
||||
*/
|
||||
copyResponse() {
|
||||
let selected = this.selectedItem.attachment;
|
||||
let text = selected.responseContent.content.text;
|
||||
|
||||
gNetwork.getString(text).then(string => {
|
||||
clipboardHelper.copyString(string);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy HAR from the network panel content to the clipboard.
|
||||
*/
|
||||
copyAllAsHar() {
|
||||
let options = this.getDefaultHarOptions();
|
||||
return HarExporter.copy(options);
|
||||
},
|
||||
|
||||
/**
|
||||
* Save HAR from the network panel content to a file.
|
||||
*/
|
||||
saveAllAsHar() {
|
||||
let options = this.getDefaultHarOptions();
|
||||
return HarExporter.save(options);
|
||||
},
|
||||
|
||||
getDefaultHarOptions() {
|
||||
let form = NetMonitorController._target.form;
|
||||
let title = form.title || form.url;
|
||||
|
||||
return {
|
||||
getString: gNetwork.getString.bind(gNetwork),
|
||||
view: NetMonitorView.RequestsMenu,
|
||||
items: NetMonitorView.RequestsMenu.items,
|
||||
title: title
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = RequestListContextMenu;
|
|
@ -1,9 +1,14 @@
|
|||
/* 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/. */
|
||||
|
||||
/* globals document, window, dumpn, $, gNetwork, EVENTS, Prefs,
|
||||
NetMonitorController, NetMonitorView */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* eslint-disable mozilla/reject-some-requires */
|
||||
const { Cu } = require("chrome");
|
||||
const Services = require("Services");
|
||||
const {Task} = require("devtools/shared/task");
|
||||
const {DeferredTask} = Cu.import("resource://gre/modules/DeferredTask.jsm", {});
|
||||
/* eslint-disable mozilla/reject-some-requires */
|
||||
|
@ -13,16 +18,12 @@ const {setImageTooltip, getImageDimensions} =
|
|||
require("devtools/client/shared/widgets/tooltip/ImageTooltipHelper");
|
||||
const {Heritage, WidgetMethods, setNamedTimeout} =
|
||||
require("devtools/client/shared/widgets/view-helpers");
|
||||
const {gDevTools} = require("devtools/client/framework/devtools");
|
||||
const Menu = require("devtools/client/framework/menu");
|
||||
const MenuItem = require("devtools/client/framework/menu-item");
|
||||
const {Curl, CurlUtils} = require("devtools/client/shared/curl");
|
||||
const {CurlUtils} = require("devtools/client/shared/curl");
|
||||
const {PluralForm} = require("devtools/shared/plural-form");
|
||||
const {Filters, isFreetextMatch} = require("./filter-predicates");
|
||||
const {Sorters} = require("./sort-predicates");
|
||||
const {L10N, WEBCONSOLE_L10N} = require("./l10n");
|
||||
const {getFormDataSections,
|
||||
formDataURI,
|
||||
const {formDataURI,
|
||||
writeHeaderText,
|
||||
getKeyWithEvent,
|
||||
getAbbreviatedMimeType,
|
||||
|
@ -31,12 +32,7 @@ const {getFormDataSections,
|
|||
getUriHost,
|
||||
loadCauseString} = require("./request-utils");
|
||||
const Actions = require("./actions/index");
|
||||
|
||||
loader.lazyServiceGetter(this, "clipboardHelper",
|
||||
"@mozilla.org/widget/clipboardhelper;1", "nsIClipboardHelper");
|
||||
|
||||
loader.lazyRequireGetter(this, "HarExporter",
|
||||
"devtools/client/netmonitor/har/har-exporter", true);
|
||||
const RequestListContextMenu = require("./request-list-context-menu");
|
||||
|
||||
loader.lazyRequireGetter(this, "NetworkHelper",
|
||||
"devtools/shared/webconsole/network-helper");
|
||||
|
@ -128,6 +124,8 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
|||
|
||||
this.store = store;
|
||||
|
||||
this.contextMenu = new RequestListContextMenu();
|
||||
|
||||
let widgetParentEl = $("#requests-menu-contents");
|
||||
this.widget = new SideMenuWidget(widgetParentEl);
|
||||
this._splitter = $("#network-inspector-view-splitter");
|
||||
|
@ -154,13 +152,6 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
|||
this.requestsMenuSortEvent = getKeyWithEvent(this.sortBy.bind(this));
|
||||
this.requestsMenuSortKeyboardEvent = getKeyWithEvent(this.sortBy.bind(this), true);
|
||||
this._onContextMenu = this._onContextMenu.bind(this);
|
||||
this._onContextNewTabCommand = this.openRequestInTab.bind(this);
|
||||
this._onContextCopyUrlCommand = this.copyUrl.bind(this);
|
||||
this._onContextCopyImageAsDataUriCommand =
|
||||
this.copyImageAsDataUri.bind(this);
|
||||
this._onContextCopyResponseCommand = this.copyResponse.bind(this);
|
||||
this._onContextResendCommand = this.cloneSelectedRequest.bind(this);
|
||||
this._onContextToggleRawHeadersCommand = this.toggleRawHeaders.bind(this);
|
||||
this._onContextPerfCommand = () => NetMonitorView.toggleFrontendMode();
|
||||
this._onReloadCommand = () => NetMonitorView.reloadPage();
|
||||
this._flushRequestsTask = new DeferredTask(this._flushRequests,
|
||||
|
@ -348,181 +339,6 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
|||
return undefined;
|
||||
},
|
||||
|
||||
/**
|
||||
* Opens selected item in a new tab.
|
||||
*/
|
||||
openRequestInTab: function () {
|
||||
let win = Services.wm.getMostRecentWindow(gDevTools.chromeWindowType);
|
||||
let selected = this.selectedItem.attachment;
|
||||
win.openUILinkIn(selected.url, "tab", { relatedToCurrent: true });
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy the request url from the currently selected item.
|
||||
*/
|
||||
copyUrl: function () {
|
||||
let selected = this.selectedItem.attachment;
|
||||
clipboardHelper.copyString(selected.url);
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy the request url query string parameters from the currently
|
||||
* selected item.
|
||||
*/
|
||||
copyUrlParams: function () {
|
||||
let selected = this.selectedItem.attachment;
|
||||
let params = NetworkHelper.nsIURL(selected.url).query.split("&");
|
||||
let string = params.join(Services.appinfo.OS === "WINNT" ? "\r\n" : "\n");
|
||||
clipboardHelper.copyString(string);
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy the request form data parameters (or raw payload) from
|
||||
* the currently selected item.
|
||||
*/
|
||||
copyPostData: Task.async(function* () {
|
||||
let selected = this.selectedItem.attachment;
|
||||
|
||||
// Try to extract any form data parameters.
|
||||
let formDataSections = yield getFormDataSections(
|
||||
selected.requestHeaders,
|
||||
selected.requestHeadersFromUploadStream,
|
||||
selected.requestPostData,
|
||||
gNetwork.getString.bind(gNetwork));
|
||||
|
||||
let params = [];
|
||||
formDataSections.forEach(section => {
|
||||
let paramsArray = NetworkHelper.parseQueryString(section);
|
||||
if (paramsArray) {
|
||||
params = [...params, ...paramsArray];
|
||||
}
|
||||
});
|
||||
|
||||
let string = params
|
||||
.map(param => param.name + (param.value ? "=" + param.value : ""))
|
||||
.join(Services.appinfo.OS === "WINNT" ? "\r\n" : "\n");
|
||||
|
||||
// Fall back to raw payload.
|
||||
if (!string) {
|
||||
let postData = selected.requestPostData.postData.text;
|
||||
string = yield gNetwork.getString(postData);
|
||||
if (Services.appinfo.OS !== "WINNT") {
|
||||
string = string.replace(/\r/g, "");
|
||||
}
|
||||
}
|
||||
|
||||
clipboardHelper.copyString(string);
|
||||
}),
|
||||
|
||||
/**
|
||||
* Copy a cURL command from the currently selected item.
|
||||
*/
|
||||
copyAsCurl: function () {
|
||||
let selected = this.selectedItem.attachment;
|
||||
|
||||
Task.spawn(function* () {
|
||||
// Create a sanitized object for the Curl command generator.
|
||||
let data = {
|
||||
url: selected.url,
|
||||
method: selected.method,
|
||||
headers: [],
|
||||
httpVersion: selected.httpVersion,
|
||||
postDataText: null
|
||||
};
|
||||
|
||||
// Fetch header values.
|
||||
for (let { name, value } of selected.requestHeaders.headers) {
|
||||
let text = yield gNetwork.getString(value);
|
||||
data.headers.push({ name: name, value: text });
|
||||
}
|
||||
|
||||
// Fetch the request payload.
|
||||
if (selected.requestPostData) {
|
||||
let postData = selected.requestPostData.postData.text;
|
||||
data.postDataText = yield gNetwork.getString(postData);
|
||||
}
|
||||
|
||||
clipboardHelper.copyString(Curl.generateCommand(data));
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy HAR from the network panel content to the clipboard.
|
||||
*/
|
||||
copyAllAsHar: function () {
|
||||
let options = this.getDefaultHarOptions();
|
||||
return HarExporter.copy(options);
|
||||
},
|
||||
|
||||
/**
|
||||
* Save HAR from the network panel content to a file.
|
||||
*/
|
||||
saveAllAsHar: function () {
|
||||
let options = this.getDefaultHarOptions();
|
||||
return HarExporter.save(options);
|
||||
},
|
||||
|
||||
getDefaultHarOptions: function () {
|
||||
let form = NetMonitorController._target.form;
|
||||
let title = form.title || form.url;
|
||||
|
||||
return {
|
||||
getString: gNetwork.getString.bind(gNetwork),
|
||||
view: this,
|
||||
items: NetMonitorView.RequestsMenu.items,
|
||||
title: title
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy the raw request headers from the currently selected item.
|
||||
*/
|
||||
copyRequestHeaders: function () {
|
||||
let selected = this.selectedItem.attachment;
|
||||
let rawHeaders = selected.requestHeaders.rawHeaders.trim();
|
||||
if (Services.appinfo.OS !== "WINNT") {
|
||||
rawHeaders = rawHeaders.replace(/\r/g, "");
|
||||
}
|
||||
clipboardHelper.copyString(rawHeaders);
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy the raw response headers from the currently selected item.
|
||||
*/
|
||||
copyResponseHeaders: function () {
|
||||
let selected = this.selectedItem.attachment;
|
||||
let rawHeaders = selected.responseHeaders.rawHeaders.trim();
|
||||
if (Services.appinfo.OS !== "WINNT") {
|
||||
rawHeaders = rawHeaders.replace(/\r/g, "");
|
||||
}
|
||||
clipboardHelper.copyString(rawHeaders);
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy image as data uri.
|
||||
*/
|
||||
copyImageAsDataUri: function () {
|
||||
let selected = this.selectedItem.attachment;
|
||||
let { mimeType, text, encoding } = selected.responseContent.content;
|
||||
|
||||
gNetwork.getString(text).then(string => {
|
||||
let data = formDataURI(mimeType, encoding, string);
|
||||
clipboardHelper.copyString(data);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy response data as a string.
|
||||
*/
|
||||
copyResponse: function () {
|
||||
let selected = this.selectedItem.attachment;
|
||||
let text = selected.responseContent.content.text;
|
||||
|
||||
gNetwork.getString(text).then(string => {
|
||||
clipboardHelper.copyString(string);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a new custom request form populated with the data from
|
||||
* the currently selected request.
|
||||
|
@ -1713,157 +1529,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
|||
*/
|
||||
_onContextMenu: function (e) {
|
||||
e.preventDefault();
|
||||
this._openMenu({
|
||||
screenX: e.screenX,
|
||||
screenY: e.screenY,
|
||||
target: e.target,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle the context menu opening. Hide items if no request is selected.
|
||||
* Since visible attribute only accept boolean value but the method call may
|
||||
* return undefined, we use !! to force convert any object to boolean
|
||||
*/
|
||||
_openMenu: function ({ target, screenX = 0, screenY = 0 } = { }) {
|
||||
let selectedItem = this.selectedItem;
|
||||
|
||||
let menu = new Menu();
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-copy-url",
|
||||
label: L10N.getStr("netmonitor.context.copyUrl"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyUrl.accesskey"),
|
||||
visible: !!selectedItem,
|
||||
click: () => this._onContextCopyUrlCommand(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-copy-url-params",
|
||||
label: L10N.getStr("netmonitor.context.copyUrlParams"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyUrlParams.accesskey"),
|
||||
visible: !!(selectedItem &&
|
||||
NetworkHelper.nsIURL(selectedItem.attachment.url).query),
|
||||
click: () => this.copyUrlParams(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-copy-post-data",
|
||||
label: L10N.getStr("netmonitor.context.copyPostData"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyPostData.accesskey"),
|
||||
visible: !!(selectedItem && selectedItem.attachment.requestPostData),
|
||||
click: () => this.copyPostData(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-copy-as-curl",
|
||||
label: L10N.getStr("netmonitor.context.copyAsCurl"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyAsCurl.accesskey"),
|
||||
visible: !!(selectedItem && selectedItem.attachment),
|
||||
click: () => this.copyAsCurl(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
type: "separator",
|
||||
visible: !!selectedItem,
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-copy-request-headers",
|
||||
label: L10N.getStr("netmonitor.context.copyRequestHeaders"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyRequestHeaders.accesskey"),
|
||||
visible: !!(selectedItem && selectedItem.attachment.requestHeaders),
|
||||
click: () => this.copyRequestHeaders(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "response-menu-context-copy-response-headers",
|
||||
label: L10N.getStr("netmonitor.context.copyResponseHeaders"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyResponseHeaders.accesskey"),
|
||||
visible: !!(selectedItem && selectedItem.attachment.responseHeaders),
|
||||
click: () => this.copyResponseHeaders(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-copy-response",
|
||||
label: L10N.getStr("netmonitor.context.copyResponse"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyResponse.accesskey"),
|
||||
visible: !!(selectedItem &&
|
||||
selectedItem.attachment.responseContent &&
|
||||
selectedItem.attachment.responseContent.content.text &&
|
||||
selectedItem.attachment.responseContent.content.text.length !== 0),
|
||||
click: () => this._onContextCopyResponseCommand(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-copy-image-as-data-uri",
|
||||
label: L10N.getStr("netmonitor.context.copyImageAsDataUri"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyImageAsDataUri.accesskey"),
|
||||
visible: !!(selectedItem &&
|
||||
selectedItem.attachment.responseContent &&
|
||||
selectedItem.attachment.responseContent.content
|
||||
.mimeType.includes("image/")),
|
||||
click: () => this._onContextCopyImageAsDataUriCommand(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
type: "separator",
|
||||
visible: !!selectedItem,
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-copy-all-as-har",
|
||||
label: L10N.getStr("netmonitor.context.copyAllAsHar"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyAllAsHar.accesskey"),
|
||||
visible: !!this.items.length,
|
||||
click: () => this.copyAllAsHar(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-save-all-as-har",
|
||||
label: L10N.getStr("netmonitor.context.saveAllAsHar"),
|
||||
accesskey: L10N.getStr("netmonitor.context.saveAllAsHar.accesskey"),
|
||||
visible: !!this.items.length,
|
||||
click: () => this.saveAllAsHar(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
type: "separator",
|
||||
visible: !!selectedItem,
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-resend",
|
||||
label: L10N.getStr("netmonitor.context.editAndResend"),
|
||||
accesskey: L10N.getStr("netmonitor.context.editAndResend.accesskey"),
|
||||
visible: !!(NetMonitorController.supportsCustomRequest &&
|
||||
selectedItem &&
|
||||
!selectedItem.attachment.isCustom),
|
||||
click: () => this._onContextResendCommand(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
type: "separator",
|
||||
visible: !!selectedItem,
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-newtab",
|
||||
label: L10N.getStr("netmonitor.context.newTab"),
|
||||
accesskey: L10N.getStr("netmonitor.context.newTab.accesskey"),
|
||||
visible: !!selectedItem,
|
||||
click: () => this._onContextNewTabCommand(),
|
||||
}));
|
||||
|
||||
menu.append(new MenuItem({
|
||||
id: "request-menu-context-perf",
|
||||
label: L10N.getStr("netmonitor.context.perfTools"),
|
||||
accesskey: L10N.getStr("netmonitor.context.perfTools.accesskey"),
|
||||
visible: !!NetMonitorController.supportsPerfStats,
|
||||
click: () => this._onContextPerfCommand(),
|
||||
}));
|
||||
|
||||
menu.popup(screenX, screenY, NetMonitorController._toolbox);
|
||||
return menu;
|
||||
this.contextMenu.open(e);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -55,7 +55,7 @@ add_task(function* () {
|
|||
RequestsMenu.selectedItem = requestItem;
|
||||
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyAsCurl();
|
||||
RequestsMenu.contextMenu.copyAsCurl();
|
||||
}, function validate(result) {
|
||||
if (typeof result !== "string") {
|
||||
return false;
|
||||
|
|
|
@ -39,7 +39,7 @@ add_task(function* () {
|
|||
].join("\n");
|
||||
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyRequestHeaders();
|
||||
RequestsMenu.contextMenu.copyRequestHeaders();
|
||||
}, function validate(result) {
|
||||
// Sometimes, a "Cookie" header is left over from other tests. Remove it:
|
||||
result = String(result).replace(/Cookie: [^\n]+\n/, "");
|
||||
|
@ -58,7 +58,7 @@ add_task(function* () {
|
|||
].join("\n");
|
||||
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyResponseHeaders();
|
||||
RequestsMenu.contextMenu.copyResponseHeaders();
|
||||
}, function validate(result) {
|
||||
// Fake the "Last-Modified" and "Date" headers because they will vary:
|
||||
result = String(result)
|
||||
|
|
|
@ -26,7 +26,7 @@ add_task(function* () {
|
|||
RequestsMenu.selectedItem = requestItem;
|
||||
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyImageAsDataUri();
|
||||
RequestsMenu.contextMenu.copyImageAsDataUri();
|
||||
}, TEST_IMAGE_DATA_URI);
|
||||
|
||||
ok(true, "Clipboard contains the currently selected image as data uri.");
|
||||
|
|
|
@ -75,7 +75,7 @@ add_task(function* () {
|
|||
|
||||
function* testCopyUrlParams(queryString) {
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyUrlParams();
|
||||
RequestsMenu.contextMenu.copyUrlParams();
|
||||
}, queryString);
|
||||
ok(true, "The url query string copied from the selected item is correct.");
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ add_task(function* () {
|
|||
|
||||
function* testCopyPostData(postData) {
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyPostData();
|
||||
RequestsMenu.contextMenu.copyPostData();
|
||||
}, postData);
|
||||
ok(true, "The post data string copied from the selected item is correct.");
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ add_task(function* () {
|
|||
RequestsMenu.selectedItem = requestItem;
|
||||
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyResponse();
|
||||
RequestsMenu.contextMenu.copyResponse();
|
||||
}, EXPECTED_RESULT);
|
||||
|
||||
yield teardown(monitor);
|
||||
|
|
|
@ -28,7 +28,7 @@ add_task(function* () {
|
|||
RequestsMenu.selectedItem = requestItem;
|
||||
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyImageAsDataUri();
|
||||
RequestsMenu.contextMenu.copyImageAsDataUri();
|
||||
}, function check(text) {
|
||||
return text.startsWith("data:") && !/undefined/.test(text);
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ add_task(function* () {
|
|||
RequestsMenu.selectedItem = requestItem;
|
||||
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyUrl();
|
||||
RequestsMenu.contextMenu.copyUrl();
|
||||
}, requestItem.attachment.url);
|
||||
|
||||
yield teardown(monitor);
|
||||
|
|
|
@ -26,7 +26,7 @@ add_task(function* () {
|
|||
RequestsMenu.selectedItem = requestItem;
|
||||
|
||||
let onTabOpen = once(gBrowser.tabContainer, "TabOpen", false);
|
||||
RequestsMenu.openRequestInTab();
|
||||
RequestsMenu.contextMenu.openRequestInTab();
|
||||
yield onTabOpen;
|
||||
|
||||
ok(true, "A new tab has been opened");
|
||||
|
|
|
@ -30,7 +30,14 @@ add_task(function* () {
|
|||
NetMonitorView.toggleFrontendMode();
|
||||
yield onEvents;
|
||||
|
||||
is(NetMonitorView.currentFrontendMode, "network-statistics-view",
|
||||
"The frontend mode is switched to the statistics view.");
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $(".pie-chart-slice"));
|
||||
|
||||
is(NetMonitorView.currentFrontendMode, "network-inspector-view",
|
||||
"The frontend mode is switched back to the inspector view.");
|
||||
|
||||
testFilterButtons(monitor, "html");
|
||||
info("The correct filtering predicate is used when exiting perf. analysis mode.");
|
||||
|
||||
|
|
|
@ -386,17 +386,19 @@ function waitFor(subject, eventName) {
|
|||
/**
|
||||
* Tests if a button for a filter of given type is the only one checked.
|
||||
*
|
||||
* @param string aFilterType
|
||||
* @param string filterType
|
||||
* The type of the filter that should be the only one checked.
|
||||
*/
|
||||
function testFilterButtons(aMonitor, aFilterType) {
|
||||
let doc = aMonitor.panelWin.document;
|
||||
let target = doc.querySelector("#requests-menu-filter-" + aFilterType + "-button");
|
||||
let buttons = doc.querySelectorAll(".requests-menu-footer-button");
|
||||
function testFilterButtons(monitor, filterType) {
|
||||
let doc = monitor.panelWin.document;
|
||||
let target = doc.querySelector("#requests-menu-filter-" + filterType + "-button");
|
||||
ok(target, `Filter button '${filterType}' was found`);
|
||||
let buttons = [...doc.querySelectorAll(".menu-filter-button")];
|
||||
ok(buttons.length > 0, "More than zero filter buttons were found");
|
||||
|
||||
// Only target should be checked.
|
||||
let checkStatus = [...buttons].map(button => button == target ? 1 : 0);
|
||||
testFilterButtonsCustom(aMonitor, checkStatus);
|
||||
let checkStatus = buttons.map(button => button == target ? 1 : 0);
|
||||
testFilterButtonsCustom(monitor, checkStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -499,11 +501,11 @@ function waitForContentMessage(name) {
|
|||
/**
|
||||
* Open the requestMenu menu and return all of it's items in a flat array
|
||||
* @param {netmonitorPanel} netmonitor
|
||||
* @param {Object} options to pass into openMenu
|
||||
* @param {Event} event mouse event with screenX and screenX coordinates
|
||||
* @return An array of MenuItems
|
||||
*/
|
||||
function openContextMenuAndGetAllItems(netmonitor, options) {
|
||||
let menu = netmonitor.RequestsMenu._openMenu(options);
|
||||
function openContextMenuAndGetAllItems(netmonitor, event) {
|
||||
let menu = netmonitor.RequestsMenu.contextMenu.open(event);
|
||||
|
||||
// Flatten all menu items into a single array to make searching through it easier
|
||||
let allItems = [].concat.apply([], menu.items.map(function addItem(item) {
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/* 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 { CHANGE_DISPLAY_PIXEL_RATIO } = require("./index");
|
||||
|
||||
module.exports = {
|
||||
|
||||
/**
|
||||
* The pixel ratio of the display has changed. This may be triggered by the user
|
||||
* when changing the monitor resolution, or when the window is dragged to a different
|
||||
* display with a different pixel ratio.
|
||||
*/
|
||||
changeDisplayPixelRatio(displayPixelRatio) {
|
||||
return {
|
||||
type: CHANGE_DISPLAY_PIXEL_RATIO,
|
||||
displayPixelRatio,
|
||||
};
|
||||
},
|
||||
|
||||
};
|
|
@ -28,9 +28,19 @@ createEnum([
|
|||
// directly entering a new URL, navigating with links, etc.
|
||||
"CHANGE_LOCATION",
|
||||
|
||||
// The pixel ratio of the display has changed. This may be triggered by the user
|
||||
// when changing the monitor resolution, or when the window is dragged to a different
|
||||
// display with a different pixel ratio.
|
||||
"CHANGE_DISPLAY_PIXEL_RATIO",
|
||||
|
||||
// Change the network throttling profile.
|
||||
"CHANGE_NETWORK_THROTTLING",
|
||||
|
||||
// The pixel ratio of the viewport has changed. This may be triggered by the user
|
||||
// when changing the device displayed in the viewport, or when a pixel ratio is
|
||||
// selected from the DPR dropdown.
|
||||
"CHANGE_VIEWPORT_PIXEL_RATIO",
|
||||
|
||||
// Indicates that the device list is being loaded
|
||||
"LOAD_DEVICE_LIST_START",
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
DevToolsModules(
|
||||
'devices.js',
|
||||
'display-pixel-ratio.js',
|
||||
'index.js',
|
||||
'location.js',
|
||||
'network-throttling.js',
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
const {
|
||||
ADD_VIEWPORT,
|
||||
CHANGE_DEVICE,
|
||||
CHANGE_VIEWPORT_PIXEL_RATIO,
|
||||
RESIZE_VIEWPORT,
|
||||
ROTATE_VIEWPORT
|
||||
} = require("./index");
|
||||
|
@ -33,6 +34,17 @@ module.exports = {
|
|||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Change the viewport pixel ratio.
|
||||
*/
|
||||
changeViewportPixelRatio(id, pixelRatio = 0) {
|
||||
return {
|
||||
type: CHANGE_VIEWPORT_PIXEL_RATIO,
|
||||
id,
|
||||
pixelRatio,
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Resize the viewport.
|
||||
*/
|
||||
|
|
|
@ -20,6 +20,7 @@ const { takeScreenshot } = require("./actions/screenshot");
|
|||
const { updateTouchSimulationEnabled } = require("./actions/touch-simulation");
|
||||
const {
|
||||
changeDevice,
|
||||
changeViewportPixelRatio,
|
||||
resizeViewport,
|
||||
rotateViewport
|
||||
} = require("./actions/viewports");
|
||||
|
@ -33,6 +34,7 @@ let App = createClass({
|
|||
|
||||
propTypes: {
|
||||
devices: PropTypes.shape(Types.devices).isRequired,
|
||||
displayPixelRatio: PropTypes.number.isRequired,
|
||||
location: Types.location.isRequired,
|
||||
networkThrottling: PropTypes.shape(Types.networkThrottling).isRequired,
|
||||
screenshot: PropTypes.shape(Types.screenshot).isRequired,
|
||||
|
@ -60,6 +62,16 @@ let App = createClass({
|
|||
}, "*");
|
||||
this.props.dispatch(changeDevice(id, device.name));
|
||||
this.props.dispatch(updateTouchSimulationEnabled(device.touch));
|
||||
this.props.dispatch(changeViewportPixelRatio(id, device.pixelRatio));
|
||||
},
|
||||
|
||||
onChangeViewportPixelRatio(pixelRatio) {
|
||||
window.postMessage({
|
||||
type: "change-viewport-pixel-ratio",
|
||||
pixelRatio,
|
||||
}, "*");
|
||||
|
||||
this.props.dispatch(changeViewportPixelRatio(0, pixelRatio));
|
||||
},
|
||||
|
||||
onContentResize({ width, height }) {
|
||||
|
@ -110,6 +122,7 @@ let App = createClass({
|
|||
render() {
|
||||
let {
|
||||
devices,
|
||||
displayPixelRatio,
|
||||
location,
|
||||
networkThrottling,
|
||||
screenshot,
|
||||
|
@ -121,6 +134,7 @@ let App = createClass({
|
|||
onBrowserMounted,
|
||||
onChangeNetworkThrottling,
|
||||
onChangeViewportDevice,
|
||||
onChangeViewportPixelRatio,
|
||||
onContentResize,
|
||||
onDeviceListUpdate,
|
||||
onExit,
|
||||
|
@ -132,15 +146,28 @@ let App = createClass({
|
|||
onUpdateTouchSimulation,
|
||||
} = this;
|
||||
|
||||
let selectedDevice = "";
|
||||
let selectedPixelRatio = 0;
|
||||
|
||||
if (viewports.length) {
|
||||
selectedDevice = viewports[0].device;
|
||||
selectedPixelRatio = viewports[0].pixelRatio;
|
||||
}
|
||||
|
||||
return dom.div(
|
||||
{
|
||||
id: "app",
|
||||
},
|
||||
GlobalToolbar({
|
||||
devices,
|
||||
displayPixelRatio,
|
||||
networkThrottling,
|
||||
screenshot,
|
||||
selectedDevice,
|
||||
selectedPixelRatio,
|
||||
touchSimulation,
|
||||
onChangeNetworkThrottling,
|
||||
onChangeViewportPixelRatio,
|
||||
onExit,
|
||||
onScreenshot,
|
||||
onUpdateTouchSimulation,
|
||||
|
|
|
@ -0,0 +1,131 @@
|
|||
/* 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/. */
|
||||
|
||||
/* eslint-env browser */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { DOM: dom, createClass, PropTypes, addons } =
|
||||
require("devtools/client/shared/vendor/react");
|
||||
|
||||
const Types = require("../types");
|
||||
const { getStr, getFormatStr } = require("../utils/l10n");
|
||||
|
||||
const PIXEL_RATIO_PRESET = [1, 2, 3];
|
||||
|
||||
const createVisibleOption = value =>
|
||||
dom.option({
|
||||
value,
|
||||
title: value,
|
||||
key: value,
|
||||
}, value);
|
||||
|
||||
const createHiddenOption = value =>
|
||||
dom.option({
|
||||
value,
|
||||
title: value,
|
||||
hidden: true,
|
||||
disabled: true,
|
||||
}, value);
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "DPRSelector",
|
||||
|
||||
propTypes: {
|
||||
devices: PropTypes.shape(Types.devices).isRequired,
|
||||
displayPixelRatio: PropTypes.number.isRequired,
|
||||
selectedDevice: PropTypes.string.isRequired,
|
||||
selectedPixelRatio: PropTypes.number.isRequired,
|
||||
onChangeViewportPixelRatio: PropTypes.func.isRequired,
|
||||
},
|
||||
|
||||
mixins: [ addons.PureRenderMixin ],
|
||||
|
||||
getInitialState() {
|
||||
return {
|
||||
isFocused: false
|
||||
};
|
||||
},
|
||||
|
||||
onFocusChange({type}) {
|
||||
this.setState({
|
||||
isFocused: type === "focus"
|
||||
});
|
||||
},
|
||||
|
||||
onSelectChange({ target }) {
|
||||
this.props.onChangeViewportPixelRatio(+target.value);
|
||||
},
|
||||
|
||||
render() {
|
||||
let {
|
||||
devices,
|
||||
displayPixelRatio,
|
||||
selectedDevice,
|
||||
selectedPixelRatio,
|
||||
} = this.props;
|
||||
|
||||
let hiddenOptions = [];
|
||||
|
||||
for (let type of devices.types) {
|
||||
for (let device of devices[type]) {
|
||||
if (device.displayed &&
|
||||
!hiddenOptions.includes(device.pixelRatio) &&
|
||||
!PIXEL_RATIO_PRESET.includes(device.pixelRatio)) {
|
||||
hiddenOptions.push(device.pixelRatio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!PIXEL_RATIO_PRESET.includes(displayPixelRatio)) {
|
||||
hiddenOptions.push(displayPixelRatio);
|
||||
}
|
||||
|
||||
let state = devices.listState;
|
||||
let isDisabled = (state !== Types.deviceListState.LOADED) || (selectedDevice !== "");
|
||||
let selectorClass = "";
|
||||
let title;
|
||||
|
||||
if (isDisabled) {
|
||||
selectorClass += " disabled";
|
||||
title = getFormatStr("responsive.autoDPR", selectedDevice);
|
||||
} else {
|
||||
title = getStr("responsive.devicePixelRatio");
|
||||
|
||||
if (selectedPixelRatio) {
|
||||
selectorClass += " selected";
|
||||
}
|
||||
}
|
||||
|
||||
if (this.state.isFocused) {
|
||||
selectorClass += " focused";
|
||||
}
|
||||
|
||||
let listContent = PIXEL_RATIO_PRESET.map(createVisibleOption);
|
||||
|
||||
if (state == Types.deviceListState.LOADED) {
|
||||
listContent = listContent.concat(hiddenOptions.map(createHiddenOption));
|
||||
}
|
||||
|
||||
return dom.label(
|
||||
{
|
||||
id: "global-dpr-selector",
|
||||
className: selectorClass,
|
||||
title,
|
||||
},
|
||||
"DPR",
|
||||
dom.select(
|
||||
{
|
||||
value: selectedPixelRatio || displayPixelRatio,
|
||||
disabled: isDisabled,
|
||||
onChange: this.onSelectChange,
|
||||
onFocus: this.onFocusChange,
|
||||
onBlur: this.onFocusChange,
|
||||
},
|
||||
...listContent
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
});
|
|
@ -9,16 +9,22 @@ const { DOM: dom, createClass, createFactory, PropTypes, addons } =
|
|||
|
||||
const { getStr } = require("../utils/l10n");
|
||||
const Types = require("../types");
|
||||
const DPRSelector = createFactory(require("./dpr-selector"));
|
||||
const NetworkThrottlingSelector = createFactory(require("./network-throttling-selector"));
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "GlobalToolbar",
|
||||
|
||||
propTypes: {
|
||||
devices: PropTypes.shape(Types.devices).isRequired,
|
||||
displayPixelRatio: PropTypes.number.isRequired,
|
||||
networkThrottling: PropTypes.shape(Types.networkThrottling).isRequired,
|
||||
screenshot: PropTypes.shape(Types.screenshot).isRequired,
|
||||
selectedDevice: PropTypes.string.isRequired,
|
||||
selectedPixelRatio: PropTypes.number.isRequired,
|
||||
touchSimulation: PropTypes.shape(Types.touchSimulation).isRequired,
|
||||
onChangeNetworkThrottling: PropTypes.func.isRequired,
|
||||
onChangeViewportPixelRatio: PropTypes.func.isRequired,
|
||||
onExit: PropTypes.func.isRequired,
|
||||
onScreenshot: PropTypes.func.isRequired,
|
||||
onUpdateTouchSimulation: PropTypes.func.isRequired,
|
||||
|
@ -28,10 +34,15 @@ module.exports = createClass({
|
|||
|
||||
render() {
|
||||
let {
|
||||
devices,
|
||||
displayPixelRatio,
|
||||
networkThrottling,
|
||||
screenshot,
|
||||
selectedDevice,
|
||||
selectedPixelRatio,
|
||||
touchSimulation,
|
||||
onChangeNetworkThrottling,
|
||||
onChangeViewportPixelRatio,
|
||||
onExit,
|
||||
onScreenshot,
|
||||
onUpdateTouchSimulation
|
||||
|
@ -57,6 +68,13 @@ module.exports = createClass({
|
|||
networkThrottling,
|
||||
onChangeNetworkThrottling,
|
||||
}),
|
||||
DPRSelector({
|
||||
devices,
|
||||
displayPixelRatio,
|
||||
selectedDevice,
|
||||
selectedPixelRatio,
|
||||
onChangeViewportPixelRatio,
|
||||
}),
|
||||
dom.button({
|
||||
id: "global-touch-simulation-button",
|
||||
className: touchButtonClass,
|
||||
|
|
|
@ -8,6 +8,7 @@ DevToolsModules(
|
|||
'browser.js',
|
||||
'device-modal.js',
|
||||
'device-selector.js',
|
||||
'dpr-selector.js',
|
||||
'global-toolbar.js',
|
||||
'network-throttling-selector.js',
|
||||
'resizable-viewport.js',
|
||||
|
|
|
@ -86,6 +86,7 @@ select {
|
|||
background-size: 7px;
|
||||
border: none;
|
||||
color: var(--viewport-color);
|
||||
height: 100%;
|
||||
padding: 0 8px;
|
||||
text-align: center;
|
||||
text-overflow: ellipsis;
|
||||
|
@ -97,7 +98,7 @@ select.selected {
|
|||
color: var(--viewport-active-color);
|
||||
}
|
||||
|
||||
select:hover {
|
||||
select:not(:disabled):hover {
|
||||
background-image: var(--viewport-selection-arrow-hovered);
|
||||
color: var(--viewport-hover-color);
|
||||
}
|
||||
|
@ -188,6 +189,43 @@ select > option.divider {
|
|||
width: 103px;
|
||||
}
|
||||
|
||||
#global-dpr-selector > select {
|
||||
padding: 0 8px 0 0;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
#global-dpr-selector {
|
||||
margin: 0 8px;
|
||||
-moz-user-select: none;
|
||||
color: var(--viewport-color);
|
||||
font-size: 11px;
|
||||
height: 15px;
|
||||
}
|
||||
|
||||
#global-dpr-selector.focused,
|
||||
#global-dpr-selector:not(.disabled):hover {
|
||||
color: var(--viewport-hover-color);
|
||||
}
|
||||
|
||||
#global-dpr-selector:not(.disabled):hover > select {
|
||||
background-image: var(--viewport-selection-arrow-hovered);
|
||||
color: var(--viewport-hover-color);
|
||||
}
|
||||
|
||||
#global-dpr-selector:focus > select {
|
||||
background-image: var(--viewport-selection-arrow-selected);
|
||||
color: var(--viewport-active-color);
|
||||
}
|
||||
|
||||
#global-dpr-selector.selected,
|
||||
#global-dpr-selector.selected > select {
|
||||
color: var(--viewport-active-color);
|
||||
}
|
||||
|
||||
#global-dpr-selector > select > option {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#viewports {
|
||||
/* Make sure left-most viewport is visible when there's horizontal overflow.
|
||||
That is, when the horizontal space become smaller than the viewports and a
|
||||
|
|
|
@ -26,6 +26,7 @@ const message = require("./utils/message");
|
|||
const App = createFactory(require("./app"));
|
||||
const Store = require("./store");
|
||||
const { changeLocation } = require("./actions/location");
|
||||
const { changeDisplayPixelRatio } = require("./actions/display-pixel-ratio");
|
||||
const { addViewport, resizeViewport } = require("./actions/viewports");
|
||||
const { loadDevices } = require("./actions/devices");
|
||||
|
||||
|
@ -89,12 +90,30 @@ Object.defineProperty(window, "store", {
|
|||
enumerable: true,
|
||||
});
|
||||
|
||||
// Dispatch a `changeDisplayPixelRatio` action when the browser's pixel ratio is changing.
|
||||
// This is usually triggered when the user changes the monitor resolution, or when the
|
||||
// browser's window is dragged to a different display with a different pixel ratio.
|
||||
function onDPRChange() {
|
||||
let dpr = window.devicePixelRatio;
|
||||
let mql = window.matchMedia(`(resolution: ${dpr}dppx)`);
|
||||
|
||||
function listener() {
|
||||
bootstrap.dispatch(changeDisplayPixelRatio(window.devicePixelRatio));
|
||||
mql.removeListener(listener);
|
||||
onDPRChange();
|
||||
}
|
||||
|
||||
mql.addListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by manager.js to add the initial viewport based on the original page.
|
||||
*/
|
||||
window.addInitialViewport = contentURI => {
|
||||
try {
|
||||
onDPRChange();
|
||||
bootstrap.dispatch(changeLocation(contentURI));
|
||||
bootstrap.dispatch(changeDisplayPixelRatio(window.devicePixelRatio));
|
||||
bootstrap.dispatch(addViewport());
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
|
|
@ -452,6 +452,9 @@ ResponsiveUI.prototype = {
|
|||
case "change-viewport-device":
|
||||
this.onChangeViewportDevice(event);
|
||||
break;
|
||||
case "change-viewport-pixel-ratio":
|
||||
this.updateDPPX(event.data.pixelRatio);
|
||||
break;
|
||||
case "content-resize":
|
||||
this.onContentResize(event);
|
||||
break;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
"use strict";
|
||||
|
||||
exports.devices = require("./reducers/devices");
|
||||
exports.displayPixelRatio = require("./reducers/display-pixel-ratio");
|
||||
exports.location = require("./reducers/location");
|
||||
exports.networkThrottling = require("./reducers/network-throttling");
|
||||
exports.screenshot = require("./reducers/screenshot");
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/* 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/. */
|
||||
|
||||
/* eslint-env browser */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { CHANGE_DISPLAY_PIXEL_RATIO } = require("../actions/index");
|
||||
const INITIAL_DISPLAY_PIXEL_RATIO = 0;
|
||||
|
||||
let reducers = {
|
||||
|
||||
[CHANGE_DISPLAY_PIXEL_RATIO](_, action) {
|
||||
return action.displayPixelRatio;
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
module.exports = function (displayPixelRatio = INITIAL_DISPLAY_PIXEL_RATIO, action) {
|
||||
let reducer = reducers[action.type];
|
||||
if (!reducer) {
|
||||
return displayPixelRatio;
|
||||
}
|
||||
return reducer(displayPixelRatio, action);
|
||||
};
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
DevToolsModules(
|
||||
'devices.js',
|
||||
'display-pixel-ratio.js',
|
||||
'location.js',
|
||||
'network-throttling.js',
|
||||
'screenshot.js',
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
const {
|
||||
ADD_VIEWPORT,
|
||||
CHANGE_DEVICE,
|
||||
CHANGE_VIEWPORT_PIXEL_RATIO,
|
||||
RESIZE_VIEWPORT,
|
||||
ROTATE_VIEWPORT,
|
||||
} = require("../actions/index");
|
||||
|
@ -19,6 +20,7 @@ const INITIAL_VIEWPORT = {
|
|||
device: "",
|
||||
width: 320,
|
||||
height: 480,
|
||||
pixelRatio: 0,
|
||||
};
|
||||
|
||||
let reducers = {
|
||||
|
@ -43,6 +45,18 @@ let reducers = {
|
|||
});
|
||||
},
|
||||
|
||||
[CHANGE_VIEWPORT_PIXEL_RATIO](viewports, {id, pixelRatio }) {
|
||||
return viewports.map(viewport => {
|
||||
if (viewport.id !== id) {
|
||||
return viewport;
|
||||
}
|
||||
|
||||
return Object.assign({}, viewport, {
|
||||
pixelRatio,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
[RESIZE_VIEWPORT](viewports, { id, width, height }) {
|
||||
return viewports.map(viewport => {
|
||||
if (viewport.id !== id) {
|
||||
|
|
|
@ -21,6 +21,7 @@ support-files =
|
|||
[browser_device_modal_exit.js]
|
||||
[browser_device_modal_submit.js]
|
||||
[browser_device_width.js]
|
||||
[browser_dpr_change.js]
|
||||
[browser_exit_button.js]
|
||||
[browser_frame_script_active.js]
|
||||
[browser_menu_item_01.js]
|
||||
|
|
|
@ -43,7 +43,7 @@ addRDMTask(TEST_URL, function* ({ ui, manager }) {
|
|||
testViewportSelectLabel(ui, "no device selected");
|
||||
|
||||
// Test device with custom properties
|
||||
yield switchDevice(ui, "Fake Phone RDM Test");
|
||||
yield selectDevice(ui, "Fake Phone RDM Test");
|
||||
yield waitForViewportResizeTo(ui, testDevice.width, testDevice.height);
|
||||
yield testUserAgent(ui, testDevice.userAgent);
|
||||
yield testDevicePixelRatio(ui, testDevice.pixelRatio);
|
||||
|
@ -60,7 +60,7 @@ addRDMTask(TEST_URL, function* ({ ui, manager }) {
|
|||
testViewportSelectLabel(ui, "no device selected");
|
||||
|
||||
// Test device with generic properties
|
||||
yield switchDevice(ui, "Laptop (1366 x 768)");
|
||||
yield selectDevice(ui, "Laptop (1366 x 768)");
|
||||
yield waitForViewportResizeTo(ui, 1366, 768);
|
||||
yield testUserAgent(ui, DEFAULT_UA);
|
||||
yield testDevicePixelRatio(ui, 1);
|
||||
|
|
|
@ -0,0 +1,146 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Tests changing viewport device
|
||||
const TEST_URL = "data:text/html;charset=utf-8,DPR list test";
|
||||
const DEFAULT_DPPX = window.devicePixelRatio;
|
||||
const VIEWPORT_DPPX = DEFAULT_DPPX + 2;
|
||||
const Types = require("devtools/client/responsive.html/types");
|
||||
|
||||
const testDevice = {
|
||||
"name": "Fake Phone RDM Test",
|
||||
"width": 320,
|
||||
"height": 470,
|
||||
"pixelRatio": 5.5,
|
||||
"userAgent": "Mozilla/5.0 (Mobile; rv:39.0) Gecko/39.0 Firefox/39.0",
|
||||
"touch": true,
|
||||
"firefoxOS": true,
|
||||
"os": "custom",
|
||||
"featured": true,
|
||||
};
|
||||
|
||||
// Add the new device to the list
|
||||
addDeviceForTest(testDevice);
|
||||
|
||||
addRDMTask(TEST_URL, function* ({ ui, manager }) {
|
||||
yield waitStartup(ui);
|
||||
|
||||
yield testDefaults(ui);
|
||||
yield testChangingDevice(ui);
|
||||
yield testResetWhenResizingViewport(ui);
|
||||
yield testChangingDPR(ui);
|
||||
});
|
||||
|
||||
function* waitStartup(ui) {
|
||||
let { store } = ui.toolWindow;
|
||||
|
||||
// Wait until the viewport has been added and the device list has been loaded
|
||||
yield waitUntilState(store, state => state.viewports.length == 1
|
||||
&& state.devices.listState == Types.deviceListState.LOADED);
|
||||
}
|
||||
|
||||
function* testDefaults(ui) {
|
||||
info("Test Defaults");
|
||||
|
||||
yield testDevicePixelRatio(ui, window.devicePixelRatio);
|
||||
testViewportDPRSelect(ui, {value: window.devicePixelRatio, disabled: false});
|
||||
testViewportDeviceSelectLabel(ui, "no device selected");
|
||||
}
|
||||
|
||||
function* testChangingDevice(ui) {
|
||||
info("Test Changing Device");
|
||||
|
||||
let waitPixelRatioChange = onceDevicePixelRatioChange(ui);
|
||||
|
||||
yield selectDevice(ui, testDevice.name);
|
||||
yield waitForViewportResizeTo(ui, testDevice.width, testDevice.height);
|
||||
yield waitPixelRatioChange;
|
||||
yield testDevicePixelRatio(ui, testDevice.pixelRatio);
|
||||
testViewportDPRSelect(ui, {value: testDevice.pixelRatio, disabled: true});
|
||||
testViewportDeviceSelectLabel(ui, testDevice.name);
|
||||
}
|
||||
|
||||
function* testResetWhenResizingViewport(ui) {
|
||||
info("Test reset when resizing the viewport");
|
||||
|
||||
let waitPixelRatioChange = onceDevicePixelRatioChange(ui);
|
||||
|
||||
yield testViewportResize(ui, ".viewport-vertical-resize-handle",
|
||||
[-10, -10], [testDevice.width, testDevice.height - 10], [0, -10], ui);
|
||||
|
||||
yield waitPixelRatioChange;
|
||||
yield testDevicePixelRatio(ui, window.devicePixelRatio);
|
||||
|
||||
testViewportDPRSelect(ui, {value: window.devicePixelRatio, disabled: false});
|
||||
testViewportDeviceSelectLabel(ui, "no device selected");
|
||||
}
|
||||
|
||||
function* testChangingDPR(ui) {
|
||||
info("Test changing device pixel ratio");
|
||||
|
||||
let waitPixelRatioChange = onceDevicePixelRatioChange(ui);
|
||||
|
||||
yield selectDPR(ui, VIEWPORT_DPPX);
|
||||
yield waitPixelRatioChange;
|
||||
yield testDevicePixelRatio(ui, VIEWPORT_DPPX);
|
||||
testViewportDPRSelect(ui, {value: VIEWPORT_DPPX, disabled: false});
|
||||
testViewportDeviceSelectLabel(ui, "no device selected");
|
||||
}
|
||||
|
||||
function testViewportDPRSelect(ui, expected) {
|
||||
info("Test viewport's DPR Select");
|
||||
|
||||
let select = ui.toolWindow.document.querySelector("#global-dpr-selector > select");
|
||||
is(select.value, expected.value,
|
||||
`DPR Select value should be: ${expected.value}`);
|
||||
is(select.disabled, expected.disabled,
|
||||
`DPR Select should be ${expected.disabled ? "disabled" : "enabled"}.`);
|
||||
}
|
||||
|
||||
function testViewportDeviceSelectLabel(ui, expected) {
|
||||
info("Test viewport's device select label");
|
||||
|
||||
let select = ui.toolWindow.document.querySelector(".viewport-device-selector");
|
||||
is(select.selectedOptions[0].textContent, expected,
|
||||
`Device Select value should be: ${expected}`);
|
||||
}
|
||||
|
||||
function* testDevicePixelRatio(ui, expected) {
|
||||
info("Test device pixel ratio");
|
||||
|
||||
let dppx = yield getViewportDevicePixelRatio(ui);
|
||||
is(dppx, expected, `devicePixelRatio should be: ${expected}`);
|
||||
}
|
||||
|
||||
function* getViewportDevicePixelRatio(ui) {
|
||||
return yield ContentTask.spawn(ui.getViewportBrowser(), {}, function* () {
|
||||
return content.devicePixelRatio;
|
||||
});
|
||||
}
|
||||
|
||||
function onceDevicePixelRatioChange(ui) {
|
||||
return ContentTask.spawn(ui.getViewportBrowser(), {}, function* () {
|
||||
info(`Listening for a pixel ratio change (current: ${content.devicePixelRatio}dppx)`);
|
||||
|
||||
let pixelRatio = content.devicePixelRatio;
|
||||
let mql = content.matchMedia(`(resolution: ${pixelRatio}dppx)`);
|
||||
|
||||
return new Promise(resolve => {
|
||||
const onWindowCreated = () => {
|
||||
if (pixelRatio !== content.devicePixelRatio) {
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
|
||||
addEventListener("DOMWindowCreated", onWindowCreated, {once: true});
|
||||
|
||||
mql.addListener(function listener() {
|
||||
mql.removeListener(listener);
|
||||
removeEventListener("DOMWindowCreated", onWindowCreated, {once: true});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
|
@ -25,7 +25,7 @@ addRDMTask(TEST_URL, function* ({ ui, manager }) {
|
|||
yield testThrottlingProfile(ui, "Regular 3G");
|
||||
|
||||
// Test switching back to no throttling
|
||||
yield switchNetworkThrottling(ui, "No throttling");
|
||||
yield selectNetworkThrottling(ui, "No throttling");
|
||||
testNetworkThrottlingSelectorLabel(ui, "No throttling");
|
||||
yield testNetworkThrottlingState(ui, null);
|
||||
});
|
||||
|
@ -44,7 +44,7 @@ var testNetworkThrottlingState = Task.async(function* (ui, expected) {
|
|||
});
|
||||
|
||||
var testThrottlingProfile = Task.async(function* (ui, profile) {
|
||||
yield switchNetworkThrottling(ui, profile);
|
||||
yield selectNetworkThrottling(ui, profile);
|
||||
testNetworkThrottlingSelectorLabel(ui, profile);
|
||||
let data = throttlingProfiles.find(({ id }) => id == profile);
|
||||
let { download, upload, latency } = data;
|
||||
|
|
|
@ -211,29 +211,33 @@ function* testViewportResize(ui, selector, moveBy,
|
|||
`The y move of ${selector} is as expected`);
|
||||
}
|
||||
|
||||
function openDeviceModal(ui) {
|
||||
let { document } = ui.toolWindow;
|
||||
function openDeviceModal({toolWindow}) {
|
||||
let { document } = toolWindow;
|
||||
let select = document.querySelector(".viewport-device-selector");
|
||||
let modal = document.querySelector("#device-modal-wrapper");
|
||||
let editDeviceOption = [...select.options].filter(o => {
|
||||
return o.value === OPEN_DEVICE_MODAL_VALUE;
|
||||
})[0];
|
||||
|
||||
info("Checking initial device modal state");
|
||||
ok(modal.classList.contains("closed") && !modal.classList.contains("opened"),
|
||||
"The device modal is closed by default.");
|
||||
|
||||
info("Opening device modal through device selector.");
|
||||
EventUtils.synthesizeMouseAtCenter(select, {type: "mousedown"},
|
||||
ui.toolWindow);
|
||||
EventUtils.synthesizeMouseAtCenter(editDeviceOption, {type: "mouseup"},
|
||||
ui.toolWindow);
|
||||
|
||||
let event = new toolWindow.UIEvent("change", {
|
||||
view: toolWindow,
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
});
|
||||
|
||||
select.value = OPEN_DEVICE_MODAL_VALUE;
|
||||
select.dispatchEvent(event);
|
||||
|
||||
ok(modal.classList.contains("opened") && !modal.classList.contains("closed"),
|
||||
"The device modal is displayed.");
|
||||
}
|
||||
|
||||
function switchSelector({ toolWindow }, selector, value) {
|
||||
function changeSelectValue({ toolWindow }, selector, value) {
|
||||
info(`Selecting ${value} in ${selector}.`);
|
||||
|
||||
return new Promise(resolve => {
|
||||
let select = toolWindow.document.querySelector(selector);
|
||||
isnot(select, null, `selector "${selector}" should match an existing element.`);
|
||||
|
@ -258,17 +262,18 @@ function switchSelector({ toolWindow }, selector, value) {
|
|||
});
|
||||
}
|
||||
|
||||
let switchDevice = Task.async(function* (ui, value) {
|
||||
let changed = once(ui, "viewport-device-changed");
|
||||
yield switchSelector(ui, ".viewport-device-selector", value);
|
||||
yield changed;
|
||||
});
|
||||
const selectDevice = (ui, value) => Promise.all([
|
||||
once(ui, "viewport-device-changed"),
|
||||
changeSelectValue(ui, ".viewport-device-selector", value)
|
||||
]);
|
||||
|
||||
let switchNetworkThrottling = Task.async(function* (ui, value) {
|
||||
let changed = once(ui, "network-throttling-changed");
|
||||
yield switchSelector(ui, "#global-network-throttling-selector", value);
|
||||
yield changed;
|
||||
});
|
||||
const selectDPR = (ui, value) =>
|
||||
changeSelectValue(ui, "#global-dpr-selector > select", value);
|
||||
|
||||
const selectNetworkThrottling = (ui, value) => Promise.all([
|
||||
once(ui, "network-throttling-changed"),
|
||||
changeSelectValue(ui, "#global-network-throttling-selector", value)
|
||||
]);
|
||||
|
||||
function getSessionHistory(browser) {
|
||||
return ContentTask.spawn(browser, {}, function* () {
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Test changing the display pixel ratio.
|
||||
|
||||
const { changeDisplayPixelRatio } =
|
||||
require("devtools/client/responsive.html/actions/display-pixel-ratio");
|
||||
const NEW_PIXEL_RATIO = 5.5;
|
||||
|
||||
add_task(function* () {
|
||||
let store = Store();
|
||||
const { getState, dispatch } = store;
|
||||
|
||||
equal(getState().displayPixelRatio, 0,
|
||||
"Defaults to 0 at startup");
|
||||
|
||||
dispatch(changeDisplayPixelRatio(NEW_PIXEL_RATIO));
|
||||
equal(getState().displayPixelRatio, NEW_PIXEL_RATIO,
|
||||
`Display Pixel Ratio changed to ${NEW_PIXEL_RATIO}`);
|
||||
});
|
|
@ -0,0 +1,22 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Test changing the viewport pixel ratio.
|
||||
|
||||
const { addViewport, changeViewportPixelRatio } =
|
||||
require("devtools/client/responsive.html/actions/viewports");
|
||||
const NEW_PIXEL_RATIO = 5.5;
|
||||
|
||||
add_task(function* () {
|
||||
let store = Store();
|
||||
const { getState, dispatch } = store;
|
||||
|
||||
dispatch(addViewport());
|
||||
dispatch(changeViewportPixelRatio(0, NEW_PIXEL_RATIO));
|
||||
|
||||
let viewport = getState().viewports[0];
|
||||
equal(viewport.pixelRatio, NEW_PIXEL_RATIO,
|
||||
`Viewport's pixel ratio changed to ${NEW_PIXEL_RATIO}`);
|
||||
});
|
|
@ -7,9 +7,11 @@ firefox-appdir = browser
|
|||
[test_add_device.js]
|
||||
[test_add_device_type.js]
|
||||
[test_add_viewport.js]
|
||||
[test_change_display_pixel_ratio.js]
|
||||
[test_change_location.js]
|
||||
[test_change_network_throttling.js]
|
||||
[test_change_viewport_device.js]
|
||||
[test_change_viewport_pixel_ratio.js]
|
||||
[test_resize_viewport.js]
|
||||
[test_rotate_viewport.js]
|
||||
[test_update_device_displayed.js]
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.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/. */
|
||||
/* eslint no-unused-vars: [2, {"vars": "local"}] */
|
||||
|
||||
"use strict";
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html class="theme-light">
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<!-- 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/. -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
|
|
|
@ -658,7 +658,6 @@ stubPackets.set("console.log('foobar', 'test')", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -692,7 +691,6 @@ stubPackets.set("console.log(undefined)", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -724,7 +722,6 @@ stubPackets.set("console.warn('danger, will robinson!')", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -758,7 +755,6 @@ stubPackets.set("console.log(NaN)", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -792,7 +788,6 @@ stubPackets.set("console.log(null)", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -824,7 +819,6 @@ stubPackets.set("console.log('鼬')", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -854,7 +848,6 @@ stubPackets.set("console.clear()", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -889,7 +882,6 @@ stubPackets.set("console.count('bar')", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -942,7 +934,6 @@ stubPackets.set("console.assert(false, {message: 'foobar'})", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -983,7 +974,6 @@ stubPackets.set("console.log('hello \nfrom \rthe \"string world!')", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -1015,7 +1005,6 @@ stubPackets.set("console.log('úṇĩçödê țĕșť')", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -1059,7 +1048,6 @@ stubPackets.set("console.dirxml(window)", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -1089,7 +1077,6 @@ stubPackets.set("console.trace()", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -1144,7 +1131,6 @@ stubPackets.set("console.time('bar')", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -1179,7 +1165,6 @@ stubPackets.set("console.timeEnd('bar')", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -1214,7 +1199,6 @@ stubPackets.set("console.table('bar')", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -1263,7 +1247,6 @@ stubPackets.set("console.table(['a', 'b', 'c'])", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -1295,7 +1278,6 @@ stubPackets.set("console.group('bar')", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -1327,7 +1309,6 @@ stubPackets.set("console.groupEnd('bar')", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -1359,7 +1340,6 @@ stubPackets.set("console.groupCollapsed('foo')", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -1391,7 +1371,6 @@ stubPackets.set("console.groupEnd('foo')", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -1421,7 +1400,6 @@ stubPackets.set("console.group()", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -1451,7 +1429,6 @@ stubPackets.set("console.groupEnd()", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
@ -1484,7 +1461,6 @@ stubPackets.set("console.log(%cfoobar)", {
|
|||
"firstPartyDomain": "",
|
||||
"inIsolatedMozBrowser": false,
|
||||
"privateBrowsingId": 0,
|
||||
"signedPkg": "",
|
||||
"userContextId": 0
|
||||
},
|
||||
"private": false,
|
||||
|
|
|
@ -178,7 +178,6 @@ ChromeUtils::IsOriginAttributesEqual(dom::GlobalObject& aGlobal,
|
|||
return aA.mAddonId == aB.mAddonId &&
|
||||
aA.mAppId == aB.mAppId &&
|
||||
aA.mInIsolatedMozBrowser == aB.mInIsolatedMozBrowser &&
|
||||
aA.mSignedPkg == aB.mSignedPkg &&
|
||||
aA.mUserContextId == aB.mUserContextId &&
|
||||
aA.mPrivateBrowsingId == aB.mPrivateBrowsingId;
|
||||
}
|
||||
|
@ -189,7 +188,6 @@ ChromeUtils::IsOriginAttributesEqualIgnoringAddonId(const dom::OriginAttributesD
|
|||
{
|
||||
return aA.mAppId == aB.mAppId &&
|
||||
aA.mInIsolatedMozBrowser == aB.mInIsolatedMozBrowser &&
|
||||
aA.mSignedPkg == aB.mSignedPkg &&
|
||||
aA.mUserContextId == aB.mUserContextId &&
|
||||
aA.mPrivateBrowsingId == aB.mPrivateBrowsingId;
|
||||
}
|
||||
|
|
|
@ -328,30 +328,6 @@ nsFrameLoader::LoadURI(nsIURI* aURI)
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::SwitchProcessAndLoadURI(nsIURI* aURI, const nsACString& aPackageId)
|
||||
{
|
||||
RefPtr<TabParent> tp = nullptr;
|
||||
|
||||
MutableTabContext context;
|
||||
nsresult rv = GetNewTabContext(&context, aURI, aPackageId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<Element> ownerElement = mOwnerContent;
|
||||
tp = ContentParent::CreateBrowserOrApp(context, ownerElement, nullptr);
|
||||
if (!tp) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mRemoteBrowserShown = false;
|
||||
|
||||
rv = SwapRemoteBrowser(tp);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
LoadURI(aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::SetIsPrerendered()
|
||||
{
|
||||
|
@ -3093,52 +3069,6 @@ nsFrameLoader::SetRemoteBrowser(nsITabParent* aTabParent)
|
|||
ShowRemoteFrame(ScreenIntSize(0, 0));
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFrameLoader::SwapRemoteBrowser(nsITabParent* aTabParent)
|
||||
{
|
||||
RefPtr<TabParent> newParent = TabParent::GetFrom(aTabParent);
|
||||
if (!newParent || !mRemoteBrowser) {
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
}
|
||||
if (!IsRemoteFrame()) {
|
||||
NS_WARNING("Switching from in-process to out-of-process is not supported.");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
if (!OwnerIsMozBrowserOrAppFrame()) {
|
||||
NS_WARNING("Switching process for non-mozbrowser/app frame is not supported.");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
if (newParent == mRemoteBrowser) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MaybeUpdatePrimaryTabParent(eTabParentRemoved);
|
||||
mRemoteBrowser->CacheFrameLoader(nullptr);
|
||||
mRemoteBrowser->SetOwnerElement(nullptr);
|
||||
mRemoteBrowser->Detach();
|
||||
mRemoteBrowser->Destroy();
|
||||
|
||||
mRemoteBrowser = newParent;
|
||||
mRemoteBrowser->Attach(this);
|
||||
mChildID = mRemoteBrowser->Manager()->ChildID();
|
||||
|
||||
MaybeUpdatePrimaryTabParent(eTabParentChanged);
|
||||
|
||||
// Force the new remote frame manager to load pending scripts
|
||||
mMessageManager->LoadPendingScripts();
|
||||
|
||||
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||
if (os) {
|
||||
os->NotifyObservers(NS_ISUPPORTS_CAST(nsIFrameLoader*, this),
|
||||
"remote-browser-swapped", nullptr);
|
||||
}
|
||||
if (!mRemoteBrowserShown) {
|
||||
ShowRemoteFrame(ScreenIntSize(0, 0));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsFrameLoader::SetDetachedSubdocFrame(nsIFrame* aDetachedFrame,
|
||||
nsIDocument* aContainerDoc)
|
||||
|
@ -3462,8 +3392,7 @@ nsFrameLoader::MaybeUpdatePrimaryTabParent(TabParentChange aChange)
|
|||
|
||||
nsresult
|
||||
nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
|
||||
nsIURI* aURI,
|
||||
const nsACString& aPackageId)
|
||||
nsIURI* aURI)
|
||||
{
|
||||
nsCOMPtr<mozIApplication> ownApp = GetOwnApp();
|
||||
nsCOMPtr<mozIApplication> containingApp = GetContainingApp();
|
||||
|
@ -3471,13 +3400,6 @@ nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
|
|||
attrs.mInIsolatedMozBrowser = OwnerIsIsolatedMozBrowserFrame();
|
||||
nsresult rv;
|
||||
|
||||
nsCString signedPkgOrigin;
|
||||
if (!aPackageId.IsEmpty()) {
|
||||
// Only when aPackageId is not empty would signed package origin
|
||||
// be meaningful.
|
||||
nsPrincipal::GetOriginForURI(aURI, signedPkgOrigin);
|
||||
}
|
||||
|
||||
// Get the AppId from ownApp
|
||||
uint32_t appId = nsIScriptSecurityManager::NO_APP_ID;
|
||||
if (ownApp) {
|
||||
|
@ -3491,9 +3413,6 @@ nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
|
|||
}
|
||||
attrs.mAppId = appId;
|
||||
|
||||
// Populate packageId to signedPkg.
|
||||
attrs.mSignedPkg = NS_ConvertUTF8toUTF16(aPackageId);
|
||||
|
||||
// set the userContextId on the attrs before we pass them into
|
||||
// the tab context
|
||||
rv = PopulateUserContextIdFromAttribute(attrs);
|
||||
|
@ -3532,7 +3451,6 @@ nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
|
|||
showAccelerators,
|
||||
showFocusRings,
|
||||
attrs,
|
||||
signedPkgOrigin,
|
||||
presentationURLStr);
|
||||
NS_ENSURE_STATE(tabContextUpdated);
|
||||
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче