Bug 1210671 - Avoid CPOW to create the test page in browser_inspector_initialization.js; r=miker draft
authorPatrick Brosset <pbrosset@mozilla.com>
Tue, 17 May 2016 12:51:44 +0200
changeset 367813 885ecd284c4dc3c82ab8229b677384af80781900
parent 367812 d9e74b75edae6fde5d4e1c47736495d8ce52e12b
child 521107 94e4dbdaf7baeea0fecaffc94ff467911b3bb1a7
push id18353
push userpbrosset@mozilla.com
push dateTue, 17 May 2016 10:53:06 +0000
reviewersmiker
bugs1210671
milestone49.0a1
Bug 1210671 - Avoid CPOW to create the test page in browser_inspector_initialization.js; r=miker 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");
 }