Skip to content

Commit

Permalink
[tests] Automated test case for issue 4542 (Quotes Issue With JavaScr…
Browse files Browse the repository at this point in the history
…ipt Function Calls Inside Inline Event Handlers)

http://code.google.com/p/fbug/issues/detail?id=4542

Removed old manual test case

git-svn-id: http://fbug.googlecode.com/svn@11161 e969d3be-0e28-0410-a27f-dd5c76401a8b
  • Loading branch information
[email protected] committed Jun 29, 2011
1 parent 6afd497 commit 825c358
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ <h1><a href="http://code.google.com/p/fbug/issues/detail?id=4542">Issue 4542</a>
</header>
<div>
<section id="content">
<input type="text" id="input" onkeydown="var output = document.getElementById(output'); output.style.display = 'block'; output.innerHTML = Hey, you entered something into the input field!&quot;">
<button id="sayHi" onclick="var output = document.getElementById(output'); output.style.display = 'block'; output.innerHTML = Hi there, tester!&quot;">
Say hi
</button>
<section id="output">
</section>
</section>
Expand All @@ -25,24 +27,26 @@ <h3>Steps to reproduce</h3>
<ol>
<li>Open Firebug</li>
<li>Switch to the HTML panel</li>
<li>Inspect the input field above (<code>#input</code>)</li>
<li>Click on the value of the <code>onkeydown</code> attribute to start editing</li>
<li>Inspect the button above (<code>#sayHi</code>)</li>
<li>Click on the value of the <code>onclick</code> attribute to start editing</li>
<li>Move the text cursor between the opening bracket and <code>output</code> of <code>getElementById(output')</code></li>
<li>Enter a single quote (<code>'</code>)</li>
<li>Move the text cursor before the <code>H</code> of <code>Hey</code></li>
<li>Enter a double quote (")</li>
<li>
Enter a single quote (<code>'</code>)<br/>
&rArr; The single quote is entered into the input field
</li>
<li>Move the text cursor before the <code>H</code> of <code>Hi</code></li>
<li>
Enter a double quote (")<br/>
&rArr; The double quote is entered into the input field
</li>
<li>Focus the input field on the page and type <code>a</code></li>
</ol>
<h3>Expected Result</h3>
<ul>
<li>After step 6: The single quote is entered into the input field</li>
<li>After step 8: The double quote is entered into the input field</li>
<li>After step 9: <code>Hey, you entered something into the input field!</code> shown below the input field</li>
<li><code>Hi there, tester!</code> shown below the button</li>
</ul>
</section>
<footer>
Gabriel Nahmias, nahmias.gabriel at gmail.com
</footer>
<footer>Sebastian Zartner, [email protected]</footer>
</div>
</body>
</html>
75 changes: 75 additions & 0 deletions tests/content/branches/1.8/html/4542/issue4542.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
function runTest()
{
FBTest.sysout("issue4542.START");
FBTest.openNewTab(basePath + "html/4542/issue4542.html", function(win)
{
FBTest.openFirebug();
var panel = FBTest.selectPanel("html");

FBTest.selectElementInHtmlPanel("sayHi", function(node)
{
var attributes = node.querySelectorAll(".nodeAttr");
var i;

hasOnClickAttribute = false;
for (i=0; i<attributes.length; i++)
{
var nodeName = attributes[i].querySelector(".nodeName");
if (nodeName.textContent == "onclick")
{
hasOnClickAttribute = true;
break;
}
}

if (FBTest.ok(hasOnClickAttribute, "There must be an 'onclick' attribute"))
{
var nodeValue = attributes[i].querySelector(".nodeValue");
// Click the attribute value to open the inline editor
FBTest.synthesizeMouse(nodeValue);

var editor = panel.panelNode.querySelector(".textEditorInner");
if (FBTest.ok(editor, "Editor must be available now"))
{
FBTest.sendKey("HOME", editor);
// Move text cursor between the opening bracket and 'output' of
// 'getElementById(output')'
for (var i=0; i<37; i++)
FBTest.sendKey("RIGHT", editor);

// Enter a single quote
FBTest.sendChar("'", editor);

if (!FBTest.ok(editor &&editor.value.search("var output") != -1,
"Editor must still be available and must not jump to the next editable " +
"item when a single quote is entered"))
{
FBTest.synthesizeMouse(nodeValue);
editor = panel.panelNode.querySelector(".textEditorInner");
}

FBTest.compare(/getElementById\('output'\)/, editor.value, "Single quote must be entered");

// Move text cursor before the 'H' of 'Hi'
for (var i=0; i<61; i++)
FBTest.sendKey("RIGHT", editor);

// Enter a double quote
FBTest.sendChar("\"", editor);

if (!FBTest.ok(editor && editor.value.search("var output") != -1,
"Editor must still be available and must not jump to the next editable " +
"item when a double quote is entered"))
{
FBTest.synthesizeMouse(nodeValue);
editor = panel.panelNode.querySelector(".textEditorInner");
}

FBTest.compare(/"Hi/, editor.value, "Double quote must be entered");
}

FBTest.testDone("issue4542.DONE");
}
});
});
}
1 change: 1 addition & 0 deletions tests/content/testlists/firebug1.8.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
{group: "html", uri: "html/breakpoints/breakOnElementCB.js", desc: "Mutation breakpoints test (Chromebug active)", testPage: "html/breakpoints/breakOnElement.html"},
{group: "html", uri: "html/onMutate.js", desc: "Html Mutation test", testPage: "html/onMutate.html"},
{group: "html", uri: "html/2426/issue2426.js", desc: "Copy XPath should include namespace", testPage: "html/2426/issue2426.html"},
{group: "html", uri: "html/4542/issue4542.js", desc: "Quotes Issue With JavaScript Function Calls Inside Inline Event Handlers", testPage: "html/4542/issue4542.html"},
{group: "css", uri: "css/537/issue537.js", desc: "Pseudo-elements are not displayed in Style side panel", testPage: "css/537/issue537.html"},
{group: "css", uri: "css/1338/issue1338.js", desc: "Increment CSS values at least significant digit", testPage: "css/1338/issue1338.html"},
{group: "css", uri: "css/2440/issue-2440.js", desc: "Duplicate stylesheet refs", testPage: "css/2440/issue-2440.html"},
Expand Down

0 comments on commit 825c358

Please sign in to comment.