forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
284 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
browser/base/content/test/newtab/browser_newtab_bug722273.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
const NOW = Date.now() * 1000; | ||
const URL = "http://fake-site.com/"; | ||
|
||
let tmp = {}; | ||
Cu.import("resource:///modules/NewTabUtils.jsm", tmp); | ||
Cc["@mozilla.org/moz/jssubscript-loader;1"] | ||
.getService(Ci.mozIJSSubScriptLoader) | ||
.loadSubScript("chrome://browser/content/sanitize.js", tmp); | ||
|
||
let {NewTabUtils, Sanitizer} = tmp; | ||
|
||
let bhist = Cc["@mozilla.org/browser/global-history;2"] | ||
.getService(Ci.nsIBrowserHistory); | ||
|
||
function runTests() { | ||
clearHistory(); | ||
fillHistory(); | ||
yield addNewTabPageTab(); | ||
|
||
is(cells[0].site.url, URL, "first site is our fake site"); | ||
|
||
let page = { | ||
update: function () { | ||
executeSoon(TestRunner.next); | ||
}, | ||
|
||
observe: function () {} | ||
}; | ||
|
||
NewTabUtils.allPages.register(page); | ||
yield clearHistory(); | ||
|
||
NewTabUtils.allPages.unregister(page); | ||
ok(!cells[0].site, "the fake site is gone"); | ||
} | ||
|
||
function fillHistory() { | ||
let uri = makeURI(URL); | ||
for (let i = 59; i > 0; i--) | ||
bhist.addPageWithDetails(uri, "fake site", NOW - i * 60 * 1000000); | ||
} | ||
|
||
function clearHistory() { | ||
let s = new Sanitizer(); | ||
s.prefDomain = "privacy.cpd."; | ||
|
||
let prefs = gPrefService.getBranch(s.prefDomain); | ||
prefs.setBoolPref("history", true); | ||
prefs.setBoolPref("downloads", false); | ||
prefs.setBoolPref("cache", false); | ||
prefs.setBoolPref("cookies", false); | ||
prefs.setBoolPref("formdata", false); | ||
prefs.setBoolPref("offlineApps", false); | ||
prefs.setBoolPref("passwords", false); | ||
prefs.setBoolPref("sessions", false); | ||
prefs.setBoolPref("siteSettings", false); | ||
|
||
s.sanitize(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
browser/devtools/styleinspector/test/browser_ruleview_focus.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* vim: set ts=2 et sw=2 tw=80: */ | ||
/* Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
// Test that focus doesn't leave the style editor when adding a property | ||
// (bug 719916) | ||
|
||
let doc; | ||
let stylePanel; | ||
|
||
function waitForRuleView(aCallback) | ||
{ | ||
if (InspectorUI.ruleView) { | ||
aCallback(); | ||
return; | ||
} | ||
|
||
let ruleViewFrame = InspectorUI.getToolIframe(InspectorUI.ruleViewObject); | ||
ruleViewFrame.addEventListener("load", function(evt) { | ||
ruleViewFrame.removeEventListener(evt.type, arguments.callee, true); | ||
executeSoon(function() { | ||
aCallback(); | ||
}); | ||
}, true); | ||
} | ||
|
||
function waitForEditorFocus(aParent, aCallback) | ||
{ | ||
aParent.addEventListener("focus", function onFocus(evt) { | ||
if (evt.target.inplaceEditor) { | ||
aParent.removeEventListener("focus", onFocus, true); | ||
let editor = evt.target.inplaceEditor; | ||
executeSoon(function() { | ||
aCallback(editor); | ||
}); | ||
} | ||
}, true); | ||
} | ||
|
||
function openRuleView() | ||
{ | ||
Services.obs.addObserver(function onOpened() { | ||
Services.obs.removeObserver(onOpened, | ||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false); | ||
|
||
// Highlight a node. | ||
let node = content.document.getElementsByTagName("h1")[0]; | ||
InspectorUI.inspectNode(node); | ||
InspectorUI.stopInspecting(); | ||
|
||
// Open the rule view sidebar. | ||
waitForRuleView(testFocus); | ||
|
||
InspectorUI.showSidebar(); | ||
InspectorUI.ruleButton.click(); | ||
|
||
testFocus(); | ||
}, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false); | ||
InspectorUI.openInspectorUI(); | ||
} | ||
|
||
function testFocus() | ||
{ | ||
let ruleViewFrame = InspectorUI.getToolIframe(InspectorUI.ruleViewObject); | ||
let brace = ruleViewFrame.contentDocument.querySelectorAll(".ruleview-ruleclose")[0]; | ||
waitForEditorFocus(brace.parentNode, function onNewElement(aEditor) { | ||
aEditor.input.value = "color"; | ||
waitForEditorFocus(brace.parentNode, function onEditingValue(aEditor) { | ||
// If we actually get this focus we're ok. | ||
ok(true, "We got focus."); | ||
aEditor.input.value = "green"; | ||
|
||
// If we've retained focus, pressing return will start a new editor. | ||
// If not, we'll wait here until we time out. | ||
waitForEditorFocus(brace.parentNode, function onNewEditor(aEditor) { | ||
aEditor.input.blur(); | ||
finishTest(); | ||
}); | ||
EventUtils.sendKey("return"); | ||
}); | ||
EventUtils.sendKey("return"); | ||
}); | ||
|
||
brace.focus(); | ||
} | ||
|
||
function finishUp() | ||
{ | ||
doc = stylePanel = null; | ||
gBrowser.removeCurrentTab(); | ||
finish(); | ||
} | ||
|
||
function test() | ||
{ | ||
waitForExplicitFinish(); | ||
gBrowser.selectedTab = gBrowser.addTab(); | ||
gBrowser.selectedBrowser.addEventListener("load", function(evt) { | ||
gBrowser.selectedBrowser.removeEventListener(evt.type, arguments.callee, true); | ||
doc = content.document; | ||
doc.title = "Rule View Test"; | ||
waitForFocus(openRuleView, content); | ||
}, true); | ||
|
||
content.location = "data:text/html,<h1>Some header text</h1>"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.