OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright 2013 Google Inc. All Rights Reserved. | |
3 | |
4 Licensed under the Apache License, Version 2.0 (the "License"); | |
5 you may not use this file except in compliance with the License. | |
6 You may obtain a copy of the License at | |
7 | |
8 http://www.apache.org/licenses/LICENSE-2.0 | |
9 | |
10 Unless required by applicable law or agreed to in writing, software | |
11 distributed under the License is distributed on an "AS IS" BASIS, | |
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 See the License for the specific language governing permissions and | |
14 limitations under the License. | |
15 --> | |
16 | |
17 <!doctype html> | |
18 <style> | |
19 #target { | |
20 background-color: lightsteelblue; | |
21 width: 50px; | |
22 height: 50px; | |
23 position: absolute; | |
24 left: 0px; | |
25 } | |
26 | |
27 #spacer { | |
28 height: 100px; | |
29 } | |
30 </style> | |
31 | |
32 | |
33 <div id="target"></div> | |
34 <div id="spacer"></div> | |
35 | |
36 <script src="../bootstrap.js"></script> | |
37 <script> | |
38 'use strict'; | |
39 | |
40 var target = document.querySelector('#target'); | |
41 | |
42 // Ensure the target cannot be monkey patched with a different style object. | |
43 // This simulates Safari's behaviour in other browsers. | |
44 try { | |
45 var originalStyle = target.style; | |
46 Object.defineProperty(target, 'style', { | |
47 get: function () {return originalStyle;}, | |
48 configurable: false, | |
49 }); | |
50 } catch (_) {} | |
51 | |
52 | |
53 document.timeline.play(new Animation(target, {left: '100px', composite: 'add'},
{duration: 1 * 1000, iterations: 2, direction: 'alternate'})); | |
54 | |
55 at(0.5 * 1000, function() { | |
56 assert_in_array(target.style.getPropertyValue('left'), ['', null]); | |
57 }); | |
58 | |
59 testharness_timeline.schedule(function() { | |
60 target.style.setProperty('left' , '50px'); | |
61 assert_styles(target, {left: '150px'}, 'getComputedStyle() should return corre
ct value after setting inline style.'); | |
62 }, 1000); | |
63 | |
64 at(1.5 * 1000, function() { | |
65 assert_equals(target.style.getPropertyValue('left'), '50px'); | |
66 }); | |
67 | |
68 testharness_timeline.schedule(function() { | |
69 target.style.setProperty('left', '100px'); | |
70 target.style.setProperty('background-color', 'green'); | |
71 }, 2500); | |
72 | |
73 at(3 * 1000, function() { | |
74 assert_equals(target.style.getPropertyValue('left'), '100px'); | |
75 assert_equals(target.style.getPropertyValue('background-color'), 'green'); | |
76 }); | |
77 | |
78 </script> | |
OLD | NEW |