Bug 1497126 - Allow 1 level of recursion when loading nested iframes with same URL, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 08 Oct 2018 16:04:56 +0200
changeset 495725 dc46a5f43a47d173b7c29226aab8bc590701bc99
parent 495702 982f91f69b39773ac302d4d01610de1414894529
child 495726 70f63648a0f6cf738d5555eb347986d7323ef16e
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1497126
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1497126 - Allow 1 level of recursion when loading nested iframes with same URL, r=smaug
dom/base/nsFrameLoader.cpp
dom/html/test/mochitest.ini
dom/html/test/test_nestediframe.html
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -124,18 +124,18 @@ using namespace mozilla::layers;
 using namespace mozilla::layout;
 typedef FrameMetrics::ViewID ViewID;
 
 // Bug 136580: Limit to the number of nested content frames that can have the
 //             same URL. This is to stop content that is recursively loading
 //             itself.  Note that "#foo" on the end of URL doesn't affect
 //             whether it's considered identical, but "?foo" or ";foo" are
 //             considered and compared.
-// Bug 228829: Limit this to 1, like IE does.
-#define MAX_SAME_URL_CONTENT_FRAMES 1
+// Limit this to 2, like chromium does.
+#define MAX_SAME_URL_CONTENT_FRAMES 2
 
 // Bug 8065: Limit content frame depth to some reasonable level. This
 // does not count chrome frames when determining depth, nor does it
 // prevent chrome recursion.  Number is fairly arbitrary, but meant to
 // keep number of shells to a reasonable number on accidental recursion with a
 // small (but not 1) branching factor.  With large branching factors the number
 // of shells can rapidly become huge and run us out of memory.  To solve that,
 // we'd need to re-institute a fixed version of bug 98158.
--- a/dom/html/test/mochitest.ini
+++ b/dom/html/test/mochitest.ini
@@ -602,8 +602,9 @@ skip-if = os == "android" # up/down arro
 [test_fakepath.html]
 [test_script_module.html]
 support-files =
   file_script_module.html
   file_script_nomodule.html
 [test_getElementsByName_after_mutation.html]
 [test_bug1279218.html]
 [test_set_input_files.html]
+[test_nestediframe.html]
new file mode 100644
--- /dev/null
+++ b/dom/html/test/test_nestediframe.html
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for same URLs nested iframes</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<script>
+
+SimpleTest.waitForExplicitFinish();
+
+function reportState(msg) {
+  if (location.href.includes("#")) {
+    parent.postMessage(msg, "*");
+    return;
+  }
+
+  if (msg == "OK 1") {
+    ok(true, "First frame loaded");
+  } else if (msg == "KO 2") {
+    ok(true, "Second frame load failed");
+    SimpleTest.finish();
+  } else {
+    ok(false, "Unknown message: " + msg);
+  }
+}
+
+addEventListener("message", event => {
+  reportState(event.data);
+});
+
+var recursion;
+if (!location.href.includes("#")) {
+  recursion = 1;
+} else {
+  recursion = parseInt(localStorage.recursion) + 1;
+}
+localStorage.recursion = "" + recursion;
+
+var ifr = document.createElement('iframe');
+ifr.src = location.href.split("#")[0] + "#" + recursion;
+document.body.appendChild(ifr);
+
+ifr.onload = function() {
+  reportState("OK " + recursion);
+}
+
+ifr.onerror = function() {
+  reportState("KO " + recursion);
+}
+
+</script>
+</body>
+</html>