<?xml version="1.0" encoding="UTF-8"?>
<ccxml xmlns="http://www.w3.org/2002/09/ccxml" xmlns:conf="http://www.w3.org/2005/ccxml-conformance" version="1.0">
<!--
Release 1.1 - 2010-06-17
FIXED: 
ISSUE-693, TA 772;
ISSUE-684,  TA 773
-->
<!--
Release 1.2 - 2010-10-25
FIXED: 
ISSUE-732: test of TA 773 (and child 1174) has been moved into 8_2_3_B.txml. 
-->
	
	<conf:docsetup/>
	<var name="ConnectionID" expr="undefined"/>
	<var name="VxmlFile2" expr="'TWO_2.vxml'"/>
	<var name="param1" expr="1"/>
	<var name="param2" expr="'hello'"/>
	<var name="chld_reason"/>
	<var name="send_id_1"/>
	<var name="DialogID"/>
	<var name="i_success"/>
	<var name="cur_event_ID"/>
	<var name="MY_BLANK" expr="''"/>
	<var name="WKR_STRING"/>
	<var name="event_source_type_ccxml" expr="'ccxml'"/>
	<script><![CDATA[
	   function GetMilliseconds() {
     var d = new Date();
     return d.getTime();  // ms from midnight on Jan 1, 2000.
   }

var t_start, t_end, t_delay = 2000, t_delta, t_delta_e = 0.05 * t_delay;
		   ]]></script>
	<script><![CDATA[

var i=0;
assertions[i++] = init_assertion('770');
assertions[i++] = init_assertion('772');
assertions[i++] = init_assertion('1271');


var assert_last = i - 1;
var assert_index = -1;
//
// out of the loop assertions (children?)
//
//
s_ASSERTIONS_LEFT = show_remained_assertions();
var b_in_test = false;


]]></script>
	<eventprocessor statevariable="current_state">
		<conf:setup type="alerting"/>
		
		<transition event="connection.alerting" state="init">
			<send targettype="'ccxml'" target="session.id" name="'user.timeout'" delay="TEST_LONG_TIMEOUT"/>
			<accept connectionid="event$.connectionid"/>
		</transition>
		
		<transition event="connection.connected" state="init">
			<assign name="ConnectionID" expr="event$.connectionid"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		
		<transition event="user.PREPARE_NEW">
			<conf:comment expr="'Event: ' + event$.name"/>
			<if cond="assert_index &gt;= 0">
				<assign name="ASSERTION_NUM" expr="assertions[assert_index].number"/>
				<assign name="t_ASSERT_RESULT" expr="assertions[assert_index].P_F"/>
				<script>t_ASSERT_REASON = assertions[assert_index].reason</script>
				<if cond="t_ASSERT_RESULT == s_PASS">
					<conf:pass reason="t_ASSERT_REASON"/>
					<elseif cond="t_ASSERT_RESULT == s_FAIL"/>
					<conf:fail reason="t_ASSERT_REASON"/>
					<else/>
					<conf:not_exec reason="t_ASSERT_REASON"/>
				</if>
			</if>
			<assign name="assert_index" expr="assert_index + 1"/>
			<if cond="assert_index &gt; assert_last">
				<log label="s_TA" expr="s_ASSERTIONS_LEFT"/>
				<conf:uncond_exit expr="'DONE'"/>
				<else/>
				<log label="s_TA" expr="s_ASSERTIONS_LEFT"/>
				<assign name="ASSERTION_NUM" expr=" assertions[assert_index].number"/>
				<assign name="t_ASSERT_REASON" expr="''"/>
				<script>assertions[assert_index].P_F = s_FAIL;</script>
				<assign name="current_state" expr="state_prefix + ASSERTION_NUM"/>
				<send targettype="'ccxml'" target="session.id" name="start_name_prefix + ASSERTION_NUM" sendid="cur_event_ID"/>
				<log label="s_TA" expr="'Loop event: SendID=' + cur_event_ID"/>
			</if>
		</transition>
		<transition event="user.START_ASSERTION_770" state="ASSERTION_NMBR_770">
			<!--
770 	
8.2.2 &lt;script&gt; 	
If the fetch identifier is invalid, has not completed, 
or the fetched content is not valid ECMAScript, an error.semantic event is thrown. 	emily.candell@comverse.com 	Accepted 	

-->
			<conf:comment expr="'Event: ' + event$.name"/>
			<var name="bogus_fetch_id" expr="'bogus_fetch_id'"/>
			<script fetchid="bogus_fetch_id"/>
			<send targettype="'ccxml'" target="session.id" name="'user.770_failed'"/>
		</transition>
		<transition event="error.semantic" state="ASSERTION_NMBR_770">
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<assign name="current_state" expr="'GEN'"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		<transition event="user.770_failed" state="ASSERTION_NMBR_770">
			<script>
			assertions[assert_index].P_F = s_FAIL;
			assertions[assert_index].reason = 'error.semantic should have been thrown.';
			 </script>
			<assign name="current_state" expr="'GEN'"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		<transition event="user.START_ASSERTION_772" state="ASSERTION_NMBR_772">
			<!--
772 	
8.2.2 
&lt;script&gt; 	
If a <fetch> element is used to fetch a document containing a <script> where both the src and fetchid attributes are present, 
the implementation must throw an error.fetch event. 	emily.candell@comverse.com 	New 	

-->
			<conf:comment expr="'Event: ' + event$.name"/>
			<!-- FIXED ISSUE-693:  ass_772_aux.txml replaced by ass_772_aux.ccxml -->
			<fetch next="'ass_772_aux.ccxml'"/>
		</transition>
		
		<transition event="error.fetch" state="ASSERTION_NMBR_772">
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<assign name="current_state" expr="'GEN'"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		
		<transition event="fetch.done" state="ASSERTION_NMBR_772">
			<script>
			assertions[assert_index].P_F = s_FAIL;
			assertions[assert_index].reason = 'error.fetch should have been thrown.';
			 </script>
			<assign name="current_state" expr="'GEN'"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		
		<transition event="user.START_ASSERTION_1271" state="ASSERTION_NMBR_1271">

<!--

1271 	
8.2.2 &lt;script&gt; 	
If a <createccxml> element is used to fetch a document containing a <script> where both the src and fetchid attributes are present, the implementation must throw an error.createccxml event. 	emily.candell@comverse.com 	New 	

-->
			<conf:comment expr="'Event: ' + event$.name"/>
				<!-- FIXED ISSUE-693:  ass_1271_aux.txml replaced by ass_772_aux.ccxml -->
			<createccxml next="'ass_772_aux.ccxml'"/>
		</transition>
		
		<transition event="error.createccxml" state="ASSERTION_NMBR_1271">
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<assign name="current_state" expr="'GEN'"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		
		<transition event="ccxml.created" state="ASSERTION_NMBR_1271">
			<script>
			assertions[assert_index].P_F = s_FAIL;
			assertions[assert_index].reason = 'error.createccxml should have been thrown.';
			 </script>
			<assign name="current_state" expr="'GEN'"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>		
		

		<transition event="user.timeout">
			<assign name="current_state" expr="'GEN'"/>
			<conf:uncond_exit expr="'TEST-TIMEOUT.' + show_remained_assertions()"/>
		</transition>
		
		<transition event="send.successful">
			<conf:comment expr="'Event: ' + event$.name + ' (generic handler) state=' + current_state"/>
		</transition>
		<transition event="*">
			<assign name="t_ASSERT_REASON" expr="'UNEXPECTED EVENT ' + event$.name + ' IN STATE ' + current_state"/>
			<conf:comment expr="t_ASSERT_REASON"/>
			<if cond="current_state == 'init'">
				<conf:uncond_exit expr="'Did not come out from init state.'"/>
				<else/>
				<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
			</if>
		</transition>
	</eventprocessor>
</ccxml>
