1
1
import {
2
- changeOption ,
3
2
insertSnippet ,
4
3
registerWebsitePreviewTour ,
5
- changeOptionInPopover ,
6
4
} from '@website/js/tours/tour_utils' ;
7
5
8
6
registerWebsitePreviewTour ( 'drop_404_ir_attachment_url' , {
@@ -26,12 +24,21 @@ registerWebsitePreviewTour('drop_404_ir_attachment_url', {
26
24
content : 'Once the image UI appears, check the image has no size (404)' ,
27
25
trigger : ":iframe [data-snippet='s_404_snippet'] img" ,
28
26
run ( ) {
29
- const imgEl = this . anchor ;
30
- if ( ! imgEl . complete
31
- || imgEl . naturalWidth !== 0
32
- || imgEl . naturalHeight !== 0 ) {
33
- throw new Error ( 'This is supposed to be a 404 image' ) ;
34
- }
27
+ return new Promise ( ( resolve , reject ) => {
28
+ const imgEl = this . anchor ;
29
+ const checkComplete = ( ) => {
30
+ if ( imgEl . complete ) {
31
+ if ( imgEl . naturalWidth !== 0 || imgEl . naturalHeight !== 0 ) {
32
+ reject ( new Error ( "This is supposed to be a 404 image" ) ) ;
33
+ } else {
34
+ resolve ( ) ;
35
+ }
36
+ } else {
37
+ requestAnimationFrame ( checkComplete ) ;
38
+ }
39
+ } ;
40
+ checkComplete ( ) ;
41
+ } ) ;
35
42
} ,
36
43
} ,
37
44
{
@@ -50,14 +57,27 @@ registerWebsitePreviewTour('drop_404_ir_attachment_url', {
50
57
} ,
51
58
{
52
59
content : 'Once the shape is applied, check the image has now a size (placeholder image)' ,
53
- trigger : ' :iframe [data-snippet=" s_404_snippet" ] img' ,
60
+ trigger : " :iframe [data-snippet=' s_404_snippet' ] img[src^='data:']" ,
54
61
run ( ) {
55
- const imgEl = this . anchor ;
56
- if ( ! imgEl . complete
57
- || imgEl . naturalWidth === 0
58
- || imgEl . naturalHeight === 0 ) {
59
- throw new Error ( 'Even though the original image was a 404, the option should have been applied on the placeholder image' ) ;
60
- }
62
+ return new Promise ( ( resolve , reject ) => {
63
+ const imgEl = this . anchor ;
64
+ const checkComplete = ( ) => {
65
+ if ( imgEl . complete ) {
66
+ if ( imgEl . naturalWidth === 0 || imgEl . naturalHeight === 0 ) {
67
+ reject (
68
+ new Error (
69
+ "Even though the original image was a 404, the option should have been applied on the placeholder image"
70
+ )
71
+ ) ;
72
+ } else {
73
+ resolve ( ) ;
74
+ }
75
+ } else {
76
+ requestAnimationFrame ( checkComplete ) ;
77
+ }
78
+ } ;
79
+ checkComplete ( ) ;
80
+ } ) ;
61
81
} ,
62
82
} ,
63
83
] ) ;
0 commit comments