Skip to content

Commit

Permalink
Merge mozilla-central to autoland.
Browse files Browse the repository at this point in the history
  • Loading branch information
CosminSabou committed Jun 3, 2019
2 parents 8a66f6b + 6daf891 commit dbcb8e5
Show file tree
Hide file tree
Showing 89 changed files with 1,834 additions and 3,083 deletions.
31 changes: 26 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion browser/base/content/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6615,6 +6615,9 @@ function handleDroppedLink(event, urlOrLinks, nameOrTriggeringPrincipal, trigger

function BrowserSetForcedCharacterSet(aCharset) {
if (aCharset) {
if (aCharset == "Japanese") {
aCharset = "Shift_JIS";
}
gBrowser.selectedBrowser.characterSet = aCharset;
// Save the forced character-set
PlacesUIUtils.setCharsetForPage(getWebNavigation().currentURI,
Expand All @@ -6629,7 +6632,8 @@ function BrowserCharsetReload() {
}

function UpdateCurrentCharset(target) {
let selectedCharset = CharsetMenu.foldCharset(gBrowser.selectedBrowser.characterSet);
let selectedCharset = CharsetMenu.foldCharset(gBrowser.selectedBrowser.characterSet,
gBrowser.selectedBrowser.charsetAutodetected);
for (let menuItem of target.getElementsByTagName("menuitem")) {
let isSelected = menuItem.getAttribute("charset") === selectedCharset;
menuItem.setAttribute("checked", isSelected);
Expand Down
3 changes: 2 additions & 1 deletion browser/components/customizableui/CustomizableWidgets.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ const CustomizableWidgets = [
},
updateCurrentCharset(aDocument) {
let currentCharset = aDocument.defaultView.gBrowser.selectedBrowser.characterSet;
currentCharset = CharsetMenu.foldCharset(currentCharset);
let {charsetAutodetected} = aDocument.defaultView.gBrowser.selectedBrowser;
currentCharset = CharsetMenu.foldCharset(currentCharset, charsetAutodetected);

let pinnedContainer = aDocument.getElementById("PanelUI-characterEncodingView-pinned");
let charsetContainer = aDocument.getElementById("PanelUI-characterEncodingView-charsets");
Expand Down
33 changes: 27 additions & 6 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,6 @@ nsDocShell::GatherCharsetMenuTelemetry() {
case kCharsetFromDocTypeDefault:
case kCharsetFromCache:
case kCharsetFromParentFrame:
case kCharsetFromHintPrevDoc:
// Changing charset on an unlabeled doc.
if (isFileURL) {
Telemetry::AccumulateCategorical(
Expand Down Expand Up @@ -1892,6 +1891,26 @@ nsDocShell::GetMayEnableCharacterEncodingMenu(
return NS_OK;
}

NS_IMETHODIMP
nsDocShell::GetCharsetAutodetected(bool* aCharsetAutodetected) {
*aCharsetAutodetected = false;
if (!mContentViewer) {
return NS_OK;
}
Document* doc = mContentViewer->GetDocument();
if (!doc) {
return NS_OK;
}
int32_t source = doc->GetDocumentCharacterSetSource();

if (source == kCharsetFromAutoDetection ||
source == kCharsetFromUserForcedAutoDetection) {
*aCharsetAutodetected = true;
}

return NS_OK;
}

NS_IMETHODIMP
nsDocShell::GetDocShellEnumerator(int32_t aItemType,
DocShellEnumeratorDirection aDirection,
Expand Down Expand Up @@ -8372,11 +8391,11 @@ nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer) {

const Encoding* forceCharset = nullptr;
const Encoding* hintCharset = nullptr;
int32_t hintCharsetSource;
float textZoom;
float pageZoom;
float overrideDPPX;
bool styleDisabled;
int32_t hintCharsetSource = kCharsetUninitialized;
float textZoom = 1.0;
float pageZoom = 1.0;
float overrideDPPX = 1.0;
bool styleDisabled = false;
// |newMUDV| also serves as a flag to set the data from the above vars
nsCOMPtr<nsIContentViewer> newCv;

Expand Down Expand Up @@ -10188,6 +10207,8 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
MOZ_ASSERT(NS_SUCCEEDED(rv));
}

Unused << rv; // Keep Coverity happy

nsCOMPtr<nsIWritablePropertyBag2> props(do_QueryInterface(channel));
if (props) {
// save true referrer for those who need it (e.g. xpinstall whitelisting)
Expand Down
5 changes: 5 additions & 0 deletions docshell/base/nsIDocShell.idl
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,11 @@ interface nsIDocShell : nsIDocShellTreeItem
*/
[infallible] readonly attribute boolean mayEnableCharacterEncodingMenu;

/**
* Indicates that the character encoding was autodetected.
*/
[infallible] readonly attribute boolean charsetAutodetected;

attribute nsIEditor editor;
readonly attribute boolean editable; /* this docShell is editable */
readonly attribute boolean hasEditingSession; /* this docShell has an editing session */
Expand Down
12 changes: 12 additions & 0 deletions docshell/test/browser/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ support-files =
file_bug1415918_beforeunload_iframe_2.html
file_bug1415918_beforeunload_iframe.html
file_bug1415918_beforeunload.html
file_bug1543077-1-child.html
file_bug1543077-1.html
file_bug1543077-2-child.html
file_bug1543077-2.html
file_bug1543077-3-child.html
file_bug1543077-3.html
file_bug1543077-4-child.html
file_bug1543077-4.html
file_multiple_pushState.html
print_postdata.sjs
test-form_sjis.html
Expand All @@ -60,6 +68,10 @@ support-files =
onpageshow_message.html
file_cross_process_csp_inheritance.html

[browser_bug1543077-1.js]
[browser_bug1543077-2.js]
[browser_bug1543077-3.js]
[browser_bug1543077-4.js]
[browser_bug1206879.js]
[browser_bug1309900_crossProcessHistoryNavigation.js]
[browser_bug1328501.js]
Expand Down
18 changes: 18 additions & 0 deletions docshell/test/browser/browser_bug1543077-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function test() {
var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/";
runCharsetTest(rootDir + "file_bug1543077-1.html", afterOpen, "Japanese", afterChangeCharset);
}

function afterOpen() {
is(content.document.documentElement.textContent.indexOf("\u00A4"), 131, "Parent doc should be windows-1252 initially");

is(content.frames[0].document.documentElement.textContent.indexOf("\u00A4"), 87, "Child doc should be windows-1252 initially");
}

function afterChangeCharset() {
is(content.document.documentElement.textContent.indexOf("\u3042"), 131, "Parent doc should decode as EUC-JP subsequently");
is(content.frames[0].document.documentElement.textContent.indexOf("\u3042"), 87, "Child doc should decode as EUC-JP subsequently");

is(content.document.characterSet, "EUC-JP", "Parent doc should report EUC-JP subsequently");
is(content.frames[0].document.characterSet, "EUC-JP", "Child doc should report EUC-JP subsequently");
}
18 changes: 18 additions & 0 deletions docshell/test/browser/browser_bug1543077-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function test() {
var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/";
runCharsetTest(rootDir + "file_bug1543077-2.html", afterOpen, "Japanese", afterChangeCharset);
}

function afterOpen() {
is(content.document.documentElement.textContent.indexOf("\u201A"), 134, "Parent doc should be windows-1252 initially");

is(content.frames[0].document.documentElement.textContent.indexOf("\u201A"), 90, "Child doc should be windows-1252 initially");
}

function afterChangeCharset() {
is(content.document.documentElement.textContent.indexOf("\u3042"), 134, "Parent doc should decode as Shift_JIS subsequently");
is(content.frames[0].document.documentElement.textContent.indexOf("\u3042"), 90, "Child doc should decode as Shift_JIS subsequently");

is(content.document.characterSet, "Shift_JIS", "Parent doc should report Shift_JIS subsequently");
is(content.frames[0].document.characterSet, "Shift_JIS", "Child doc should report Shift_JIS subsequently");
}
18 changes: 18 additions & 0 deletions docshell/test/browser/browser_bug1543077-3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function test() {
var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/";
runCharsetTest(rootDir + "file_bug1543077-3.html", afterOpen, "Japanese", afterChangeCharset);
}

function afterOpen() {
is(content.document.documentElement.textContent.indexOf("\u001B"), 136, "Parent doc should be windows-1252 initially");

is(content.frames[0].document.documentElement.textContent.indexOf("\u001B"), 92, "Child doc should be windows-1252 initially");
}

function afterChangeCharset() {
is(content.document.documentElement.textContent.indexOf("\u3042"), 136, "Parent doc should decode as ISO-2022-JP subsequently");
is(content.frames[0].document.documentElement.textContent.indexOf("\u3042"), 92, "Child doc should decode as ISO-2022-JP subsequently");

is(content.document.characterSet, "ISO-2022-JP", "Parent doc should report ISO-2022-JP subsequently");
is(content.frames[0].document.characterSet, "ISO-2022-JP", "Child doc should report ISO-2022-JP subsequently");
}
18 changes: 18 additions & 0 deletions docshell/test/browser/browser_bug1543077-4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function test() {
var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/";
runCharsetTest(rootDir + "file_bug1543077-4.html", afterOpen, "Japanese", afterChangeCharset);
}

function afterOpen() {
is(content.document.documentElement.textContent.indexOf("\u00A4"), 131, "Parent doc should be windows-1252 initially");

is(content.frames[0].document.documentElement.textContent.indexOf("\u201A"), 90, "Child doc should be windows-1252 initially");
}

function afterChangeCharset() {
is(content.document.documentElement.textContent.indexOf("\u3042"), 131, "Parent doc should decode as EUC-JP subsequently");
is(content.frames[0].document.documentElement.textContent.indexOf("\u3042"), 90, "Child doc should decode as Shift_JIS subsequently");

is(content.document.characterSet, "EUC-JP", "Parent doc should report EUC-JP subsequently");
is(content.frames[0].document.characterSet, "Shift_JIS", "Child doc should report Shift_JIS subsequently");
}
11 changes: 11 additions & 0 deletions docshell/test/browser/file_bug1543077-1-child.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>No encoding declaration in parent or child</title>
</head>
<body>
<p>Hiragana letter a if decoded as EUC-JP: ¤¢</p>
</body>
</html>

16 changes: 16 additions & 0 deletions docshell/test/browser/file_bug1543077-1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>No encoding declaration in parent or child</title>
</head>
<body>
<h1>No encoding declaration in parent or child</h1>

<p>Hiragana letter a if decoded as EUC-JP: ¤¢</p>

<iframe src="file_bug1543077-1-child.html"></iframe>

</body>
</html>

11 changes: 11 additions & 0 deletions docshell/test/browser/file_bug1543077-2-child.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>No encoding declaration in parent or child</title>
</head>
<body>
<p>Hiragana letter a if decoded as Shift_JIS: ‚ </p>
</body>
</html>

16 changes: 16 additions & 0 deletions docshell/test/browser/file_bug1543077-2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>No encoding declaration in parent or child</title>
</head>
<body>
<h1>No encoding declaration in parent or child</h1>

<p>Hiragana letter a if decoded as Shift_JIS: ‚ </p>

<iframe src="file_bug1543077-2-child.html"></iframe>

</body>
</html>

11 changes: 11 additions & 0 deletions docshell/test/browser/file_bug1543077-3-child.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>No encoding declaration in parent or child</title>
</head>
<body>
<p>Hiragana letter a if decoded as ISO-2022-JP: $B$"(B</p>
</body>
</html>

16 changes: 16 additions & 0 deletions docshell/test/browser/file_bug1543077-3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>No encoding declaration in parent or child</title>
</head>
<body>
<h1>No encoding declaration in parent or child</h1>

<p>Hiragana letter a if decoded as ISO-2022-JP: $B$"(B</p>

<iframe src="file_bug1543077-3-child.html"></iframe>

</body>
</html>

11 changes: 11 additions & 0 deletions docshell/test/browser/file_bug1543077-4-child.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>No encoding declaration in parent or child</title>
</head>
<body>
<p>Hiragana letter a if decoded as Shift_JIS: ‚ </p>
</body>
</html>

Loading

0 comments on commit dbcb8e5

Please sign in to comment.