Bug 1282660 - Part 2 : Add a test cast to test that style editor can load stylesheets correctly with containers. r=gl
authorTim Huang <tihuang@mozilla.com>
Thu, 14 Jul 2016 04:13:00 +0200
changeset 305237 1d657d984bed365b1c2bdc499532cf34c60b1edd
parent 305236 f57d23de8ac2b6645624f120b2508c8542eca412
child 305238 33e438fbb442212265493d533b3794a29308b981
push id79519
push usercbook@mozilla.com
push dateSun, 17 Jul 2016 08:15:20 +0000
treeherdermozilla-inbound@1d657d984bed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl
bugs1282660
milestone50.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 1282660 - Part 2 : Add a test cast to test that style editor can load stylesheets correctly with containers. r=gl
devtools/client/styleeditor/test/browser.ini
devtools/client/styleeditor/test/browser_styleeditor_loading_with_containers.js
--- a/devtools/client/styleeditor/test/browser.ini
+++ b/devtools/client/styleeditor/test/browser.ini
@@ -67,16 +67,17 @@ support-files =
 [browser_styleeditor_fetch-from-cache.js]
 [browser_styleeditor_filesave.js]
 [browser_styleeditor_highlight-selector.js]
 [browser_styleeditor_import.js]
 [browser_styleeditor_import_rule.js]
 [browser_styleeditor_init.js]
 [browser_styleeditor_inline_friendly_names.js]
 [browser_styleeditor_loading.js]
+[browser_styleeditor_loading_with_containers.js]
 [browser_styleeditor_media_sidebar.js]
 [browser_styleeditor_media_sidebar_links.js]
 skip-if = e10s && debug # Bug 1252201 - Docshell leak on debug e10s
 [browser_styleeditor_media_sidebar_sourcemaps.js]
 [browser_styleeditor_missing_stylesheet.js]
 [browser_styleeditor_navigate.js]
 [browser_styleeditor_new.js]
 [browser_styleeditor_nostyle.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/styleeditor/test/browser_styleeditor_loading_with_containers.js
@@ -0,0 +1,63 @@
+/* vim: set 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 the stylesheets can be loaded correctly with containers
+// (bug 1282660).
+
+const TESTCASE_URI = TEST_BASE_HTTP + "simple.html";
+const EXPECTED_SHEETS = [
+  {
+    sheetIndex: 0,
+    name: /^simple.css$/,
+    rules: 1,
+    active: true
+  }, {
+    sheetIndex: 1,
+    name: /^<.*>$/,
+    rules: 3,
+    active: false
+  }
+];
+
+add_task(function* () {
+  // Using the personal container.
+  let userContextId = 1;
+  let { tab } = yield* openTabInUserContext(TESTCASE_URI, userContextId);
+  let { ui } = yield openStyleEditor(tab);
+
+  is(ui.editors.length, 2, "The UI contains two style sheets.");
+  checkSheet(ui.editors[0], EXPECTED_SHEETS[0]);
+  checkSheet(ui.editors[1], EXPECTED_SHEETS[1]);
+});
+
+function* openTabInUserContext(uri, userContextId) {
+  // Open the tab in the correct userContextId.
+  let tab = gBrowser.addTab(uri, {userContextId});
+
+  // Select tab and make sure its browser is focused.
+  gBrowser.selectedTab = tab;
+  tab.ownerDocument.defaultView.focus();
+
+  let browser = gBrowser.getBrowserForTab(tab);
+  yield BrowserTestUtils.browserLoaded(browser);
+  return {tab, browser};
+}
+
+function checkSheet(editor, expected) {
+  is(editor.styleSheet.styleSheetIndex, expected.sheetIndex,
+    "Style sheet has correct index.");
+
+  let summary = editor.summary;
+  let name = summary.querySelector(".stylesheet-name > label")
+                    .getAttribute("value");
+  ok(expected.name.test(name), "The name '" + name + "' is correct.");
+
+  let ruleCount = summary.querySelector(".stylesheet-rule-count").textContent;
+  is(parseInt(ruleCount, 10), expected.rules, "the rule count is correct");
+
+  is(summary.classList.contains("splitview-active"), expected.active,
+    "The active status for this sheet is correct.");
+}