Skip to content

Commit

Permalink
Merge m-i to m-c, a=merge
Browse files Browse the repository at this point in the history
  • Loading branch information
philor committed Feb 14, 2016
2 parents 159f125 + fad51b1 commit a6d7a8a
Show file tree
Hide file tree
Showing 220 changed files with 2,680 additions and 6,753 deletions.
24 changes: 23 additions & 1 deletion browser/base/content/browser-context.inc
Expand Up @@ -57,7 +57,29 @@
<menuitem id="context-openlinkintab"
label="&openLinkCmdInTab.label;"
accesskey="&openLinkCmdInTab.accesskey;"
oncommand="gContextMenu.openLinkInTab();"/>
usercontextid="0"
oncommand="gContextMenu.openLinkInTab(event);"/>

<menu id="context-openlinkinusercontext-menu"
label="&openLinkCmdInContainerTab.label;"
accesskey="&openLinkCmdInContainerTab.accesskey;"
hidden="true">
<menupopup oncommand="gContextMenu.openLinkInTab(event);">
<menuitem label="&userContextPersonal.label;"
usercontextid="1"
accesskey="&userContextPersonal.accesskey;"/>
<menuitem label="&userContextWork.label;"
usercontextid="2"
accesskey="&userContextWork.accesskey;"/>
<menuitem label="&userContextBanking.label;"
usercontextid="3"
accesskey="&userContextBanking.accesskey;"/>
<menuitem label="&userContextShopping.label;"
usercontextid="4"
accesskey="&userContextShopping.accesskey;"/>
</menupopup>
</menu>

<menuitem id="context-openlink"
label="&openLinkCmd.label;"
accesskey="&openLinkCmd.accesskey;"
Expand Down
14 changes: 11 additions & 3 deletions browser/base/content/browser-safebrowsing.js
Expand Up @@ -8,9 +8,14 @@
var gSafeBrowsing = {

setReportPhishingMenu: function() {
// A phishing page will have a specific about:blocked content documentURI
var uri = gBrowser.currentURI;
var isPhishingPage = uri && uri.spec.startsWith("about:blocked?e=phishingBlocked");
// In order to detect whether or not we're at the phishing warning
// page, we have to check the documentURI instead of the currentURI.
// This is because when the DocShell loads an error page, the
// currentURI stays at the original target, while the documentURI
// will point to the internal error page we loaded instead.
var docURI = gBrowser.selectedBrowser.documentURI;
var isPhishingPage =
docURI && docURI.spec.startsWith("about:blocked?e=phishingBlocked");

// Show/hide the appropriate menu item.
document.getElementById("menu_HelpPopup_reportPhishingtoolmenu")
Expand All @@ -26,6 +31,9 @@ var gSafeBrowsing = {
if (!broadcaster)
return;

// Now look at the currentURI to learn which page we were trying
// to browse to.
let uri = gBrowser.currentURI;
if (uri && (uri.schemeIs("http") || uri.schemeIs("https")))
broadcaster.removeAttribute("disabled");
else
Expand Down
5 changes: 4 additions & 1 deletion browser/base/content/nsContextMenu.js
Expand Up @@ -144,9 +144,11 @@ nsContextMenu.prototype = {

var shouldShow = this.onSaveableLink || isMailtoInternal || this.onPlainTextLink;
var isWindowPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
var showContainers = Services.prefs.getBoolPref("privacy.userContext.enabled");
this.showItem("context-openlink", shouldShow && !isWindowPrivate);
this.showItem("context-openlinkprivate", shouldShow);
this.showItem("context-openlinkintab", shouldShow);
this.showItem("context-openlinkinusercontext-menu", shouldShow && showContainers);
this.showItem("context-openlinkincurrent", this.onPlainTextLink);
this.showItem("context-sep-open", shouldShow);
},
Expand Down Expand Up @@ -960,7 +962,7 @@ nsContextMenu.prototype = {
},

// Open linked-to URL in a new tab.
openLinkInTab: function() {
openLinkInTab: function(event) {
urlSecurityCheck(this.linkURL, this.principal);
let referrerURI = gContextMenuContentData.documentURIObject;

Expand All @@ -981,6 +983,7 @@ nsContextMenu.prototype = {

let params = this._openLinkInParameters({
allowMixedContent: persistAllowMixedContentInChildTab,
userContextId: event.target.getAttribute('usercontextid'),
});
openLinkIn(this.linkURL, "tab", params);
},
Expand Down
4 changes: 1 addition & 3 deletions browser/components/safebrowsing/content/test/browser.ini
Expand Up @@ -5,8 +5,6 @@ support-files = head.js
[browser_bug400731.js]
skip-if = e10s
[browser_bug415846.js]
skip-if = true
# Disabled because it seems to now touch network resources
# skip-if = os == "mac"
skip-if = os == "mac" || e10s
# Disabled on Mac because of its bizarre special-and-unique
# snowflake of a help menu.
114 changes: 69 additions & 45 deletions browser/components/safebrowsing/content/test/browser_bug415846.js
Expand Up @@ -3,60 +3,84 @@ menu items.
Mac makes this astonishingly painful to test since their help menu is special magic,
but we can at least test it on the other platforms.*/
var menu;

function test() {
waitForExplicitFinish();
const NORMAL_PAGE = "http://example.com";
const PHISH_PAGE = "http://www.itisatrap.org/firefox/its-a-trap.html";

gBrowser.selectedTab = gBrowser.addTab();
/**
* Opens a new tab and browses to some URL, tests for the existence
* of the phishing menu items, and then runs a test function to check
* the state of the menu once opened. This function will take care of
* opening and closing the menu.
*
* @param url (string)
* The URL to browse the tab to.
* @param testFn (function)
* The function to run once the menu has been opened. This
* function will be passed the "reportMenu" and "errorMenu"
* DOM nodes as arguments, in that order. This function
* should not yield anything.
* @returns Promise
*/
function check_menu_at_page(url, testFn) {
return BrowserTestUtils.withNewTab({
gBrowser,
url: "about:blank",
}, function*(browser) {
// We don't get load events when the DocShell redirects to error
// pages, but we do get DOMContentLoaded, so we'll wait for that.
let dclPromise = ContentTask.spawn(browser, null, function*() {
yield ContentTaskUtils.waitForEvent(this, "DOMContentLoaded", false);
});
browser.loadURI(url);
yield dclPromise;

// Navigate to a normal site
gBrowser.addEventListener("DOMContentLoaded", testNormal, false);
content.location = "http://example.com/";
}

function testNormal() {
gBrowser.removeEventListener("DOMContentLoaded", testNormal, false);
let menu = document.getElementById("menu_HelpPopup");
ok(menu, "Help menu should exist");

// open the menu, to force it to update
menu = document.getElementById("menu_HelpPopup");
ok(menu, "Help menu should exist!");
let reportMenu =
document.getElementById("menu_HelpPopup_reportPhishingtoolmenu");
ok(reportMenu, "Report phishing menu item should exist");

menu.addEventListener("popupshown", testNormal_PopupListener, false);
menu.openPopup(null, "", 0, 0, false, null);
}
let errorMenu =
document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu");
ok(errorMenu, "Report phishing error menu item should exist");

function testNormal_PopupListener() {
menu.removeEventListener("popupshown", testNormal_PopupListener, false);
let menuOpen = BrowserTestUtils.waitForEvent(menu, "popupshown");
menu.openPopup(null, "", 0, 0, false, null);
yield menuOpen;

var reportMenu = document.getElementById("menu_HelpPopup_reportPhishingtoolmenu");
var errorMenu = document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu");
is(reportMenu.hidden, false, "Report phishing menu should be visible on normal sites");
is(errorMenu.hidden, true, "Report error menu item should be hidden on normal sites");
menu.hidePopup();
testFn(reportMenu, errorMenu);

// Now launch the phishing test. Can't use onload here because error pages don't
// fire normal load events.
window.addEventListener("DOMContentLoaded", testPhishing, true);
content.location = "http://www.itisatrap.org/firefox/its-a-trap.html";
let menuClose = BrowserTestUtils.waitForEvent(menu, "popuphidden");
menu.hidePopup();
yield menuClose;
});
}

function testPhishing() {
window.removeEventListener("DOMContentLoaded", testPhishing, true);
/**
* Tests that we show the "Report this page" menu item at a normal
* page.
*/
add_task(function*() {
yield check_menu_at_page(NORMAL_PAGE, (reportMenu, errorMenu) => {
ok(!reportMenu.hidden,
"Report phishing menu should be visible on normal sites");
ok(errorMenu.hidden,
"Report error menu item should be hidden on normal sites");
});
});

menu.addEventListener("popupshown", testPhishing_PopupListener, false);
menu.openPopup(null, "", 0, 0, false, null);
}
/**
* Tests that we show the "Report this page is okay" menu item at
* a reported attack site.
*/
add_task(function*() {
yield check_menu_at_page(PHISH_PAGE, (reportMenu, errorMenu) => {
ok(reportMenu.hidden,
"Report phishing menu should be hidden on phishing sites");
ok(!errorMenu.hidden,
"Report error menu item should be visible on phishing sites");
});
});

function testPhishing_PopupListener() {
menu.removeEventListener("popupshown", testPhishing_PopupListener, false);

var reportMenu = document.getElementById("menu_HelpPopup_reportPhishingtoolmenu");
var errorMenu = document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu");
is(reportMenu.hidden, true, "Report phishing menu should be hidden on phishing sites");
is(errorMenu.hidden, false, "Report error menu item should be visible on phishing sites");
menu.hidePopup();

gBrowser.removeCurrentTab();
finish();
}
2 changes: 2 additions & 0 deletions browser/locales/en-US/chrome/browser/browser.dtd
Expand Up @@ -529,6 +529,8 @@ These should match what Safari and other Apple applications use on OS X Lion. --
<!ENTITY openFrameCmdInTab.accesskey "T">
<!ENTITY openFrameCmd.label "Open Frame in New Window">
<!ENTITY openFrameCmd.accesskey "W">
<!ENTITY openLinkCmdInContainerTab.label "Open Link in New Container Tab">
<!ENTITY openLinkCmdInContainerTab.accesskey "C">
<!ENTITY showOnlyThisFrameCmd.label "Show Only This Frame">
<!ENTITY showOnlyThisFrameCmd.accesskey "S">
<!ENTITY reloadCmd.commandkey "r">
Expand Down
15 changes: 6 additions & 9 deletions docshell/base/nsDocShell.cpp
Expand Up @@ -3492,22 +3492,19 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,

nsCOMPtr<nsIDocShell> targetDS = do_QueryInterface(aTargetItem);
nsCOMPtr<nsIDocShell> accessingDS = do_QueryInterface(aAccessingItem);
if (!!targetDS != !!accessingDS) {
// We must be able to convert both or neither to nsIDocShell.
if (!targetDS || !accessingDS) {
// We must be able to convert both to nsIDocShell.
return false;
}

if (targetDS && accessingDS &&
(targetDS->GetIsInBrowserElement() !=
accessingDS->GetIsInBrowserElement() ||
targetDS->GetAppId() != accessingDS->GetAppId())) {
if (targetDS->GetIsInBrowserElement() != accessingDS->GetIsInBrowserElement() ||
targetDS->GetAppId() != accessingDS->GetAppId()) {
return false;
}

// A private document can't access a non-private one, and vice versa.
if (aTargetItem->GetDocument()->GetLoadContext()->UsePrivateBrowsing() !=
aAccessingItem->GetDocument()->GetLoadContext()->UsePrivateBrowsing())
{
if (static_cast<nsDocShell*>(targetDS.get())->UsePrivateBrowsing() !=
static_cast<nsDocShell*>(accessingDS.get())->UsePrivateBrowsing()) {
return false;
}

Expand Down
10 changes: 9 additions & 1 deletion docshell/test/navigation/file_document_write_1.html
Expand Up @@ -6,14 +6,22 @@
document.write("<h5 id='dynamic'>document.written content</h5>");
document.close();
window.history.go(-1);
opener.setTimeout("isTestDynamic()", 2500);
}

function start() {
if (++opener.testCount == 1) {
setTimeout(run, 0);
}
}

window.addEventListener("pageshow",
function() {
++opener.file_document_write_1_loadCount;
if (opener.file_document_write_1_loadCount == 2) {
opener.setTimeout("isTestDynamic()", 0);
}
opener.ok(opener.file_document_write_1_loadCount <= 2);
});
</script>
</head>
<body onload="start();">
Expand Down
1 change: 1 addition & 0 deletions docshell/test/navigation/test_sessionhistory.html
Expand Up @@ -49,6 +49,7 @@
}

// Needed by file_document_write_1.html
window.file_document_write_1_loadCount = 0;
function isTestDynamic() {
var dyn = testWindow.document.getElementById("dynamic");
is(dyn, null, "Should have gone back to the static page!");
Expand Down
3 changes: 2 additions & 1 deletion dom/animation/AnimationUtils.cpp
Expand Up @@ -11,6 +11,7 @@
#include "nsIAtom.h"
#include "nsIContent.h"
#include "nsString.h"
#include "mozilla/Attributes.h"
#include "mozilla/ComputedTimingFunction.h" // ComputedTimingFunction
#include "mozilla/dom/Element.h" // For dom::Element

Expand Down Expand Up @@ -69,7 +70,7 @@ AnimationUtils::ParseEasing(const dom::Element* aTarget,
NS_STYLE_TRANSITION_TIMING_FUNCTION_LINEAR) {
return Nothing();
}
// Fall through
MOZ_FALLTHROUGH;
case eCSSUnit_Cubic_Bezier:
case eCSSUnit_Steps: {
nsTimingFunction timingFunction;
Expand Down
6 changes: 4 additions & 2 deletions dom/asmjscache/AsmJSCache.cpp
Expand Up @@ -1004,7 +1004,8 @@ ParentRunnable::Run()

// Metadata is now open.
if (!SendOnOpenMetadataForRead(mMetadata)) {
Unused << Send__delete__(this, JS::AsmJSCache_InternalError);
Fail();
return NS_OK;
}

return NS_OK;
Expand Down Expand Up @@ -1038,7 +1039,8 @@ ParentRunnable::Run()
FileDescriptor::PlatformHandleType handle =
FileDescriptor::PlatformHandleType(PR_FileDesc2NativeHandle(mFileDesc));
if (!SendOnOpenCacheFile(mFileSize, FileDescriptor(handle))) {
Unused << Send__delete__(this, JS::AsmJSCache_InternalError);
Fail();
return NS_OK;
}

return NS_OK;
Expand Down
11 changes: 8 additions & 3 deletions dom/base/Console.cpp
Expand Up @@ -1547,7 +1547,7 @@ bool
Console::ProcessArguments(JSContext* aCx,
const Sequence<JS::Value>& aData,
Sequence<JS::Value>& aSequence,
Sequence<JS::Value>& aStyles) const
Sequence<nsString>& aStyles) const
{
AssertIsOnMainThread();

Expand Down Expand Up @@ -1693,13 +1693,18 @@ Console::ProcessArguments(JSContext* aCx,
int32_t diff = aSequence.Length() - aStyles.Length();
if (diff > 0) {
for (int32_t i = 0; i < diff; i++) {
if (!aStyles.AppendElement(JS::NullValue(), fallible)) {
if (!aStyles.AppendElement(NullString(), fallible)) {
return false;
}
}
}

if (!aStyles.AppendElement(JS::StringValue(jsString), fallible)) {
nsAutoJSString string;
if (!string.init(aCx, jsString)) {
return false;
}

if (!aStyles.AppendElement(string, fallible)) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion dom/base/Console.h
Expand Up @@ -169,7 +169,7 @@ class Console final : public nsIObserver
bool
ProcessArguments(JSContext* aCx, const Sequence<JS::Value>& aData,
Sequence<JS::Value>& aSequence,
Sequence<JS::Value>& aStyles) const;
Sequence<nsString>& aStyles) const;

void
MakeFormatString(nsCString& aFormat, int32_t aInteger, int32_t aMantissa,
Expand Down

0 comments on commit a6d7a8a

Please sign in to comment.