Bug 1171919 - Add a test which asserts that StyleSheetsActor can handle iframes without a content document. r=bgrins, a=ritu
authorSami Jaktholm <sjakthol@outlook.com>
Tue, 14 Jul 2015 19:54:59 +0300
changeset 281628 c2a9f6033b62f32ed5495ec5bd66065c86b1228e
parent 281627 b0e1b21da2ff169e5a1de77aced8284de63781e2
child 281629 25815ce3c29bff8889b68dc69e4901af02648740
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins, ritu
bugs1171919
milestone41.0a2
Bug 1171919 - Add a test which asserts that StyleSheetsActor can handle iframes without a content document. r=bgrins, a=ritu
toolkit/devtools/server/tests/browser/browser.ini
toolkit/devtools/server/tests/browser/browser_stylesheets_nested-iframes.js
toolkit/devtools/server/tests/browser/stylesheets-nested-iframes.html
--- a/toolkit/devtools/server/tests/browser/browser.ini
+++ b/toolkit/devtools/server/tests/browser/browser.ini
@@ -7,16 +7,17 @@ support-files =
   animation.html
   navigate-first.html
   navigate-second.html
   storage-dynamic-windows.html
   storage-listings.html
   storage-unsecured-iframe.html
   storage-updates.html
   storage-secured-iframe.html
+  stylesheets-nested-iframes.html
   timeline-iframe-child.html
   timeline-iframe-parent.html
   director-script-target.html
 
 [browser_animation_actors_01.js]
 [browser_animation_actors_02.js]
 [browser_animation_actors_03.js]
 [browser_animation_actors_04.js]
@@ -37,16 +38,17 @@ support-files =
 [browser_canvasframe_helper_03.js]
 [browser_canvasframe_helper_04.js]
 [browser_canvasframe_helper_05.js]
 [browser_canvasframe_helper_06.js]
 [browser_navigateEvents.js]
 [browser_storage_dynamic_windows.js]
 [browser_storage_listings.js]
 [browser_storage_updates.js]
+[browser_stylesheets_nested-iframes.js]
 [browser_timeline.js]
 skip-if = buildapp == 'mulet'
 [browser_timeline_actors.js]
 skip-if = buildapp == 'mulet'
 [browser_timeline_iframes.js]
 skip-if = buildapp == 'mulet'
 [browser_directorscript_actors_exports.js]
 [browser_directorscript_actors_error_events.js]
new file mode 100644
--- /dev/null
+++ b/toolkit/devtools/server/tests/browser/browser_stylesheets_nested-iframes.js
@@ -0,0 +1,39 @@
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Test that StyleSheetsActor.getStyleSheets() works if an iframe does not have
+// a content document.
+
+const {StyleSheetsFront} = require("devtools/server/actors/stylesheets");
+
+add_task(function*() {
+  let doc = yield addTab(MAIN_DOMAIN + "stylesheets-nested-iframes.html");
+
+  info("Initialising the debugger server and client.");
+  initDebuggerServer();
+  let client = new DebuggerClient(DebuggerServer.connectPipe());
+  let form = yield connectDebuggerClient(client);
+
+  info("Attaching to the active tab.");
+  yield new Promise(resolve => {
+    client.attachTab(form.actor, resolve);
+  });
+
+  let front = StyleSheetsFront(client, form);
+  ok(front, "The StyleSheetsFront was created.");
+
+  let sheets = yield front.getStyleSheets();
+  ok(sheets, "getStyleSheets() succeeded even with documentless iframes.");
+
+  // Bug 285395 limits the number of nested iframes to 10. There's one sheet per
+  // frame so we should get 10 sheets. However, the limit might change in the
+  // future so it's better not to rely on the limit. Asserting > 2 ensures that
+  // the test page is actually loading nested iframes and this test is doing
+  // something sensible (if we got this far, the test has served its purpose).
+  ok(sheets.length > 2, sheets.length + " sheets found (expected 3 or more).");
+
+  yield closeDebuggerClient(client);
+});
new file mode 100644
--- /dev/null
+++ b/toolkit/devtools/server/tests/browser/stylesheets-nested-iframes.html
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>StyleSheetsActor iframe test</title>
+  <style>
+    p {
+      padding: 1em;
+    }
+  </style>
+</head>
+<body>
+  <p>A test page with nested iframes</p>
+  <iframe></iframe>
+  <script type="application/javascript;version=1.8">
+    let iframe = document.querySelector("iframe");
+    let i = parseInt(location.href.split("?")[1]) || 1;
+
+    // The frame can't have the same src URL as any of its ancestors.
+    // This will not infinitely recurse because a frame won't get a content
+    // document once it's nested deeply enough.
+    iframe.src = location.href.split("?")[0] + "?" + (++i);
+  </script>
+</body>
+</html>