fune/browser/base/content/test/general/browser_PageMetaData_pushstate.js
Kris Maglione 918ed6c474 Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian
This was done using the following script:
37e3803c7a/processors/chromeutils-import.jsm

MozReview-Commit-ID: 1Nc3XDu0wGl

--HG--
extra : source : 12fc4dee861c812fd2bd032c63ef17af61800c70
extra : intermediate-source : 34c999fa006bffe8705cf50c54708aa21a962e62
extra : histedit_source : b2be2c5e5d226e6c347312456a6ae339c1e634b0
2018-01-29 15:20:18 -08:00

31 lines
1.4 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
add_task(async function() {
let rooturi = "https://example.com/browser/toolkit/modules/tests/browser/";
await BrowserTestUtils.openNewForegroundTab(gBrowser, rooturi + "metadata_simple.html");
await ContentTask.spawn(gBrowser.selectedBrowser, { rooturi }, async function(args) {
ChromeUtils.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);
});