Bug 1165052 - Part 0: Add throwOutOfMemory testing function and use it instead of Array.prototype.splice in test_oom_reporting.html. r=efaust
authorTooru Fujisawa <arai_a@mac.com>
Thu, 07 Apr 2016 19:20:22 +0900
changeset 292151 ac7bd86f3e6020d1afd3271bb26e04e146472b29
parent 292150 1837056e2ce28c7a5149f60fb2392af9b72abce6
child 292152 ef8f61469172c5f62bf990e1b38f5c25526ce3a0
push id74764
push userarai_a@mac.com
push dateThu, 07 Apr 2016 10:49:15 +0000
treeherdermozilla-inbound@4d0f975a2311 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust
bugs1165052
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1165052 - Part 0: Add throwOutOfMemory testing function and use it instead of Array.prototype.splice in test_oom_reporting.html. r=efaust
dom/bindings/test/test_oom_reporting.html
js/src/builtin/TestingFunctions.cpp
--- a/dom/bindings/test/test_oom_reporting.html
+++ b/dom/bindings/test/test_oom_reporting.html
@@ -8,20 +8,20 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug </title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
 
   /** Test for Bug  **/
   SimpleTest.waitForExplicitFinish();
 
-  window.length = 0xffffffff;
-
   SimpleTest.expectUncaughtException();
-  setTimeout(Array.prototype.splice, 0, undefined);
+  setTimeout(function() {
+    SpecialPowers.Cu.getJSTestingFunctions().throwOutOfMemory();
+  }, 0);
 
   addEventListener("error", function(e) {
     is(e.type, "error", "Should have an error event");
     is(e.message, "uncaught exception: out of memory",
        "Should have the right error message");
     // Make sure we finish async, in case the expectUncaughtException assertion
     // about having seen the exception runs after our listener
     SimpleTest.executeSoon(SimpleTest.finish);
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -2443,16 +2443,23 @@ ReportOutOfMemory(JSContext* cx, unsigne
     CallArgs args = CallArgsFromVp(argc, vp);
     JS_ReportOutOfMemory(cx);
     cx->clearPendingException();
     args.rval().setUndefined();
     return true;
 }
 
 static bool
+ThrowOutOfMemory(JSContext* cx, unsigned argc, Value* vp)
+{
+    JS_ReportOutOfMemory(cx);
+    return false;
+}
+
+static bool
 ReportLargeAllocationFailure(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     void* buf = cx->runtime()->onOutOfMemoryCanGC(AllocFunction::Malloc, JSRuntime::LARGE_ALLOCATION);
     js_free(buf);
     args.rval().setUndefined();
     return true;
 }
@@ -3854,16 +3861,20 @@ gc::ZealModeHelpText),
 "stopTraceLogger()",
 "  Stop logging the mainThread."),
 #endif
 
     JS_FN_HELP("reportOutOfMemory", ReportOutOfMemory, 0, 0,
 "reportOutOfMemory()",
 "  Report OOM, then clear the exception and return undefined. For crash testing."),
 
+    JS_FN_HELP("throwOutOfMemory", ThrowOutOfMemory, 0, 0,
+"throwOutOfMemory()",
+"  Throw out of memory exception, for OOM handling testing."),
+
     JS_FN_HELP("reportLargeAllocationFailure", ReportLargeAllocationFailure, 0, 0,
 "reportLargeAllocationFailure()",
 "  Call the large allocation failure callback, as though a large malloc call failed,\n"
 "  then return undefined. In Gecko, this sends a memory pressure notification, which\n"
 "  can free up some memory."),
 
     JS_FN_HELP("findPath", FindPath, 2, 0,
 "findPath(start, target)",