Skip to content

Commit

Permalink
Merge inbound to mozilla-central. a=merge
Browse files Browse the repository at this point in the history
  • Loading branch information
nerli1 committed Oct 8, 2018
2 parents 67d0cf7 + 504ea44 commit 31184dd
Show file tree
Hide file tree
Showing 49 changed files with 1,288 additions and 114 deletions.
10 changes: 5 additions & 5 deletions browser/components/urlbar/UrlbarInput.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ class UrlbarInput {
// Private methods below.

_updateTextOverflow() {
if (!this._inOverflow) {
if (!this._overflowing) {
this.removeAttribute("textoverflow");
return;
}

this.window.promiseDocumentFlushed(() => {
// Check overflow again to ensure it didn't change in the meantime.
let input = this.inputField;
if (input && this._inOverflow) {
if (input && this._overflowing) {
let side = input.scrollLeft &&
input.scrollLeft == input.scrollLeftMax ? "start" : "end";
this.setAttribute("textoverflow", side);
Expand All @@ -212,7 +212,7 @@ class UrlbarInput {
}

_updateUrlTooltip() {
if (this.focused || !this._inOverflow) {
if (this.focused || !this._overflowing) {
this.inputField.removeAttribute("title");
} else {
this.inputField.setAttribute("title", this.value);
Expand Down Expand Up @@ -392,7 +392,7 @@ class UrlbarInput {
if (targetIsPlaceholder) {
return;
}
this._inOverflow = true;
this._overflowing = true;
this._updateTextOverflow();
}

Expand All @@ -404,7 +404,7 @@ class UrlbarInput {
if (targetIsPlaceholder) {
return;
}
this._inOverflow = false;
this._overflowing = false;

this._updateTextOverflow();

Expand Down
11 changes: 9 additions & 2 deletions devtools/client/netmonitor/src/selectors/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,17 @@ function sortWithClones(requests, sorter, a, b) {
return sorter(a, b);
}

const getFilterFn = createSelector(
/**
* Take clones into account when filtering. If a request is
* a clone, it's not filtered out.
*/
const getFilterWithCloneFn = createSelector(
state => state.filters,
filters => r => {
const matchesType = Object.keys(filters.requestFilterTypes).some(filter => {
if (r.id.endsWith("-clone")) {
return true;
}
return filters.requestFilterTypes[filter] && Filters[filter] && Filters[filter](r);
});
return matchesType && isFreetextMatch(r, filters.requestFilterText);
Expand Down Expand Up @@ -78,7 +85,7 @@ const getSortedRequests = createSelector(

const getDisplayedRequests = createSelector(
state => state.requests,
getFilterFn,
getFilterWithCloneFn,
getSortFn,
({ requests }, filterFn, sortFn) => {
const arr = [...requests.values()].filter(filterFn).sort(sortFn);
Expand Down
1 change: 1 addition & 0 deletions devtools/client/netmonitor/test/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ subsuite = clipboard
skip-if = (os == 'mac') # Bug 1479782
[browser_net_header-docs.js]
[browser_net_edit_resend_caret.js]
[browser_net_edit_resend_with_filtering.js]
[browser_net_filter-01.js]
[browser_net_filter-02.js]
[browser_net_filter-03.js]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/**
* Tests if resending a XHR request while filtering XHR displays
* the correct requests
*/
add_task(async function() {
const { tab, monitor } = await initNetMonitor(POST_RAW_URL);

const { document, store, windowRequire, parent } = monitor.panelWin;
const parentDocument = parent.document;
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
store.dispatch(Actions.batchEnable(false));

// Execute XHR request and filter by XHR
await performRequests(monitor, tab, 1);
document.querySelector(".requests-list-filter-xhr-button").click();

// Confirm XHR request and click it
const xhrRequestItem = document.querySelectorAll(".request-list-item")[0];
EventUtils.sendMouseEvent({ type: "mousedown" }, xhrRequestItem);

const {
getSelectedRequest
} = windowRequire("devtools/client/netmonitor/src/selectors/index");
const firstRequest = getSelectedRequest(store.getState());

// Open context menu and execute "Edit & Resend".
EventUtils.sendMouseEvent({ type: "contextmenu" }, xhrRequestItem);
parentDocument.querySelector("#request-list-context-resend").click();

// Click Resend
await waitUntil(() => document.querySelector("#custom-request-send-button"));
document.querySelector("#custom-request-send-button").click();

// Filtering by "other" so the resent request is visible after completion
document.querySelector(".requests-list-filter-other-button").click();

// Select the cloned request
document.querySelectorAll(".request-list-item")[0].click();
const resendRequest = getSelectedRequest(store.getState());

ok(resendRequest.id !== firstRequest.id,
"The second XHR request was made and is unique");

ok(resendRequest.id.replace(/-clone$/, "") == firstRequest.id,
"The second XHR request is a clone of the first");

return teardown(monitor);
});
65 changes: 63 additions & 2 deletions dom/base/nsFrameLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@
#include "mozilla/dom/ChromeMessageSender.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/FrameLoaderBinding.h"
#include "mozilla/gfx/CrossProcessPaint.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "mozilla/layout/RenderFrameParent.h"
#include "mozilla/ServoCSSParser.h"
#include "mozilla/ServoStyleSet.h"
#include "nsGenericHTMLFrameElement.h"
#include "GeckoProfiler.h"

Expand Down Expand Up @@ -129,8 +132,8 @@ typedef FrameMetrics::ViewID ViewID;
// itself. Note that "#foo" on the end of URL doesn't affect
// whether it's considered identical, but "?foo" or ";foo" are
// considered and compared.
// Bug 228829: Limit this to 1, like IE does.
#define MAX_SAME_URL_CONTENT_FRAMES 1
// Limit this to 2, like chromium does.
#define MAX_SAME_URL_CONTENT_FRAMES 2

// Bug 8065: Limit content frame depth to some reasonable level. This
// does not count chrome frames when determining depth, nor does it
Expand Down Expand Up @@ -3103,6 +3106,64 @@ nsFrameLoader::Print(uint64_t aOuterWindowID,
#endif
}

already_AddRefed<mozilla::dom::Promise>
nsFrameLoader::DrawSnapshot(double aX,
double aY,
double aW,
double aH,
double aScale,
const nsAString& aBackgroundColor,
mozilla::ErrorResult& aRv)
{
RefPtr<nsIGlobalObject> global = GetOwnerContent()->GetOwnerGlobal();
RefPtr<Promise> promise = Promise::Create(global, aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}

RefPtr<nsIDocument> document = GetOwnerContent()->GetOwnerDocument();
if (NS_WARN_IF(!document)) {
aRv = NS_ERROR_FAILURE;
return nullptr;
}
nsIPresShell* presShell = document->GetShell();
if (NS_WARN_IF(!presShell)) {
aRv = NS_ERROR_FAILURE;
return nullptr;
}

nscolor color;
css::Loader* loader = document->CSSLoader();
ServoStyleSet* set = presShell->StyleSet();
if (NS_WARN_IF(!ServoCSSParser::ComputeColor(set,
NS_RGB(0, 0, 0),
aBackgroundColor,
&color,
nullptr,
loader))) {
aRv = NS_ERROR_FAILURE;
return nullptr;
}

gfx::IntRect rect = gfx::IntRect::RoundOut(gfx::Rect(aX, aY, aW, aH));

if (IsRemoteFrame()) {
gfx::CrossProcessPaint::StartRemote(mRemoteBrowser->GetTabId(),
rect,
aScale,
color,
promise);
} else {
gfx::CrossProcessPaint::StartLocal(mDocShell,
rect,
aScale,
color,
promise);
}

return promise.forget();
}

already_AddRefed<nsITabParent>
nsFrameLoader::GetTabParent()
{
Expand Down
9 changes: 9 additions & 0 deletions dom/base/nsFrameLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ class nsFrameLoader final : public nsStubMutationObserver,
nsIWebProgressListener* aProgressListener,
mozilla::ErrorResult& aRv);

already_AddRefed<mozilla::dom::Promise>
DrawSnapshot(double aX,
double aY,
double aW,
double aH,
double aScale,
const nsAString& aBackgroundColor,
mozilla::ErrorResult& aRv);

void StartPersistence(uint64_t aOuterWindowID,
nsIWebBrowserPersistDocumentReceiver* aRecv,
mozilla::ErrorResult& aRv);
Expand Down
11 changes: 11 additions & 0 deletions dom/canvas/ImageBitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,17 @@ ImageBitmap::ToCloneData() const
return result;
}

/* static */ already_AddRefed<ImageBitmap>
ImageBitmap::CreateFromSourceSurface(nsIGlobalObject* aGlobal,
gfx::SourceSurface* aSource,
ErrorResult& aRv)
{
RefPtr<layers::Image> data = CreateImageFromSurface(aSource);
RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, data);
ret->mAllocatedImageData = true;
return ret.forget();
}

/* static */ already_AddRefed<ImageBitmap>
ImageBitmap::CreateFromCloneData(nsIGlobalObject* aGlobal,
ImageBitmapCloneData* aData)
Expand Down
5 changes: 5 additions & 0 deletions dom/canvas/ImageBitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ class ImageBitmap final : public nsISupports,
UniquePtr<ImageBitmapCloneData>
ToCloneData() const;

static already_AddRefed<ImageBitmap>
CreateFromSourceSurface(nsIGlobalObject* aGlobal,
gfx::SourceSurface* aSource,
ErrorResult& aRv);

static already_AddRefed<ImageBitmap>
CreateFromCloneData(nsIGlobalObject* aGlobal, ImageBitmapCloneData* aData);

Expand Down
1 change: 1 addition & 0 deletions dom/html/test/mochitest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -607,3 +607,4 @@ support-files =
[test_getElementsByName_after_mutation.html]
[test_bug1279218.html]
[test_set_input_files.html]
[test_nestediframe.html]
55 changes: 55 additions & 0 deletions dom/html/test/test_nestediframe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for same URLs nested iframes</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script>

SimpleTest.waitForExplicitFinish();

function reportState(msg) {
if (location.href.includes("#")) {
parent.postMessage(msg, "*");
return;
}

if (msg == "OK 1") {
ok(true, "First frame loaded");
} else if (msg == "KO 2") {
ok(true, "Second frame load failed");
SimpleTest.finish();
} else {
ok(false, "Unknown message: " + msg);
}
}

addEventListener("message", event => {
reportState(event.data);
});

var recursion;
if (!location.href.includes("#")) {
recursion = 1;
} else {
recursion = parseInt(localStorage.recursion) + 1;
}
localStorage.recursion = "" + recursion;

var ifr = document.createElement('iframe');
ifr.src = location.href.split("#")[0] + "#" + recursion;
document.body.appendChild(ifr);

ifr.onload = function() {
reportState("OK " + recursion);
}

ifr.onerror = function() {
reportState("KO " + recursion);
}

</script>
</body>
</html>
17 changes: 17 additions & 0 deletions dom/ipc/ContentProcessManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ ContentProcessManager::RegisterRemoteFrame(const TabId& aTabId,
}

iter->second.mRemoteFrames[aTabId] = info;
mTabProcessMap[aTabId] = aChildCpId;
return true;
}

Expand All @@ -200,6 +201,11 @@ ContentProcessManager::UnregisterRemoteFrame(const ContentParentId& aChildCpId,
if (remoteFrameIter != iter->second.mRemoteFrames.end()) {
iter->second.mRemoteFrames.erase(aChildTabId);
}

auto tabProcessIter = mTabProcessMap.find(aChildTabId);
if (tabProcessIter != mTabProcessMap.end()) {
mTabProcessMap.erase(tabProcessIter);
}
}

bool
Expand Down Expand Up @@ -273,6 +279,17 @@ ContentProcessManager::GetRemoteFrameOpenerTabId(const ContentParentId& aChildCp
return true;
}

ContentParentId
ContentProcessManager::GetTabProcessId(const TabId& aTabId)
{
auto tabProcessIter = mTabProcessMap.find(aTabId);
MOZ_ASSERT(tabProcessIter != mTabProcessMap.end());
if (tabProcessIter == mTabProcessMap.end()) {
return ContentParentId(0);
}
return tabProcessIter->second;
}

already_AddRefed<TabParent>
ContentProcessManager::GetTabParentByProcessAndTabId(const ContentParentId& aChildCpId,
const TabId& aChildTabId)
Expand Down
7 changes: 7 additions & 0 deletions dom/ipc/ContentProcessManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ class ContentProcessManager final
/*out*/ContentParentId* aOpenerCpId,
/*out*/ TabId* aOpenerTabId);

/**
* Get the ContentParentId of the parent of the given tab id.
*/
ContentParentId
GetTabProcessId(const TabId& aTabId);

/**
* Get all TabParents' Ids managed by the givent content process.
* Return empty array when TabParent couldn't be found via aChildCpId
Expand Down Expand Up @@ -157,6 +163,7 @@ class ContentProcessManager final
private:
static StaticAutoPtr<ContentProcessManager> sSingleton;
std::map<ContentParentId, ContentProcessInfo> mContentParentMap;
std::map<TabId, ContentParentId> mTabProcessMap;

ContentProcessManager() {MOZ_COUNT_CTOR(ContentProcessManager);};
};
Expand Down
Loading

0 comments on commit 31184dd

Please sign in to comment.