2012-03-09 06:27:37 +04:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
// Test that focus doesn't leave the style editor when adding a property
|
|
|
|
// (bug 719916)
|
|
|
|
|
2012-03-27 02:26:21 +04:00
|
|
|
let tempScope = {};
|
|
|
|
Cu.import("resource:///modules/devtools/CssRuleView.jsm", tempScope);
|
|
|
|
let inplaceEditor = tempScope._getInplaceEditorForSpan;
|
2012-03-09 06:27:37 +04:00
|
|
|
let doc;
|
|
|
|
let stylePanel;
|
|
|
|
|
|
|
|
function waitForRuleView(aCallback)
|
|
|
|
{
|
2012-04-19 22:04:46 +04:00
|
|
|
InspectorUI.currentInspector.once("sidebaractivated-ruleview", aCallback);
|
2012-03-09 06:27:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function openRuleView()
|
|
|
|
{
|
|
|
|
Services.obs.addObserver(function onOpened() {
|
|
|
|
Services.obs.removeObserver(onOpened,
|
|
|
|
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
|
|
|
|
|
|
|
// Highlight a node.
|
|
|
|
let node = content.document.getElementsByTagName("h1")[0];
|
|
|
|
InspectorUI.inspectNode(node);
|
|
|
|
InspectorUI.stopInspecting();
|
|
|
|
|
|
|
|
// Open the rule view sidebar.
|
|
|
|
waitForRuleView(testFocus);
|
|
|
|
|
2012-04-19 22:04:46 +04:00
|
|
|
InspectorUI.sidebar.show();
|
|
|
|
InspectorUI.sidebar.activatePanel("ruleview");
|
2012-03-09 06:27:37 +04:00
|
|
|
|
|
|
|
testFocus();
|
|
|
|
}, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
|
|
|
InspectorUI.openInspectorUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
function testFocus()
|
|
|
|
{
|
2012-04-19 22:04:46 +04:00
|
|
|
let ruleViewFrame = InspectorUI.sidebar._tools["ruleview"].frame;
|
2012-03-09 06:27:37 +04:00
|
|
|
let brace = ruleViewFrame.contentDocument.querySelectorAll(".ruleview-ruleclose")[0];
|
|
|
|
waitForEditorFocus(brace.parentNode, function onNewElement(aEditor) {
|
|
|
|
aEditor.input.value = "color";
|
|
|
|
waitForEditorFocus(brace.parentNode, function onEditingValue(aEditor) {
|
|
|
|
// If we actually get this focus we're ok.
|
|
|
|
ok(true, "We got focus.");
|
|
|
|
aEditor.input.value = "green";
|
|
|
|
|
|
|
|
// If we've retained focus, pressing return will start a new editor.
|
|
|
|
// If not, we'll wait here until we time out.
|
|
|
|
waitForEditorFocus(brace.parentNode, function onNewEditor(aEditor) {
|
|
|
|
aEditor.input.blur();
|
2012-03-19 22:38:13 +04:00
|
|
|
finishUp();
|
2012-03-09 06:27:37 +04:00
|
|
|
});
|
|
|
|
EventUtils.sendKey("return");
|
|
|
|
});
|
|
|
|
EventUtils.sendKey("return");
|
|
|
|
});
|
|
|
|
|
2012-06-02 02:13:48 +04:00
|
|
|
brace.click();
|
2012-03-09 06:27:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function finishUp()
|
|
|
|
{
|
2012-04-19 22:04:46 +04:00
|
|
|
InspectorUI.sidebar.hide();
|
2012-03-19 22:38:13 +04:00
|
|
|
InspectorUI.closeInspectorUI();
|
2012-03-09 06:27:37 +04:00
|
|
|
doc = stylePanel = null;
|
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
function test()
|
|
|
|
{
|
|
|
|
waitForExplicitFinish();
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
gBrowser.selectedBrowser.addEventListener("load", function(evt) {
|
|
|
|
gBrowser.selectedBrowser.removeEventListener(evt.type, arguments.callee, true);
|
|
|
|
doc = content.document;
|
|
|
|
doc.title = "Rule View Test";
|
|
|
|
waitForFocus(openRuleView, content);
|
|
|
|
}, true);
|
|
|
|
|
|
|
|
content.location = "data:text/html,<h1>Some header text</h1>";
|
|
|
|
}
|