Skip to content
This repository has been archived by the owner on Apr 21, 2021. It is now read-only.

Commit

Permalink
Saves the unescaped title string
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando Souza committed Jan 6, 2017
1 parent eb89819 commit 7a91e9e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/screen/HtmlScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class HtmlScreen extends RequestScreen {
resolveTitleFromVirtualDocument() {
var title = this.virtualDocument.querySelector(this.titleSelector);
if (title) {
this.setTitle(title.innerHTML.trim());
this.setTitle(title.textContent.trim());
}
}

Expand Down
19 changes: 19 additions & 0 deletions test/screen/HtmlScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,25 @@ describe('HtmlScreen', function() {
this.requests[0].respond(200, null, '<link id="style" data-senna-track="temporary" rel="stylesheet" href="/base/src/senna.js">');
});

it('should have correct title', (done) => {
var screen = new HtmlScreen();
screen.allocateVirtualDocumentForContent('<title>left</title>');
screen.resolveTitleFromVirtualDocument();
screen.flip([]).then(() => {
assert.strictEqual('left', screen.getTitle());
done();
});
});

it('should have correct title when the title contains html entities', (done) => {
var screen = new HtmlScreen();
screen.allocateVirtualDocumentForContent('<title>left &amp; right</title>');
screen.resolveTitleFromVirtualDocument();
screen.flip([]).then(() => {
assert.strictEqual('left & right', screen.getTitle());
done();
});
});
});

function enterDocumentSurfaceElement(surfaceId, opt_content) {
Expand Down

0 comments on commit 7a91e9e

Please sign in to comment.