Theory Node_removeChild
section‹Testing Node\_removeChild›
text‹This theory contains the test cases for Node\_removeChild.›
theory Node_removeChild
imports
"Core_DOM_BaseTest"
begin
definition Node_removeChild_heap :: heap⇩f⇩i⇩n⇩a⇩l where
"Node_removeChild_heap = create_heap [(cast (document_ptr.Ref 1), cast (create_document_obj html (Some (cast (element_ptr.Ref 1))) [])),
(cast (element_ptr.Ref 1), cast (create_element_obj ''html'' [cast (element_ptr.Ref 2), cast (element_ptr.Ref 7)] fmempty None)),
(cast (element_ptr.Ref 2), cast (create_element_obj ''head'' [cast (element_ptr.Ref 3), cast (element_ptr.Ref 4), cast (element_ptr.Ref 5), cast (element_ptr.Ref 6)] fmempty None)),
(cast (element_ptr.Ref 3), cast (create_element_obj ''title'' [cast (character_data_ptr.Ref 1)] fmempty None)),
(cast (character_data_ptr.Ref 1), cast (create_character_data_obj ''Node.removeChild'')),
(cast (element_ptr.Ref 4), cast (create_element_obj ''script'' [] (fmap_of_list [(''src'', ''/resources/testharness.js'')]) None)),
(cast (element_ptr.Ref 5), cast (create_element_obj ''script'' [] (fmap_of_list [(''src'', ''/resources/testharnessreport.js'')]) None)),
(cast (element_ptr.Ref 6), cast (create_element_obj ''script'' [] (fmap_of_list [(''src'', ''creators.js'')]) None)),
(cast (element_ptr.Ref 7), cast (create_element_obj ''body'' [cast (element_ptr.Ref 8), cast (element_ptr.Ref 9), cast (element_ptr.Ref 10)] fmempty None)),
(cast (element_ptr.Ref 8), cast (create_element_obj ''div'' [] (fmap_of_list [(''id'', ''log'')]) None)),
(cast (element_ptr.Ref 9), cast (create_element_obj ''iframe'' [] (fmap_of_list [(''src'', ''about:blank'')]) None)),
(cast (element_ptr.Ref 10), cast (create_element_obj ''script'' [cast (character_data_ptr.Ref 2)] fmempty None)),
(cast (character_data_ptr.Ref 2), cast (create_character_data_obj ''%3C%3Cscript%3E%3E''))]"
definition Node_removeChild_document :: "(unit, unit, unit, unit, unit, unit) object_ptr option" where "Node_removeChild_document = Some (cast (document_ptr.Ref 1))"
text ‹"Passing a detached Element to removeChild should not affect it."›
lemma "test (do {
doc ← return Node_removeChild_document;
s ← doc . createElement(''div'');
tmp0 ← s . ownerDocument;
assert_equals(tmp0, doc);
tmp1 ← Node_removeChild_document . body;
assert_throws(NotFoundError, tmp1 . removeChild(s));
tmp2 ← s . ownerDocument;
assert_equals(tmp2, doc)
}) Node_removeChild_heap"
by eval
text ‹"Passing a non-detached Element to removeChild should not affect it."›
lemma "test (do {
doc ← return Node_removeChild_document;
s ← doc . createElement(''div'');
tmp0 ← doc . documentElement;
tmp0 . appendChild(s);
tmp1 ← s . ownerDocument;
assert_equals(tmp1, doc);
tmp2 ← Node_removeChild_document . body;
assert_throws(NotFoundError, tmp2 . removeChild(s));
tmp3 ← s . ownerDocument;
assert_equals(tmp3, doc)
}) Node_removeChild_heap"
by eval
text ‹"Calling removeChild on an Element with no children should throw NOT\_FOUND\_ERR."›
lemma "test (do {
doc ← return Node_removeChild_document;
s ← doc . createElement(''div'');
tmp0 ← doc . body;
tmp0 . appendChild(s);
tmp1 ← s . ownerDocument;
assert_equals(tmp1, doc);
assert_throws(NotFoundError, s . removeChild(doc))
}) Node_removeChild_heap"
by eval
text ‹"Passing a detached Element to removeChild should not affect it."›
lemma "test (do {
doc ← createDocument('''');
s ← doc . createElement(''div'');
tmp0 ← s . ownerDocument;
assert_equals(tmp0, doc);
tmp1 ← Node_removeChild_document . body;
assert_throws(NotFoundError, tmp1 . removeChild(s));
tmp2 ← s . ownerDocument;
assert_equals(tmp2, doc)
}) Node_removeChild_heap"
by eval
text ‹"Passing a non-detached Element to removeChild should not affect it."›
lemma "test (do {
doc ← createDocument('''');
s ← doc . createElement(''div'');
tmp0 ← doc . documentElement;
tmp0 . appendChild(s);
tmp1 ← s . ownerDocument;
assert_equals(tmp1, doc);
tmp2 ← Node_removeChild_document . body;
assert_throws(NotFoundError, tmp2 . removeChild(s));
tmp3 ← s . ownerDocument;
assert_equals(tmp3, doc)
}) Node_removeChild_heap"
by eval
text ‹"Calling removeChild on an Element with no children should throw NOT\_FOUND\_ERR."›
lemma "test (do {
doc ← createDocument('''');
s ← doc . createElement(''div'');
tmp0 ← doc . body;
tmp0 . appendChild(s);
tmp1 ← s . ownerDocument;
assert_equals(tmp1, doc);
assert_throws(NotFoundError, s . removeChild(doc))
}) Node_removeChild_heap"
by eval
text ‹"Passing a value that is not a Node reference to removeChild should throw TypeError."›
lemma "test (do {
tmp0 ← Node_removeChild_document . body;
assert_throws(TypeError, tmp0 . removeChild(None))
}) Node_removeChild_heap"
by eval
end