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 94247e7 commit bffc8ae
Show file tree
Hide file tree
Showing 2 changed files with 30 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
29 changes: 29 additions & 0 deletions test/screen/HtmlScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,35 @@ 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();
});
});

it('should return HTML markup as text from the document title', (done) => {
var screen = new HtmlScreen();
screen.allocateVirtualDocumentForContent('<title>left <span>&amp;</span> right</title>');
screen.resolveTitleFromVirtualDocument();
screen.flip([]).then(() => {
assert.strictEqual('left <span>&</span> right', screen.getTitle());
done();
});
});
});

function enterDocumentSurfaceElement(surfaceId, opt_content) {
Expand Down

0 comments on commit bffc8ae

Please sign in to comment.