[Pkg-mozext-commits] [firebug] 17/55: FBTest for issue 5592
David Prévot
taffit at moszumanska.debian.org
Mon Mar 31 22:46:08 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to tag firebug-1.10.1
in repository firebug.
commit c6f50ab14884cd2a559d11c6eb0c70bdc6e03106
Author: Jan Odvarko <odvarko at gmail.com>
Date: Tue Jul 17 15:20:17 2012 +0200
FBTest for issue 5592
---
tests/content/firebug.html | 1 +
tests/content/net/5592/issue5592.html | 68 +++++++++++----------------------
tests/content/net/5592/issue5592.js | 71 +++++++++++++++++++++++++++++++++++
tests/content/net/5592/issue5592.php | 5 +--
4 files changed, 95 insertions(+), 50 deletions(-)
diff --git a/tests/content/firebug.html b/tests/content/firebug.html
index df09eae..5c93103 100644
--- a/tests/content/firebug.html
+++ b/tests/content/firebug.html
@@ -306,6 +306,7 @@ var testList = [
{group: "net", uri: "net/4905/issue4905.js", desc: "Show the \"Connection\" header in the network/headers part", testPage: "net/4905/issue4905.html" },
{group: "net", uri: "net/5004/issue5004.js", desc: "Only raw http post request parameters view", testPage: "net/5004/issue5004.html" },
{group: "net", uri: "net/5007/issue5007.js", desc: "Headers from POST request body are not displayed anymore", testPage: "net/5007/issue5007.html" },
+ {group: "net", uri: "net/5592/issue5592.js", desc: "Add option to copy request parameters", testPage: "net/5592/issue5592.html" },
{group: "cookies", uri: "cookies/general/cookiesPanel.js", desc: "Existence of cookie panel", testPage: "cookies/general/cookiesPanel.html" },
{group: "cookies", uri: "cookies/general/cookieInfo.js", desc: "Existence of cookie info", testPage: "cookies/general/cookieInfo.php" },
{group: "cookies", uri: "cookies/general/clipboard.js", desc: "Clipboard functionality for the Cookies panel (copy and paste)", testPage: "cookies/general/clipboard.php" },
diff --git a/tests/content/net/5592/issue5592.html b/tests/content/net/5592/issue5592.html
index 3d85ae9..d8f8105 100755
--- a/tests/content/net/5592/issue5592.html
+++ b/tests/content/net/5592/issue5592.html
@@ -11,62 +11,38 @@
- <span class="h3">Add option to copy request parameters</span>.
<br/>
-<i>Bharath Thiruveedula, bharaththiruveedula at gmail.com</i>
+<i>Bharath Thiruveedula, bharaththiruveedula at gmail.com</i><br/>
+<i>Jan Odvarko, odvarko at gmail.com</i>
</p>
<ol>
<li>Open the firebug , enable and open the net Panel</li>
-<li>Use the <i>POST</i> button to post data to a server (it will generate XMLHttpRequests) , or enter the value in the textbox and enter the get button</li>
-<li>Now you can see the GET/POST requests in the net panel depends on what type of button you clicked.</li>
-<li>Now right click on the GET/POST request and select the "Copy URL Parameters" or "Copy POST Parameters".</li>
-
+<li>Click this button to generate a request
+<button id="testButton" onclick="executeTest()">Click Me!</button></li>
+<li>Right click on the new entry in the Net panel and execute
+ <i>Copy URL Parameters</i></li>
+<li>Check the clipboard it should be equal to:
+<pre>v1=d1
+v2=d2</pre></li>
+
+<li>Right click on the new entry in the Net panel and execute
+ <i>Copy POST Parameters</i></li>
+<li>Check the clipboard it should be equal to:
+<pre>value1=param1
+value2=param2</pre></li>
</ol>
-<button id="testButton" onclick="postRequest()">POST</button>
-<form action="issue5592.html" method="GET">
-<input type="text" name="text">
-<input type="submit" value="GET" placeholder="Enter the Value">
-</form>
-
-<p><i>As soon as the user selects the "Copy URL/POST Parameters" the parameters are copied to the user's clipboard</i></p>
-
<script type="text/javascript">
-function postRequest(postData, callback)
+function executeTest()
{
- try
- {
- if (!postData)
- {
- var date = (new Date()).toUTCString();
- postData = "date=" + date;
- }
-
-
-
- var request = new XMLHttpRequest();
- request.open("POST", "issue5592.php", true);
- request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- request.setRequestHeader("Content-Length", postData.length);
-
- request.onreadystatechange = function()
- {
- if (request.readyState == 4 && request.status == 200)
- {
- if (callback) {
- setTimeout(function() {
- callback(request);
- }, 300);
- }
- }
- }
+ var request = new XMLHttpRequest();
+ request.open("POST", "issue5592.php?v1=d1&v2=d2", true);
- request.send(postData);
- }
- catch (err)
- {
- alert("Error initializing XMLHttpRequest.\n" + err);
- }
+ var postData = "value1=param1&value2=param2";
+ request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ request.setRequestHeader("Content-Length", postData.length);
+ request.send(postData);
}
</script>
diff --git a/tests/content/net/5592/issue5592.js b/tests/content/net/5592/issue5592.js
new file mode 100644
index 0000000..fe43fbf
--- /dev/null
+++ b/tests/content/net/5592/issue5592.js
@@ -0,0 +1,71 @@
+// Test entry point. Every test driver needs to implement this function.
+// It's automatically executed by Firebug test harness (FBTest).
+function runTest()
+{
+ // Just a log into the Firebug tracing console (FBTrace). You need to set
+ // 'TESTCASE' option to see logs made through FBTest.sysout.
+ FBTest.sysout("issue5592.START");
+
+ // Open a new tab with the test page. 'basePath' variable is provided
+ // by test harness.
+ FBTest.openNewTab(basePath + "net/5592/issue5592.html", function(win)
+ {
+ // Open Firebug UI and enable Net panel.
+ FBTest.enableNetPanel(function(win)
+ {
+ var options = {
+ tagName: "tr",
+ classes: "netRow category-xhr hasHeaders loaded"
+ };
+
+ // Wait till a 'HTTP request' entry is displayed in the Net panel.
+ FBTest.waitForDisplayedElement("net", options, function(row)
+ {
+ FBTest.sysout("issue5592.response received");
+
+ // Create list of asynchronous tasks, see:
+ // https://getfirebug.com/wiki/index.php/Firebug_Automated_Test_Examples#Example:_Asynchronous_tasks_within_a_test
+ var tasks = new FBTest.TaskList();
+
+ // There are two async operation.
+ // 1) Copy URL Parameters to the clipboard and verify
+ // 1) Copy POST Parameters to the clipboard and verify
+ tasks.push(executeAndVerify, row, "fbCopyUrlParameters",
+ /v1=d1\s*v2=d2/);
+ tasks.push(executeAndVerify, row, "fbCopyPOSTParameters",
+ /value1=param1\s*value2=param2/);
+
+ // Run both async tasks
+ tasks.run(function()
+ {
+ FBTest.testDone("issue5592.DONE");
+ });
+ });
+
+ // Run test implemented on the page by clicking on the
+ // test button.
+ FBTest.click(win.document.getElementById("testButton"));
+ });
+ });
+}
+
+// The first 'callback' parameter is passed automatically by
+// FBTest.TaskList object. As soon as the function finishes
+// its asynchronous job, the callback must be executed to
+// allow the next registered task to be started.
+function executeAndVerify(callback, target, actionID, expected)
+{
+ // Open context menu on the specified target.
+ FBTest.executeContextMenuCommand(target, actionID, function()
+ {
+ // Data can be copyied into the clipboard asynchronously,
+ // so wait till they are available.
+ FBTest.waitForClipboard(expected, function(text)
+ {
+ // Verify data in the clipboard
+ FBTest.compare(expected, text,
+ "Proper data must be in the clipboard. Current: " + text);
+ callback();
+ });
+ });
+}
diff --git a/tests/content/net/5592/issue5592.php b/tests/content/net/5592/issue5592.php
index 9fa6473..7f0c605 100755
--- a/tests/content/net/5592/issue5592.php
+++ b/tests/content/net/5592/issue5592.php
@@ -1,7 +1,4 @@
<?php
header("Content-Type: text/plain");
-echo "date=";
-echo $_GET["date"];
-echo $_POST["date"];
-echo $_GET["date"];
+echo "Test response 5592";
?>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firebug.git
More information about the Pkg-mozext-commits
mailing list