Bug 875155 - Make bug 809674 test self-contained. r=bholley

This commit is contained in:
Masatoshi Kimura 2013-05-25 07:55:18 +09:00
parent 0d7e133a80
commit bf3edb05d3
9 changed files with 73 additions and 36 deletions

View File

@ -17,6 +17,7 @@ NO_DIST_INSTALL = 1
JS_FILES = \
xpctest_attributes.js \
xpctest_bug809674.js \
xpctest_interfaces.js \
xpctest_params.js \
$(NULL)

View File

@ -4,6 +4,9 @@ contract @mozilla.org/js/xpc/test/js/ObjectReadWrite;1 {8ff41d9c-66e9-4453-924a-
component {916c4247-253d-4ed0-a425-adfedf53ecc8} xpctest_attributes.js
contract @mozilla.org/js/xpc/test/js/ObjectReadOnly;1 {916c4247-253d-4ed0-a425-adfedf53ecc8}
component {2df46559-da21-49bf-b863-0d7b7bbcbc73} xpctest_bug809674.js
contract @mozilla.org/js/xpc/test/js/Bug809674;1 {2df46559-da21-49bf-b863-0d7b7bbcbc73}
component {e3b86f4e-49c0-487c-a2b0-3a986720a044} xpctest_params.js
contract @mozilla.org/js/xpc/test/js/Params;1 {e3b86f4e-49c0-487c-a2b0-3a986720a044}

View File

@ -0,0 +1,19 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource:///modules/XPCOMUtils.jsm");
function TestBug809674() {}
TestBug809674.prototype = {
/* Boilerplate */
QueryInterface: XPCOMUtils.generateQI([Components.interfaces["nsIXPCTestBug809674"]]),
contractID: "@mozilla.org/js/xpc/test/js/Bug809674;1",
classID: Components.ID("{2df46559-da21-49bf-b863-0d7b7bbcbc73}"),
/* nsIXPCTestBug809674 */
jsvalProperty: {},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TestBug809674]);

View File

@ -6,6 +6,7 @@
XPIDL_SOURCES += [
'xpctest_attributes.idl',
'xpctest_bug809674.idl',
'xpctest_interfaces.idl',
'xpctest_params.idl',
]

View File

@ -0,0 +1,18 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
/*
* Test interface for https://bugzilla.mozilla.org/show_bug.cgi?id=809674 .
*
* This test makes sure that accessing an attribute marked with
* [implicit_jscontext] will throw without crashing.
*/
[scriptable, uuid(2df46559-da21-49bf-b863-0d7b7bbcbc73)]
interface nsIXPCTestBug809674 : nsISupports {
[implicit_jscontext] attribute jsval jsvalProperty;
};

View File

@ -91,7 +91,6 @@ MOCHITEST_FILES = chrome_wrappers_helper.html \
file_bug802557.html \
test_bug803730.html \
test_bug809547.html \
test_bug809674.html \
test_bug829872.html \
test_bug862380.html \
test_bug865260.html \

View File

@ -1,35 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=809674
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 809674</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=809674">Mozilla Bug 809674</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 809674 **/
var mse = document.createEvent('TimeEvents');
mse.initTimeEvent('', {}, '');
try {
mse.view.onunload;
ok(false, "Should have thrown");
} catch(e) {
ok(!!/implicit_jscontext/.exec(e), "Should throw a helpful error");
}
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,30 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const Cc = Components.classes;
const Ci = Components.interfaces;
function run_test() {
// Load the component manifest.
Components.manager.autoRegister(do_get_file('../components/js/xpctest.manifest'));
// Test for each component.
test_property_throws("@mozilla.org/js/xpc/test/js/Bug809674;1");
}
function test_property_throws(contractid) {
// Instantiate the object.
var o = Cc[contractid].createInstance(Ci["nsIXPCTestBug809674"]);
// Test the initial values.
try {
o.jsvalProperty;
do_check_true(false, "Should have thrown");
} catch (e) {
do_check_true(/implicit_jscontext/.test(e), "Should throw a helpful error");
}
}

View File

@ -15,6 +15,7 @@ tail =
[test_bug780370.js]
[test_bug805807.js]
[test_bug809652.js]
[test_bug809674.js]
[test_bug813901.js]
[test_bug845201.js]
[test_bug845862.js]