diff --git a/docshell/test/navigation/file_bug1379762-1.html b/docshell/test/navigation/file_bug1379762-1.html
new file mode 100644
index 0000000000..e8cd8b30b4
--- /dev/null
+++ b/docshell/test/navigation/file_bug1379762-1.html
@@ -0,0 +1,32 @@
+
+
+
+
+ Bug 1379762
+
+
+
+
diff --git a/docshell/test/navigation/mochitest.ini b/docshell/test/navigation/mochitest.ini
index 1b5f33c7f5..f3bb3d244f 100644
--- a/docshell/test/navigation/mochitest.ini
+++ b/docshell/test/navigation/mochitest.ini
@@ -59,6 +59,7 @@ skip-if = (toolkit == 'android') || (!debug && (os == 'mac' || os == 'win')) # B
skip-if = (toolkit == 'android') || (debug && e10s) #too slow on Android 4.3 aws only; bug 1030403; bug 1263213 for debug e10s
[test_sessionhistory.html]
skip-if = toolkit == 'android' #RANDOM
+support-files = file_bug1379762-1.html
[test_sibling-matching-parent.html]
[test_sibling-off-domain.html]
[test_triggeringprincipal_frame_nav.html]
diff --git a/docshell/test/navigation/test_sessionhistory.html b/docshell/test/navigation/test_sessionhistory.html
index 452271a41f..b922ce4ea1 100644
--- a/docshell/test/navigation/test_sessionhistory.html
+++ b/docshell/test/navigation/test_sessionhistory.html
@@ -31,7 +31,8 @@ var testFiles =
"file_nested_frames.html",
"file_shiftReload_and_pushState.html",
"file_scrollRestoration.html",
- "file_bug1300461.html"
+ "file_bug1300461.html",
+ "file_bug1379762-1.html",
];
var testCount = 0; // Used by the test files.
diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp
index 4a54a84323..3106ff3868 100644
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -1307,10 +1307,15 @@ nsPresContext::SetFullZoom(float aZoom)
void
nsPresContext::SetOverrideDPPX(float aDPPX)
{
- mOverrideDPPX = aDPPX;
+ // SetOverrideDPPX is called during navigations, including history
+ // traversals. In that case, it's typically called with our current value,
+ // and we don't need to actually do anything.
+ if (aDPPX != mOverrideDPPX) {
+ mOverrideDPPX = aDPPX;
- if (HasCachedStyleData()) {
- MediaFeatureValuesChanged(nsRestyleHint(0), nsChangeHint(0));
+ if (HasCachedStyleData()) {
+ MediaFeatureValuesChanged(nsRestyleHint(0), nsChangeHint(0));
+ }
}
}