Bug 1496990 - Move the onSidebarSelect event handler before adding the sidebar tabs...
[gecko.git] / devtools / client / inspector / computed / test / browser_computed_default_tab.js
blob43f5c772c4814afba485ed661c48dc94562978b3
1 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
2 /* Any copyright is dedicated to the Public Domain.
3  http://creativecommons.org/publicdomain/zero/1.0/ */
5 "use strict";
7 // Test that the computed view is initialized when the computed view is the default tab
8 // for the inspector.
10 const TEST_URI = `
11   <style type="text/css">
12     #matches {
13       color: #F00;
14     }
15   </style>
16   <span id="matches">Some styled text</span>
19 add_task(async function() {
20   await pushPref("devtools.inspector.activeSidebar", "computedview");
21   await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
22   const {inspector, view} = await openComputedView();
23   await selectNode("#matches", inspector);
24   is(isPropertyVisible("color", view), true, "span #matches color property is visible");
25 });
27 function isPropertyVisible(name, view) {
28   info("Checking property visibility for " + name);
29   const propertyViews = view.propertyViews;
30   for (const propView of propertyViews) {
31     if (propView.name == name) {
32       return propView.visible;
33     }
34   }
35   return false;