summaryrefslogtreecommitdiffstats
path: root/devtools/client/styleeditor/test/browser_styleeditor_syncIntoRuleView.js
blob: 143e4e92c322a94005345bd6529ef8b9b7b9e23b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

// Test that changes in the style editor are synchronized into the
// style inspector.

const TEST_URI = `
  <style type='text/css'>
  </style>
  <div id='testid' class='testclass'>Styled Node</div>
`;

const TESTCASE_CSS_SOURCE = "#testid { color: chartreuse; }";

add_task(async function () {
  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));

  info("Open the inspector and select the node we want to add style to");
  const { inspector, view } = await openRuleView();
  await selectNode("#testid", inspector);

  info("Open the StyleEditor");
  const { panel, ui } = await openStyleEditor();

  const editor = await ui.editors[0].getSourceEditor();
  await new Promise(res => waitForFocus(res, panel.panelWindow));

  info("Type new rule in stylesheet");
  editor.focus();
  EventUtils.sendString(TESTCASE_CSS_SOURCE, panel.panelWindow);
  ok(editor.unsaved, "new editor has unsaved flag");

  info("Wait for ruleview to update");
  await inspector.toolbox.selectTool("inspector");
  await waitFor(() => getRuleViewRule(view, "#testid"));

  info("Check that edits were synced to rule view");
  const value = getRuleViewPropertyValue(view, "#testid", "color");
  is(value, "chartreuse", "Got the expected color property");
});