gecko-dev/browser/base/content/test/general/browser_PageMetaData_pushstate.js
Mark Banner 427e3b23dc Bug 1342459 - Fix various no-undef issues in browser/base. r=mossop
MozReview-Commit-ID: CRYxu7copKb

--HG--
extra : rebase_source : bc176c5e6890ffc6a4e26cb9bc9d441d9486ce7b
2017-04-04 13:42:33 +01:00

33 lines
1.4 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* eslint-env mozilla/frame-script */
add_task(function* () {
let rooturi = "https://example.com/browser/toolkit/modules/tests/browser/";
yield BrowserTestUtils.openNewForegroundTab(gBrowser, rooturi + "metadata_simple.html");
yield ContentTask.spawn(gBrowser.selectedBrowser, { rooturi }, function* (args) {
Components.utils.import("resource://gre/modules/PageMetadata.jsm");
let result = PageMetadata.getData(content.document);
// Result should have description.
Assert.equal(result.url, args.rooturi + "metadata_simple.html", "metadata url is correct");
Assert.equal(result.title, "Test Title", "metadata title is correct");
Assert.equal(result.description, "A very simple test page", "description is correct");
content.history.pushState({}, "2", "2.html");
result = PageMetadata.getData(content.document);
// Result should not have description.
Assert.equal(result.url, args.rooturi + "2.html", "metadata url is correct");
Assert.equal(result.title, "Test Title", "metadata title is correct");
Assert.ok(!result.description, "description is undefined");
Assert.equal(content.document.documentURI, args.rooturi + "2.html",
"content.document has correct url");
});
is(gBrowser.currentURI.spec, rooturi + "2.html", "gBrowser has correct url");
gBrowser.removeTab(gBrowser.selectedTab);
});