fix: prevent duplicate titles on Taobao login page
Keep a single native title on the entry page even when the host ignores title clearing. Preserve centered headers elsewhere and normalize manifest line endings during shared-code checks.
This commit is contained in:
@@ -39,6 +39,23 @@ test('native errors cannot block page loading and rejected promises are observed
|
||||
assert.equal(loaded, 2);
|
||||
});
|
||||
|
||||
test('native-only entry never draws its own title even when the host reports success without changing the native title', () => {
|
||||
for (const mode of ['ignored-success', 'failure', 'missing-api']) {
|
||||
const calls = [];
|
||||
const platform = mode === 'missing-api' ? {} : { setNavigationBar(options) {
|
||||
calls.push(options.title);
|
||||
if (mode === 'ignored-success') options.success({}); else options.fail({});
|
||||
} };
|
||||
const p = header.page({ data: {} }, platform, { nativeTitleOnly: true });
|
||||
p.setData = patch => Object.assign(p.data, patch);
|
||||
assert.equal(p.data.brandHeader.showTitle, false, 'no duplicate on the first frame');
|
||||
for (const lifecycle of ['onLoad', 'onShow', 'onReady', 'onResize', 'onHide', 'onShow']) {
|
||||
p[lifecycle](); assert.equal(p.data.brandHeader.showTitle, false, lifecycle);
|
||||
}
|
||||
assert(calls.every(title => title === "1'me肌肤状态检测"), 'entry keeps the native title instead of trying to clear it');
|
||||
}
|
||||
});
|
||||
|
||||
test('actual header template centers on the full screen and keeps clear of status and native buttons', async () => {
|
||||
const fs = require('node:fs'), path = require('node:path'), { chromium } = require('playwright');
|
||||
const root = path.resolve(__dirname, '..');
|
||||
@@ -63,7 +80,8 @@ test('actual header template centers on the full screen and keeps clear of statu
|
||||
}
|
||||
for (const route of JSON.parse(fs.readFileSync(path.join(root, 'app.json'), 'utf8')).pages) {
|
||||
const config = JSON.parse(fs.readFileSync(path.join(root, route + '.json'), 'utf8'));
|
||||
assert.equal(config.transparentTitle, 'always'); assert.equal(config.defaultTitle, '\u200b');
|
||||
assert.equal(config.transparentTitle, 'always');
|
||||
assert.equal(config.defaultTitle, route === 'pages/login/login' ? header.layout().title : '\u200b');
|
||||
assert.match(fs.readFileSync(path.join(root, route + '.axml'), 'utf8'), /template is="brand-header"/);
|
||||
}
|
||||
} finally { await browser.close(); }
|
||||
|
||||
Reference in New Issue
Block a user