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
shindli committed Oct 9, 2018
2 parents 90d3be0 + e851a15 commit 80ac71c
Show file tree
Hide file tree
Showing 26 changed files with 216 additions and 82 deletions.
10 changes: 9 additions & 1 deletion browser/components/nsBrowserGlue.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
ChromeUtils.defineModuleGetter(this, "ActorManagerParent",
"resource://gre/modules/ActorManagerParent.jsm");

const PREF_PDFJS_ENABLED_CACHE_STATE = "pdfjs.enabledCache.state";

let ACTORS = {
AboutReader: {
child: {
Expand Down Expand Up @@ -993,7 +995,13 @@ BrowserGlue.prototype = {
_beforeUIStartup: function BG__beforeUIStartup() {
SessionStartup.init();

PdfJs.earlyInit();
if (Services.prefs.prefHasUserValue(PREF_PDFJS_ENABLED_CACHE_STATE)) {
Services.ppmm.sharedData.set(
"pdfjs.enabled",
Services.prefs.getBoolPref(PREF_PDFJS_ENABLED_CACHE_STATE));
} else {
PdfJs.earlyInit();
}

// check if we're in safe mode
if (Services.appinfo.inSafeMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const SPOOFED_UA_OS = {
android: "Android 6.0; Mobile",
other: "X11; Linux x86_64",
};
const SPOOFED_BUILDID = "20100101";
const SPOOFED_HW_CONCURRENCY = 2;

const CONST_APPCODENAME = "Mozilla";
Expand All @@ -70,7 +69,6 @@ async function testNavigator() {
is(result.mimeTypesLength, 0, "Navigator.mimeTypes has a length of 0.");
is(result.pluginsLength, 0, "Navigator.plugins has a length of 0.");
is(result.oscpu, SPOOFED_OSCPU[AppConstants.platform], "Navigator.oscpu is correctly spoofed.");
is(result.buildID, SPOOFED_BUILDID, "Navigator.buildID is correctly spoofed.");
is(result.hardwareConcurrency, SPOOFED_HW_CONCURRENCY, "Navigator.hardwareConcurrency is correctly spoofed.");

is(result.appCodeName, CONST_APPCODENAME, "Navigator.appCodeName reports correct constant value.");
Expand Down Expand Up @@ -140,7 +138,6 @@ add_task(async function runOverrideTest() {
["general.platform.override", "platform overridden"],
["general.useragent.override", "userAgent overridden"],
["general.oscpu.override", "oscpu overridden"],
["general.buildID.override", "buildID overridden"],
],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
result.mimeTypesLength = navigator.mimeTypes.length;
result.pluginsLength = navigator.plugins.length;
result.oscpu = navigator.oscpu;
result.buildID = navigator.buildID;
result.hardwareConcurrency = navigator.hardwareConcurrency;

// eslint-disable-next-line no-unsanitized/property
Expand Down
2 changes: 2 additions & 0 deletions browser/extensions/pdfjs/content/PdfJs.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ var PdfJs = {
},

earlyInit() {
// Note: Please keep this in sync with the duplicated logic in
// nsBrowserGlue.js.
Services.ppmm.sharedData.set("pdfjs.enabled", this.checkEnabled());
},

Expand Down
Binary file modified build/pgo/certs/cert9.db
Binary file not shown.
Binary file modified build/pgo/certs/key4.db
Binary file not shown.
Binary file modified build/pgo/certs/mochitest.client
Binary file not shown.
8 changes: 3 additions & 5 deletions build/pgo/server-locations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,6 @@ http://example.cn:80 privileged
http://example.co.jp:80 privileged
http://example.fi:80 privileged

# Hosts for testing marketplace apps installations
https://marketplace.firefox.com:443 privileged
https://marketplace-dev.allizom.org:443 privileged
https://marketplace.allizom.org:443 privileged

# Host for HPKP
https://include-subdomains.pinning-dynamic.example.com:443 privileged,cert=dynamicPinningGood
https://bad.include-subdomains.pinning-dynamic.example.com:443 privileged,cert=dynamicPinningBad
Expand All @@ -291,3 +286,6 @@ https://mochitest.youtube.com:443

# Host for U2F localhost tests
https://localhost:443

# Host for testing APIs whitelisted for mozilla.org
https://www.mozilla.org:443
27 changes: 25 additions & 2 deletions dom/base/Navigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ Navigator::GetProduct(nsAString& aProduct)
void
Navigator::GetProductSub(nsAString& aProductSub)
{
// Legacy build ID hardcoded for backward compatibility (bug 776376)
aProductSub.AssignLiteral(LEGACY_BUILD_ID);
// Legacy build date hardcoded for backward compatibility (bug 776376)
aProductSub.AssignLiteral(LEGACY_UA_GECKO_TRAIL);
}

nsMimeTypeArray*
Expand Down Expand Up @@ -573,12 +573,35 @@ Navigator::GetBuildID(nsAString& aBuildID, CallerType aCallerType,
aBuildID.AssignLiteral(LEGACY_BUILD_ID);
return;
}

nsAutoString override;
nsresult rv = Preferences::GetString("general.buildID.override", override);
if (NS_SUCCEEDED(rv)) {
aBuildID = override;
return;
}

nsAutoCString host;
bool isHTTPS = false;
if (mWindow) {
nsCOMPtr<nsIDocument> doc = mWindow->GetDoc();
if (doc) {
nsIURI* uri = doc->GetDocumentURI();
if (uri) {
MOZ_ALWAYS_SUCCEEDS(uri->SchemeIs("https", &isHTTPS));
if (isHTTPS) {
MOZ_ALWAYS_SUCCEEDS(uri->GetHost(host));
}
}
}
}

// Spoof the buildID on pages not loaded from "https://*.mozilla.org".
if (!isHTTPS ||
!StringEndsWith(host, NS_LITERAL_CSTRING(".mozilla.org"))) {
aBuildID.AssignLiteral(LEGACY_BUILD_ID);
return;
}
}

nsCOMPtr<nsIXULAppInfo> appInfo =
Expand Down
2 changes: 1 addition & 1 deletion dom/tests/mochitest/bugs/mochitest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ skip-if = toolkit == 'android'
[test_bug342448.html]
[test_bug345521.html]
[test_bug346659.html]
[test_bug351601.html]
[test_bug369306.html]
skip-if = toolkit == 'android' #TIMED_OUT
[test_bug370098.html]
Expand Down Expand Up @@ -136,6 +135,7 @@ skip-if = toolkit == 'android'
skip-if = toolkit == 'android' #bug 775227
[test_domparser_after_blank.html]
[test_errorReporting.html]
[test_navigator_buildID.html]
[test_onerror_message.html]
[test_protochains.html]
[test_resize_move_windows.html]
Expand Down
35 changes: 0 additions & 35 deletions dom/tests/mochitest/bugs/test_bug351601.html

This file was deleted.

99 changes: 99 additions & 0 deletions dom/tests/mochitest/bugs/test_navigator_buildID.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=583181
-->
<head>
<title>Test for Bug 583181</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=583181">Mozilla Bug 583181</a>
<p id="display"></p>
<div id="content" style="display: none">

</div>
<pre id="test">
<script class="testbody" type="text/javascript">
"use strict";

SimpleTest.waitForExplicitFinish();

const LEGACY_BUILD_ID = 20181001000000;

//
// Access navigator.buildID from unprivileged web content.
//
var isOK = false;
try {
var contentBuildID = navigator.buildID;
isOK = true;
} catch (ex) {
}
ok(isOK, "navigator.buildID should never throw");
is(typeof(contentBuildID), "string", "navigator.buildID should be a string");
is(+contentBuildID, LEGACY_BUILD_ID,
"navigator.buildID should be spoofed in content");

//
// Access navigator.buildID from chrome.
//
let chromeScript = SpecialPowers.loadChromeScript(() => {
ChromeUtils.import("resource://gre/modules/Services.jsm");
addMessageListener("test:getBuildID", nav => {
let browser = Services.wm.getMostRecentWindow('navigator:browser');
return browser.navigator.buildID;
});
});

let chromeBuildID = chromeScript.sendSyncMessage("test:getBuildID")[0][0];
chromeScript.destroy();

ok(+chromeBuildID > LEGACY_BUILD_ID,
`navigator.buildID should be exposed in chrome - got "${chromeBuildID}"`);

function onMozillaIFrameLoaded() {
//
// Access navigator.buildID from mozilla.org.
//
let mozillaBuildID = getMozillaBuildID();

ok(+mozillaBuildID > LEGACY_BUILD_ID,
`navigator.buildID should be exposed on mozilla.org ` +
`- got "${mozillaBuildID}"`);
is(chromeBuildID, mozillaBuildID,
"navigator.buildID should be the same in chrome and on mozilla.org");

//
// Access navigator.buildID from mozilla.org when resisting fingerprinting.
//
SpecialPowers.pushPrefEnv(
{"set": [["privacy.resistFingerprinting", true]]},
() => {
let resistBuildID = getMozillaBuildID();

is(+resistBuildID, LEGACY_BUILD_ID,
"navigator.buildID should be spoofed on mozilla.org when " +
"resisting fingerprinting");

SimpleTest.finish();
}
);
}

function getMozillaBuildID() {
let Cu = SpecialPowers.Cu;
let mozillaIFrame = document.getElementById("mozillaIFrame").contentWindow;
let mozillaSandbox = Cu.Sandbox(mozillaIFrame,
{sandboxPrototype: mozillaIFrame});
let mozillaBuildID = Cu.evalInSandbox("window.navigator.buildID",
mozillaSandbox);
Cu.nukeSandbox(mozillaSandbox);
return mozillaBuildID;
}
</script>
</pre>
<iframe id="mozillaIFrame" onload="onMozillaIFrameLoaded();" src="https://www.mozilla.org/" />
</body>
</html>
7 changes: 3 additions & 4 deletions editor/libeditor/EditorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4667,11 +4667,10 @@ EditorBase::HandleInlineSpellCheck(EditSubAction aEditSubAction,
aEndOffset);
}

already_AddRefed<nsIContent>
EditorBase::FindSelectionRoot(nsINode* aNode)
Element*
EditorBase::FindSelectionRoot(nsINode* aNode) const
{
nsCOMPtr<nsIContent> rootContent = GetRoot();
return rootContent.forget();
return GetRoot();
}

void
Expand Down
2 changes: 1 addition & 1 deletion editor/libeditor/EditorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ class EditorBase : public nsIEditor
* designMode, you should set the document node to aNode except that an
* element in the document has focus.
*/
virtual already_AddRefed<nsIContent> FindSelectionRoot(nsINode* aNode);
virtual Element* FindSelectionRoot(nsINode* aNode) const;

/**
* This method has to be called by EditorEventListener::Focus.
Expand Down
42 changes: 42 additions & 0 deletions editor/libeditor/HTMLEditRules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,41 @@ class EmptyEditableFunctor final : public BoolDomIterFunctor
HTMLEditor* mHTMLEditor;
};


class MOZ_RAII AutoSetTemporaryAncestorLimiter final
{
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER;

public:
explicit AutoSetTemporaryAncestorLimiter(HTMLEditor& aHTMLEditor,
Selection& aSelection,
nsINode& aStartPointNode
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;

if (aSelection.GetAncestorLimiter()) {
return;
}

Element* root = aHTMLEditor.FindSelectionRoot(&aStartPointNode);
if (root) {
aHTMLEditor.InitializeSelectionAncestorLimit(aSelection, *root);
mSelection = &aSelection;
}
}

~AutoSetTemporaryAncestorLimiter()
{
if (mSelection) {
mSelection->SetAncestorLimiter(nullptr);
}
}

private:
RefPtr<Selection> mSelection;
};

/********************************************************
* mozilla::HTMLEditRules
********************************************************/
Expand Down Expand Up @@ -2405,6 +2440,13 @@ HTMLEditRules::WillDeleteSelection(nsIEditor::EDirection aAction,
return NS_OK;
}

// ExtendSelectionForDelete will use selection controller to set
// selection for delete. But if focus event doesn't receive yet,
// ancestor isn't set. So we must set root eleement of editor to
// ancestor.
AutoSetTemporaryAncestorLimiter autoSetter(HTMLEditorRef(), SelectionRef(),
*startPoint.GetContainer());

rv = HTMLEditorRef().ExtendSelectionForDelete(&SelectionRef(), &aAction);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
Expand Down
Loading

0 comments on commit 80ac71c

Please sign in to comment.