-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #39 GET params values get dropped from URL
- use encodeURIComponent to encode the 'path' query parameter so that any question marks (and other special chars) in the path are processed correctly. - add tests/functional/testIssue39.js
- Loading branch information
Showing
4 changed files
with
107 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!doctype html> | ||
<?php | ||
require_once("config.php"); | ||
?> | ||
<html> | ||
<head> | ||
<title>testIssue39.html.php</title> | ||
</head> | ||
<body> | ||
|
||
<!-- Test local (relative) HAR --> | ||
<div id="previewLocalWithQueryString" class="har" height="100" data-har="/selenium/tests/hars/simple.har?action=show_me_har_file"></div> | ||
|
||
<!-- Test remote (JSONP) HAR --> | ||
<div id="previewNonLocalWithQueryString" class="har" height="100" data-har="<?php echo $test_base.'tests/hars/testLoad1.harp?action=show_me_har_file' ?>" data-callback="callback_testLoad1"></div> | ||
|
||
<script> | ||
(function() { | ||
var har = document.createElement("script"); | ||
har.src = "<?php echo $harviewer_base ?>har.js"; | ||
har.setAttribute("id", "har"); | ||
har.setAttribute("async", "true"); | ||
document.documentElement.firstChild.appendChild(har); | ||
})(); | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
define([ | ||
'intern', | ||
'intern!object', | ||
'intern/chai!assert', | ||
'require', | ||
'./DriverUtils', | ||
'intern/dojo/node!leadfoot/helpers/pollUntil' | ||
], function(intern, registerSuite, assert, require, DriverUtils, pollUntil) { | ||
var harViewerBase = intern.config.harviewer.harViewerBase; | ||
var testBase = intern.config.harviewer.testBase; | ||
|
||
registerSuite({ | ||
name: 'testIssue39', | ||
|
||
/** | ||
* https://github.com/janodvarko/harviewer/issues/39 | ||
* Query param values get dropped from URL when used as "data-har" HTML attribute. | ||
* E.g.: | ||
* <div class="har" height="500" data-har="http://example.com/index.php?action=show_me_har_file"></div> | ||
* Leads to IFRAME URL of: | ||
* http://example.com/index.php?action&callback=onInputData&_=1440704124791 | ||
*/ | ||
'testIssue39': function() { | ||
// Some of these tests need a larger timeout for finding DOM elements | ||
// because we need the HAR to parse/display fully before we query the DOM. | ||
var findTimeout = intern.config.harviewer.findTimeout; | ||
var r = this.remote; | ||
var utils = new DriverUtils(r); | ||
|
||
var url = testBase + "tests/testIssue39.html.php"; | ||
|
||
return r | ||
.setFindTimeout(findTimeout) | ||
.get(url) | ||
.then(DriverUtils.waitForElements("iframe", 2, findTimeout)) | ||
.then(pollUntil(DriverUtils.querySelectAllInFrameAndReturnLengthOrNull, ['#previewLocalWithQueryString', '.pageTable'], findTimeout)) | ||
.then(function(len) { | ||
assert.strictEqual(len, 1, "#previewLocalWithQueryString.pageTable"); | ||
}) | ||
.findByCssSelector("#previewLocalWithQueryString iframe") | ||
.then(function(iframe) { | ||
return iframe.getAttribute("src").then(function(src) { | ||
// search for the action parameter and value. | ||
// "%3D" === encodeURIComponent("=") | ||
assert.include(src, "action%3Dshow_me_har_file"); | ||
}); | ||
}) | ||
.end() // end IFRAME | ||
.then(pollUntil(DriverUtils.querySelectAllInFrameAndReturnLengthOrNull, ['#previewNonLocalWithQueryString', '.pageTable'], findTimeout)) | ||
.then(function(len) { | ||
assert.strictEqual(len, 1, "#previewNonLocalWithQueryString.pageTable"); | ||
}) | ||
.findByCssSelector("#previewNonLocalWithQueryString iframe") | ||
.then(function(iframe) { | ||
return iframe.getAttribute("src").then(function(src) { | ||
// search for the action parameter and value. | ||
// "%3D" === encodeURIComponent("=") | ||
assert.include(src, "action%3Dshow_me_har_file"); | ||
}); | ||
}) | ||
.end() // end IFRAME | ||
.then(pollUntil(DriverUtils.querySelectAllInFrameAndReturnLengthOrNull, ['#previewLocalWithQueryString', '.netRow'], findTimeout)) | ||
.then(function(len) { | ||
assert.strictEqual(len, 2, "#previewLocalWithQueryString.netRow"); | ||
}) | ||
.then(pollUntil(DriverUtils.querySelectAllInFrameAndReturnLengthOrNull, ['#previewNonLocalWithQueryString', '.netRow'], findTimeout)) | ||
.then(function(len) { | ||
assert.strictEqual(len, 11, "#previewNonLocalWithQueryString.netRow"); | ||
}); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters