PageRenderTime 40ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/content/branches/1.10/net/1308/issue1308.js

http://fbug.googlecode.com/
JavaScript | 55 lines | 38 code | 10 blank | 7 comment | 1 complexity | cefe3437ca7f364ed3227396c52ebbd7 MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0
  1. function runTest()
  2. {
  3. FBTest.sysout("issue1308.START");
  4. var pageURI = basePath + "net/1308/issue1308.html";
  5. var scriptURI = basePath + "net/1308/issue1308.js";
  6. FBTest.openNewTab(pageURI, function(win)
  7. {
  8. FBTest.enableNetPanel(function(win)
  9. {
  10. win.runTest(checkCopyLocationWithParametersAction);
  11. });
  12. });
  13. }
  14. function checkCopyLocationWithParametersAction(request)
  15. {
  16. // Expand the test request with params
  17. var panel = FBTest.selectPanel("net");
  18. var netRow = FW.FBL.getElementByClass(panel.panelNode, "netRow", "category-xhr",
  19. "hasHeaders", "loaded");
  20. if (!netRow)
  21. {
  22. FBTest.ok(false, "There must be a XHR entry within the Net panel.");
  23. return FBTest.testDone();
  24. }
  25. // Test the "Copy Location With Parameters action" available in the context menu
  26. // for specific Net panel entry.
  27. panel.copyParams(netRow.repObject);
  28. // Get data from the clipboard.
  29. var clipboard = FW.FBL.CCSV("@mozilla.org/widget/clipboard;1", "nsIClipboard");
  30. var trans = FW.FBL.CCIN("@mozilla.org/widget/transferable;1", "nsITransferable");
  31. trans.addDataFlavor("text/unicode");
  32. clipboard.getData(trans, Ci.nsIClipboard.kGlobalClipboard);
  33. var str = new Object();
  34. var strLength = new Object();
  35. trans.getTransferData("text/unicode", str, strLength);
  36. str = str.value.QueryInterface(Ci.nsISupportsString);
  37. var actual = str.data.substring(0, strLength.value / 2);
  38. // Complete expected result.
  39. var requestUri = FBTest.getHTTPURLBase() + "net/1308/issue1308.txt";
  40. var expected = requestUri + "?param1=1%20%2B%202";
  41. // Verification.
  42. FBTest.compare(expected, actual, "Verify that the copied URL is properly encoded.");
  43. // Finish test
  44. FBTest.testDone("issue1308.DONE");
  45. }