641function testStyleAttributePropertyAccess() {
642 var svgDoc, div, path;
643 var observer;
644
645 function start() {
646 debug('Testing that modifying an elements style property dispatches Mutation Records.');
647
648 mutations = null;
649 observer = new WebKitMutationObserver(function(m) {
650 mutations = m;
651 });
652
653 div = document.createElement('div');
654 div.setAttribute('style', 'color: yellow; width: 100px; ');
655 observer.observe(div, { attributes: true });
656 div.style.color = 'red';
657 div.style.width = '200px';
658 div.style.color = 'blue';
659
660 setTimeout(checkAndContinue, 0);
661 }
662
663 function checkAndContinue() {
664 shouldBe('mutations.length', '3');
665 shouldBe('mutations[0].type', '"attributes"');
666 shouldBe('mutations[0].attributeName', '"style"');
667 shouldBe('mutations[0].oldValue', 'null');
668 shouldBe('mutations[1].type', '"attributes"');
669 shouldBe('mutations[1].attributeName', '"style"');
670 shouldBe('mutations[1].oldValue', 'null');
671 shouldBe('mutations[2].type', '"attributes"');
672 shouldBe('mutations[2].attributeName', '"style"');
673 shouldBe('mutations[2].oldValue', 'null');
674
675 mutations = null;
676 div.getAttribute('style');
677 setTimeout(finish, 0);
678 }
679
680 function finish() {
681 debug('...mutation record created.');
682
683 shouldBe('mutations', 'null');
684
685 observer.disconnect();
686 debug('');
687 runNextTest();
688 }
689
690 start();
691}
692
693function testStyleAttributePropertyAccessOldValue() {
694 var svgDoc, div, path;
695 var observer;
696
697 function start() {
698 debug('Testing that modifying an elements style property dispatches Mutation Records with correct oldValues.');
699
700 mutations = null;
701 observer = new WebKitMutationObserver(function(m) {
702 mutations = m;
703 });
704
705 div = document.createElement('div');
706 div.setAttribute('style', 'color: yellow; width: 100px; ');
707 observer.observe(div, { attributes: true, attributeOldValue: true });
708 div.style.color = 'red';
709 div.style.width = '200px';
710 div.style.color = 'blue';
711
712 setTimeout(checkAndContinue, 0);
713 }
714
715 function checkAndContinue() {
716 shouldBe('mutations.length', '3');
717 shouldBe('mutations[0].type', '"attributes"');
718 shouldBe('mutations[0].attributeName', '"style"');
719 shouldBe('mutations[0].oldValue', '"color: yellow; width: 100px; "');
720 shouldBe('mutations[1].type', '"attributes"');
721 shouldBe('mutations[1].attributeName', '"style"');
722 shouldBe('mutations[1].oldValue', '"width: 100px; color: red; "');
723 shouldBe('mutations[2].type', '"attributes"');
724 shouldBe('mutations[2].attributeName', '"style"');
725 shouldBe('mutations[2].oldValue', '"color: red; width: 200px; "');
726
727 mutations = null;
728 div.getAttribute('style');
729 setTimeout(finish, 0);
730 }
731
732 function finish() {
733 debug('...mutation record created.');
734
735 shouldBe('mutations', 'null');
736
737 observer.disconnect();
738 debug('');
739 runNextTest();
740 }
741
742 start();
743}
744