END_TEST /** * check refragment join asserts on NULL parameter */ START_TEST(nsurl_api_assert_refragment1_test) { nsurl *res; nserror err; err = nsurl_refragment(NULL, corestring_lwc_http, &res); ck_assert(err != NSERROR_OK); }
END_TEST /** * refragment url */ START_TEST(nsurl_refragment_test) { nserror err; nsurl *url; nsurl *res_url; const struct test_pairs *tst = &fragment_tests[_i]; lwc_string *frag; /* not testing create, this should always succeed */ err = nsurl_create(tst->test, &url); ck_assert(err == NSERROR_OK); /* grab the fragment - not testing should succeed */ frag = nsurl_get_component(url, NSURL_FRAGMENT); ck_assert(frag != NULL); nsurl_unref(url); /* not testing create, this should always succeed */ err = nsurl_create(tst->res, &url); ck_assert(err == NSERROR_OK); err = nsurl_refragment(url, frag, &res_url); if (tst->res == NULL) { /* result must be invalid (bad input) */ ck_assert(err != NSERROR_OK); } else { /* result must be valid */ ck_assert(err == NSERROR_OK); ck_assert_str_eq(nsurl_access(res_url), tst->test); nsurl_unref(res_url); } lwc_string_unref(frag); nsurl_unref(url); }
END_TEST /** * check refragment asserts on NULL parameter */ START_TEST(nsurl_api_assert_refragment2_test) { nsurl *url; nsurl *res; nserror err; err = nsurl_create(base_str, &url); ck_assert(err == NSERROR_OK); err = nsurl_refragment(url, NULL, &res); ck_assert(err != NSERROR_OK); nsurl_unref(url); }
/* Documented in local_history.h */ void browser_window_history_go(struct browser_window *bw, struct history_entry *entry, bool new_window) { struct history *history; nsurl *url; struct history_entry *current; nserror error; assert(bw != NULL); history = bw->history; if (entry->page.frag_id) { error = nsurl_refragment(entry->page.url, entry->page.frag_id, &url); if (error != NSERROR_OK) { warn_user("NoMemory", 0); return; } } else { url = nsurl_ref(entry->page.url); } if (new_window) { current = history->current; history->current = entry; error = browser_window_create(BW_CREATE_CLONE, url, NULL, bw, NULL); history->current = current; if (error != NSERROR_OK) { nsurl_unref(url); return; } } else { history->current = entry; browser_window_navigate(bw, url, NULL, BW_NAVIGATE_NONE, NULL, NULL, NULL); } nsurl_unref(url); }