How to use guid method in wpt

Best JavaScript code snippet using wpt

test_bookmark_order.js

Source:test_bookmark_order.js Github

copy

Full Screen

1/* Any copyright is dedicated to the Public Domain.2 http://creativecommons.org/publicdomain/zero/1.0/ */3_(4 "Making sure after processing incoming bookmarks, they show up in the right order"5);6const { Bookmark, BookmarkFolder, BookmarksEngine } = ChromeUtils.import(7 "resource://services-sync/engines/bookmarks.js"8);9const { Weave } = ChromeUtils.import("resource://services-sync/main.js");10const { Service } = ChromeUtils.import("resource://services-sync/service.js");11async function serverForFoo(engine) {12 await generateNewKeys(Service.collectionKeys);13 let clientsEngine = Service.clientsEngine;14 let clientsSyncID = await clientsEngine.resetLocalSyncID();15 let engineSyncID = await engine.resetLocalSyncID();16 return serverForUsers(17 { foo: "password" },18 {19 meta: {20 global: {21 syncID: Service.syncID,22 storageVersion: STORAGE_VERSION,23 engines: {24 clients: {25 version: clientsEngine.version,26 syncID: clientsSyncID,27 },28 [engine.name]: {29 version: engine.version,30 syncID: engineSyncID,31 },32 },33 },34 },35 crypto: {36 keys: encryptPayload({37 id: "keys",38 // Generate a fake default key bundle to avoid resetting the client39 // before the first sync.40 default: [41 await Weave.Crypto.generateRandomKey(),42 await Weave.Crypto.generateRandomKey(),43 ],44 }),45 },46 [engine.name]: {},47 }48 );49}50async function resolveConflict(51 engine,52 collection,53 timestamp,54 buildTree,55 message56) {57 let guids = {58 // These items don't exist on the server.59 fx: Utils.makeGUID(),60 nightly: Utils.makeGUID(),61 support: Utils.makeGUID(),62 customize: Utils.makeGUID(),63 // These exist on the server, but in a different order, and `res`64 // has completely different children.65 res: Utils.makeGUID(),66 tb: Utils.makeGUID(),67 // These don't exist locally.68 bz: Utils.makeGUID(),69 irc: Utils.makeGUID(),70 mdn: Utils.makeGUID(),71 };72 await PlacesUtils.bookmarks.insertTree({73 guid: PlacesUtils.bookmarks.menuGuid,74 children: [75 {76 guid: guids.fx,77 title: "Get Firefox!",78 url: "http://getfirefox.com/",79 },80 {81 guid: guids.res,82 title: "Resources",83 type: PlacesUtils.bookmarks.TYPE_FOLDER,84 children: [85 {86 guid: guids.nightly,87 title: "Nightly",88 url: "https://nightly.mozilla.org/",89 },90 {91 guid: guids.support,92 title: "Support",93 url: "https://support.mozilla.org/",94 },95 {96 guid: guids.customize,97 title: "Customize",98 url: "https://mozilla.org/firefox/customize/",99 },100 ],101 },102 {103 title: "Get Thunderbird!",104 guid: guids.tb,105 url: "http://getthunderbird.com/",106 },107 ],108 });109 let serverRecords = [110 {111 id: "menu",112 type: "folder",113 title: "Bookmarks Menu",114 parentid: "places",115 children: [guids.tb, guids.res],116 },117 {118 id: guids.tb,119 type: "bookmark",120 parentid: "menu",121 bmkUri: "http://getthunderbird.com/",122 title: "Get Thunderbird!",123 },124 {125 id: guids.res,126 type: "folder",127 parentid: "menu",128 title: "Resources",129 children: [guids.irc, guids.bz, guids.mdn],130 },131 {132 id: guids.bz,133 type: "bookmark",134 parentid: guids.res,135 bmkUri: "https://bugzilla.mozilla.org/",136 title: "Bugzilla",137 },138 {139 id: guids.mdn,140 type: "bookmark",141 parentid: guids.res,142 bmkUri: "https://developer.mozilla.org/",143 title: "MDN",144 },145 {146 id: guids.irc,147 type: "bookmark",148 parentid: guids.res,149 bmkUri: "ircs://irc.mozilla.org/nightly",150 title: "IRC",151 },152 ];153 for (let record of serverRecords) {154 collection.insert(record.id, encryptPayload(record), timestamp);155 }156 engine.lastModified = collection.timestamp;157 await sync_engine_and_validate_telem(engine, false);158 let expectedTree = buildTree(guids);159 await assertBookmarksTreeMatches(160 PlacesUtils.bookmarks.menuGuid,161 expectedTree,162 message163 );164}165add_task(async function setup() {166 await Service.engineManager.unregister("bookmarks");167});168add_task(async function test_local_order_newer() {169 let engine = new BookmarksEngine(Service);170 await engine.initialize();171 let server = await serverForFoo(engine);172 await SyncTestingInfrastructure(server);173 try {174 let collection = server.user("foo").collection("bookmarks");175 let serverModified = Date.now() / 1000 - 120;176 await resolveConflict(177 engine,178 collection,179 serverModified,180 guids => [181 {182 guid: guids.fx,183 index: 0,184 },185 {186 guid: guids.res,187 index: 1,188 children: [189 {190 guid: guids.nightly,191 index: 0,192 },193 {194 guid: guids.support,195 index: 1,196 },197 {198 guid: guids.customize,199 index: 2,200 },201 {202 guid: guids.irc,203 index: 3,204 },205 {206 guid: guids.bz,207 index: 4,208 },209 {210 guid: guids.mdn,211 index: 5,212 },213 ],214 },215 {216 guid: guids.tb,217 index: 2,218 },219 ],220 "Should use local order as base if remote is older"221 );222 } finally {223 await engine.wipeClient();224 await Service.startOver();225 await promiseStopServer(server);226 await engine.finalize();227 }228});229add_task(async function test_remote_order_newer() {230 let engine = new BookmarksEngine(Service);231 await engine.initialize();232 let server = await serverForFoo(engine);233 await SyncTestingInfrastructure(server);234 try {235 let collection = server.user("foo").collection("bookmarks");236 let serverModified = Date.now() / 1000 + 120;237 await resolveConflict(238 engine,239 collection,240 serverModified,241 guids => [242 {243 guid: guids.tb,244 index: 0,245 },246 {247 guid: guids.res,248 index: 1,249 children: [250 {251 guid: guids.irc,252 index: 0,253 },254 {255 guid: guids.bz,256 index: 1,257 },258 {259 guid: guids.mdn,260 index: 2,261 },262 {263 guid: guids.nightly,264 index: 3,265 },266 {267 guid: guids.support,268 index: 4,269 },270 {271 guid: guids.customize,272 index: 5,273 },274 ],275 },276 {277 guid: guids.fx,278 index: 2,279 },280 ],281 "Should use remote order as base if local is older"282 );283 } finally {284 await engine.wipeClient();285 await Service.startOver();286 await promiseStopServer(server);287 await engine.finalize();288 }289});290add_task(async function test_bookmark_order() {291 let engine = new BookmarksEngine(Service);292 let store = engine._store;293 _("Starting with a clean slate of no bookmarks");294 await store.wipe();295 await assertBookmarksTreeMatches(296 "",297 [298 {299 guid: PlacesUtils.bookmarks.menuGuid,300 index: 0,301 },302 {303 guid: PlacesUtils.bookmarks.toolbarGuid,304 index: 1,305 },306 {307 // Index 2 is the tags root. (Root indices depend on the order of the308 // `CreateRoot` calls in `Database::CreateBookmarkRoots`).309 guid: PlacesUtils.bookmarks.unfiledGuid,310 index: 3,311 },312 {313 guid: PlacesUtils.bookmarks.mobileGuid,314 index: 4,315 },316 ],317 "clean slate"318 );319 function bookmark(name, parent) {320 let bm = new Bookmark("http://weave.server/my-bookmark");321 bm.id = name;322 bm.title = name;323 bm.bmkUri = "http://uri/";324 bm.parentid = parent || "unfiled";325 bm.tags = [];326 return bm;327 }328 function folder(name, parent, children) {329 let bmFolder = new BookmarkFolder("http://weave.server/my-bookmark-folder");330 bmFolder.id = name;331 bmFolder.title = name;332 bmFolder.parentid = parent || "unfiled";333 bmFolder.children = children;334 return bmFolder;335 }336 async function apply(record) {337 store._childrenToOrder = {};338 await store.applyIncoming(record);339 await store._orderChildren();340 delete store._childrenToOrder;341 }342 let id10 = "10_aaaaaaaaa";343 _("basic add first bookmark");344 await apply(bookmark(id10, ""));345 await assertBookmarksTreeMatches(346 "",347 [348 {349 guid: PlacesUtils.bookmarks.menuGuid,350 index: 0,351 },352 {353 guid: PlacesUtils.bookmarks.toolbarGuid,354 index: 1,355 },356 {357 guid: PlacesUtils.bookmarks.unfiledGuid,358 index: 3,359 children: [360 {361 guid: id10,362 index: 0,363 },364 ],365 },366 {367 guid: PlacesUtils.bookmarks.mobileGuid,368 index: 4,369 },370 ],371 "basic add first bookmark"372 );373 let id20 = "20_aaaaaaaaa";374 _("basic append behind 10");375 await apply(bookmark(id20, ""));376 await assertBookmarksTreeMatches(377 "",378 [379 {380 guid: PlacesUtils.bookmarks.menuGuid,381 index: 0,382 },383 {384 guid: PlacesUtils.bookmarks.toolbarGuid,385 index: 1,386 },387 {388 guid: PlacesUtils.bookmarks.unfiledGuid,389 index: 3,390 children: [391 {392 guid: id10,393 index: 0,394 },395 {396 guid: id20,397 index: 1,398 },399 ],400 },401 {402 guid: PlacesUtils.bookmarks.mobileGuid,403 index: 4,404 },405 ],406 "basic append behind 10"407 );408 let id31 = "31_aaaaaaaaa";409 let id30 = "f30_aaaaaaaa";410 _("basic create in folder");411 await apply(bookmark(id31, id30));412 let f30 = folder(id30, "", [id31]);413 await apply(f30);414 await assertBookmarksTreeMatches(415 "",416 [417 {418 guid: PlacesUtils.bookmarks.menuGuid,419 index: 0,420 },421 {422 guid: PlacesUtils.bookmarks.toolbarGuid,423 index: 1,424 },425 {426 guid: PlacesUtils.bookmarks.unfiledGuid,427 index: 3,428 children: [429 {430 guid: id10,431 index: 0,432 },433 {434 guid: id20,435 index: 1,436 },437 {438 guid: id30,439 index: 2,440 children: [441 {442 guid: id31,443 index: 0,444 },445 ],446 },447 ],448 },449 {450 guid: PlacesUtils.bookmarks.mobileGuid,451 index: 4,452 },453 ],454 "basic create in folder"455 );456 let id41 = "41_aaaaaaaaa";457 let id40 = "f40_aaaaaaaa";458 _("insert missing parent -> append to unfiled");459 await apply(bookmark(id41, id40));460 await assertBookmarksTreeMatches(461 "",462 [463 {464 guid: PlacesUtils.bookmarks.menuGuid,465 index: 0,466 },467 {468 guid: PlacesUtils.bookmarks.toolbarGuid,469 index: 1,470 },471 {472 guid: PlacesUtils.bookmarks.unfiledGuid,473 index: 3,474 children: [475 {476 guid: id10,477 index: 0,478 },479 {480 guid: id20,481 index: 1,482 },483 {484 guid: id30,485 index: 2,486 children: [487 {488 guid: id31,489 index: 0,490 },491 ],492 },493 {494 guid: id41,495 index: 3,496 requestedParent: id40,497 },498 ],499 },500 {501 guid: PlacesUtils.bookmarks.mobileGuid,502 index: 4,503 },504 ],505 "insert missing parent -> append to unfiled"506 );507 let id42 = "42_aaaaaaaaa";508 _("insert another missing parent -> append");509 await apply(bookmark(id42, id40));510 await assertBookmarksTreeMatches(511 "",512 [513 {514 guid: PlacesUtils.bookmarks.menuGuid,515 index: 0,516 },517 {518 guid: PlacesUtils.bookmarks.toolbarGuid,519 index: 1,520 },521 {522 guid: PlacesUtils.bookmarks.unfiledGuid,523 index: 3,524 children: [525 {526 guid: id10,527 index: 0,528 },529 {530 guid: id20,531 index: 1,532 },533 {534 guid: id30,535 index: 2,536 children: [537 {538 guid: id31,539 index: 0,540 },541 ],542 },543 {544 guid: id41,545 index: 3,546 requestedParent: id40,547 },548 {549 guid: id42,550 index: 4,551 requestedParent: id40,552 },553 ],554 },555 {556 guid: PlacesUtils.bookmarks.mobileGuid,557 index: 4,558 },559 ],560 "insert another missing parent -> append"561 );562 _("insert folder -> move children and followers");563 let f40 = folder(id40, "", [id41, id42]);564 await apply(f40);565 await assertBookmarksTreeMatches(566 "",567 [568 {569 guid: PlacesUtils.bookmarks.menuGuid,570 index: 0,571 },572 {573 guid: PlacesUtils.bookmarks.toolbarGuid,574 index: 1,575 },576 {577 guid: PlacesUtils.bookmarks.unfiledGuid,578 index: 3,579 children: [580 {581 guid: id10,582 index: 0,583 },584 {585 guid: id20,586 index: 1,587 },588 {589 guid: id30,590 index: 2,591 children: [592 {593 guid: id31,594 index: 0,595 },596 ],597 },598 {599 guid: id40,600 index: 3,601 children: [602 {603 guid: id41,604 index: 0,605 },606 {607 guid: id42,608 index: 1,609 },610 ],611 },612 ],613 },614 {615 guid: PlacesUtils.bookmarks.mobileGuid,616 index: 4,617 },618 ],619 "insert folder -> move children and followers"620 );621 _("Moving 41 behind 42 -> update f40");622 f40.children = [id42, id41];623 await apply(f40);624 await assertBookmarksTreeMatches(625 "",626 [627 {628 guid: PlacesUtils.bookmarks.menuGuid,629 index: 0,630 },631 {632 guid: PlacesUtils.bookmarks.toolbarGuid,633 index: 1,634 },635 {636 guid: PlacesUtils.bookmarks.unfiledGuid,637 index: 3,638 children: [639 {640 guid: id10,641 index: 0,642 },643 {644 guid: id20,645 index: 1,646 },647 {648 guid: id30,649 index: 2,650 children: [651 {652 guid: id31,653 index: 0,654 },655 ],656 },657 {658 guid: id40,659 index: 3,660 children: [661 {662 guid: id42,663 index: 0,664 },665 {666 guid: id41,667 index: 1,668 },669 ],670 },671 ],672 },673 {674 guid: PlacesUtils.bookmarks.mobileGuid,675 index: 4,676 },677 ],678 "Moving 41 behind 42 -> update f40"679 );680 _("Moving 10 back to front -> update 10, 20");681 f40.children = [id41, id42];682 await apply(f40);683 await assertBookmarksTreeMatches(684 "",685 [686 {687 guid: PlacesUtils.bookmarks.menuGuid,688 index: 0,689 },690 {691 guid: PlacesUtils.bookmarks.toolbarGuid,692 index: 1,693 },694 {695 guid: PlacesUtils.bookmarks.unfiledGuid,696 index: 3,697 children: [698 {699 guid: id10,700 index: 0,701 },702 {703 guid: id20,704 index: 1,705 },706 {707 guid: id30,708 index: 2,709 children: [710 {711 guid: id31,712 index: 0,713 },714 ],715 },716 {717 guid: id40,718 index: 3,719 children: [720 {721 guid: id41,722 index: 0,723 },724 {725 guid: id42,726 index: 1,727 },728 ],729 },730 ],731 },732 {733 guid: PlacesUtils.bookmarks.mobileGuid,734 index: 4,735 },736 ],737 "Moving 10 back to front -> update 10, 20"738 );739 _("Moving 20 behind 42 in f40 -> update 50");740 await apply(bookmark(id20, id40));741 await assertBookmarksTreeMatches(742 "",743 [744 {745 guid: PlacesUtils.bookmarks.menuGuid,746 index: 0,747 },748 {749 guid: PlacesUtils.bookmarks.toolbarGuid,750 index: 1,751 },752 {753 guid: PlacesUtils.bookmarks.unfiledGuid,754 index: 3,755 children: [756 {757 guid: id10,758 index: 0,759 },760 {761 guid: id30,762 index: 1,763 children: [764 {765 guid: id31,766 index: 0,767 },768 ],769 },770 {771 guid: id40,772 index: 2,773 children: [774 {775 guid: id41,776 index: 0,777 },778 {779 guid: id42,780 index: 1,781 },782 {783 guid: id20,784 index: 2,785 },786 ],787 },788 ],789 },790 {791 guid: PlacesUtils.bookmarks.mobileGuid,792 index: 4,793 },794 ],795 "Moving 20 behind 42 in f40 -> update 50"796 );797 _("Moving 10 in front of 31 in f30 -> update 10, f30");798 await apply(bookmark(id10, id30));799 f30.children = [id10, id31];800 await apply(f30);801 await assertBookmarksTreeMatches(802 "",803 [804 {805 guid: PlacesUtils.bookmarks.menuGuid,806 index: 0,807 },808 {809 guid: PlacesUtils.bookmarks.toolbarGuid,810 index: 1,811 },812 {813 guid: PlacesUtils.bookmarks.unfiledGuid,814 index: 3,815 children: [816 {817 guid: id30,818 index: 0,819 children: [820 {821 guid: id10,822 index: 0,823 },824 {825 guid: id31,826 index: 1,827 },828 ],829 },830 {831 guid: id40,832 index: 1,833 children: [834 {835 guid: id41,836 index: 0,837 },838 {839 guid: id42,840 index: 1,841 },842 {843 guid: id20,844 index: 2,845 },846 ],847 },848 ],849 },850 {851 guid: PlacesUtils.bookmarks.mobileGuid,852 index: 4,853 },854 ],855 "Moving 10 in front of 31 in f30 -> update 10, f30"856 );857 _("Moving 20 from f40 to f30 -> update 20, f30");858 await apply(bookmark(id20, id30));859 f30.children = [id10, id20, id31];860 await apply(f30);861 await assertBookmarksTreeMatches(862 "",863 [864 {865 guid: PlacesUtils.bookmarks.menuGuid,866 index: 0,867 },868 {869 guid: PlacesUtils.bookmarks.toolbarGuid,870 index: 1,871 },872 {873 guid: PlacesUtils.bookmarks.unfiledGuid,874 index: 3,875 children: [876 {877 guid: id30,878 index: 0,879 children: [880 {881 guid: id10,882 index: 0,883 },884 {885 guid: id20,886 index: 1,887 },888 {889 guid: id31,890 index: 2,891 },892 ],893 },894 {895 guid: id40,896 index: 1,897 children: [898 {899 guid: id41,900 index: 0,901 },902 {903 guid: id42,904 index: 1,905 },906 ],907 },908 ],909 },910 {911 guid: PlacesUtils.bookmarks.mobileGuid,912 index: 4,913 },914 ],915 "Moving 20 from f40 to f30 -> update 20, f30"916 );917 _("Move 20 back to front -> update 20, f30");918 await apply(bookmark(id20, ""));919 f30.children = [id10, id31];920 await apply(f30);921 await assertBookmarksTreeMatches(922 "",923 [924 {925 guid: PlacesUtils.bookmarks.menuGuid,926 index: 0,927 },928 {929 guid: PlacesUtils.bookmarks.toolbarGuid,930 index: 1,931 },932 {933 guid: PlacesUtils.bookmarks.unfiledGuid,934 index: 3,935 children: [936 {937 guid: id30,938 index: 0,939 children: [940 {941 guid: id10,942 index: 0,943 },944 {945 guid: id31,946 index: 1,947 },948 ],949 },950 {951 guid: id40,952 index: 1,953 children: [954 {955 guid: id41,956 index: 0,957 },958 {959 guid: id42,960 index: 1,961 },962 ],963 },964 {965 guid: id20,966 index: 2,967 },968 ],969 },970 {971 guid: PlacesUtils.bookmarks.mobileGuid,972 index: 4,973 },974 ],975 "Move 20 back to front -> update 20, f30"976 );977 await engine.wipeClient();978 await Service.startOver();979 await engine.finalize();...

Full Screen

Full Screen

test_import_mobile_bookmarks.js

Source:test_import_mobile_bookmarks.js Github

copy

Full Screen

1async function importFromFixture(fixture, replace) {2 let cwd = await OS.File.getCurrentDirectory();3 let path = OS.Path.join(cwd, fixture);4 info(`Importing from ${path}`);5 await BookmarkJSONUtils.importFromFile(path, { replace });6 await PlacesTestUtils.promiseAsyncUpdates();7}8async function treeEquals(guid, expected, message) {9 let root = await PlacesUtils.promiseBookmarksTree(guid);10 let bookmarks = (function nodeToEntry(node) {11 let entry = { guid: node.guid, index: node.index };12 if (node.children) {13 entry.children = node.children.map(nodeToEntry);14 }15 return entry;16 })(root);17 info(`Checking if ${guid} tree matches ${JSON.stringify(expected)}`);18 info(`Got bookmarks tree for ${guid}: ${JSON.stringify(bookmarks)}`);19 deepEqual(bookmarks, expected, message);20}21add_task(async function test_restore_mobile_bookmarks_root() {22 await importFromFixture(23 "mobile_bookmarks_root_import.json",24 /* replace */ true25 );26 await treeEquals(27 PlacesUtils.bookmarks.rootGuid,28 {29 guid: PlacesUtils.bookmarks.rootGuid,30 index: 0,31 children: [32 {33 guid: PlacesUtils.bookmarks.menuGuid,34 index: 0,35 children: [{ guid: "X6lUyOspVYwi", index: 0 }],36 },37 {38 guid: PlacesUtils.bookmarks.toolbarGuid,39 index: 1,40 },41 {42 guid: PlacesUtils.bookmarks.unfiledGuid,43 index: 3,44 },45 {46 guid: PlacesUtils.bookmarks.mobileGuid,47 index: 4,48 children: [49 { guid: "_o8e1_zxTJFg", index: 0 },50 { guid: "QCtSqkVYUbXB", index: 1 },51 ],52 },53 ],54 },55 "Should restore mobile bookmarks from root"56 );57 await PlacesUtils.bookmarks.eraseEverything();58});59add_task(async function test_import_mobile_bookmarks_root() {60 await importFromFixture(61 "mobile_bookmarks_root_import.json",62 /* replace */ false63 );64 await importFromFixture(65 "mobile_bookmarks_root_merge.json",66 /* replace */ false67 );68 await treeEquals(69 PlacesUtils.bookmarks.rootGuid,70 {71 guid: PlacesUtils.bookmarks.rootGuid,72 index: 0,73 children: [74 {75 guid: PlacesUtils.bookmarks.menuGuid,76 index: 0,77 children: [78 { guid: "X6lUyOspVYwi", index: 0 },79 { guid: "Utodo9b0oVws", index: 1 },80 ],81 },82 {83 guid: PlacesUtils.bookmarks.toolbarGuid,84 index: 1,85 },86 {87 guid: PlacesUtils.bookmarks.unfiledGuid,88 index: 3,89 },90 {91 guid: PlacesUtils.bookmarks.mobileGuid,92 index: 4,93 children: [94 // The first two are in ..._import.json, the second two are in95 // ..._merge.json96 { guid: "_o8e1_zxTJFg", index: 0 },97 { guid: "QCtSqkVYUbXB", index: 1 },98 { guid: "a17yW6-nTxEJ", index: 2 },99 { guid: "xV10h9Wi3FBM", index: 3 },100 ],101 },102 ],103 },104 "Should merge bookmarks root contents"105 );106 await PlacesUtils.bookmarks.eraseEverything();107});108add_task(async function test_restore_mobile_bookmarks_folder() {109 // This tests importing a mobile bookmarks folder with the annotation,110 // and the old, random guid.111 await importFromFixture(112 "mobile_bookmarks_folder_import.json",113 /* replace */ true114 );115 await treeEquals(116 PlacesUtils.bookmarks.rootGuid,117 {118 guid: PlacesUtils.bookmarks.rootGuid,119 index: 0,120 children: [121 {122 guid: PlacesUtils.bookmarks.menuGuid,123 index: 0,124 children: [125 { guid: "X6lUyOspVYwi", index: 0 },126 { guid: "XF4yRP6bTuil", index: 1 },127 ],128 },129 {130 guid: PlacesUtils.bookmarks.toolbarGuid,131 index: 1,132 children: [{ guid: "buy7711R3ZgE", index: 0 }],133 },134 {135 guid: PlacesUtils.bookmarks.unfiledGuid,136 index: 3,137 children: [{ guid: "KIa9iKZab2Z5", index: 0 }],138 },139 {140 guid: PlacesUtils.bookmarks.mobileGuid,141 index: 4,142 children: [143 { guid: "_o8e1_zxTJFg", index: 0 },144 { guid: "QCtSqkVYUbXB", index: 1 },145 ],146 },147 ],148 },149 "Should restore mobile bookmark folder contents into mobile root"150 );151 let queryById = await PlacesUtils.bookmarks.fetch("XF4yRP6bTuil");152 equal(153 queryById.url.href,154 `place:parent=${PlacesUtils.bookmarks.mobileGuid}`,155 "Should rewrite mobile query to point to root GUID"156 );157 await PlacesUtils.bookmarks.eraseEverything();158});159add_task(async function test_import_mobile_bookmarks_folder() {160 await importFromFixture(161 "mobile_bookmarks_folder_import.json",162 /* replace */ false163 );164 await importFromFixture(165 "mobile_bookmarks_folder_merge.json",166 /* replace */ false167 );168 await treeEquals(169 PlacesUtils.bookmarks.rootGuid,170 {171 guid: PlacesUtils.bookmarks.rootGuid,172 index: 0,173 children: [174 {175 guid: PlacesUtils.bookmarks.menuGuid,176 index: 0,177 children: [178 { guid: "X6lUyOspVYwi", index: 0 },179 { guid: "XF4yRP6bTuil", index: 1 },180 { guid: "Utodo9b0oVws", index: 2 },181 ],182 },183 {184 guid: PlacesUtils.bookmarks.toolbarGuid,185 index: 1,186 children: [{ guid: "buy7711R3ZgE", index: 0 }],187 },188 {189 guid: PlacesUtils.bookmarks.unfiledGuid,190 index: 3,191 children: [{ guid: "KIa9iKZab2Z5", index: 0 }],192 },193 {194 guid: PlacesUtils.bookmarks.mobileGuid,195 index: 4,196 children: [197 { guid: "_o8e1_zxTJFg", index: 0 },198 { guid: "QCtSqkVYUbXB", index: 1 },199 { guid: "a17yW6-nTxEJ", index: 2 },200 { guid: "xV10h9Wi3FBM", index: 3 },201 ],202 },203 ],204 },205 "Should merge bookmarks folder contents into mobile root"206 );207 await PlacesUtils.bookmarks.eraseEverything();208});209add_task(async function test_restore_multiple_bookmarks_folders() {210 await importFromFixture(211 "mobile_bookmarks_multiple_folders.json",212 /* replace */ true213 );214 await treeEquals(215 PlacesUtils.bookmarks.rootGuid,216 {217 guid: PlacesUtils.bookmarks.rootGuid,218 index: 0,219 children: [220 {221 guid: PlacesUtils.bookmarks.menuGuid,222 index: 0,223 children: [224 { guid: "buy7711R3ZgE", index: 0 },225 { guid: "F_LBgd1fS_uQ", index: 1 },226 { guid: "oIpmQXMWsXvY", index: 2 },227 ],228 },229 {230 guid: PlacesUtils.bookmarks.toolbarGuid,231 index: 1,232 children: [{ guid: "Utodo9b0oVws", index: 0 }],233 },234 {235 guid: PlacesUtils.bookmarks.unfiledGuid,236 index: 3,237 children: [{ guid: "xV10h9Wi3FBM", index: 0 }],238 },239 {240 guid: PlacesUtils.bookmarks.mobileGuid,241 index: 4,242 children: [243 { guid: "a17yW6-nTxEJ", index: 0 },244 { guid: "sSZ86WT9WbN3", index: 1 },245 ],246 },247 ],248 },249 "Should restore multiple bookmarks folder contents into root"250 );251 await PlacesUtils.bookmarks.eraseEverything();252});253add_task(async function test_import_multiple_bookmarks_folders() {254 await importFromFixture(255 "mobile_bookmarks_root_import.json",256 /* replace */ false257 );258 await importFromFixture(259 "mobile_bookmarks_multiple_folders.json",260 /* replace */ false261 );262 await treeEquals(263 PlacesUtils.bookmarks.rootGuid,264 {265 guid: PlacesUtils.bookmarks.rootGuid,266 index: 0,267 children: [268 {269 guid: PlacesUtils.bookmarks.menuGuid,270 index: 0,271 children: [272 { guid: "X6lUyOspVYwi", index: 0 },273 { guid: "buy7711R3ZgE", index: 1 },274 { guid: "F_LBgd1fS_uQ", index: 2 },275 { guid: "oIpmQXMWsXvY", index: 3 },276 ],277 },278 {279 guid: PlacesUtils.bookmarks.toolbarGuid,280 index: 1,281 children: [{ guid: "Utodo9b0oVws", index: 0 }],282 },283 {284 guid: PlacesUtils.bookmarks.unfiledGuid,285 index: 3,286 children: [{ guid: "xV10h9Wi3FBM", index: 0 }],287 },288 {289 guid: PlacesUtils.bookmarks.mobileGuid,290 index: 4,291 children: [292 { guid: "_o8e1_zxTJFg", index: 0 },293 { guid: "QCtSqkVYUbXB", index: 1 },294 { guid: "a17yW6-nTxEJ", index: 2 },295 { guid: "sSZ86WT9WbN3", index: 3 },296 ],297 },298 ],299 },300 "Should merge multiple mobile folders into root"301 );302 await PlacesUtils.bookmarks.eraseEverything();...

Full Screen

Full Screen

test_pageGuid_bookmarkGuid.js

Source:test_pageGuid_bookmarkGuid.js Github

copy

Full Screen

...120 query.uri = sourceURI;121 let root = histsvc.executeQuery(query, options).root;122 root.containerOpen = true;123 Assert.equal(root.childCount, 1);124 do_check_valid_places_guid(root.getChild(0).pageGuid);125 Assert.equal(root.getChild(0).bookmarkGuid, "");126 root.containerOpen = false;127 await PlacesUtils.history.clear();128});129add_task(async function test_addItemsWithInvalidGUIDsFails() {130 const INVALID_GUID = "XYZ";131 try {132 await PlacesUtils.bookmarks.insert({133 parentGuid: PlacesUtils.bookmarks.menuGuid,134 guid: INVALID_GUID,135 title: "XYZ folder",136 type: PlacesUtils.bookmarks.TYPE_FOLDER,137 });138 do_throw("Adding a folder with an invalid guid should fail");...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wp = wptools.page('Albert Einstein');3wp.get(function(err, resp) {4 if (err) {5 console.log(err);6 } else {7 console.log(resp);8 }9});10var wptools = require('wptools');11var wp = wptools.page('Albert Einstein');12wp.get(function(err, resp) {13 if (err) {14 console.log(err);15 } else {16 console.log(resp);17 }18});19var wptools = require('wptools');20var wp = wptools.page('Albert Einstein');21wp.get(function(err, resp) {22 if (err) {23 console.log(err);24 } else {25 console.log(resp);26 }27});28var wptools = require('wptools');29var wp = wptools.page('Albert Einstein');30wp.get(function(err, resp) {31 if (err) {32 console.log(err);33 } else {34 console.log(resp);35 }36});37var wptools = require('wptools');38var wp = wptools.page('Albert Einstein');39wp.get(function(err, resp) {40 if (err) {41 console.log(err);42 } else {43 console.log(resp);44 }45});46var wptools = require('wptools');47var wp = wptools.page('Albert Einstein');48wp.get(function(err, resp) {49 if (err) {50 console.log(err);51 } else {52 console.log(resp);53 }54});55var wptools = require('wptools');56var wp = wptools.page('Albert Einstein');57wp.get(function(err, resp) {58 if (err) {59 console.log(err);60 } else {61 console.log(resp);62 }63});64var wptools = require('

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var guid = wptools.guid();3var wikidataSdk = require('wikidata-sdk');4var guid = wikidataSdk.guid();5var wikidataEdit = require('wikidata-edit');6var guid = wikidataEdit.guid();7var wikidataTaxonomy = require('wikidata-taxonomy');8var guid = wikidataTaxonomy.guid();9var wikibaseEdit = require('wikibase-edit');10var guid = wikibaseEdit.guid();11var wikibaseSdk = require('wikibase-sdk');12var guid = wikibaseSdk.guid();13* [wikidata-sdk](

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wptools');2const wiki = wptools.page('Barack Obama');3wiki.get((err, info) => {4 if (err) {5 console.log(err);6 }7 console.log(info);8});9const wikipedia = require("wikipedia-js");10const options = { query: "Barack Obama", format: "html", summaryOnly: true };11wikipedia.searchArticle(options, function(err, htmlWikiText) {12 if (err) {13 console.log("An error occurred[query=%s, error=%s]", options.query, err);14 return;15 }16 console.log("Query successful[query=%s, html-formatted-wiki-text=%s]", options.query, htmlWikiText);17});

Full Screen

Using AI Code Generation

copy

Full Screen

1var Wiki = require('wptools');2var wiki = new Wiki('Guido van Rossum');3wiki.get(function(err, data) {4 console.log(data);5});6var Wiki = require('wptools');7var wiki = new Wiki('Guido van Rossum');8wiki.get(function(err, data) {9 console.log(data);10});11var Wiki = require('wptools');12var wiki = new Wiki('Guido van Rossum');13wiki.get(function(err, data) {14 console.log(data);15});16var Wiki = require('wptools');17var wiki = new Wiki('Guido van Rossum');18wiki.get(function(err, data) {19 console.log(data);20});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wiki = new wptools('Albert Einstein');3wiki.get(function(err, resp) {4 console.log(resp);5});6{7 "extract": "Albert Einstein (/ˈaɪnstaɪn/; German: [ˈalbɛɐ̯t ˈʔaɪnʃtaɪn] (About this soundlisten); 14 March 1879 – 18 April 1955) was a German-born theoretical physicist. He developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). Einstein's work is also known for its influence on the philosophy of science. Einstein is best known to the general public for his mass–energy equivalence formula E = mc2 (which has been dubbed \"the world's most famous equation\"). He received the 1921 Nobel Prize in Physics \"for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect\", a pivotal step in the evolution of quantum theory.",8 {9 }10 "infobox": {11 "death_date": "18 April 1955 (aged 76)",

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wiki = wptools.page('Tiger_Woods');3wiki.get(function(err, resp) {4 console.log(resp.data.infobox);5});6var wtf = require('wtf_wikipedia');7wtf.fetch('Tiger Woods', function(err, doc) {8 console.log(doc.infobox());9});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var guid = wptoolkit.guid();3console.log(guid);4var wptoolkit = require('wptoolkit');5var guid = wptoolkit.guid();6console.log(guid);7var wptoolkit = require('wptoolkit');8var guid = wptoolkit.guid();9console.log(guid);10var wptoolkit = require('wptoolkit');11var guid = wptoolkit.guid();12console.log(guid);13var wptoolkit = require('wptoolkit');14var guid = wptoolkit.guid();15console.log(guid);16var wptoolkit = require('wptoolkit');17var guid = wptoolkit.guid();18console.log(guid);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful