Commit e41c92b5 e41c92b553ada4477aa8836b66e842c6c1ee5bb0 by Nicolas Perriault

fixed getHTML() doesn't retrieve active frame contents

1 parent 73265252
......@@ -4,7 +4,8 @@ CasperJS Changelog
XXXX-XX-XX, v1.0.0
------------------
- merged PR [#322](https://github.com/n1k0/casperjs/pull/322) - Support number in withFrame()
- fixed `Casper.getHTML()` wasn't retrieving active frame contents when using `Casper.withFrame()`
- merged PR [#322](https://github.com/n1k0/casperjs/pull/322) - Support number in `Casper.withFrame()`
- fixed [#323](https://github.com/n1k0/casperjs/issues/323) - `thenEvaluate()` should be updated to take the same parameters as `evaluate()`, while maintaining backwards compatibility.
- merged PR [#319](https://github.com/n1k0/casperjs/pull/319), fixed [#209](https://github.com/n1k0/casperjs/issues/209) - test duration has been added to XUnit XML result file.
- `Casper.userAgent()` does not require the instance to be started anymore
......
......@@ -770,7 +770,7 @@ Casper.prototype.getPageContent = function getPageContent() {
this.checkStarted();
var contentType = utils.getPropertyPath(this, 'currentResponse.contentType');
if (!utils.isString(contentType)) {
return this.page.content;
return this.page.frameContent;
}
// for some reason webkit/qtwebkit will always enclose body contents within html tags
var sanitizedHtml = this.evaluate(function checkHtml() {
......@@ -780,7 +780,7 @@ Casper.prototype.getPageContent = function getPageContent() {
return __utils__.findOne('body pre').textContent.trim();
}
});
return sanitizedHtml ? sanitizedHtml : this.page.content;
return sanitizedHtml ? sanitizedHtml : this.page.frameContent;
};
/**
......@@ -931,7 +931,7 @@ Casper.prototype.getHTML = function getHTML(selector, outer) {
"use strict";
this.checkStarted();
if (!selector) {
return this.page.content;
return this.page.frameContent;
}
if (!this.exists(selector)) {
throw new CasperError("No element matching selector found: " + selector);
......
......@@ -367,6 +367,9 @@ Tester.prototype.assertHttpStatus = function assertHttpStatus(status, message) {
*/
Tester.prototype.assertMatch = Tester.prototype.assertMatches = function assertMatch(subject, pattern, message) {
"use strict";
if (utils.betterTypeOf(pattern) !== "regexp") {
throw new CasperError('Invalid regexp.');
}
return this.assert(pattern.test(subject), message, {
type: "assertMatch",
standard: "Subject matches the provided pattern",
......@@ -609,6 +612,9 @@ Tester.prototype.assertTitle = function assertTitle(expected, message) {
*/
Tester.prototype.assertTitleMatch = Tester.prototype.assertTitleMatches = function assertTitleMatch(pattern, message) {
"use strict";
if (utils.betterTypeOf(pattern) !== "regexp") {
throw new CasperError('Invalid regexp.');
}
var currentTitle = this.casper.getTitle();
return this.assert(pattern.test(currentTitle), message, {
type: "assertTitle",
......
/*global casper __utils__*/
/*jshint strict:false*/
casper.start('tests/site/frames.html');
casper.start('tests/site/frames.html').wait(1000);
casper.withFrame('frame1', function() {
this.test.assertTitle('CasperJS frame 1');
......@@ -9,6 +9,8 @@ casper.withFrame('frame1', function() {
this.test.assertEval(function() {
return '__utils__' in window && 'getBinary' in __utils__;
}, '__utils__ object is available in child frame');
this.test.assertMatches(this.page.frameContent, /This is frame 1/);
this.test.assertMatches(this.getHTML(), /This is frame 1/);
});
casper.withFrame('frame2', function() {
......@@ -37,5 +39,5 @@ casper.withFrame(1, function() {
casper.run(function() {
this.test.assertTitle('CasperJS test frames');
this.test.done(14);
this.test.done(16);
});
......