зеркало из https://github.com/mozilla/gecko-dev.git
Bug 630593 Remove try/catch and test for saving history r=mfinkle
This commit is contained in:
Родитель
a3c470c111
Коммит
6a9a54c600
|
@ -261,9 +261,7 @@ let Content = {
|
|||
addEventListener("pagehide", this, false);
|
||||
addEventListener("keypress", this, false, false);
|
||||
|
||||
try{
|
||||
docShell.QueryInterface(Ci.nsIDocShellHistory).useGlobalHistory = true;
|
||||
} catch(e) { }
|
||||
},
|
||||
|
||||
handleEvent: function handleEvent(aEvent) {
|
||||
|
|
|
@ -67,6 +67,7 @@ _BROWSER_FILES = \
|
|||
browser_forms.js \
|
||||
browser_formsZoom.html \
|
||||
browser_formsZoom.js \
|
||||
browser_history.js \
|
||||
browser_mainui.js \
|
||||
browser_navigation.js \
|
||||
browser_preferences_text.js \
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Make sure history is being recorded when we visit websites.
|
||||
*/
|
||||
|
||||
var testURL_01 = "http://mochi.test:8888/browser/mobile/chrome/browser_blank_01.html";
|
||||
|
||||
// A queue to order the tests and a handle for each test
|
||||
var gTests = [];
|
||||
var gCurrentTest = null;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Entry point (must be named "test")
|
||||
function test() {
|
||||
// The "runNextTest" approach is async, so we need to call "waitForExplicitFinish()"
|
||||
// We call "finish()" when the tests are finished
|
||||
waitForExplicitFinish();
|
||||
|
||||
// Start the tests
|
||||
runNextTest();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Iterating tests by shifting test out one by one as runNextTest is called.
|
||||
function runNextTest() {
|
||||
// Run the next test until all tests completed
|
||||
if (gTests.length > 0) {
|
||||
gCurrentTest = gTests.shift();
|
||||
info(gCurrentTest.desc);
|
||||
gCurrentTest.run();
|
||||
}
|
||||
else {
|
||||
// Cleanup. All tests are completed at this point
|
||||
try {
|
||||
}
|
||||
finally {
|
||||
// We must finialize the tests
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* One-time observer callback.
|
||||
*/
|
||||
function waitForObserve(name, callback) {
|
||||
var observerService = Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(Ci.nsIObserverService);
|
||||
var observer = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
|
||||
observe: function(subject, topic, data) {
|
||||
observerService.removeObserver(observer, name);
|
||||
observer = null;
|
||||
callback(subject, topic, data);
|
||||
}
|
||||
};
|
||||
|
||||
observerService.addObserver(observer, name, false);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
gTests.push({
|
||||
desc: "Test history being added with page visit",
|
||||
_currentTab: null,
|
||||
|
||||
run: function() {
|
||||
this._currentTab = Browser.addTab(testURL_01, true);
|
||||
waitForObserve("uri-visit-saved", function(subject, topic, data) {
|
||||
let uri = subject.QueryInterface(Ci.nsIURI);
|
||||
ok(uri.spec == testURL_01, "URI was saved to history");
|
||||
Browser.closeTab(gCurrentTest._currentTab);
|
||||
runNextTest();
|
||||
});
|
||||
}
|
||||
});
|
Загрузка…
Ссылка в новой задаче