gecko-dev/browser/base/content/test/general/browser_PageMetaData_pushstate.js
Mark Banner 92c422a2d6 Bug 1342459 - Add a rule to automatically detect ContentTask.spawn and inject the relevant globals. r=mossop
This reduces the amount of places where we need to specify the mozilla/frame-script environment. It does have
the side effect of allowing those globals in the whole file, but that is what specifying the environment would
do, and this is also for mochitest test files only.

MozReview-Commit-ID: 1LLFbn6fFJR

--HG--
extra : rebase_source : 82a6934d90bbbbd25f91b7b06bf4f9354e38865a
2017-04-05 10:00:25 +01:00

31 lines
1.4 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
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);
});