зеркало из https://github.com/mozilla/gecko-dev.git
Bug 965860 - patch 3 - Console replacable in IDL, r=bz
This commit is contained in:
Родитель
286e0c9290
Коммит
f9c15a539b
|
@ -13366,12 +13366,44 @@ nsGlobalWindow::SetHasAudioAvailableEventListeners()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::GetConsole(nsISupports** aConsole)
|
||||
nsGlobalWindow::GetConsole(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aConsole)
|
||||
{
|
||||
ErrorResult rv;
|
||||
nsRefPtr<Console> console = GetConsole(rv);
|
||||
console.forget(aConsole);
|
||||
return rv.ErrorCode();
|
||||
if (rv.Failed()) {
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> thisObj(aCx, mJSObject);
|
||||
if (!mJSObject) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (!JS_WrapObject(aCx, &thisObj) ||
|
||||
!WrapNewBindingObject(aCx, thisObj, console, aConsole)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::SetConsole(JSContext* aCx, JS::Handle<JS::Value> aValue)
|
||||
{
|
||||
JS::Rooted<JSObject*> thisObj(aCx, mJSObject);
|
||||
if (!mJSObject) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (!JS_WrapObject(aCx, &thisObj) ||
|
||||
!JS_DefineProperty(aCx, thisObj, "console", aValue,
|
||||
JS_PropertyStub, JS_StrictPropertyStub,
|
||||
JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Console*
|
||||
|
|
|
@ -6,3 +6,4 @@ support-files =
|
|||
[test_bug715041_removal.xul]
|
||||
[test_domrequesthelper.xul]
|
||||
[test_url.xul]
|
||||
[test_console.xul]
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
<window title="Test for URL API"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<iframe id="iframe" />
|
||||
</body>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
|
||||
ok("console" in window, "Console exists");
|
||||
window.console.log(42);
|
||||
window.console = 42;
|
||||
is(window.console, 42, "Console is replacable");
|
||||
|
||||
var frame = document.getElementById("iframe");
|
||||
ok(frame, "Frame must exist");
|
||||
frame.src="http://mochi.test:8888/tests/dom/base/test/file_empty.html";
|
||||
frame.onload = function() {
|
||||
ok("console" in frame.contentWindow, "Console exists in the iframe");
|
||||
frame.contentWindow.console.log(42);
|
||||
frame.contentWindow.console = 42;
|
||||
is(frame.contentWindow.console, 42, "Console is replacable in the iframe");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
]]></script>
|
||||
</window>
|
|
@ -508,7 +508,7 @@ interface nsIDOMWindow : nsISupports
|
|||
/**
|
||||
* Console API
|
||||
*/
|
||||
readonly attribute nsISupports console;
|
||||
[implicit_jscontext] attribute jsval console;
|
||||
};
|
||||
|
||||
[scriptable, uuid(2146c906-57f7-486c-a1b4-8cdb57ef577f)]
|
||||
|
|
Загрузка…
Ссылка в новой задаче