|
40 | 40 | * - date: (Date) |
41 | 41 | * The time the visit occurred. |
42 | 42 | * - transition: (number) |
43 | | - * How the user reached the page. See constants `TRANSITION_*` |
| 43 | + * How the user reached the page. See constants `TRANSITIONS.*` |
44 | 44 | * for the possible transition types. |
45 | 45 | * - referrer: (URL) |
46 | 46 | * or (nsIURI) |
@@ -408,51 +408,58 @@ this.History = Object.freeze({ |
408 | 408 | * objects. |
409 | 409 | */ |
410 | 410 |
|
411 | | - /** |
412 | | - * The user followed a link and got a new toplevel window. |
413 | | - */ |
414 | | - TRANSITION_LINK: Ci.nsINavHistoryService.TRANSITION_LINK, |
415 | | - |
416 | | - /** |
417 | | - * The user typed the page's URL in the URL bar or selected it from |
418 | | - * URL bar autocomplete results, clicked on it from a history query |
419 | | - * (from the History sidebar, History menu, or history query in the |
420 | | - * personal toolbar or Places organizer. |
421 | | - */ |
422 | | - TRANSITION_TYPED: Ci.nsINavHistoryService.TRANSITION_TYPED, |
423 | | - |
424 | | - /** |
425 | | - * The user followed a bookmark to get to the page. |
426 | | - */ |
427 | | - TRANSITION_BOOKMARK: Ci.nsINavHistoryService.TRANSITION_BOOKMARK, |
428 | | - |
429 | | - /** |
430 | | - * Some inner content is loaded. This is true of all images on a |
431 | | - * page, and the contents of the iframe. It is also true of any |
432 | | - * content in a frame if the user did not explicitly follow a link |
433 | | - * to get there. |
434 | | - */ |
435 | | - TRANSITION_EMBED: Ci.nsINavHistoryService.TRANSITION_EMBED, |
436 | | - |
437 | | - /** |
438 | | - * Set when the transition was a permanent redirect. |
439 | | - */ |
440 | | - TRANSITION_REDIRECT_PERMANENT: Ci.nsINavHistoryService.TRANSITION_REDIRECT_PERMANENT, |
441 | | - |
442 | | - /** |
443 | | - * Set when the transition was a temporary redirect. |
444 | | - */ |
445 | | - TRANSITION_REDIRECT_TEMPORARY: Ci.nsINavHistoryService.TRANSITION_REDIRECT_TEMPORARY, |
446 | | - |
447 | | - /** |
448 | | - * Set when the transition is a download. |
449 | | - */ |
450 | | - TRANSITION_DOWNLOAD: Ci.nsINavHistoryService.TRANSITION_REDIRECT_DOWNLOAD, |
451 | | - |
452 | | - /** |
453 | | - * The user followed a link and got a visit in a frame. |
454 | | - */ |
455 | | - TRANSITION_FRAMED_LINK: Ci.nsINavHistoryService.TRANSITION_FRAMED_LINK, |
| 411 | + TRANSITIONS: { |
| 412 | + /** |
| 413 | + * The user followed a link and got a new toplevel window. |
| 414 | + */ |
| 415 | + LINK: Ci.nsINavHistoryService.TRANSITION_LINK, |
| 416 | + |
| 417 | + /** |
| 418 | + * The user typed the page's URL in the URL bar or selected it from |
| 419 | + * URL bar autocomplete results, clicked on it from a history query |
| 420 | + * (from the History sidebar, History menu, or history query in the |
| 421 | + * personal toolbar or Places organizer. |
| 422 | + */ |
| 423 | + TYPED: Ci.nsINavHistoryService.TRANSITION_TYPED, |
| 424 | + |
| 425 | + /** |
| 426 | + * The user followed a bookmark to get to the page. |
| 427 | + */ |
| 428 | + BOOKMARK: Ci.nsINavHistoryService.TRANSITION_BOOKMARK, |
| 429 | + |
| 430 | + /** |
| 431 | + * Some inner content is loaded. This is true of all images on a |
| 432 | + * page, and the contents of the iframe. It is also true of any |
| 433 | + * content in a frame if the user did not explicitly follow a link |
| 434 | + * to get there. |
| 435 | + */ |
| 436 | + EMBED: Ci.nsINavHistoryService.TRANSITION_EMBED, |
| 437 | + |
| 438 | + /** |
| 439 | + * Set when the transition was a permanent redirect. |
| 440 | + */ |
| 441 | + REDIRECT_PERMANENT: Ci.nsINavHistoryService.TRANSITION_REDIRECT_PERMANENT, |
| 442 | + |
| 443 | + /** |
| 444 | + * Set when the transition was a temporary redirect. |
| 445 | + */ |
| 446 | + REDIRECT_TEMPORARY: Ci.nsINavHistoryService.TRANSITION_REDIRECT_TEMPORARY, |
| 447 | + |
| 448 | + /** |
| 449 | + * Set when the transition is a download. |
| 450 | + */ |
| 451 | + DOWNLOAD: Ci.nsINavHistoryService.TRANSITION_DOWNLOAD, |
| 452 | + |
| 453 | + /** |
| 454 | + * The user followed a link and got a visit in a frame. |
| 455 | + */ |
| 456 | + FRAMED_LINK: Ci.nsINavHistoryService.TRANSITION_FRAMED_LINK, |
| 457 | + |
| 458 | + /** |
| 459 | + * The user reloaded a page. |
| 460 | + */ |
| 461 | + RELOAD: Ci.nsINavHistoryService.TRANSITION_RELOAD, |
| 462 | + }, |
456 | 463 | }); |
457 | 464 |
|
458 | 465 | /** |
@@ -484,7 +491,7 @@ function validatePageInfo(pageInfo) { |
484 | 491 | for (let inVisit of pageInfo.visits) { |
485 | 492 | let visit = { |
486 | 493 | date: new Date(), |
487 | | - transition: inVisit.transition || History.TRANSITION_LINK, |
| 494 | + transition: inVisit.transition || History.TRANSITIONS.LINK, |
488 | 495 | }; |
489 | 496 |
|
490 | 497 | if (!isValidTransitionType(visit.transition)) { |
@@ -541,16 +548,7 @@ function convertForUpdatePlaces(pageInfo) { |
541 | 548 | * @return (Boolean) |
542 | 549 | */ |
543 | 550 | function isValidTransitionType(transitionType) { |
544 | | - return [ |
545 | | - History.TRANSITION_LINK, |
546 | | - History.TRANSITION_TYPED, |
547 | | - History.TRANSITION_BOOKMARK, |
548 | | - History.TRANSITION_EMBED, |
549 | | - History.TRANSITION_REDIRECT_PERMANENT, |
550 | | - History.TRANSITION_REDIRECT_TEMPORARY, |
551 | | - History.TRANSITION_DOWNLOAD, |
552 | | - History.TRANSITION_FRAMED_LINK |
553 | | - ].includes(transitionType); |
| 551 | + return Object.values(History.TRANSITIONS).includes(transitionType); |
554 | 552 | } |
555 | 553 |
|
556 | 554 | /** |
|
0 commit comments