Bug 1264702 - [rep tests] Add tests for window rep. r=Honza
authorLin Clark <lclark@mozilla.com>
Tue, 03 May 2016 10:59:00 -0400
changeset 296377 ec7b54a0d8125df63b6c11a36e35941a9d81ac31
parent 296376 7fa2a19a9c5357a46722e3dd5088c177fc4e2d7d
child 296378 2451d15ff23433445b43eee9ceb565b7d8750029
push id76311
push usercbook@mozilla.com
push dateFri, 06 May 2016 12:26:12 +0000
treeherdermozilla-inbound@84a3e5716801 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1264702
milestone49.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 1264702 - [rep tests] Add tests for window rep. r=Honza
devtools/client/shared/components/reps/window.js
devtools/client/shared/components/test/mochitest/chrome.ini
devtools/client/shared/components/test/mochitest/test_reps_window.html
--- a/devtools/client/shared/components/reps/window.js
+++ b/devtools/client/shared/components/reps/window.js
@@ -27,24 +27,16 @@ define(function(require, exports, module
     },
 
     displayName: "Window",
 
     getLocation: function(grip) {
       return cropString(grip.preview.url);
     },
 
-    getTitle: function(grip, context) {
-      return grip.class;
-    },
-
-    getTooltip: function(grip) {
-      return grip.preview.url;
-    },
-
     render: function() {
       let grip = this.props.object;
 
       return (
         ObjectBox({className: "Window"},
           DOM.span({className: "objectPropValue"},
             this.getLocation(grip)
           )
--- a/devtools/client/shared/components/test/mochitest/chrome.ini
+++ b/devtools/client/shared/components/test/mochitest/chrome.ini
@@ -1,15 +1,16 @@
 [DEFAULT]
 support-files =
   head.js
 
 [test_HSplitBox_01.html]
 [test_reps_object-with-url.html]
 [test_reps_undefined.html]
+[test_reps_window.html]
 [test_frame_01.html]
 [test_tree_01.html]
 [test_tree_02.html]
 [test_tree_03.html]
 [test_tree_04.html]
 [test_tree_05.html]
 [test_tree_06.html]
 [test_tree_07.html]
new file mode 100644
--- /dev/null
+++ b/devtools/client/shared/components/test/mochitest/test_reps_window.html
@@ -0,0 +1,56 @@
+
+<!DOCTYPE HTML>
+<html>
+<!--
+Test window rep
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Rep tests - window</title>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
+</head>
+<body>
+<pre id="test">
+<script src="head.js" type="application/javascript;version=1.8"></script>
+<script type="application/javascript;version=1.8">
+window.onload = Task.async(function* () {
+  try {
+    let ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");
+    let React = browserRequire("devtools/client/shared/vendor/react");
+    let { Rep } = browserRequire("devtools/client/shared/components/reps/rep");
+    let { Window } = browserRequire("devtools/client/shared/components/reps/window");
+
+    let gripStub = {
+      "type": "object",
+      "class": "Window",
+      "actor": "server1.conn3.obj198",
+      "extensible": true,
+      "frozen": false,
+      "sealed": false,
+      "ownPropertyLength": 887,
+      "preview": {
+        "kind": "ObjectWithURL",
+        "url": "about:newtab"
+      }
+    };
+
+    // Test that correct rep is chosen
+    const renderedRep = shallowRenderComponent(Rep, { object: gripStub });
+    is(renderedRep.type, Window.rep, `Rep correctly selects ${Window.rep.displayName}`);
+
+    // Test rendering
+    const renderedComponent = renderComponent(Window.rep, { object: gripStub });
+    ok(renderedComponent.className.includes("objectBox-Window"), "Window rep has expected class name");
+    const innerNode = renderedComponent.querySelector(".objectPropValue");
+    is(innerNode.textContent, "about:newtab", "Window rep has expected inner HTML structure and text content");
+  } catch(e) {
+    ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
+  } finally {
+    SimpleTest.finish();
+  }
+});
+</script>
+</pre>
+</body>
+</html>