language-model-prompt-monitor-callback-exception.tentative.https.window.js (777B)
1 // META: title=Language Model Prompt Monitor Callback Exception 2 // META: script=/resources/testdriver.js 3 // META: script=../resources/util.js 4 // META: timeout=long 5 6 'use strict'; 7 8 // Test that the exception from the callback will be re-thrown by the session 9 // creation, and the session won't be created. 10 promise_test(async t => { 11 // Make sure the model availability is `downloadable`. 12 const availability = await LanguageModel.availability(); 13 if (availability === "downloadable") { 14 const error = new Error("test"); 15 const sessionPromise = createLanguageModel({ 16 // Start a new session with callback that will throw error. 17 monitor(m) { 18 throw error; 19 } 20 }); 21 await promise_rejects_exactly( 22 t, error, sessionPromise 23 ); 24 } 25 });