Bug 1210671 - Avoid CPOW to create the test page in browser_inspector_initialization.js. r=miker, a=test-only
authorPatrick Brosset <pbrosset@mozilla.com>
Tue, 17 May 2016 12:51:44 +0200
changeset 332933 31728fa2783e7e2718c7137674a698344e5c6af6
parent 332932 fce8621653ed6231a29514b3914a159f17b1bb85
child 332934 b713a048b8c5925a16efaab49ad5e88ea15b5f0a
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmiker, test-only
bugs1210671
milestone48.0a2
Bug 1210671 - Avoid CPOW to create the test page in browser_inspector_initialization.js. r=miker, a=test-only MozReview-Commit-ID: Jjq5SUWZTXa
devtools/client/inspector/test/browser_inspector_initialization.js
--- a/devtools/client/inspector/test/browser_inspector_initialization.js
+++ b/devtools/client/inspector/test/browser_inspector_initialization.js
@@ -3,39 +3,35 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 // Tests for different ways to initialize the inspector.
 
-const DOCUMENT_HTML = '<div id="first" style="{margin: 10em; font-size: 14pt;' +
-  'font-family: helvetica, sans-serif; color: #AAA}">\n' +
-  '<h1>Some header text</h1>\n' +
-  '<p id="salutation" style="{font-size: 12pt}">hi.</p>\n' +
-  '<p id="body" style="{font-size: 12pt}">I am a test-case. This text exists ' +
-  'solely to provide some things to test the inspector initialization.</p>\n' +
-  'If you are reading this, you should go do something else instead. Maybe ' +
-  'read a book. Or better yet, write some test-cases for another bit of code. ' +
-  '<span style="{font-style: italic}">Inspector\'s!</span></p>\n' +
-  '<p id="closing">end transmission</p>\n' +
-  '</div>';
+const HTML = `
+  <div id="first" style="margin: 10em; font-size: 14pt;
+                         font-family: helvetica, sans-serif; color: gray">
+    <h1>Some header text</h1>
+    <p id="salutation" style="font-size: 12pt">hi.</p>
+    <p id="body" style="font-size: 12pt">I am a test-case. This text exists
+    solely to provide some things to test the inspector initialization.</p>
+    <p>If you are reading this, you should go do something else instead. Maybe
+    read a book. Or better yet, write some test-cases for another bit of code.
+      <span style="font-style: italic">Inspector's!</span>
+    </p>
+    <p id="closing">end transmission</p>
+  </div>
+`;
 
-const TEST_URI = "data:text/html;charset=utf-8,test page";
+const TEST_URI = "data:text/html;charset=utf-8," + encodeURI(HTML);
 
 add_task(function* () {
   let tab = yield addTab(TEST_URI);
-  content.document.body.innerHTML = DOCUMENT_HTML;
-  content.document.title = "Inspector Initialization Test";
-
-  let deferred = promise.defer();
-  executeSoon(deferred.resolve);
-  yield deferred.promise;
-
   let testActor = yield getTestActorWithoutToolbox(tab);
 
   yield testToolboxInitialization(tab);
   yield testContextMenuInitialization(testActor);
   yield testContextMenuInspectorAlreadyOpen(testActor);
 });
 
 function* testToolboxInitialization(tab) {
@@ -93,24 +89,25 @@ function* testContextMenuInspectorAlread
 }
 
 function* testMarkupView(selector, inspector) {
   inspector = inspector || getActiveInspector();
   let nodeFront = yield getNodeFront(selector, inspector);
   try {
     is(inspector.selection.nodeFront, nodeFront,
        "Right node is selected in the markup view");
-  } catch(ex) {
+  } catch (ex) {
     ok(false, "Got exception while resolving selected node of markup view.");
     console.error(ex);
   }
 }
 
 function* testBreadcrumbs(selector, inspector) {
   inspector = inspector || getActiveInspector();
   let nodeFront = yield getNodeFront(selector, inspector);
 
   let b = inspector.breadcrumbs;
   let expectedText = b.prettyPrintNodeAsText(nodeFront);
   let button = b.container.querySelector("button[checked=true]");
   ok(button, "A crumbs is checked=true");
-  is(button.getAttribute("tooltiptext"), expectedText, "Crumb refers to the right node");
+  is(button.getAttribute("tooltiptext"), expectedText,
+     "Crumb refers to the right node");
 }