queryUrl expected url
This commit is contained in:
@ -86,10 +86,10 @@ function redirectTab(tab, url) {
|
|||||||
action: ACTION_GOTO_URL,
|
action: ACTION_GOTO_URL,
|
||||||
url: url
|
url: url
|
||||||
}
|
}
|
||||||
sendMessage(tab, req, `Goto url: ${url}`);
|
return sendMessage(tab, req, `Goto url: ${url}`);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(() => queryUrl(tab, curUrl, 'Check if tab url matches expected...'))
|
.then(() => queryUrl(tab, url, 'Check if tab url matches expected...'))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,14 +125,14 @@ function reportIn(tab) {
|
|||||||
/**
|
/**
|
||||||
* get the url of the target tab
|
* get the url of the target tab
|
||||||
* @param {any} tab target tab
|
* @param {any} tab target tab
|
||||||
* @param {string} urlExcluded if specified, queryUrl resolves only when response not equals to urlExcluded
|
* @param {string} expected if specified, queryUrl resolves only when tab url equals to expected
|
||||||
* @returns {Promise<string>} a promise of the url
|
* @returns {Promise<string>} a promise of the url
|
||||||
*/
|
*/
|
||||||
function queryUrl(tab, urlExcluded, log) {
|
function queryUrl(tab, expected, log) {
|
||||||
let req = {
|
let req = {
|
||||||
action: ACTION_QUERY_URL
|
action: ACTION_QUERY_URL
|
||||||
}
|
}
|
||||||
let cond = url => url && (!urlExcluded || (urlExcluded && urlExcluded != url));
|
let cond = url => url && (!expected || (expected && expected == url));
|
||||||
return sendMessage(tab, req, log, cond);
|
return sendMessage(tab, req, log, cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user