mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 621644 - $ is shadowed in web console; f=rcampbell r=dolske approval2.0=dolske
This commit is contained in:
parent
fd56b45e59
commit
28f0e500be
@ -4032,7 +4032,31 @@ JSTerm.prototype = {
|
||||
if (aString.trim() === "help" || aString.trim() === "?") {
|
||||
aString = "help()";
|
||||
}
|
||||
return Cu.evalInSandbox(aString, this.sandbox, "1.8", "Web Console", 1);
|
||||
|
||||
let window = unwrap(this.sandbox.window);
|
||||
let $ = null, $$ = null;
|
||||
|
||||
// We prefer to execute the page-provided implementations for the $() and
|
||||
// $$() functions.
|
||||
if (typeof window.$ == "function") {
|
||||
$ = this.sandbox.$;
|
||||
delete this.sandbox.$;
|
||||
}
|
||||
if (typeof window.$$ == "function") {
|
||||
$$ = this.sandbox.$$;
|
||||
delete this.sandbox.$$;
|
||||
}
|
||||
|
||||
let result = Cu.evalInSandbox(aString, this.sandbox, "1.8", "Web Console", 1);
|
||||
|
||||
if ($) {
|
||||
this.sandbox.$ = $;
|
||||
}
|
||||
if ($$) {
|
||||
this.sandbox.$$ = $$;
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
|
@ -121,6 +121,7 @@ _BROWSER_TEST_FILES = \
|
||||
browser_webconsole_bug_618078_network_exceptions.js \
|
||||
browser_webconsole_bug_613280_jsterm_copy.js \
|
||||
browser_webconsole_bug_630733_response_redirect_headers.js \
|
||||
browser_webconsole_bug_621644_jsterm_dollar.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
||||
@ -187,6 +188,7 @@ _BROWSER_TEST_PAGES = \
|
||||
test-bug-599725-response-headers.sjs \
|
||||
test-bug-618078-network-exceptions.html \
|
||||
test-bug-630733-response-redirect-headers.sjs \
|
||||
test-bug-621644-jsterm-dollar.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_BROWSER_TEST_FILES)
|
||||
|
@ -0,0 +1,48 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mihai Sucan <mihai.sucan@gmail.com>
|
||||
*/
|
||||
|
||||
const TEST_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-bug-621644-jsterm-dollar.html";
|
||||
|
||||
function tabLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
|
||||
waitForFocus(function () {
|
||||
openConsole();
|
||||
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
let HUD = HUDService.hudReferences[hudId];
|
||||
|
||||
HUD.jsterm.clearOutput();
|
||||
|
||||
HUD.jsterm.setInputValue("$(document.body)");
|
||||
HUD.jsterm.execute();
|
||||
|
||||
let outputItem = HUD.outputNode.
|
||||
querySelector(".webconsole-msg-output:last-child");
|
||||
ok(outputItem.textContent.indexOf("<p>") > -1,
|
||||
"jsterm output is correct for $()");
|
||||
|
||||
HUD.jsterm.clearOutput();
|
||||
|
||||
HUD.jsterm.setInputValue("$$(document)");
|
||||
HUD.jsterm.execute();
|
||||
|
||||
outputItem = HUD.outputNode.
|
||||
querySelector(".webconsole-msg-output:last-child");
|
||||
ok(outputItem.textContent.indexOf("621644") > -1,
|
||||
"jsterm output is correct for $$()");
|
||||
|
||||
executeSoon(finishTest);
|
||||
}, content);
|
||||
}
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", tabLoad, true);
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html dir="ltr" xml:lang="en-US" lang="en-US">
|
||||
<head>
|
||||
<title>Web Console test for bug 621644</title>
|
||||
<script>
|
||||
function $(elem) {
|
||||
return elem.innerHTML;
|
||||
}
|
||||
function $$(doc) {
|
||||
return doc.title;
|
||||
}
|
||||
</script>
|
||||
<!--
|
||||
- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
<h1>Web Console test for bug 621644</h1>
|
||||
<p>hello world!</p>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user