mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-30 01:59:29 +00:00
Bug 950909 - Tests. r=smaug
This commit is contained in:
parent
3e1858537b
commit
9f6b17cb86
@ -1,6 +1,7 @@
|
||||
[DEFAULT]
|
||||
support-files =
|
||||
file_bug944407.xml
|
||||
file_bug950909.xml
|
||||
|
||||
[test_bug378518.xul]
|
||||
[test_bug398135.xul]
|
||||
@ -9,3 +10,4 @@ support-files =
|
||||
[test_bug723676.xul]
|
||||
[test_bug772966.xul]
|
||||
[test_bug944407.xul]
|
||||
[test_bug950909.xul]
|
||||
|
8
content/xbl/test/file_bug950909.html
Normal file
8
content/xbl/test/file_bug950909.html
Normal file
@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div style="-moz-binding: url(chrome://mochitests/content/chrome/content/xbl/test/file_bug950909.xml#testBinding"></div>
|
||||
</body>
|
||||
</html>
|
37
content/xbl/test/file_bug950909.xml
Normal file
37
content/xbl/test/file_bug950909.xml
Normal file
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0"?>
|
||||
<bindings id="chromeTestBindings" xmlns="http://www.mozilla.org/xbl">
|
||||
<binding id="testBinding">
|
||||
<implementation implements="nsIObserver">
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
// This binding gets applied to a content object, and thus is actually
|
||||
// running in a content XBL scope.
|
||||
var win = XPCNativeWrapper.unwrap(window);
|
||||
var SpecialPowers = win.SpecialPowers;
|
||||
var ok = SpecialPowers.unwrap(SpecialPowers.wrap(window).parent.ok);
|
||||
ok(win != window, "Should be running in an XBL scope with Xrays");
|
||||
|
||||
// Generate an XPCWrappedJS for the reflector. We need to do this
|
||||
// explicitly with a testing helper, because we're converging on
|
||||
// removing XPConnect from the web, which means that it won't be
|
||||
// possible to generate an XPCWrappedJS from content (or XBL) code.
|
||||
var scope = {};
|
||||
var holder = SpecialPowers.Cu.generateXPCWrappedJS(this, scope);
|
||||
|
||||
// Now, QI |this|, which will generate an aggregated native.
|
||||
this.QueryInterface(Components.interfaces.nsIObserver);
|
||||
|
||||
ok(true, "Didn't assert or crash");
|
||||
|
||||
SpecialPowers.wrap(window).parent.SimpleTest.finish();
|
||||
]]>
|
||||
</constructor>
|
||||
<method name="observe">
|
||||
<parameter name="aSubject"/>
|
||||
<parameter name="aTopic"/>
|
||||
<parameter name="aData"/>
|
||||
<body><![CDATA[]]></body>
|
||||
</method>
|
||||
</implementation>
|
||||
</binding>
|
||||
</bindings>
|
@ -14,6 +14,7 @@ support-files =
|
||||
file_bug844783.xhtml
|
||||
file_bug944407.html
|
||||
file_bug944407.xml
|
||||
file_bug950909.html
|
||||
|
||||
[test_bug310107.html]
|
||||
[test_bug366770.html]
|
||||
|
36
content/xbl/test/test_bug950909.xul
Normal file
36
content/xbl/test/test_bug950909.xul
Normal file
@ -0,0 +1,36 @@
|
||||
<?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"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=950909
|
||||
-->
|
||||
<window title="Mozilla Bug 950909"
|
||||
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">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=950909"
|
||||
target="_blank">Mozilla Bug 950909</a>
|
||||
</body>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
/*
|
||||
* Test for bug 950909. This has to be a chrome tests because content needs
|
||||
* to apply a chrome binding (file_bug950909.xml), which will only be registered
|
||||
* as a chrome:// URI during mochitest-chrome runs. And the binding has to be
|
||||
* served from a chrome origin, because otherwise implements="nsIFoo" attributes
|
||||
* are ignored. So this test needs 3 files, all told. Ugh.
|
||||
*/
|
||||
|
||||
// Just wait. When the iframe loads, it'll apply the binding, which will
|
||||
// trigger the constructor for the binding.
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
]]>
|
||||
</script>
|
||||
<iframe src="http://example.com/tests/content/xbl/test/file_bug950909.html"/>
|
||||
</window>
|
@ -120,7 +120,7 @@ interface ScheduledGCCallback : nsISupports
|
||||
/**
|
||||
* interface of Components.utils
|
||||
*/
|
||||
[scriptable, uuid(e14f588b-63aa-4091-be82-a459a52f8ca6)]
|
||||
[scriptable, uuid(ae292d08-cfb0-4862-a2b6-4779e5ef7e72)]
|
||||
interface nsIXPCComponents_Utils : nsISupports
|
||||
{
|
||||
|
||||
@ -519,6 +519,17 @@ interface nsIXPCComponents_Utils : nsISupports
|
||||
[implicit_jscontext]
|
||||
jsval getIncumbentGlobal([optional] in jsval callback);
|
||||
|
||||
/**
|
||||
* Forces the generation of an XPCWrappedJS for a given object. For internal
|
||||
* and testing use only. This is only useful to set up wrapper map conditions
|
||||
* for a testcase. The return value is not an XPCWrappedJS itself, but an
|
||||
* opaque nsISupports holder that keeps the underlying XPCWrappedJS alive.
|
||||
*
|
||||
* if |scope| is passed, the XPCWrappedJS is generated in the scope of that object.
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
nsISupports generateXPCWrappedJS(in jsval obj, [optional] in jsval scope);
|
||||
|
||||
/**
|
||||
* Retrieve the last time, in microseconds since epoch, that a given
|
||||
* watchdog-related event occured.
|
||||
|
@ -3514,6 +3514,46 @@ nsXPCComponents_Utils::GetIncumbentGlobal(const Value &aCallback,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Below is a bunch of awkward junk to allow JS test code to trigger the
|
||||
* creation of an XPCWrappedJS, such that it ends up in the map. We need to
|
||||
* hand the caller some sort of reference to hold onto (to prevent the
|
||||
* refcount from dropping to zero as soon as the function returns), but trying
|
||||
* to return a bonafide XPCWrappedJS to script causes all sorts of trouble. So
|
||||
* we create a benign holder class instead, which acts as an opaque reference
|
||||
* that script can use to keep the XPCWrappedJS alive and in the map.
|
||||
*/
|
||||
|
||||
class WrappedJSHolder : public nsISupports
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
WrappedJSHolder() {}
|
||||
virtual ~WrappedJSHolder() {}
|
||||
|
||||
nsRefPtr<nsXPCWrappedJS> mWrappedJS;
|
||||
};
|
||||
NS_IMPL_ISUPPORTS0(WrappedJSHolder);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::GenerateXPCWrappedJS(const Value &aObj, const Value &aScope,
|
||||
JSContext *aCx, nsISupports **aOut)
|
||||
{
|
||||
if (!aObj.isObject())
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
RootedObject obj(aCx, &aObj.toObject());
|
||||
RootedObject scope(aCx, aScope.isObject() ? js::UncheckedUnwrap(&aScope.toObject())
|
||||
: CurrentGlobalOrNull(aCx));
|
||||
JSAutoCompartment ac(aCx, scope);
|
||||
if (!JS_WrapObject(aCx, &obj))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsRefPtr<WrappedJSHolder> holder = new WrappedJSHolder();
|
||||
nsresult rv = nsXPCWrappedJS::GetNewOrUsed(obj, NS_GET_IID(nsISupports),
|
||||
getter_AddRefs(holder->mWrappedJS));
|
||||
holder.forget(aOut);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::GetWatchdogTimestamp(const nsAString& aCategory, PRTime *aOut)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user