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
nbeleuzu committed Feb 16, 2018
2 parents 52a54e4 + 0aeff2d commit cb03a12
Show file tree
Hide file tree
Showing 217 changed files with 35,503 additions and 1,165 deletions.
14 changes: 14 additions & 0 deletions browser/components/extensions/ExtensionPopups.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class BasePopup {
});

this.viewNode.addEventListener(this.DESTROY_EVENT, this);
this.panel.addEventListener("popuppositioned", this, {once: true, capture: true});

this.browser = null;
this.browserLoaded = new Promise((resolve, reject) => {
Expand Down Expand Up @@ -211,6 +212,18 @@ class BasePopup {
this.destroy();
}
break;
case "popuppositioned":
if (!this.destroyed) {
this.browserLoaded.then(() => {
if (this.destroyed) {
return;
}
this.browser.messageManager.sendAsyncMessage("Extension:GrabFocus", {});
}).catch(() => {
// If the panel closes too fast an exception is raised here and tests will fail.
});
}
break;
}
}

Expand Down Expand Up @@ -438,6 +451,7 @@ class ViewPopup extends BasePopup {
this.viewNode.addEventListener(this.DESTROY_EVENT, this);
this.viewNode.setAttribute("closemenu", "none");

this.panel.addEventListener("popuppositioned", this, {once: true, capture: true});
if (this.extension.remote) {
this.panel.setAttribute("remote", "true");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ skip-if = (os == 'win' && ccov) # Bug 1423667
[browser_ext_popup_api_injection.js]
[browser_ext_popup_background.js]
[browser_ext_popup_corners.js]
[browser_ext_popup_focus.js]
[browser_ext_popup_sendMessage.js]
[browser_ext_popup_shutdown.js]
[browser_ext_runtime_openOptionsPage.js]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ add_task(async function() {
is((await extension.awaitMessage("result")), winId, `${name} is on top (check 3) [${kind}]`);
}

await focusWindow(win1);
await checkWindow("background", winId1, "win1");
await focusWindow(win2);
await checkWindow("background", winId2, "win2");

async function triggerPopup(win, callback) {
await clickBrowserAction(extension, win);
await awaitExtensionPanel(extension, win);
Expand All @@ -120,13 +115,14 @@ add_task(async function() {
closeBrowserAction(extension, win);
}

// Set focus to some other window.
await focusWindow(window);

await focusWindow(win1);
await checkWindow("background", winId1, "win1");
await triggerPopup(win1, async function() {
await checkWindow("popup", winId1, "win1");
});

await focusWindow(win2);
await checkWindow("background", winId2, "win2");
await triggerPopup(win2, async function() {
await checkWindow("popup", winId2, "win2");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ add_task(async function() {
await checkViewsWithFilter({tabId: tabId2}, 1);

async function triggerPopup(win, callback) {
// Window needs focus to open popups.
await focusWindow(win);
await clickBrowserAction(extension, win);
await awaitExtensionPanel(extension, win);

Expand All @@ -158,12 +160,6 @@ add_task(async function() {
closeBrowserAction(extension, win);
}

// The popup occasionally closes prematurely if we open it immediately here.
// I'm not sure what causes it to close (it's something internal, and seems to
// be focus-related, but it's not caused by JS calling hidePopup), but even a
// short timeout seems to consistently fix it.
await new Promise(resolve => win1.setTimeout(resolve, 10));

await triggerPopup(win1, async function() {
await checkViews("background", 2, 1, 0);
await checkViews("popup", 2, 1, 1);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";

const DUMMY_PAGE = "http://example.com/browser/browser/components/extensions/test/browser/file_dummy.html";

add_task(async function testPageActionFocus() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
"page_action": {
"default_popup": "popup.html",
"show_matches": ["<all_urls>"],
},
},
files: {
"popup.html": `<!DOCTYPE html><html><head><meta charset="utf-8">
<script src="popup.js"></script>
</head><body>
</body></html>
`,
"popup.js": function() {
window.addEventListener("focus", (event) => {
browser.test.assertEq(true, document.hasFocus(), "document should be focused");
browser.test.notifyPass("focused");
}, {once: true});
},
},
});
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, DUMMY_PAGE);

await extension.startup();
let finish = extension.awaitFinish("focused");
await clickPageAction(extension);
await finish;
await closePageAction(extension);

await BrowserTestUtils.removeTab(tab);
await extension.unload();
});

add_task(async function testBrowserActionFocus() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
"browser_action": {"default_popup": "popup.html"},
},
files: {
"popup.html": `<!DOCTYPE html><html><head><meta charset="utf-8">
<script src="popup.js"></script>
</head><body>
</body></html>
`,
"popup.js": function() {
window.addEventListener("focus", (event) => {
browser.test.assertEq(true, document.hasFocus(), "document should be focused");
browser.test.notifyPass("focused");
}, {once: true});
},
},
});
await extension.startup();

let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, DUMMY_PAGE);
let finish = extension.awaitFinish("focused");
await clickBrowserAction(extension);
await finish;

await closeBrowserAction(extension);

await BrowserTestUtils.removeTab(tab);
await extension.unload();
});
2 changes: 1 addition & 1 deletion browser/components/migration/tests/marionette/manifest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
run-if = buildapp == 'browser'

[test_refresh_firefox.py]

skip-if = (os == 'win' && !debug) #bug 1425323
11 changes: 9 additions & 2 deletions build/moz.configure/windows.configure
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,19 @@ def valid_ucrt_sdk_dir(windows_sdk_dir, windows_sdk_dir_env):
@depends(c_compiler)
@imports('os')
def vc_path(c_compiler):
if c_compiler.type != 'msvc':
if c_compiler.type not in ('msvc', 'clang-cl'):
return

# Normally, we'd start from c_compiler.compiler, but for now, it's not the
# ideal full path to the compiler. At least, we're guaranteed find_program
# will get us the one we found in toolchain.configure.
cl = find_program(c_compiler.compiler)
vc_program = c_compiler.compiler

# In clang-cl builds, we use the headers and libraries from an MSVC installation.
if c_compiler.type == 'clang-cl':
vc_program = 'cl.exe'

cl = find_program(vc_program)
result = os.path.dirname(cl)
while True:
next, p = os.path.split(result)
Expand Down
9 changes: 0 additions & 9 deletions build/sanitizers/ubsan_signed_overflow_blacklist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ src:*/mfbt/double-conversion/source/bignum.cc
# Exclude anything within gtests
src:*/gtest/*

# The JS engine has a lot of code doing all sorts of overflows. This code
# is pretty well tested though and excluding it here will allow us to go
# for other, less tested code. Ideally, we would include the JS engine here
# at some point.
src:*/js/src/*
src:*/js/public/*
src:*/js/*.h
src:*/jsfriendapi.h

# Atomics can overflow, but without a full stack we can't trace these back
# to what is actually causing the overflow. Ignoring these for now, as it will
# be too much effort to determine every single source here.
Expand Down
47 changes: 35 additions & 12 deletions devtools/server/actors/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -907,25 +907,48 @@ let SourceActor = ActorClassWithSpec(sourceSpec, {
entryPoints.push({ script, offsets });
}
}
} else {
// This is a column breakpoint, so we are interested in all column
// offsets that correspond to the given line *and* column number.

if (entryPoints.length > 0) {
setBreakpointAtEntryPoints(actor, entryPoints);
return true;
}

return false;
}

// This is a column breakpoint, so we are interested in all column
// offsets that correspond to the given line *and* column number.
for (let script of scripts) {
let columnToOffsetMap = script.getAllColumnOffsets()
.filter(({ lineNumber }) => {
return lineNumber === generatedLine;
});
for (let { columnNumber: column, offset } of columnToOffsetMap) {
if (column >= generatedColumn && column <= generatedLastColumn) {
entryPoints.push({ script, offsets: [offset] });
}
}
}

// If we don't find any matching entrypoints, then
// we should check to see if the breakpoint is to the left of the first offset.
if (entryPoints.length === 0) {
for (let script of scripts) {
let columnToOffsetMap = script.getAllColumnOffsets()
.filter(({ lineNumber }) => {
return lineNumber === generatedLine;
});
for (let { columnNumber: column, offset } of columnToOffsetMap) {
if (column >= generatedColumn && column <= generatedLastColumn) {
let columnToOffsetMap = script
.getAllColumnOffsets()
.filter(({ lineNumber }) => {
return lineNumber === generatedLine;
});

if (columnToOffsetMap.length > 0) {
let { columnNumber: column, offset } = columnToOffsetMap[0];
if (generatedColumn < column) {
entryPoints.push({ script, offsets: [offset] });
}
}
}
}

if (entryPoints.length === 0) {
return false;
}
setBreakpointAtEntryPoints(actor, entryPoints);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"use strict";

var SOURCE_URL = getFileUrl("setBreakpoint-on-column.js");

function run_test() {
return Task.spawn(function* () {
do_test_pending();

DebuggerServer.registerModule("xpcshell-test/testactors");
DebuggerServer.init(() => true);

let global = createTestGlobal("test");
DebuggerServer.addTestGlobal(global);

let client = new DebuggerClient(DebuggerServer.connectPipe());
yield connect(client);

let { tabs } = yield listTabs(client);
let tab = findTab(tabs, "test");
let [, tabClient] = yield attachTab(client, tab);
let [, threadClient] = yield attachThread(tabClient);
yield resume(threadClient);

let promise = waitForNewSource(threadClient, SOURCE_URL);
loadSubScript(SOURCE_URL, global);
let { source } = yield promise;
let sourceClient = threadClient.source(source);

let location = { line: 4, column: 2 };
let [packet, breakpointClient] = yield setBreakpoint(
sourceClient,
location
);

Assert.ok(!packet.isPending);
Assert.equal(false, "actualLocation" in packet);

packet = yield executeOnNextTickAndWaitForPause(function () {
Cu.evalInSandbox("f()", global);
}, client);

Assert.equal(packet.type, "paused");
let why = packet.why;
Assert.equal(why.type, "breakpoint");
Assert.equal(why.actors.length, 1);
Assert.equal(why.actors[0], breakpointClient.actor);

let frame = packet.frame;
let where = frame.where;
Assert.equal(where.source.actor, source.actor);
Assert.equal(where.line, location.line);
Assert.equal(where.column, 6);

let variables = frame.environment.bindings.variables;
Assert.equal(variables.a.value.type, "undefined");
Assert.equal(variables.b.value.type, "undefined");
Assert.equal(variables.c.value.type, "undefined");

yield resume(threadClient);
yield close(client);

do_test_finished();
});
}
1 change: 1 addition & 0 deletions devtools/server/tests/unit/xpcshell.ini
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ reason = bug 937197
[test_get-executable-lines-source-map.js]
[test_xpcshell_debugging.js]
support-files = xpcshell_debugging_script.js
[test_setBreakpoint-at-the-beginning-of-a-line.js]
[test_setBreakpoint-on-column.js]
[test_setBreakpoint-on-column-in-gcd-script.js]
[test_setBreakpoint-on-column-with-no-offsets-at-end-of-line.js]
Expand Down
3 changes: 1 addition & 2 deletions devtools/shared/builtin-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const promise = require("resource://gre/modules/Promise.jsm").Promise;
const jsmScope = require("resource://gre/modules/Services.jsm");
const { Services } = jsmScope;
// Steal various globals only available in JSM scope (and not Sandbox one)
const { PromiseDebugging, ChromeUtils, HeapSnapshot,
const { ChromeUtils, HeapSnapshot,
atob, btoa, TextEncoder, TextDecoder } = Cu.getGlobalForObject(jsmScope);

// Create a single Sandbox to access global properties needed in this module.
Expand Down Expand Up @@ -178,7 +178,6 @@ exports.modules = {
// and so are never frozen, even if the browser loader module which
// pull it is destroyed. See bug 1402779.
Promise,
PromiseDebugging,
ChromeUtils,
HeapSnapshot,
InspectorUtils,
Expand Down
9 changes: 5 additions & 4 deletions dom/base/nsRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3473,7 +3473,8 @@ nsRange::GetClientRectsAndTexts(
}

nsresult
nsRange::GetUsedFontFaces(nsTArray<nsAutoPtr<InspectorFontFace>>& aResult)
nsRange::GetUsedFontFaces(nsTArray<nsAutoPtr<InspectorFontFace>>& aResult,
uint32_t aMaxRanges)
{
NS_ENSURE_TRUE(mStart.Container(), NS_ERROR_UNEXPECTED);

Expand Down Expand Up @@ -3517,17 +3518,17 @@ nsRange::GetUsedFontFaces(nsTArray<nsAutoPtr<InspectorFontFace>>& aResult)
int32_t offset = startContainer == endContainer ?
mEnd.Offset() : content->GetText()->GetLength();
nsLayoutUtils::GetFontFacesForText(frame, mStart.Offset(), offset,
true, fontFaces);
true, fontFaces, aMaxRanges);
continue;
}
if (node == endContainer) {
nsLayoutUtils::GetFontFacesForText(frame, 0, mEnd.Offset(),
true, fontFaces);
true, fontFaces, aMaxRanges);
continue;
}
}

nsLayoutUtils::GetFontFacesForFrames(frame, fontFaces);
nsLayoutUtils::GetFontFacesForFrames(frame, fontFaces, aMaxRanges);
}

// Take ownership of the InspectorFontFaces in the table and move them into
Expand Down
Loading

0 comments on commit cb03a12

Please sign in to comment.